diff --git a/src/c.lang b/src/c.lang index 63458b2..361fa40 100644 --- a/src/c.lang +++ b/src/c.lang @@ -6,6 +6,8 @@ (ptr "void *") (sz "size_t") (flag "bool") + (ffi_cif "ffi_cif *") + (ffi_closure "ffi_closure *") (comp_decl_type "compound_type") (live_var_val "union value *")) @@ -184,6 +186,11 @@ (deftype T_FN_CALL "Function Call" "tFNCALL" ("ID" "ARGS")) +(deftype T_CLOSURE "Closure Call" "tCLOSURE" + ("ARG_TYPES" "RET_TYPE" "FN" + ("CIF" ffi_cif) + ("CLOSURE" ffi_closure))) + (deftype T_FN_ARG "Function Argument" "tFNARG" ("EXP")) diff --git a/src/gc.c b/src/gc.c index 2d00420..e68ce52 100644 --- a/src/gc.c +++ b/src/gc.c @@ -101,6 +101,10 @@ static void dealloc_object(gc_obj obj) case E_ALLOC: free(tALLOC_PTR(t)); break; + case T_CLOSURE: + ffi_closure_free(tCLOSURE_CLOSURE(t)); + free(tCLOSURE_CIF(t)); + break; default: /* All other types don't contain any other referencies to * dynamic memory. */ diff --git a/src/tree-dump-primitives.h b/src/tree-dump-primitives.h index 8af1c43..b2a8d93 100644 --- a/src/tree-dump-primitives.h +++ b/src/tree-dump-primitives.h @@ -68,6 +68,17 @@ static inline void tree_dump_integer(tree t, mpz_t val, enum DUMP_TYPE dt) gmp_fprintf(stderr, "%Zd", val); } +static inline void tree_dump_ffi_closure(tree t, ffi_closure *closure, enum DUMP_TYPE dt) +{ + return; +} + +static inline void tree_dump_ffi_cif(tree t, ffi_cif *closure, + enum DUMP_TYPE dt) +{ + return; +} + static inline void tree_dump_comp_decl_type(tree t, compound_type v, enum DUMP_TYPE dt) { switch(v) { diff --git a/src/tree.h b/src/tree.h index c3b5118..38238a1 100644 --- a/src/tree.h +++ b/src/tree.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "list.h" #include "tree-access.h"