diff options
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/c-util.boot | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot index 6fca669a..596a7949 100644 --- a/src/interp/c-util.boot +++ b/src/interp/c-util.boot @@ -1069,18 +1069,27 @@ 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 op + nil + middleEndExpand: %Form -> %Form middleEndExpand x == isAtomicForm x => x - first x in $middleEndMacroList => + [op,:args] := x + op in $middleEndMacroList => middleEndExpand MACROEXPAND_-1 x - a := middleEndExpand first x - b := middleEndExpand rest x - EQ(a,first x) and EQ(b,rest x) => x + IDENTP op and (fun := getOpcodeExpander op) => apply(fun,args) + a := middleEndExpand op + b := middleEndExpand args + EQ(a,op) and EQ(b,args) => x [a,:b] - -- A function is simple if it looks like a super combinator, and it -- does not use its environment argument. They can be safely replaced -- by more efficient (hopefully) functions. |