aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-05-25 02:41:40 +0000
committerdos-reis <gdr@axiomatics.org>2010-05-25 02:41:40 +0000
commitd08100e5c7cc7ebf2c30c490033f1ccd5b57fb86 (patch)
treeee7c772e820813fde4e02de79c2b545f936bfa17
parent8993bc2fe00eb48b57945b850c14bde8fae1dfb7 (diff)
downloadopen-axiom-d08100e5c7cc7ebf2c30c490033f1ccd5b57fb86.tar.gz
* interp/g-util.boot (expandToVMForm): New. Export.
(getOpcodeExpander): move to here from c-util.boot. ($middleEndOpcodes): Likewise.
-rw-r--r--src/ChangeLog6
-rw-r--r--src/interp/c-util.boot10
-rw-r--r--src/interp/g-timer.boot2
-rw-r--r--src/interp/g-util.boot25
4 files changed, 33 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 664a8acb..ac68364e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
2010-05-24 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/g-util.boot (expandToVMForm): New. Export.
+ (getOpcodeExpander): move to here from c-util.boot.
+ ($middleEndOpcodes): Likewise.
+
+2010-05-24 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/i-object.boot (object): New. Abstract over boilerplate.
* interp/i-analy.boot: Use it in place of boilerplate.
* interp/i-eval.boot: Likewise.
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