Permalink
Browse files

Add ability for contextuals to also search %*ENV.

  • Loading branch information...
1 parent a746af0 commit 8566a62a491b72e6fef9e23918ae4ce5e3c7db77 @pmichaud pmichaud committed Sep 5, 2009
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/builtins/globals.pir
@@ -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)

0 comments on commit 8566a62

Please sign in to comment.