cvsuser 03/07/14 03:32:36
Modified: . pmc.c
t/pmc env.t
Log:
create only one Env object
Revision Changes Path
1.25 +15 -2 parrot/pmc.c
Index: pmc.c
===================================================================
RCS file: /cvs/public/parrot/pmc.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -w -r1.24 -r1.25
--- pmc.c 23 Jun 2003 11:05:51 -0000 1.24
+++ pmc.c 14 Jul 2003 10:32:29 -0000 1.25
@@ -1,7 +1,7 @@
/* pmc.c
* Copyright: (When this is determined...it will go here)
* CVS Info
- * $Id: pmc.c,v 1.24 2003/06/23 11:05:51 leo Exp $
+ * $Id: pmc.c,v 1.25 2003/07/14 10:32:29 leo Exp $
* Overview:
* The base vtable calling functions.
* Data Structure and Algorithms:
@@ -73,7 +73,20 @@
PMC *
pmc_new_noinit(struct Parrot_Interp *interpreter, INTVAL base_type)
{
- PMC *pmc = get_new_pmc_header(interpreter, base_type,
+ PMC *pmc;
+ /* we only have one global Env object, livin in the interpreter */
+ if (base_type == enum_class_Env) {
+ pmc = VTABLE_get_pmc_keyed_int(interpreter, interpreter->iglobals,
+ (INTVAL)IGLOBALS_ENV_HASH);
+ if (!pmc) {
+ pmc = get_new_pmc_header(interpreter, base_type,
+ interpreter->arena_base->pmc_pool);
+ VTABLE_set_pmc_keyed_int(interpreter, interpreter->iglobals,
+ (INTVAL)IGLOBALS_ENV_HASH, pmc);
+ }
+ return pmc;
+ }
+ pmc = get_new_pmc_header(interpreter, base_type,
interpreter->arena_base->pmc_pool);
switch (base_type) {
case enum_class_PerlInt:
1.3 +19 -2 parrot/t/pmc/env.t
Index: env.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/env.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- env.t 14 Jul 2003 08:38:30 -0000 1.2
+++ env.t 14 Jul 2003 10:32:36 -0000 1.3
@@ -1,10 +1,10 @@
#! perl -w
-use Parrot::Test tests => 3;
+use Parrot::Test tests => 4;
use Test::More;
use Parrot::Config;
SKIP: {
- skip("no setenv", 2) unless $PConfig{"setenv"};
+ skip("no setenv", 3) unless $PConfig{"setenv"};
$ENV{"PARROT_TMP"} = "riding a ponie";
output_like(<<'CODE', <<OUT, "getenv");
new P0, .Env
@@ -25,6 +25,23 @@
/hello polly/i
OUT
}
+
+output_is(<<'CODE', <<OUT, "envs are all the same");
+ new P0, .Env
+ set P0["PARROT_TMP"], "hello polly"
+ set S0, P0["PARROT_TMP"]
+ new P1, .Env
+ set S1, P1["PARROT_TMP"]
+ eq S0, S1, ok
+ print "not ok\n"
+ end
+ok:
+ print "ok\n"
+ end
+CODE
+ok
+OUT
+
SKIP: {
skip("no unsetenv", 1) unless $PConfig{"unsetenv"};