aboutsummaryrefslogtreecommitdiff
path: root/src/interp/g-util.boot
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 /src/interp/g-util.boot
parent8993bc2fe00eb48b57945b850c14bde8fae1dfb7 (diff)
downloadopen-axiom-d08100e5c7cc7ebf2c30c490033f1ccd5b57fb86.tar.gz
* interp/g-util.boot (expandToVMForm): New. Export.
(getOpcodeExpander): move to here from c-util.boot. ($middleEndOpcodes): Likewise.
Diffstat (limited to 'src/interp/g-util.boot')
-rw-r--r--src/interp/g-util.boot25
1 files changed, 25 insertions, 0 deletions
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