Improve dynamic scope inference
parent
0fb57e1e9e
commit
16e7efc481
|
@ -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 ;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue