Squashed 'lispBM/lispBM/' changes from ca26715a..e76a3deb

e76a3deb removed GC from finish_ctx. Can be taken care of from the C interface
91924e68 clean up heap after an error. Most important after an out_of_memory a bit dependent on how one interacts with the RTS
ba1c57ad new test on setvar together with let - passes.
df38cde4 small cleaning around bug fix area

git-subtree-dir: lispBM/lispBM
git-subtree-split: e76a3debc2abfd8528becb4295eb6f22492b3826
This commit is contained in:
Benjamin Vedder 2022-10-11 19:12:37 +02:00
parent c30054a533
commit 898e4df503
3 changed files with 26 additions and 7 deletions

View File

@ -661,7 +661,7 @@ int main(int argc, char **argv) {
file_str);
/* Get exclusive access to the heap */
lbm_pause_eval();
lbm_pause_eval_with_gc(50);
while(lbm_get_eval_state() != EVAL_CPS_STATE_PAUSED) {
sleep_callback(10);
}
@ -809,7 +809,7 @@ int main(int argc, char **argv) {
int i_val;
if (sscanf(str + 5, "%d%d", &id, &i_val) == 2) {
lbm_pause_eval();
lbm_pause_eval_with_gc(50);
while(lbm_get_eval_state() != EVAL_CPS_STATE_PAUSED) {
sleep_callback(10);
}
@ -849,7 +849,7 @@ int main(int argc, char **argv) {
printf("symbol does not exist\n");
}
} else if (strncmp(str, ":undef", 6) == 0) {
lbm_pause_eval();
lbm_pause_eval_with_gc(50);
while(lbm_get_eval_state() != EVAL_CPS_STATE_PAUSED) {
sleep_callback(10);
}
@ -861,7 +861,7 @@ int main(int argc, char **argv) {
} else {
/* Get exclusive access to the heap */
read_t *r = malloc(sizeof(read_t));
lbm_pause_eval();
lbm_pause_eval_with_gc(50);
while(lbm_get_eval_state() != EVAL_CPS_STATE_PAUSED) {
sleep_callback(10);
}

View File

@ -1997,19 +1997,17 @@ static void cont_application_args(eval_context_t *ctx) {
lbm_value rest = sptr[2];
lbm_value arg = ctx->r;
ctx->curr_env = env;
sptr[0] = arg;
if (lbm_is_symbol_nil(rest)) {
// no arguments
sptr[1] = count;
lbm_stack_drop(&ctx->K, 1);
ctx->curr_env = env;
cont_application(ctx);
} else if (lbm_is_cons(rest)) {
sptr[1] = env;
sptr[2] = lbm_enc_u(lbm_dec_u(count) + 1);
CHECK_STACK(lbm_push_2(&ctx->K,lbm_cdr(rest), APPLICATION_ARGS));
ctx->curr_exp = lbm_car(rest);
ctx->curr_env = env;
} else {
error_ctx(ENC_SYM_EERROR);
}

View File

@ -0,0 +1,21 @@
(define a 12)
(defun b () 18)
(define res
(let ((a 9))
(+ (b) (let ((b 6))
(progn
(setvar 'b 7)
(setvar 'a (+ b 2))
a))
a)
))
; Expected:
; res = 36
; a = 12
; (b) = 18
(and (= res 36)
(= a 12)
(= (b) 18))