core: Add the 'make-binding' builtin.

* src/eval-apply.c (make_binding): New function.
* include/mes/builtins.h (make_binding): Declare it.
* src/builtins.c (mes_builtins): Register it.
This commit is contained in:
Timothy Sample 2022-04-11 16:04:42 -06:00
parent 2cf520f595
commit b525923e91
3 changed files with 8 additions and 0 deletions

View File

@ -56,6 +56,7 @@ struct scm *set_cdr_x (struct scm *x, struct scm *e);
struct scm *add_formals (struct scm *formals, struct scm *x);
struct scm *eval_apply ();
struct scm *primitive_load (struct scm *filename);
struct scm *make_binding (struct scm *name, struct scm *variable);
/* src/gc.c */
struct scm *gc_stats ();
struct scm *cons (struct scm *x, struct scm *y);

View File

@ -166,6 +166,7 @@ mes_builtins (struct scm *a) /*:((internal)) */
a = init_builtin (builtin_type, "add-formals", 2, &add_formals, a);
a = init_builtin (builtin_type, "eval-apply", 0, &eval_apply, a);
a = init_builtin (builtin_type, "primitive-load", 1, &primitive_load, a);
a = init_builtin (builtin_type, "make-binding", 2, &make_binding, a);
/* src/gc.c */
a = init_builtin (builtin_type, "gc-stats", 0, &gc_stats, a);
a = init_builtin (builtin_type, "cons", 2, &cons, a);

View File

@ -170,6 +170,12 @@ make_binding_ (struct scm *handle, long lexical_p) /*:((internal)) */
return binding;
}
struct scm *
make_binding (struct scm *name, struct scm *variable)
{
return make_binding_ (cons (name, variable), 0);
}
struct scm *
macro_get_handle (struct scm *name) /*:((internal)) */
{