Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add ability for contextuals to also search %*ENV.
  • Loading branch information
pmichaud committed Sep 5, 2009
1 parent a746af0 commit 8566a62
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/builtins/globals.pir
Expand Up @@ -97,16 +97,30 @@ src/builtins/globals.pir - initialize miscellaneous global variables
.sub '!find_contextual'
.param string name

# first search caller scopes
$P0 = find_dynamic_lex name
unless null $P0 goto done

# next, strip twigil and search PROCESS package
.local string pkgname
pkgname = clone name
substr pkgname, 1, 1, ''
$P0 = get_hll_global ['PROCESS'], pkgname
unless null $P0 goto done
$P0 = get_global pkgname
unless null $P0 goto done

# if still not found, try %*ENV
.local pmc env
env = '!find_contextual'('%*ENV')
.local string envname
envname = clone name
substr envname, 0, 2, ''
$I0 = exists env[envname]
unless $I0 goto fail
$P0 = env[envname]
unless null $P0 goto done
fail:
$P0 = '!FAIL'('Contextual ', name, ' not found')
done:
.return ($P0)
Expand Down

0 comments on commit 8566a62

Please sign in to comment.