From b04a1b30903636bf97a8e04efe88e8a177855bcb Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 9 Mar 2024 16:03:38 -0500 Subject: Implement lambdas and closures --- environment.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'environment.h') diff --git a/environment.h b/environment.h index 8660fe68..2ab7a9d2 100644 --- a/environment.h +++ b/environment.h @@ -16,10 +16,17 @@ typedef struct { CORD main; } compilation_unit_t; +typedef struct { + type_t *return_type; + table_t *closure_scope; + table_t *closed_vars; +} fn_context_t; + typedef struct { table_t *types, *globals, *locals; table_t *type_namespaces; // Map of type name -> namespace table compilation_unit_t *code; + fn_context_t *fn_ctx; CORD scope_prefix; } env_t; @@ -29,6 +36,7 @@ typedef struct { } binding_t; env_t *new_compilation_unit(void); +env_t *global_scope(env_t *env); env_t *fresh_scope(env_t *env); env_t *namespace_env(env_t *env, const char *namespace_name); __attribute__((noreturn)) -- cgit v1.2.3