4 #include "interpreter.h"
7 #include "repl_runtime.h"
9 static struct EvalResult gc_inspect_adapter(void *param, Gc *gc, struct Scope *scope, struct Expr args)
18 return eval_success(NIL(gc));
21 static struct EvalResult quit(void *param, Gc *gc, struct Scope *scope, struct Expr args)
30 return eval_success(NIL(gc));
33 static struct EvalResult get_scope(void *param, Gc *gc, struct Scope *scope, struct Expr args)
40 return eval_success(scope->expr);
43 static struct EvalResult print(void *param, Gc *gc, struct Scope *scope, struct Expr args)
50 struct EvalResult result = match_list(gc, "s", args, &s);
51 if (result.is_error) {
57 return eval_success(NIL(gc));
60 void load_repl_runtime(Gc *gc, struct Scope *scope)
62 set_scope_value(gc, scope, SYMBOL(gc, "quit"), NATIVE(gc, quit, NULL));
63 set_scope_value(gc, scope, SYMBOL(gc, "gc-inspect"), NATIVE(gc, gc_inspect_adapter, NULL));
64 set_scope_value(gc, scope, SYMBOL(gc, "scope"), NATIVE(gc, get_scope, NULL));
65 set_scope_value(gc, scope, SYMBOL(gc, "print"), NATIVE(gc, print, NULL));