@@ -52,7 +52,11 @@ static void save(obj dat, struct core *cr)
52
52
eprintf (AREA , "Halting - Reached Memory Limit" );
53
53
exit (1 );
54
54
}
55
- return ;
55
+ }
56
+
57
+ static void save_nogc (obj dat , struct core * cr )
58
+ {
59
+ cr -> stack = cons (dat , cr -> stack );
56
60
}
57
61
58
62
static obj restore (struct core * cr )
@@ -77,11 +81,10 @@ static void set_proc_name(struct core *cr)
77
81
of_string ("<unknown>" );
78
82
}
79
83
80
- static obj ecevalcr ( obj expression , obj _environment , struct core * cr )
84
+ static obj ecevalgoto ( struct core * cr )
81
85
{
82
- cr -> expr = expression ;
83
- cr -> env = _environment ;
84
- cr -> cont = ev_return_caller ;
86
+ obj go_obj = restore (cr );
87
+ goto go_obj ;
85
88
86
89
// 5.4.1 The Core of the Evaluator
87
90
@@ -419,35 +422,44 @@ static obj ecevalcr(obj expression, obj _environment, struct core *cr)
419
422
return error_eval (AREA , "Unknown procedure type: %s" , errstr (cr -> proc ));
420
423
421
424
go_cont :
422
- if (is_eq (cr -> cont , ev_return_caller ))
425
+ go_obj = cr -> cont ;
426
+ go_obj :
427
+ if (is_eq (go_obj , ev_return_caller ))
423
428
return cr -> val ;
424
- if (is_eq (cr -> cont , ev_appl_accum_last_arg ))
429
+ if (is_eq (go_obj , ev_appl_accum_last_arg ))
425
430
goto ev_appl_accum_last_arg ;
426
- if (is_eq (cr -> cont , ev_appl_accumulate_arg ))
431
+ if (is_eq (go_obj , ev_appl_accumulate_arg ))
427
432
goto ev_appl_accumulate_arg ;
428
- if (is_eq (cr -> cont , ev_appl_did_operator ))
433
+ if (is_eq (go_obj , ev_appl_did_operator ))
429
434
goto ev_appl_did_operator ;
430
- if (is_eq (cr -> cont , ev_apply_2 ))
435
+ if (is_eq (go_obj , ev_apply_2 ))
431
436
goto ev_apply_2 ;
432
- if (is_eq (cr -> cont , ev_apply_3 ))
437
+ if (is_eq (go_obj , ev_apply_3 ))
433
438
goto ev_apply_3 ;
434
- if (is_eq (cr -> cont , ev_assignment_1 ))
439
+ if (is_eq (go_obj , ev_assignment_1 ))
435
440
goto ev_assignment_1 ;
436
- if (is_eq (cr -> cont , ev_definition_1 ))
441
+ if (is_eq (go_obj , ev_definition_1 ))
437
442
goto ev_definition_1 ;
438
- if (is_eq (cr -> cont , ev_if_decide ))
443
+ if (is_eq (go_obj , ev_eval_dispatch ))
444
+ goto eval_dispatch ;
445
+ if (is_eq (go_obj , ev_if_decide ))
439
446
goto ev_if_decide ;
440
- if (is_eq (cr -> cont , ev_quoted ))
447
+ if (is_eq (go_obj , ev_quoted ))
441
448
goto ev_quoted ;
442
- if (is_eq (cr -> cont , ev_sequence_continue ))
449
+ if (is_eq (go_obj , ev_sequence_continue ))
443
450
goto ev_sequence_continue ;
444
- if (is_eq (cr -> cont , ev_timed_done ))
451
+ if (is_eq (go_obj , ev_timed_done ))
445
452
goto ev_timed_done ;
446
453
return error_internal (AREA , "BUG! Goto... where?: %s" ,
447
- to_string (cr -> cont ));
454
+ to_string (go_obj ));
448
455
}
449
456
450
457
obj eceval (obj expression , obj _environment )
451
458
{
452
- return ecevalcr (expression , _environment , dfltcore ());
459
+ struct core * cr = dfltcore ();
460
+ cr -> expr = expression ;
461
+ cr -> env = _environment ;
462
+ cr -> cont = ev_return_caller ;
463
+ save_nogc (ev_eval_dispatch , cr );
464
+ return ecevalgoto (cr );
453
465
}
0 commit comments