aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
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