core: eval_apply: Prepare for M2-Planet.

* src/eval-apply.c (eval_apply): Prepare for M2-Planet.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2019-10-24 21:10:27 +02:00
parent 1496159bcf
commit da80e97402
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 106 additions and 89 deletions

View File

@ -612,7 +612,8 @@ eval:
} }
else else
{ {
if (TYPE (R1) == TPAIR && (CAR (R1) == cell_symbol_define || CAR (R1) == cell_symbol_define_macro)) if (TYPE (R1) == TPAIR)
if (CAR (R1) == cell_symbol_define || CAR (R1) == cell_symbol_define_macro)
{ {
global_p = CAAR (R0) != cell_closure; global_p = CAAR (R0) != cell_closure;
macro_p = CAR (R1) == cell_symbol_define_macro; macro_p = CAR (R1) == cell_symbol_define_macro;
@ -728,12 +729,16 @@ macro_expand:
goto vm_return; goto vm_return;
} }
if (TYPE (R1) == TPAIR && (macro = get_macro (CAR (R1))) != cell_f) if (TYPE (R1) == TPAIR)
{
macro = get_macro (CAR (R1));
if (macro != cell_f)
{ {
R1 = cons (macro, CDR (R1)); R1 = cons (macro, CDR (R1));
push_cc (R1, cell_nil, R0, cell_vm_macro_expand); push_cc (R1, cell_nil, R0, cell_vm_macro_expand);
goto apply; goto apply;
} }
}
if (CAR (R1) == cell_symbol_define || CAR (R1) == cell_symbol_define_macro) if (CAR (R1) == cell_symbol_define || CAR (R1) == cell_symbol_define_macro)
{ {
@ -762,12 +767,18 @@ macro_expand:
goto vm_return; goto vm_return;
} }
if (TYPE (R1) == TPAIR if (TYPE (R1) == TPAIR)
&& TYPE (CAR (R1)) == TSYMBOL {
&& CAR (R1) != cell_symbol_begin if (TYPE (CAR (R1)) == TSYMBOL && CAR (R1) != cell_symbol_begin)
&& ((macro = macro_get_handle (cell_symbol_portable_macro_expand)) != cell_f) {
&& ((expanders = module_ref (R0, cell_symbol_sc_expander_alist)) != cell_undefined) macro = macro_get_handle (cell_symbol_portable_macro_expand);
&& ((macro = assq (CAR (R1), expanders)) != cell_f)) if (macro != cell_f)
{
expanders = module_ref (R0, cell_symbol_sc_expander_alist);
if (expanders != cell_undefined)
{
macro = assq (CAR (R1), expanders);
if (macro != cell_f)
{ {
sc_expand = module_ref (R0, cell_symbol_macro_expand); sc_expand = module_ref (R0, cell_symbol_macro_expand);
R2 = R1; R2 = R1;
@ -777,6 +788,10 @@ macro_expand:
goto apply; goto apply;
} }
} }
}
}
}
}
push_cc (CAR (R1), R1, R0, cell_vm_macro_expand_car); push_cc (CAR (R1), R1, R0, cell_vm_macro_expand_car);
goto macro_expand; goto macro_expand;
@ -814,7 +829,8 @@ begin:
} }
} }
if (TYPE (R1) == TPAIR && TYPE (CAR (R1)) == TPAIR) if (TYPE (R1) == TPAIR)
if (TYPE (CAR (R1)) == TPAIR)
{ {
if (CAAR (R1) == cell_symbol_begin) if (CAAR (R1) == cell_symbol_begin)
R1 = append2 (CDAR (R1), CDR (R1)); R1 = append2 (CDAR (R1), CDR (R1));
@ -842,14 +858,15 @@ begin_expand:
if (TYPE (R1) == TPAIR) if (TYPE (R1) == TPAIR)
{ {
if (TYPE (CAR (R1)) == TPAIR && CAAR (R1) == cell_symbol_begin) if (TYPE (CAR (R1)) == TPAIR)
if (CAAR (R1) == cell_symbol_begin)
R1 = append2 (CDAR (R1), CDR (R1)); R1 = append2 (CDAR (R1), CDR (R1));
if (CAAR (R1) == cell_symbol_primitive_load) if (CAAR (R1) == cell_symbol_primitive_load)
{ {
push_cc (CADR (CAR (R1)), R1, R0, cell_vm_begin_expand_primitive_load); push_cc (CADR (CAR (R1)), R1, R0, cell_vm_begin_expand_primitive_load);
goto eval; goto eval;
begin_expand_primitive_load: begin_expand_primitive_load:
if (TYPE (R1) == TNUMBER && VALUE (R1) == 0) if ((TYPE (R1) == TNUMBER) && VALUE (R1) == 0)
0; 0;
else if (TYPE (R1) == TSTRING) else if (TYPE (R1) == TSTRING)
input = set_current_input_port (open_input_file (R1)); input = set_current_input_port (open_input_file (R1));