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? [
|
dup meta-n get [ hash-member? ] contains-with? [
|
||||||
drop
|
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 ;
|
] if ;
|
||||||
|
|
||||||
: apply-var-write ( symbol -- )
|
: apply-var-write ( symbol -- )
|
||||||
|
@ -40,7 +44,12 @@ TUPLE: inferred-vars reads writes reads-globals writes-globals ;
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: apply-global-read ( symbol -- )
|
: 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 -- )
|
: apply-global-write ( symbol -- )
|
||||||
inferred-vars get inferred-vars-writes-globals push-new ;
|
inferred-vars get inferred-vars-writes-globals push-new ;
|
||||||
|
|
|
@ -378,3 +378,5 @@ SYMBOL: x
|
||||||
[ [ >n ] [ ] if ] unit-test-fails
|
[ [ >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{ 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