3 static struct Expr find_frame_with_name(struct Expr scope, struct Expr name)
7 /* TODO: find_frame_with_name is not implemented */
11 struct Expr empty_scope(void)
13 return CONS(NIL, NIL); /* '(()) */
16 struct Expr get_scope_value(struct Expr scope, struct Expr name)
20 struct Expr value = assoc(name, scope.cons->car);
21 return nil_p(value) ? get_scope_value(scope.cons->cdr, name) : value;
29 void set_scope_value(struct Expr scope, struct Expr name, struct Expr value)
31 struct Expr frame = find_frame_with_name(scope, name);
32 push(CONS(name, value), frame);
35 struct Expr push_scope_frame(struct Expr scope)
37 return CONS(empty_scope(), scope);
40 struct Expr pop_scope_frame(struct Expr scope)
42 if (scope.type == EXPR_CONS) {
43 return scope.cons->cdr;