File tree Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 36
36
" src/storage.c" ,
37
37
" src/strbldr.c" ,
38
38
//
39
- " -O1 " , // Optimization Level. Tail Call Optimization seem to need >= 2
39
+ " -O3 " , // Optimization Level. Tail Call Optimization seem to need >= 2
40
40
" -std=c17" , // 'ISO C 2017' standard
41
41
" -o" ,
42
42
" ${workspaceFolder}/bin/sicp" , // output e.g., "${fileDirname}/sicp",
76
76
],
77
77
},
78
78
]
79
- }
79
+ }
Original file line number Diff line number Diff line change 3
3
4
4
#include "eceval.h"
5
5
6
+ #include <stdbool.h>
6
7
#include <stdlib.h>
8
+
7
9
#include "error.h"
8
10
#include "list.h"
9
11
#include "mceval.h"
@@ -81,7 +83,7 @@ static void set_proc_name(struct core *cr)
81
83
of_string ("<unknown>" );
82
84
}
83
85
84
- static obj ecevalgoto (struct core * cr )
86
+ static obj ecevalgoto (struct core * cr , bool yield )
85
87
{
86
88
obj go_obj = restore (cr );
87
89
goto go_obj ;
@@ -422,6 +424,10 @@ static obj ecevalgoto(struct core *cr)
422
424
return error_eval (AREA , "Unknown procedure type: %s" , errstr (cr -> proc ));
423
425
424
426
go_cont :
427
+ if (yield ) {
428
+ save (cr -> cont , cr );
429
+ return yielded ;
430
+ }
425
431
go_obj = cr -> cont ;
426
432
go_obj :
427
433
if (is_eq (go_obj , ev_return_caller ))
@@ -456,10 +462,14 @@ static obj ecevalgoto(struct core *cr)
456
462
457
463
obj eceval (obj expression , obj _environment )
458
464
{
465
+ obj rslt ;
466
+
459
467
struct core * cr = dfltcore ();
460
468
cr -> expr = expression ;
461
469
cr -> env = _environment ;
462
470
cr -> cont = ev_return_caller ;
463
471
save_nogc (ev_eval_dispatch , cr );
464
- return ecevalgoto (cr );
472
+ while (is_yielded (rslt = ecevalgoto (cr , false)))
473
+ ;
474
+ return rslt ;
465
475
}
Original file line number Diff line number Diff line change @@ -302,6 +302,11 @@ bool is_void(obj dat)
302
302
return type (dat ) == TYPE_VOID ;
303
303
}
304
304
const obj void_o = OBJ_2 (TYPE_VOID , SUBTYPE_NOT_SET );
305
+ const obj yielded = OBJ_2 (TYPE_YIELDED , SUBTYPE_NOT_SET );
306
+ bool is_yielded (obj dat )
307
+ {
308
+ return type (dat ) == TYPE_YIELDED ;
309
+ }
305
310
306
311
// BROKEN HEART
307
312
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ enum type {
29
29
TYPE_BROKEN_HEART , // 11
30
30
TYPE_BITMAP , // 12
31
31
TYPE_UNASSIGNED , // 13
32
- TYPE_ERROR // 14
32
+ TYPE_YIELDED , // 14
33
+ TYPE_ERROR // 15
33
34
};
34
35
35
36
enum { SUBTYPE_NOT_SET = 0 };
@@ -172,6 +173,8 @@ extern const obj ok;
172
173
extern const obj unspecified ;
173
174
bool is_void (obj dat );
174
175
extern const obj void_o ;
176
+ extern const obj yielded ;
177
+ bool is_yielded (obj dat );
175
178
176
179
// BROKEN HEART
177
180
You can’t perform that action at this time.
0 commit comments