Author: leo
Date: Tue Mar 7 03:23:48 2006
New Revision: 11808
Modified:
trunk/config/gen/core_pmcs.pm
trunk/include/parrot/interpreter.h
trunk/src/dod.c
trunk/src/dynpmc/subproxy.pmc
trunk/src/global.c
trunk/src/inter_create.c
trunk/src/inter_misc.c
trunk/src/pmc/namespace.pmc
trunk/src/pmc/parrotinterpreter.pmc
Log:
Namespaces 2 - remove Stash structure
* the namespace hashes will have a pointer to parent
* add pod for the planned namespace data layout
* create initial top-level namespace
Modified: trunk/config/gen/core_pmcs.pm
==============================================================================
--- trunk/config/gen/core_pmcs.pm (original)
+++ trunk/config/gen/core_pmcs.pm Tue Mar 7 03:23:48 2006
@@ -45,7 +45,7 @@
/*
* DO NOT EDIT THIS FILE
*
- * Automatically generated by config/gen/core_pmcs.pl
+ * Automatically generated by config/gen/core_pmcs.pm
*/
/* &gen_from_enum(pmctypes.pasm) subst(s/enum_class_(\\w+)/\$1/e) */
@@ -116,10 +116,8 @@
PMC *classname_hash, *iglobals;
int i;
/* Need an empty stash */
- interp->globals = mem_sys_allocate(sizeof(struct Stash));
- interp->globals->stash_hash =
- pmc_new(interp, enum_class_Hash);
- interp->globals->parent_stash = NULL;
+ interp->stash_hash =
+ pmc_new(interp, enum_class_NameSpace);
/* We need a class hash */
interp->class_hash = classname_hash =
pmc_new(interp, enum_class_Hash);
Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h (original)
+++ trunk/include/parrot/interpreter.h Tue Mar 7 03:23:48 2006
@@ -277,8 +277,7 @@
struct Interp_Context ctx;
context_mem ctx_mem; /* ctx memory managment */
- struct Stash *globals; /* Pointer to the global variable
- * area */
+ struct PMC *stash_hash; /* namespace hash */
struct Arenas *arena_base; /* Pointer to this interpreter's
* arena */
Modified: trunk/src/dod.c
==============================================================================
--- trunk/src/dod.c (original)
+++ trunk/src/dod.c Tue Mar 7 03:23:48 2006
@@ -275,7 +275,6 @@
* note: adding locals here did cause increased DOD runs
*/
unsigned int i = 0;
- struct Stash *stash = 0;
if (trace_stack == 2) {
trace_system_areas(interpreter);
@@ -324,12 +323,8 @@
for (i = 0; i <= E_LAST_PYTHON_E; ++i) {
pobject_lives(interpreter, (PObj*)interpreter->exception_list[i]);
}
- /* Walk through the stashes */
- stash = interpreter->globals;
- while (stash) {
- pobject_lives(interpreter, (PObj *)stash->stash_hash);
- stash = stash->parent_stash;
- }
+ /* mark the stash_hash */
+ pobject_lives(interpreter, (PObj *)interpreter->stash_hash);
/* s. packfile.c */
mark_const_subs(interpreter);
Modified: trunk/src/dynpmc/subproxy.pmc
==============================================================================
--- trunk/src/dynpmc/subproxy.pmc (original)
+++ trunk/src/dynpmc/subproxy.pmc Tue Mar 7 03:23:48 2006
@@ -40,7 +40,7 @@
internal_exception(1, "SubProxy: no sub");
Parrot_load_bytecode(INTERP, file);
rsub = VTABLE_get_pmc_keyed(INTERP,
- INTERP->globals->stash_hash, sub);
+ INTERP->stash_hash, sub);
if (!VTABLE_defined(INTERP, rsub))
internal_exception(1, "SubProxy: sub not found");
Modified: trunk/src/global.c
==============================================================================
--- trunk/src/global.c (original)
+++ trunk/src/global.c Tue Mar 7 03:23:48 2006
@@ -59,7 +59,7 @@
PIO_printf(interpreter, "find_global class '%Ss' meth '%Ss'\n",
class, globalname);
#endif
- stash = interpreter->globals->stash_hash;
+ stash = interpreter->stash_hash;
if (class) {
ns_name = string_concat(interpreter,
string_from_cstring(interpreter, "\0", 1),
@@ -91,16 +91,16 @@
string_from_cstring(interpreter, "\0", 1),
class, 0);
if (!VTABLE_exists_keyed_str(interpreter,
- interpreter->globals->stash_hash,
+ interpreter->stash_hash,
ns_name)) {
return NULL;
}
stash = VTABLE_get_pmc_keyed_str(interpreter,
- interpreter->globals->stash_hash,
+ interpreter->stash_hash,
ns_name);
}
else {
- stash = interpreter->globals->stash_hash;
+ stash = interpreter->stash_hash;
}
if (!globalname)
return stash;
@@ -124,7 +124,7 @@
case enum_class_String:
return Parrot_find_global(interpreter, PMC_str_val(ns), name);
case enum_class_Key:
- stash = interpreter->globals->stash_hash;
+ stash = interpreter->stash_hash;
while (1) {
class = key_string(interpreter, ns);
ns_name = string_concat(interpreter,
@@ -289,7 +289,7 @@
Parrot_store_global(Interp *interpreter, STRING *class,
STRING *globalname, PMC *pmc)
{
- PMC *globals = interpreter->globals->stash_hash;
+ PMC *globals = interpreter->stash_hash;
PMC *stash;
if (class) {
stash = Parrot_global_namespace(interpreter, globals, class);
@@ -304,7 +304,7 @@
store_sub_in_namespace(Parrot_Interp interpreter, PMC* sub_pmc,
PMC *namespace, STRING *sub_name)
{
- PMC *globals = interpreter->globals->stash_hash;
+ PMC *globals = interpreter->stash_hash;
INTVAL type, class_type;
#if DEBUG_GLOBAL
Modified: trunk/src/inter_create.c
==============================================================================
--- trunk/src/inter_create.c (original)
+++ trunk/src/inter_create.c Tue Mar 7 03:23:48 2006
@@ -299,7 +299,6 @@
{
int i;
Interp *interpreter = (Interp*) vinterp;
- struct Stash *stash, *next_stash;
UNUSED(exit_code);
@@ -368,13 +367,6 @@
PackFile_destroy(interpreter, pf);
}
- /* walk and free the stash, pmc's are already dead */
- stash = interpreter->globals;
- while (stash) {
- next_stash = stash->parent_stash;
- mem_sys_free(stash);
- stash = next_stash;
- }
/* free vtables */
if (!interpreter->parent_interpreter)
for (i = 1; i < (int)enum_class_max; i++)
Modified: trunk/src/inter_misc.c
==============================================================================
--- trunk/src/inter_misc.c (original)
+++ trunk/src/inter_misc.c Tue Mar 7 03:23:48 2006
@@ -250,7 +250,7 @@
case CURRENT_OBJECT:
return CONTEXT(interpreter->ctx)->current_object;
case NAMESPACE_ROOT: /* XXX */
- return interpreter->globals->stash_hash;
+ return interpreter->stash_hash;
case CURRENT_LEXPAD:
return CONTEXT(interpreter->ctx)->lex_pad;
default: /* or a warning only? */
Modified: trunk/src/pmc/namespace.pmc
==============================================================================
--- trunk/src/pmc/namespace.pmc (original)
+++ trunk/src/pmc/namespace.pmc Tue Mar 7 03:23:48 2006
@@ -1,6 +1,6 @@
/*
Copyright: 2005 The Perl Foundation. All Rights Reserved.
-$Id:$
+$Id$
=head1 NAME
@@ -10,6 +10,13 @@
These are the vtable functions for the namespace PMC.
+=head2 Data
+
+ PMC_struct_val ... the hash, bucket->value is an array
+ of 3 PMCs (namespace, sub, var) slot
+ PMC_pmc_val ... parent namespace
+ PMC_data ... name string of this namespace part
+
=head2 Functions
=over 4
Modified: trunk/src/pmc/parrotinterpreter.pmc
==============================================================================
--- trunk/src/pmc/parrotinterpreter.pmc (original)
+++ trunk/src/pmc/parrotinterpreter.pmc Tue Mar 7 03:23:48 2006
@@ -286,7 +286,7 @@
new_interp->iglobals, key);
/* quick hack to get the global stash */
if (key == -1)
- return new_interp->globals->stash_hash;
+ return new_interp->stash_hash;
return NULL;
}
@@ -320,7 +320,7 @@
item = key_string(interpreter, key);
s = CONST_STRING(interpreter, "globals");
if (string_equal(interpreter, item, s) == 0)
- return interpreter->globals->stash_hash;
+ return interpreter->stash_hash;
outer = NULL;
s = CONST_STRING(interpreter, "outer");
if (string_equal(interpreter, item, s) == 0) {