Add basic lexenv support
This commit is contained in:
17
src/stack.h
17
src/stack.h
@ -40,6 +40,15 @@ static ALWAYS_INLINE struct StackFrame *LISP_STACK_TOP(void) {
|
||||
return the_stack.depth ? &the_stack.frames[the_stack.depth - 1] : NULL;
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE LispVal *TOP_LEXENV(void) {
|
||||
return the_stack.depth ? LISP_STACK_TOP()->lexenv : Qnil;
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE LispVal *PARENT_LEXENV(void) {
|
||||
return the_stack.depth > 1 ? the_stack.frames[the_stack.depth - 2].lexenv
|
||||
: Qnil;
|
||||
}
|
||||
|
||||
void lisp_init_stack(void);
|
||||
void lisp_teardown_stack(void);
|
||||
void push_stack_frame(LispVal *name, LispVal *fobj, LispVal *args);
|
||||
@ -47,6 +56,14 @@ void pop_stack_frame(void);
|
||||
void add_local_reference_no_recurse(LispVal *obj);
|
||||
void add_local_reference(LispVal *obj);
|
||||
|
||||
// Return true if successful, false if not found and not created
|
||||
bool set_lexical_variable(LispVal *name, LispVal *value, bool create_if_absent);
|
||||
// Just add a new lexical variable without any checking
|
||||
void new_lexical_variable(LispVal *name, LispVal *value);
|
||||
|
||||
// Copy the previous frame's lexenv to the top of the stack.
|
||||
void copy_parent_lexenv(void);
|
||||
|
||||
// used by the GC
|
||||
void compact_stack_frame(struct StackFrame *restrict frame);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user