aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2009-07-14 02:30:28 +0000
committerdos-reis <gdr@axiomatics.org>2009-07-14 02:30:28 +0000
commit4f065a4bf2b814ffde4ef743cb89b384156e691d (patch)
tree75feeee33912cc9ba28573872e1710e9ce02ee9c /src/interp
parentc6efaa6ac903c17bd85eb51e672f80e9baa0ebc4 (diff)
downloadopen-axiom-4f065a4bf2b814ffde4ef743cb89b384156e691d.tar.gz
* interp/g-opt.boot (optCatch): Lift nested functions.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/g-opt.boot50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index f3a29f81..9e08d9a8 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -114,36 +114,40 @@ subrname u ==
COMPILED_-FUNCTION_-P u or MBPIP u => BPINAME u
nil
+changeThrowToExit(s,g) ==
+ atom s or MEMQ(first s,'(QUOTE SEQ REPEAT COLLECT)) => nil
+ s is ["THROW", =g,:u] => (rplac(first s,"EXIT"); rplac(rest s,u))
+ changeThrowToExit(first s,g)
+ changeThrowToExit(rest s,g)
+
+hasNoThrows(a,g) ==
+ a is ["THROW", =g,:.] => false
+ atom a => true
+ hasNoThrows(first a,g) and hasNoThrows(rest a,g)
+
+changeThrowToGo(s,g) ==
+ atom s or first s='QUOTE => nil
+ s is ["THROW", =g,u] =>
+ changeThrowToGo(u,g)
+ rplac(first s,"PROGN")
+ rplac(rest s,[["%LET",second g,u],["GO",second g]])
+ changeThrowToGo(first s,g)
+ changeThrowToGo(rest s,g)
+
optCatch (x is ["CATCH",g,a]) ==
$InteractiveMode => x
atom a => a
if a is ["SEQ",:s,["THROW", =g,u]] then
- changeThrowToExit(s,g) where
- changeThrowToExit(s,g) ==
- atom s or MEMQ(first s,'(QUOTE SEQ REPEAT COLLECT)) => nil
- s is ["THROW", =g,:u] => (rplac(first s,"EXIT"); rplac(rest s,u))
- changeThrowToExit(first s,g)
- changeThrowToExit(rest s,g)
+ changeThrowToExit(s,g)
rplac(rest a,[:s,["EXIT",u]])
["CATCH",y,a]:= optimize x
- if hasNoThrows(a,g) where
- hasNoThrows(a,g) ==
- a is ["THROW", =g,:.] => false
- atom a => true
- hasNoThrows(first a,g) and hasNoThrows(rest a,g)
- then (rplac(first x,first a); rplac(rest x,rest a))
- else
- changeThrowToGo(a,g) where
- changeThrowToGo(s,g) ==
- atom s or first s='QUOTE => nil
- s is ["THROW", =g,u] =>
- changeThrowToGo(u,g)
- rplac(first s,"PROGN")
- rplac(rest s,[["%LET",CADR g,u],["GO",CADR g]])
- changeThrowToGo(first s,g)
- changeThrowToGo(rest s,g)
+ if hasNoThrows(a,g) then
+ rplac(first x,first a)
+ rplac(rest x,rest a)
+ else
+ changeThrowToGo(a,g)
rplac(first x,"SEQ")
- rplac(rest x,[["EXIT",a],CADR g,["EXIT",CADR g]])
+ rplac(rest x,[["EXIT",a],second g,["EXIT",second g]])
x
optSPADCALL(form is ['SPADCALL,:argl]) ==