Mercurial > lbo > hg > ylisp
changeset 180:6eb17b273514
types: Make closure a pointer; add some size tests
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Thu, 12 Sep 2019 08:25:27 +0200 |
parents | 53dc68a0488d |
children | 3ec2b2edb977 |
files | src/func.h src/sizes_test.c src/types.h |
diffstat | 3 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/func.h Thu Sep 12 08:25:03 2019 +0200 +++ b/src/func.h Thu Sep 12 08:25:27 2019 +0200 @@ -39,7 +39,7 @@ /// Vector of yarg_desc_t values, each describing an argument, in order of /// appearance. yvec_t args; - /// Vector of yarg_desc_t values, each describing a value to be captured in + /// Vector of yref_t values, each describing a value to be captured in /// a closure. When defining the function, the interpreter should copy the /// values of these references into the closure yexpr_t value (via the /// to-be-implemented _mkclsr built-in). / When calling a function, the
--- a/src/sizes_test.c Thu Sep 12 08:25:03 2019 +0200 +++ b/src/sizes_test.c Thu Sep 12 08:25:27 2019 +0200 @@ -17,6 +17,7 @@ PRINT_SIZE(ystr_t); PRINT_SIZE(yvalue_id_t); PRINT_SIZE(yvec_t); + PRINT_SIZE(yclosure_t); PRINT_SIZE(YREF_TYPE); PRINT_SIZE(YEXPR_TYPE); @@ -28,6 +29,12 @@ void assert_sizes(void) { assert(16 == sizeof(ystr_t)); assert(16 == sizeof(yvec_t)); + + assert(8 == sizeof(yatom_t)); + assert(24 == sizeof(yexpr_t)); + assert(16 == sizeof(yref_t)); + assert(64 == sizeof(yfunc_t)); + assert(32 == sizeof(yclosure_t)); } /**
--- a/src/types.h Thu Sep 12 08:25:03 2019 +0200 +++ b/src/types.h Thu Sep 12 08:25:27 2019 +0200 @@ -115,10 +115,10 @@ /// closure data. YEXPR_FUNC = 6, /// A reference to a built-in function. - YEXPR_BUILTIN = 6, + YEXPR_BUILTIN = 7, /// An exception described by the `str` field - when returned from a /// function, the interpreter "bubbles up" the call stack. - YEXPR_EXCEPTION = 7, + YEXPR_EXCEPTION = 8, } YEXPR_TYPE; /** @@ -141,7 +141,7 @@ /// A builtin such as `for`, `let`, ... YBUILTIN_TYPE builtin; /// A closure, i.e. function reference with associated data. - yclosure_t closure; + yclosure_t* closure; } value; /// Type of this expression. YEXPR_TYPE typ;