diff --git a/src/builtins/globals.pir b/src/builtins/globals.pir index 09310241f7a..776311f1c11 100644 --- a/src/builtins/globals.pir +++ b/src/builtins/globals.pir @@ -18,10 +18,8 @@ src/builtins/globals.pir - initialize miscellaneous global variables p6meta = get_hll_global ['Perl6Object'], '$!P6META' ## set up %*ENV - $P0 = get_hll_global 'Hash' - p6meta.'register'('Env', 'parent'=>$P0, 'protoobject'=>$P0) .local pmc env - env = root_new ['parrot';'Env'] + env = '!env_to_hash'() set_hll_global ['PROCESS'], '%ENV', env ## set up @*INC @@ -127,6 +125,52 @@ src/builtins/globals.pir - initialize miscellaneous global variables .end +.sub '!env_to_hash' + .local pmc env, hash + env = root_new ['parrot';'Env'] + hash = new ['Perl6Hash'] + $P0 = iter env + env_loop: + unless $P0 goto env_done + $S0 = shift $P0 + $S1 = env[$S0] + hash[$S0] = $S1 + goto env_loop + env_done: + .return (hash) +.end + + +.sub '!hash_to_env' + .param pmc hash :optional + .param int has_hash :opt_flag + + if has_hash goto have_hash + hash = '!find_contextual'('%*ENV') + have_hash: + + .local pmc env + env = root_new ['parrot';'Env'] + $P0 = iter env + env_loop: + unless $P0 goto env_done + $S0 = shift $P0 + $I0 = exists hash[$S0] + if $I0 goto env_loop + delete env[$S0] + goto env_loop + env_done: + + $P0 = iter hash + hash_loop: + unless $P0 goto hash_done + $S0 = shift $P0 + $S1 = hash[$S0] + env[$S0] = $S1 + goto hash_loop + hash_done: +.end + # Local Variables: # mode: pir # fill-column: 100 diff --git a/src/builtins/io.pir b/src/builtins/io.pir index b0e726ea3f6..b816877602f 100644 --- a/src/builtins/io.pir +++ b/src/builtins/io.pir @@ -129,6 +129,7 @@ It is an error to use bare C without arguments. .sub '!qx' .param string cmd .local pmc pio + '!hash_to_env'() pio = open cmd, 'rp' unless pio goto err_qx pio.'encoding'('utf8') diff --git a/src/builtins/system.pir b/src/builtins/system.pir index 3a0d1705c6e..7657a11dd2e 100644 --- a/src/builtins/system.pir +++ b/src/builtins/system.pir @@ -29,6 +29,7 @@ return the status code from the C opcode. .param string cmd .local int retval + '!hash_to_env'() spawnw retval, cmd .return (retval) .end @@ -39,6 +40,7 @@ return the status code from the C opcode. .local int retval unshift args, path + '!hash_to_env'() spawnw retval, args .return (retval) .end @@ -47,6 +49,7 @@ return the status code from the C opcode. .param pmc path_and_args .local int retval + '!hash_to_env'() spawnw retval, path_and_args .return (retval) .end diff --git a/src/parser/actions.pm b/src/parser/actions.pm index 22081307731..5d457bdf9c5 100644 --- a/src/parser/actions.pm +++ b/src/parser/actions.pm @@ -2136,7 +2136,6 @@ method variable($/, $key) { $vardecl.name($varname); $vardecl.namespace(@ns); $vardecl.scope('package'); - $vardecl.viviself( container_itype($sigil) ); $var := $vardecl; $twigil := ''; }