~tim/lydia

ref: ac491010406397ebf135aa7cc0de4489660823a3 lydia/src/closure.h -rw-r--r-- 1.1 KiB View raw
ac491010Tim Morgan Backfill vars from function closure on tail calls. 8 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef CLOSURE_H
#define CLOSURE_H

typedef struct LClosure {
  hashmap_p vars;
  hashmap_p locals;
  struct LClosure *parent;
  bool cloneable;
  LNode *node;
  jmp_buf jmp;
} LClosure;

LClosure *l_closure_new(LNode *node);
LClosure *l_closure_clone(LClosure *parent, LNode *node);
LClosure *l_closure_backfill(LClosure *source, LClosure *target, LNode *node);
void l_clone_vars(hashmap_p from, hashmap_p to);
void l_clone_vars_if_missing(hashmap_p from, hashmap_p to);
void l_closure_free(LClosure *closure);
LClosure *l_closure_root(LClosure *closure);
LValue **l_ref_get(hashmap_p hash, char *name);
void l_ref_put(hashmap_p hash, char *name, LValue **ref);
void l_closure_set(LClosure *closure, char *name, LValue *value, bool local);
void l_closure_set_funcs(LClosure *closure);
LValue *l_closure_get(LClosure *closure, char *name);
LValue **l_closure_get_ref(LClosure *closure, char *name);
LValue **l_closure_pass_by_ref(LNode *node, char *name, LClosure *outer_closure, LClosure *inner_closure);

void l_inspect_closure(LClosure* closure);
int l_closure_size(LClosure *closure);

#endif