Author: leo
Date: Tue Mar 7 13:22:22 2006
New Revision: 11819
Modified:
trunk/include/parrot/interpreter.h
trunk/src/global_setup.c
trunk/src/hll.c
Log:
Namespaces 8 - get rid of previous hack (r11817)
* create a distinct Interp.HLL_namespace array to cache HLL toplevel ns
* less hackish, and less indirections to use it
Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h (original)
+++ trunk/include/parrot/interpreter.h Tue Mar 7 13:22:22 2006
@@ -347,6 +347,7 @@
PMC* DOD_registry; /* registered PMCs added to the
root set */
PMC* HLL_info; /* storage for HLL names and
types */
+ PMC* HLL_namespace; /* cache of HLL toplevel ns */
MMD_table *binop_mmd_funcs; /* Table of MMD functions */
UINTVAL n_binop_mmd_funcs; /* function count */
Modified: trunk/src/global_setup.c
==============================================================================
--- trunk/src/global_setup.c (original)
+++ trunk/src/global_setup.c Tue Mar 7 13:22:22 2006
@@ -145,12 +145,16 @@
/*
* HLL support
*/
- if (interpreter->parent_interpreter)
+ if (interpreter->parent_interpreter) {
interpreter->HLL_info = interpreter->parent_interpreter->HLL_info;
+ interpreter->HLL_namespace =
interpreter->parent_interpreter->HLL_namespace;
+ }
else {
STRING *parrot = CONST_STRING(interpreter, "parrot");
interpreter->HLL_info = constant_pmc_new(interpreter,
enum_class_ResizablePMCArray);
+ interpreter->HLL_namespace = constant_pmc_new(interpreter,
+ enum_class_ResizablePMCArray);
Parrot_register_HLL(interpreter, parrot, NULL);
}
/*
Modified: trunk/src/hll.c
==============================================================================
--- trunk/src/hll.c (original)
+++ trunk/src/hll.c Tue Mar 7 13:22:22 2006
@@ -62,7 +62,6 @@
e_HLL_name,
e_HLL_lib,
e_HLL_typemap,
- e_HLL_namespace,
e_HLL_MAX
} HLL_enum_t;
@@ -106,6 +105,7 @@
/* create HLL namespace */
hll_name = string_downcase(interpreter, hll_name);
+
/* HLL type mappings aren't yet created, we can't create
* a namespace in HLL's flavor yet - mabe promote the
* ns_hash to another type, if mappings provide one
@@ -115,7 +115,8 @@
ns_hash = pmc_new(interpreter, enum_class_NameSpace);
VTABLE_set_pmc_keyed_str(interpreter, interpreter->stash_hash,
hll_name, ns_hash);
- VTABLE_set_pmc_keyed_int(interpreter, entry, e_HLL_namespace, ns_hash);
+ /* cache HLLs toplevel namespace */
+ VTABLE_set_pmc_keyed_int(interpreter, interpreter->HLL_namespace, idx,
ns_hash);
/* register HLL lib */
name = constant_pmc_new_noinit(interpreter, enum_class_String);
@@ -125,7 +126,7 @@
VTABLE_set_string_native(interpreter, name, hll_lib);
VTABLE_set_pmc_keyed_int(interpreter, entry, e_HLL_lib, name);
- /* register HLL typemap */
+ /* create HLL typemap hash */
type_hash = Parrot_new_INTVAL_hash(interpreter, PObj_constant_FLAG);
VTABLE_set_pmc_keyed_int(interpreter, entry, e_HLL_typemap, type_hash);
if (string_length(interpreter, hll_lib)) {
@@ -135,15 +136,6 @@
/* UNLOCK */
- /*
- * XXX the HLL_info is frozen with the ParrotInterpreter, to be able
- * to preserve all in the PBC *but* the namespace hash shouldn't be
- * included in the bytecode - HACK - reduce array.elems by one
- * so that namespace isn't seen by freeze/thaw
- * XXX this still doesn't recreate the namespace slot TODO
- * better use a distinct structure for namespaces ?
- */
- PMC_int_val(entry) = e_HLL_namespace;
return idx;
}