aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-06-12 08:39:06 +0000
committerdos-reis <gdr@axiomatics.org>2010-06-12 08:39:06 +0000
commitfecb6dc501ce3eeadb6d3f5a39de6a1ac808190d (patch)
tree323f1ff27b039394706ab2e78c00fa7b544dec91 /src/interp
parent30e7e66530a05b57abbb3bc29383c45adc5d4ec4 (diff)
downloadopen-axiom-fecb6dc501ce3eeadb6d3f5a39de6a1ac808190d.tar.gz
* interp/g-opt.boot (replaceableTemporary?): New.
(optSEQ) [getRidOfTemps]: Use it to decide when to safely inline a temporary variable definition.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/g-opt.boot15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index be39629b..119da259 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -330,7 +330,18 @@ optCONDtail l ==
optPredicateIfTrue p => [[$true,c]]
null rest l => [frst,[$true,["CondError"]]]
[frst,:optCONDtail l']
-
+
+++ Determine whether the symbol `g' is the name of a temporary that
+++ can be replaced in the form `x', if it is of linear usage and not
+++ the name of a program point. The latter occurs when THROW forms
+++ are changed to %LET form followed by a GO form -- see optCatch.
+replaceableTemporary?(g,x) ==
+ GENSYMP g and numOfOccurencesOf(g,x) < 2 and not jumpTarget?(g,x) where
+ jumpTarget?(g,x) ==
+ isAtomicForm x => false
+ x is ['GO,=g] => true
+ or/[jumpTarget?(g,x') for x' in x]
+
optSEQ ["SEQ",:l] ==
tryToRemoveSEQ SEQToCOND getRidOfTemps splicePROGN l where
splicePROGN l ==
@@ -339,7 +350,7 @@ optSEQ ["SEQ",:l] ==
l.rest := splicePROGN rest l
getRidOfTemps l ==
null l => nil
- l is [["%LET",g,x,:.],:r] and GENSYMP g and 2>numOfOccurencesOf(g,r) =>
+ l is [["%LET",g,x],:r] and replaceableTemporary?(g,r) =>
getRidOfTemps substitute(x,g,r)
first l="/throwAway" => getRidOfTemps rest l
--this gets rid of unwanted labels generated by declarations in SEQs