From 3307ff377b32a791fcf7ba57a64fcdc79adcf230 Mon Sep 17 00:00:00 2001 From: Benjamin Vedder Date: Tue, 1 Feb 2022 21:51:54 +0100 Subject: [PATCH] Squashed 'lispBM/lispBM/' changes from 046eb52e..18d9001b 18d9001b fixes the to the eval_state statemachine git-subtree-dir: lispBM/lispBM git-subtree-split: 18d9001b32052a3de09517ae4e954c221155ef27 --- repl-cps/repl.c | 28 +++++++++++++++++++--------- src/eval_cps.c | 3 ++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/repl-cps/repl.c b/repl-cps/repl.c index 78adc998..d6089d6a 100644 --- a/repl-cps/repl.c +++ b/repl-cps/repl.c @@ -457,32 +457,42 @@ int main(int argc, char **argv) { lbm_load_and_define_program(&string_tok, "prelude"); lbm_continue_eval(); - /* Something better is needed. - this sleep ís to ensure the string is alive until parsing + /* Something better is needed. + this sleep ís to ensure the string is alive until parsing is done */ sleep_callback(10000); } else if (strncmp(str, ":send", 5) == 0) { int id; int i_val; - + if (sscanf(str + 5, "%d%d", &id, &i_val) == 2) { lbm_pause_eval(); while(lbm_get_eval_state() != EVAL_CPS_STATE_PAUSED) { sleep_callback(10); } - + if (lbm_send_message((lbm_cid)id, lbm_enc_i(i_val)) == 0) { printf("Could not send message\n"); } - + lbm_continue_eval(); } else { printf("Incorrect arguments to send\n"); } - - } else { + } else if (strncmp(str, ":pause", 6) == 0) { + lbm_pause_eval_with_gc(30); + while(lbm_get_eval_state() != EVAL_CPS_STATE_PAUSED) { + sleep_callback(10); + } + printf("Evaluator paused\n"); + + } else if (strncmp(str, ":continue", 9) == 0) { + lbm_continue_eval(); + } else if (strncmp(str, ":step", 5) == 0) { + lbm_step_eval(); + } else { /* Get exclusive access to the heap */ lbm_pause_eval(); while(lbm_get_eval_state() != EVAL_CPS_STATE_PAUSED) { @@ -497,8 +507,8 @@ int main(int argc, char **argv) { lbm_continue_eval(); printf("started ctx: %u\n", cid); - /* Something better is needed. - this sleep ís to ensure the string is alive until parsing + /* Something better is needed. + this sleep ís to ensure the string is alive until parsing is done */ sleep_callback(10000); } diff --git a/src/eval_cps.c b/src/eval_cps.c index c8d08376..b6fb2d8d 100644 --- a/src/eval_cps.c +++ b/src/eval_cps.c @@ -1927,7 +1927,7 @@ void lbm_run_eval(void){ eval_cps_run_state = EVAL_CPS_STATE_RUNNING; break; case EVAL_CPS_STATE_STEP: - eval_cps_run_state = EVAL_CPS_STATE_PAUSED; + eval_cps_next_state = EVAL_CPS_STATE_PAUSED; break; case EVAL_CPS_STATE_PAUSED: if (eval_cps_run_state != EVAL_CPS_STATE_PAUSED) { @@ -1943,6 +1943,7 @@ void lbm_run_eval(void){ eval_running = false; continue; default: + eval_cps_run_state = eval_cps_next_state; break; }