From 40ea76e2310ef826aad64970eee9851f0917b830 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 15 Nov 2019 09:12:08 +0100 Subject: [PATCH] HACK: flat-variable. --- include/mes/builtins.h | 1 + src/builtins.c | 1 + src/variable.c | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/include/mes/builtins.h b/include/mes/builtins.h index 08b4d844..47ff1eee 100644 --- a/include/mes/builtins.h +++ b/include/mes/builtins.h @@ -172,6 +172,7 @@ struct scm *struct_ref (struct scm *x, struct scm *i); struct scm *struct_set_x (struct scm *x, struct scm *i, struct scm *e); /* src/variable.c */ struct scm *variable_ref (struct scm *var); +struct scm *flat_variable_ref (struct scm *var); struct scm *variable_set_x (struct scm *var, struct scm *value); struct scm *variable_bound_p (struct scm *var); struct scm *lookup_variable (struct scm *name, struct scm *define_p); diff --git a/src/builtins.c b/src/builtins.c index d9e5abad..0f11d3a5 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -282,6 +282,7 @@ mes_builtins (struct scm *a) /*:((internal)) */ a = init_builtin (builtin_type, "struct-set!", 3, &struct_set_x, a); /* src/variable.c */ a = init_builtin (builtin_type, "variable-ref", 1, &variable_ref, a); + a = init_builtin (builtin_type, "flat-variable-ref", 1, &flat_variable_ref, a); a = init_builtin (builtin_type, "variable-set!", 2, &variable_set_x, a); a = init_builtin (builtin_type, "variable-bound?", 1, &variable_bound_p, a); a = init_builtin (builtin_type, "lookup-variable", 2, &lookup_variable, a); diff --git a/src/variable.c b/src/variable.c index 384d403f..a7a2a272 100644 --- a/src/variable.c +++ b/src/variable.c @@ -32,6 +32,16 @@ variable_ref (struct scm *var) return value; } +struct scm * +flat_variable_ref (struct scm *var) +{ + assert_variable (1, var); + struct scm *value = var->variable; + if (value == cell_undefined) + error (cell_symbol_unbound_variable, var); + return value; +} + struct scm * variable_set_x (struct scm *var, struct scm *value) {