Author: leo
Date: Tue Mar  7 03:38:59 2006
New Revision: 11809

Modified:
   trunk/lib/Parrot/Vtable.pm
   trunk/src/pmc/default.pmc
   trunk/src/pmc/namespace.pmc
   trunk/t/src/extend.t
   trunk/vtable.tbl

Log:
Namespaces 3 - add namespace vtable function

* rename vtable->namespace to _namespace (the PMC*)
* add default namespace method, which returns _namespace
* fix src/extend.t tests

Please make realclean due to the vtable changes


Modified: trunk/lib/Parrot/Vtable.pm
==============================================================================
--- trunk/lib/Parrot/Vtable.pm  (original)
+++ trunk/lib/Parrot/Vtable.pm  Tue Mar  7 03:38:59 2006
@@ -138,7 +138,7 @@
 } vtable_flags_t;
 
 struct _vtable {
-    PMC *namespace;          /* Pointer to namespace for this class */
+    PMC * _namespace;        /* Pointer to namespace for this class */
     INTVAL base_type;        /* 'type' value for MMD */
     STRING* whoami;          /* Name of class this vtable is for */
     UINTVAL flags;           /* Flags. Duh */

Modified: trunk/src/pmc/default.pmc
==============================================================================
--- trunk/src/pmc/default.pmc   (original)
+++ trunk/src/pmc/default.pmc   Tue Mar  7 03:38:59 2006
@@ -371,6 +371,10 @@
 
 /*
 
+=item C<PMC* namespace>
+
+Return the namespace for this PMC.
+
 =item C<PMC *find_method(STRING *method_name)>
 
 Looks up the method for C<*method_name> and returns it. If no method is
@@ -384,6 +388,10 @@
 
 */
 
+    PMC* namespace() {
+        return SELF->vtable->_namespace;
+    }
+
 
     PMC* find_method(STRING* method_name) {
         PMC *method = Parrot_find_method_with_cache(INTERP, SELF, method_name);

Modified: trunk/src/pmc/namespace.pmc
==============================================================================
--- trunk/src/pmc/namespace.pmc (original)
+++ trunk/src/pmc/namespace.pmc Tue Mar  7 03:38:59 2006
@@ -29,6 +29,17 @@
 #include <assert.h>
 
 pmclass NameSpace extends Hash need_ext {
+
+    voit init {
+        SUPER();                        /* _struct_val := Hash */
+        PMC_pmc_val(SELF) = NULL;       /* parent */
+        PMC_data(SELF)    = NULL;       /* namespace name */
+    }
+
+    PMC* namespace() {
+        return SELF;
+    }
+
 }
 
 /*

Modified: trunk/t/src/extend.t
==============================================================================
--- trunk/t/src/extend.t        (original)
+++ trunk/t/src/extend.t        Tue Mar  7 03:38:59 2006
@@ -446,7 +446,7 @@
     Parrot_loadbc(interpreter, pf);
     key = key_new_cstring(interpreter, "_sub1");
     sub = VTABLE_get_pmc_keyed(interpreter,
-                              interpreter->globals->stash_hash, key);
+                              interpreter->stash_hash, key);
     Parrot_call_sub(interpreter, sub, "v");
     PIO_eprintf(interpreter, "back\n");
 
@@ -455,7 +455,7 @@
 
     key = key_new_cstring(interpreter, "_sub2");
     sub = VTABLE_get_pmc_keyed(interpreter,
-                              interpreter->globals->stash_hash, key);
+                              interpreter->stash_hash, key);
     arg = pmc_new(interpreter, enum_class_String);
     VTABLE_set_string_native(interpreter, arg,
                             string_from_cstring(interpreter, "hello ", 0));
@@ -520,7 +520,7 @@
     Parrot_loadbc(interpreter, pf);
     key = key_new_cstring(interpreter, "_sub1");
     sub = VTABLE_get_pmc_keyed(interpreter,
-                              interpreter->globals->stash_hash, key);
+                              interpreter->stash_hash, key);
 
     if (setjmp(jb.destination)) {
        PIO_eprintf(interpreter, "caught\n");

Modified: trunk/vtable.tbl
==============================================================================
--- trunk/vtable.tbl    (original)
+++ trunk/vtable.tbl    Tue Mar  7 03:38:59 2006
@@ -15,6 +15,7 @@
 void morph(INTVAL type)
 void mark()
 void destroy()
+PMC* namespace()
 
 PMC* getprop(STRING* key)
 void setprop(STRING* key, PMC* value)

Reply via email to