Author: coke
Date: Mon Jan 9 14:44:50 2006
New Revision: 11030
Modified:
trunk/languages/tcl/t/tcl_misc.t
trunk/languages/tcl/tcl.pir_template
Log:
tcl - Add support for environment variables via the global 'env'
Modified: trunk/languages/tcl/t/tcl_misc.t
==============================================================================
--- trunk/languages/tcl/t/tcl_misc.t (original)
+++ trunk/languages/tcl/t/tcl_misc.t Mon Jan 9 14:44:50 2006
@@ -2,7 +2,7 @@
use strict;
use lib qw(tcl/t t . ../lib ../../lib ../../../lib);
-use Parrot::Test tests => 22;
+use Parrot::Test tests => 23;
use Test::More;
language_output_is("tcl",<<'TCL',<<OUT,"leading spacex2 should be ok");
@@ -155,6 +155,18 @@ TCL
1 {unmatched open brace in list}
OUT
+{
+ local undef %ENV;
+ $ENV{cow} = "moo";
+ $ENV{pig} = "oink";
+ $ENV{cowpig} = "moink";
-
+language_output_is("tcl",<<'TCL',<<'OUT',"compiler bug with reusing
registers");
+ parray env
+TCL
+env(cow) = moo
+env(cowpig) = moink
+env(pig) = oink
+OUT
+}
Modified: trunk/languages/tcl/tcl.pir_template
==============================================================================
--- trunk/languages/tcl/tcl.pir_template (original)
+++ trunk/languages/tcl/tcl.pir_template Mon Jan 9 14:44:50 2006
@@ -92,6 +92,25 @@ providing a compreg-compatible method.
#_load_grammar()
+ # Expose Environment variables.
+ .local pmc env,tcl_env,iterator
+ env = new .Env
+ tcl_env = new .TclArray
+
+ iterator = new .Iterator, env
+ iterator = 0
+
+ .local string key,value
+env_loop:
+ unless iterator goto env_loop_done
+ key = shift iterator
+ value = env[key]
+ tcl_env[key] = value
+
+ goto env_loop
+
+env_loop_done:
+ store_global "Tcl", "$env", tcl_env
# keep track of names of file types.
.local pmc filetypes