core: builtins: MES_MINI.

* include/mes/mes.h (g_mini): New global.
* src/mes.c (init): Initialize it with environment variable MES_MINI.
* src/builtins.c (mes_builtins): Register a minimal set of builtins
when g_mini.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-08-18 09:36:19 +02:00
parent 9e684b9886
commit e1efd41abe
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
3 changed files with 21 additions and 3 deletions

View file

@ -59,6 +59,7 @@ char *g_buf;
SCM g_continuations; SCM g_continuations;
SCM g_symbols; SCM g_symbols;
SCM g_symbol_max; SCM g_symbol_max;
int g_mini;
/* a/env */ /* a/env */
SCM R0; SCM R0;

View file

@ -109,11 +109,27 @@ init_builtin (SCM builtin_type, char const *name, int arity, FUNCTION function,
SCM SCM
mes_builtins (SCM a) /*:((internal)) */ mes_builtins (SCM a) /*:((internal)) */
{ {
// TODO minimal: cons, car, cdr, list, null_p, eq_p minus, plus
// display_, display_error_, getenv
SCM builtin_type = make_builtin_type (); SCM builtin_type = make_builtin_type ();
if (g_mini != 0)
{
a = init_builtin (builtin_type, "cons", 2, &cons, a);
a = init_builtin (builtin_type, "car", 1, &car, a);
a = init_builtin (builtin_type, "list", -1, &list, a);
a = init_builtin (builtin_type, "eq?", 2, &eq_p, a);
a = init_builtin (builtin_type, "-", -1, &minus, a);
a = init_builtin (builtin_type, "+", -1, &plus, a);
a = init_builtin (builtin_type, "core:display", 1, &display_, a);
a = init_builtin (builtin_type, "core:write", 1, &write_, a);
a = init_builtin (builtin_type, "core:display-error", 1, &display_error_, a);
a = init_builtin (builtin_type, "getenv", 1, &getenv_, a);
a = init_builtin (builtin_type, "gc", 0, &gc, a);
a = init_builtin (builtin_type, ">", -1, &greater_p, a);
a = init_builtin (builtin_type, "<", -1, &less_p, a);
a = init_builtin (builtin_type, "make-vector", -1, &make_vector, a);
return a;
}
/* src/builtins.c */ /* src/builtins.c */
a = init_builtin (builtin_type, "make-builtin", 4, &make_builtin, a); a = init_builtin (builtin_type, "make-builtin", 4, &make_builtin, a);
a = init_builtin (builtin_type, "builtin-name", 1, &builtin_name, a); a = init_builtin (builtin_type, "builtin-name", 1, &builtin_name, a);

View file

@ -177,6 +177,7 @@ init (char **envp)
char *p; char *p;
if (p = getenv ("MES_DEBUG")) if (p = getenv ("MES_DEBUG"))
g_debug = atoi (p); g_debug = atoi (p);
g_mini = getenv ("MES_MINI");
open_boot (); open_boot ();
gc_init (); gc_init ();
} }