From 0e841ba86255626a17d29105e6df715250aebbdc Mon Sep 17 00:00:00 2001 From: dos-reis Date: Mon, 24 May 2010 07:41:13 +0000 Subject: * interp/c-util.boot ($middleEndOpcodes): New. (getOpcodeExpander): Likewise. (middleEndExpand): Use it to expand middle end opcodes. --- src/interp/c-util.boot | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/interp') 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. -- cgit v1.2.3