From 98d71b26fa0926b5493e27ae36ab75444a197ba4 Mon Sep 17 00:00:00 2001 From: Benjamin Vedder Date: Tue, 15 Feb 2022 21:01:47 +0100 Subject: [PATCH] Squashed 'lispBM/lispBM/' changes from da9fb6cd..0a69a489 0a69a489 small rephrasing of a conditional in eval_define 4a0d6b9f redefining any non-RUNTIME_SYMBOL is now an error. dbc4bb71 removed left over printf git-subtree-dir: lispBM/lispBM git-subtree-split: 0a69a4896c83c1dc0ef4577cf54d42b5614de5b9 --- src/eval_cps.c | 21 +++++++++++---------- src/tokpar.c | 1 - 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/eval_cps.c b/src/eval_cps.c index b6ed2038..b7323284 100644 --- a/src/eval_cps.c +++ b/src/eval_cps.c @@ -889,26 +889,27 @@ static inline void eval_define(eval_context_t *ctx) { lbm_value key = lbm_car(lbm_cdr(ctx->curr_exp)); lbm_value val_exp = lbm_car(lbm_cdr(lbm_cdr(ctx->curr_exp))); - if (lbm_type_of(key) != LBM_VAL_TYPE_SYMBOL || - key == NIL) { - error_ctx(lbm_enc_sym(SYM_EERROR)); - return; - } + if ((lbm_type_of(key) == LBM_VAL_TYPE_SYMBOL) && + (lbm_dec_sym(key) >= RUNTIME_SYMBOLS_START)) { - CHECK_STACK(lbm_push_u32_2(&ctx->K, key, lbm_enc_u(SET_GLOBAL_ENV))); - ctx->curr_exp = val_exp; + CHECK_STACK(lbm_push_u32_2(&ctx->K, key, lbm_enc_u(SET_GLOBAL_ENV))); + ctx->curr_exp = val_exp; + } else { + error_ctx(lbm_enc_sym(SYM_EERROR)); + } + return; } static inline void eval_progn(eval_context_t *ctx) { lbm_value exps = lbm_cdr(ctx->curr_exp); lbm_value env = ctx->curr_env; - + if (lbm_type_of(exps) == LBM_VAL_TYPE_SYMBOL && exps == NIL) { ctx->r = NIL; ctx->app_cont = true; return; - } + } if (lbm_is_error(exps)) { error_ctx(exps); @@ -920,7 +921,7 @@ static inline void eval_progn(eval_context_t *ctx) { } static inline void eval_lambda(eval_context_t *ctx) { - + lbm_value env_cpy = lbm_env_copy_shallow(ctx->curr_env); if (lbm_is_symbol_merror(env_cpy)) { diff --git a/src/tokpar.c b/src/tokpar.c index 602bd662..4ab95ba3 100644 --- a/src/tokpar.c +++ b/src/tokpar.c @@ -585,7 +585,6 @@ lbm_value lbm_get_next_token(lbm_tokenizer_char_stream_t *str) { int r = 0; if (sym_str[0] == '#') { r = lbm_add_variable_symbol(sym_str, &symbol_id); - printf("added variable: %s as %d\n", sym_str, symbol_id - VARIABLE_SYMBOLS_START); } else { r = lbm_add_symbol(sym_str, &symbol_id); }