aboutsummaryrefslogtreecommitdiff
path: root/builtins
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-03-09 14:02:19 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-03-09 14:02:19 -0500
commit955f047e069497be4cbeffa3e0309360aeb1efa7 (patch)
tree20b59546bb79c75d368739959d15c28317e913bd /builtins
parent0921f3723bf7fe7539aa7a5dfdbd921f445777af (diff)
First pass at lambdas/closures
Diffstat (limited to 'builtins')
-rw-r--r--builtins/datatypes.h4
-rw-r--r--builtins/types.h2
2 files changed, 6 insertions, 0 deletions
diff --git a/builtins/datatypes.h b/builtins/datatypes.h
index a9c9ac27..20dede35 100644
--- a/builtins/datatypes.h
+++ b/builtins/datatypes.h
@@ -30,4 +30,8 @@ typedef struct table_s {
void *default_value;
} table_t;
+typedef struct {
+ void *fn, *userdata;
+} closure_t;
+
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0
diff --git a/builtins/types.h b/builtins/types.h
index 397e14c1..533ffb86 100644
--- a/builtins/types.h
+++ b/builtins/types.h
@@ -52,6 +52,8 @@ typedef struct TypeInfo {
.tag=TableInfo, .TableInfo.key=key_expr, .TableInfo.value=value_expr})
#define $FunctionInfo(typestr) &((TypeInfo){.size=sizeof(void*), .align=__alignof__(void*), \
.tag=FunctionInfo, .FunctionInfo.type_str=typestr})
+#define $ClosureInfo(typestr) &((TypeInfo){.size=2*sizeof(void*), .align=__alignof__(void*), \
+ .tag=FunctionInfo, .FunctionInfo.type_str=typestr})
#define $TypeInfoInfo(typestr) &((TypeInfo){.size=sizeof(TypeInfo), .align=__alignof__(TypeInfo), \
.tag=TypeInfoInfo, .TypeInfoInfo.type_str=typestr})