diff options
author | dos-reis <gdr@axiomatics.org> | 2010-05-24 07:41:13 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2010-05-24 07:41:13 +0000 |
commit | 0e841ba86255626a17d29105e6df715250aebbdc (patch) | |
tree | b355155160d80db73036101e6f3a82099f268620 /src/interp | |
parent | cd465d2c88f45cb35d3488dbe0ad24e4ee0e05ab (diff) | |
download | open-axiom-0e841ba86255626a17d29105e6df715250aebbdc.tar.gz |
* interp/c-util.boot ($middleEndOpcodes): New.
(getOpcodeExpander): Likewise.
(middleEndExpand): Use it to expand middle end opcodes.
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. |