Improve dynamic scope inference

slava 2006-11-21 09:05:46 +00:00
parent 0fb57e1e9e
commit 16e7efc481
2 changed files with 13 additions and 2 deletions

View File

@ -29,7 +29,11 @@ TUPLE: inferred-vars reads writes reads-globals writes-globals ;
dup meta-n get [ hash-member? ] contains-with? [
drop
] [
inferred-vars get inferred-vars-reads push-new
inferred-vars get 2dup inferred-vars-writes member? [
2drop
] [
inferred-vars-reads push-new
] if
] if ;
: apply-var-write ( symbol -- )
@ -40,7 +44,12 @@ TUPLE: inferred-vars reads writes reads-globals writes-globals ;
] if ;
: apply-global-read ( symbol -- )
inferred-vars get inferred-vars-reads-globals push-new ;
inferred-vars get
2dup inferred-vars-writes-globals member? [
2drop
] [
inferred-vars-reads-globals push-new
] if ;
: apply-global-write ( symbol -- )
inferred-vars get inferred-vars-writes-globals push-new ;

View File

@ -378,3 +378,5 @@ SYMBOL: x
[ [ >n ] [ ] if ] unit-test-fails
[ V{ 2 3 } ] [ [ [ [ 2 get 3 throw ] [ 3 get ] if ] with-scope ] infer drop inferred-vars-reads ] unit-test
[ V{ } ] [ [ 5 set 5 get ] infer drop inferred-vars-reads ] unit-test