aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-05-05 01:23:36 +0000
committerdos-reis <gdr@axiomatics.org>2010-05-05 01:23:36 +0000
commit5768bef1b2b7cd3fd38733a26a33ec2f0d8e6c01 (patch)
treebbe038276bb180f6d391dee2ca22388cd1aba2d2 /src/interp
parent9d2955097e1bd70c06df5c5a55da67fb151466c2 (diff)
downloadopen-axiom-5768bef1b2b7cd3fd38733a26a33ec2f0d8e6c01.tar.gz
* interp/c-util.boot (backendCompileSPADSLAM): Generate more
readable Lisp code.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/c-util.boot26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot
index e82cfc23..efe6852a 100644
--- a/src/interp/c-util.boot
+++ b/src/interp/c-util.boot
@@ -1336,7 +1336,7 @@ backendCompileSLAM(name,args,body) ==
COMP370 [u]
name
-++ Same as backendCompileSPADSLAM, except that the cache is a hash
+++ Same as backendCompileSLAM, except that the cache is a hash
++ table. This backend compiler is used to compile constructors.
backendCompileSPADSLAM: (%Symbol,%List,%Code) -> %Symbol
backendCompileSPADSLAM(name,args,body) ==
@@ -1348,20 +1348,18 @@ backendCompileSPADSLAM(name,args,body) ==
null args => [nil,nil,[auxfn]]
null rest args => [[g1],["devaluate",g1],[auxfn,g1]]
[g1,["devaluateList",g1],["APPLY",["FUNCTION",auxfn],g1]]
- arg := first u
+ arg := first u -- parameter list
argtran := second u -- devaluate argument
- app := third u
- codePart1 := -- if value already computed, grab it.
- null args => [al]
- [["SETQ",g2,["assoc",argtran,al]], ["CDR",g2]]
- codePart2 := -- otherwise compute it, and cache it.
- -- Note: at most five values are cached.
- null args => [true,["SETQ",al,app]]
- [true,["SETQ",al,["cons5",["CONS",argtran, ["SETQ",g2,app]],al]],g2]
- decl := -- declare the cache variable.
- null args => nil
- [g2]
- lamex := ["LAM",arg,["LET",decl,["COND",codePart1,codePart2]]]
+ app := third u -- code to compute value
+ code :=
+ args = nil => ["COND",[al],[true,["SETQ",al,app]]]
+ ["LET",[[g2,["assoc",argtran,al]]],
+ ["COND",
+ [g2,["CDR",g2]],
+ [true,
+ ["PROGN",["SETQ",g2,app],
+ ["SETQ",al,["cons5",["CONS",argtran, g2],al]],g2]]]]
+ lamex := ["LAM",arg,code]
SETANDFILE(al,nil) -- define the global cache.
-- compile the worker function first.
u := [auxfn,["LAMBDA",args,:body]]