417 |
* Environment Access (whereIs, returning object access path) * |
* Environment Access (whereIs, returning object access path) * |
418 |
****************************************************************************) |
****************************************************************************) |
419 |
|
|
420 |
fun whereIs(env as Env(valueL,closureL,_,whatMap),target) = |
fun whereIs (env as Env(valueL,closureL,_,whatMap), target) = let |
421 |
let fun bfs(nil,nil) = raise Lookup("whereIs",target,env) |
fun bfs (nil, nil) = raise Lookup("whereIs",target,env) |
422 |
| bfs(nil,next) = bfs(next,nil) |
| bfs(nil,next) = bfs(next,nil) |
423 |
| bfs((h, ox as (_, CR(off, {functions,values, |
| bfs ((h, ox as (_, CR(off, {functions,values, closures,stamp,...})))::m, next) = let |
424 |
closures,stamp,...})))::m, next) = |
fun cls(nil, _, next) = bfs(m,next) |
|
let fun cls(nil, _, next) = bfs(m,next) |
|
425 |
| cls((u as (v,cr))::t, i, next) = |
| cls((u as (v,cr))::t, i, next) = |
426 |
if target=v then h(SELp(i, OFFp 0), []) |
if target=v then h(SELp(i, OFFp 0), []) |
427 |
else let val nh = fn (p,z) => h(SELp(i, p), u::z) |
else let val nh = fn (p,z) => h(SELp(i, p), u::z) |
442 |
else h(OFFp(~off), [ox]) |
else h(OFFp(~off), [ox]) |
443 |
else fns(functions, 0) |
else fns(functions, 0) |
444 |
end |
end |
445 |
fun search closures = |
fun search closures = let |
446 |
let val s = map (fn x => (fn (p,z) => (#1 x,p,z), x)) closures |
val s = map (fn x => (fn (p,z) => (#1 x,p,z), x)) closures |
447 |
in Path (bfs(s,nil)) |
in |
448 |
|
Path (bfs(s,nil)) |
449 |
end |
end |
450 |
fun withTgt(v,CR(_,{free,...})) = member free target |
fun withTgt(v,CR(_,{free,...})) = member free target |
451 |
fun lookC ((v,cr)::tl) = |
fun lookC ((v,cr)::tl) = |
469 |
end |
end |
470 |
|
|
471 |
|
|
472 |
|
|
473 |
(**************************************************************************** |
(**************************************************************************** |
474 |
* Environment Filtering (get the set of current reusable closures) * |
* Environment Filtering (get the set of current reusable closures) * |
475 |
****************************************************************************) |
****************************************************************************) |