diff options
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/c-util.boot | 10 | ||||
-rw-r--r-- | src/interp/g-timer.boot | 2 | ||||
-rw-r--r-- | src/interp/g-util.boot | 25 |
3 files changed, 27 insertions, 10 deletions
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot index e496ad7c..bf47eecb 100644 --- a/src/interp/c-util.boot +++ b/src/interp/c-util.boot @@ -1069,21 +1069,13 @@ mutateLETFormWithUnaryFunction(form,fun) == $middleEndMacroList == '(COLLECT REPEAT SUCHTHATCLAUSE THETA THETA1 SPADREDUCE SPADDO) -++ List of opcode-expander pairs. -$middleEndOpcodes == nil - -++ Return the expander of a middle-end opcode, or nil if there is none. -getOpcodeExpander op == - x := ASSOC(op,$middleEndOpcodes) => rest x - nil - middleEndExpand: %Form -> %Form middleEndExpand x == isAtomicForm x => x [op,:args] := x op in $middleEndMacroList => middleEndExpand MACROEXPAND_-1 x - IDENTP op and (fun := getOpcodeExpander op) => apply(fun,args) + IDENTP op and (fun := getOpcodeExpander op) => apply(fun,x,nil) a := middleEndExpand op b := middleEndExpand args EQ(a,op) and EQ(b,args) => x diff --git a/src/interp/g-timer.boot b/src/interp/g-timer.boot index 49f73575..83570472 100644 --- a/src/interp/g-timer.boot +++ b/src/interp/g-timer.boot @@ -255,7 +255,7 @@ timedOptimization(code) == timedEVALFUN(code) == startTimingProcess 'evaluation - r := timedEvaluate code + r := timedEvaluate expandToVMForm code stopTimingProcess 'evaluation r diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot index 9b2ea472..3181c0c8 100644 --- a/src/interp/g-util.boot +++ b/src/interp/g-util.boot @@ -43,7 +43,32 @@ module g_-util where pairList: (%List,%List) -> %List mkList: %List -> %List isSubDomain: (%Mode,%Mode) -> %Form + expandToVMForm: %Thing -> %Thing + +--% +--% Opcode expansion to VM codes. +--% + +++ List of opcode-expander pairs. +$middleEndOpcodes == nil + +++ Return the expander of a middle-end opcode, or nil if there is none. +getOpcodeExpander op == + x := ASSOC(op,$middleEndOpcodes) => rest x + nil + +++ Expand all opcodes contained in the form `x' into a form +++ suitable for evaluation by the VM. +expandToVMForm x == + isAtomicForm x => x + [op,:args] := x + IDENTP op and (fun:= getOpcodeExpander op) => apply(fun,x,nil) + op' := expandToVMForm op + args' := expandToVMForm args + EQ(op,op') and EQ(args,args') => x + [op',:args'] + ++ $interpOnly := false |