aboutsummaryrefslogtreecommitdiff
path: root/src/boot/ast.boot
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2009-08-28 17:29:17 +0000
committerdos-reis <gdr@axiomatics.org>2009-08-28 17:29:17 +0000
commitd2aa4652224e0dd476e9bbe53cea718ec3d89506 (patch)
treece39cad3dc5ed02ac0e83a4680c02022dc6b5666 /src/boot/ast.boot
parent5c7fc79609933c1fbfcd629d9df0ce72563bd573 (diff)
downloadopen-axiom-d2aa4652224e0dd476e9bbe53cea718ec3d89506.tar.gz
* boot/ast.boot (bfCase): Don't introduce temporary for scrutinee
when it is already reduced.
Diffstat (limited to 'src/boot/ast.boot')
-rw-r--r--src/boot/ast.boot22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/boot/ast.boot b/src/boot/ast.boot
index eb0f6940..adfa6b2e 100644
--- a/src/boot/ast.boot
+++ b/src/boot/ast.boot
@@ -1143,12 +1143,22 @@ bfCaseItem(x,y) ==
bfCase: (%Thing,%Thing) -> %List
bfCase(x,y)==
- g:=bfGenSymbol()
- g1:=bfGenSymbol()
- a:=bfLET(g,x)
- b:=bfLET(g1,["CDR",g])
- c:=bfCaseItems (g1,y)
- bfMKPROGN [a,b,["CASE",["CAR", g],:c]]
+ -- Introduce a temporary to hold the value of the scrutinee.
+ -- To minimize the number of GENSYMS and assignments, we want
+ -- to do this only when the scrutinee is not reduced yet.
+ g :=
+ atom x => x
+ bfGenSymbol()
+ a :=
+ EQ(g,x) => nil
+ [[g,x]]
+ -- We need a temporary for the rest of the structure.
+ g1 := bfGenSymbol()
+ -- locally bind newly introduced temporaries in the alternatives
+ inits := [:a,[g1,["CDR",g]]]
+ body := ["CASE",["CAR", g], :bfCaseItems (g1,y)]
+ #inits = 1 => ["LET",inits,body]
+ ["LET*",inits,body]
bfCaseItems: (%Thing,%List) -> %List
bfCaseItems(g,x) ==