Author: mdiep
Date: Tue Oct 11 21:50:00 2005
New Revision: 9465

Modified:
   trunk/DEPRECATED
   trunk/classes/sub.pmc
   trunk/imcc/pbc.c
   trunk/include/parrot/sub.h
   trunk/src/global.c
   trunk/src/mmd.c
   trunk/src/packdump.c
   trunk/src/sub.c
   trunk/t/pmc/namespace.t
Log:
Namespace is now one word, not two.

Deprecate the Sub PMC method 'get_name_space' in favor of 'get_namespace' as a
result of the change.


Modified: trunk/DEPRECATED
==============================================================================
--- trunk/DEPRECATED    (original)
+++ trunk/DEPRECATED    Tue Oct 11 21:50:00 2005
@@ -25,6 +25,17 @@ user stack opcodes save/restore instead.
 
 =back
 
+=head1 Deprecated methods
+
+=over 4
+
+=item Sub.get_name_space()
+
+The Sub PMC method get_name_space is being replaced with get_namespace to
+reflect the internal change from name_space to the one-word namespace.
+
+=back
+
 =head1 FUTURE changes
 
 Not yet deprecated, but it's recommended to use the new syxtax and

Modified: trunk/classes/sub.pmc
==============================================================================
--- trunk/classes/sub.pmc       (original)
+++ trunk/classes/sub.pmc       Tue Oct 11 21:50:00 2005
@@ -63,7 +63,7 @@ print_sub_name(Interp* interpreter, PMC*
 }
 
 /*
- * A sub now contains more data like name_space, which makes it
+ * A sub now contains more data like namespace, which makes it
  * effectively a container. Therefore need_ext has to be set
  */
 pmclass Sub need_ext {
@@ -396,8 +396,8 @@ Marks the continuation as live.
             return;
         if (sub->name)
             pobject_lives(INTERP, (PObj *) sub->name);
-        if (!PMC_IS_NULL(sub->name_space))
-            pobject_lives(INTERP, (PObj *) sub->name_space);
+        if (!PMC_IS_NULL(sub->namespace))
+            pobject_lives(INTERP, (PObj *) sub->namespace);
         if (!PMC_IS_NULL(sub->multi_signature))
             pobject_lives(INTERP, (PObj *) sub->multi_signature);
     }
@@ -447,8 +447,8 @@ Archives the subroutine.
     void visit(visit_info *info) {
         struct Parrot_sub * sub = PMC_sub(SELF);
 
-        info->thaw_ptr = &sub->name_space;
-        (info->visit_pmc_now)(INTERP, sub->name_space, info);
+        info->thaw_ptr = &sub->namespace;
+        (info->visit_pmc_now)(INTERP, sub->namespace, info);
         info->thaw_ptr = &sub->multi_signature;
         (info->visit_pmc_now)(INTERP, sub->multi_signature, info);
         SUPER(info);
@@ -468,7 +468,7 @@ Archives the subroutine.
          * - segment TODO ???
          * - flags  (i.e. :load pragma and such)
          * - name of the sub's label
-         * - name_space
+         * - namespace
          * - HLL_id
          * - multi_signature
          * - n_regs_used[i]
@@ -572,8 +572,10 @@ Called after the subroutine as been unar
 
 =item C<METHOD PMC* get_name_space()>
 
-Return the name_space PMC or Undef. The name_space PMC is either a
-String PMC or a Key PMC for a nested name_space.
+=item C<METHOD PMC* get_namespace()>
+
+Return the namespace PMC or Undef. The namespace PMC is either a
+String PMC or a Key PMC for a nested namespace.
 
 =item C<METHOD INTVAL __get_regs_used(char *kind)>
 
@@ -586,8 +588,15 @@ Return amount of used registers for regi
     METHOD PMC* get_name_space() {
         struct Parrot_sub * sub = PMC_sub(SELF);
 
-        return PMC_IS_NULL(sub->name_space) ?
-            pmc_new(INTERP, enum_class_Undef) : sub->name_space;
+        return PMC_IS_NULL(sub->namespace) ?
+            pmc_new(INTERP, enum_class_Undef) : sub->namespace;
+    }
+
+    METHOD PMC* get_namespace() {
+        struct Parrot_sub * sub = PMC_sub(SELF);
+
+        return PMC_IS_NULL(sub->namespace) ?
+            pmc_new(INTERP, enum_class_Undef) : sub->namespace;
     }
 
     METHOD INTVAL __get_regs_used(char *kind) {

Modified: trunk/imcc/pbc.c
==============================================================================
--- trunk/imcc/pbc.c    (original)
+++ trunk/imcc/pbc.c    Tue Oct 11 21:50:00 2005
@@ -648,7 +648,7 @@ add_const_pmc_sub(Interp *interpreter, S
 {
     int i, k;
     INTVAL type;
-    PMC *name_space;
+    PMC *namespace;
     PMC *sub_pmc;
     struct Parrot_sub *sub;
     struct PackFile_Constant *pfc;
@@ -693,21 +693,21 @@ add_const_pmc_sub(Interp *interpreter, S
     sub = PMC_sub(sub_pmc);
     sub->name = string_from_cstring(interpreter, real_name, 0);
 
-    name_space = NULL;
+    namespace = NULL;
     if (ns_const >= 0 && ns_const < ct->const_count) {
         switch (ct->constants[ns_const]->type) {
             case PFC_KEY:
-                name_space = ct->constants[ns_const]->u.key;
+                namespace = ct->constants[ns_const]->u.key;
                 break;
             case PFC_STRING:
-                name_space = constant_pmc_new(interpreter,
+                namespace = constant_pmc_new(interpreter,
                         enum_class_String);
-                PMC_str_val(name_space) =
+                PMC_str_val(namespace) =
                     ct->constants[ns_const]->u.string;
                 break;
         }
     }
-    sub->name_space = name_space;
+    sub->namespace = namespace;
     sub->address = (opcode_t*)(long)offs;
     sub->end = (opcode_t*)(long)end;
     sub->HLL_id = unit->HLL_id;

Modified: trunk/include/parrot/sub.h
==============================================================================
--- trunk/include/parrot/sub.h  (original)
+++ trunk/include/parrot/sub.h  Tue Oct 11 21:50:00 2005
@@ -57,7 +57,7 @@ typedef struct Parrot_sub {
     opcode_t *end;              /* end of bytecode */
 
     INTVAL   HLL_id;            /* see src/hll.c XXX or per segment? */
-    PMC      *name_space;       /* where this Sub is in */
+    PMC      *namespace;       /* where this Sub is in */
     STRING   *name;             /* name of the sub */
     PMC      *multi_signature;  /* list of types for MMD */
     INTVAL   n_regs_used[4];   /* INSP in PBC */
@@ -81,7 +81,7 @@ typedef struct Parrot_coro {
     opcode_t *end;              /* end of bytecode */
 
     INTVAL   HLL_id;            /* see src/hll.c XXX or per segment? */
-    PMC      *name_space;       /* where this Sub is in */
+    PMC      *namespace;       /* where this Sub is in */
     STRING   *name;             /* name of the sub */
     PMC      *multi_signature;  /* list of types for MMD */
     INTVAL   n_regs_used[4];   /* INSP in PBC */

Modified: trunk/src/global.c
==============================================================================
--- trunk/src/global.c  (original)
+++ trunk/src/global.c  Tue Oct 11 21:50:00 2005
@@ -195,16 +195,16 @@ the interpreter's errors setting.
 PMC *
 Parrot_get_name(Interp* interpreter, STRING *name)
 {
-    PMC *g, *pad, *current_sub, *name_space;
+    PMC *g, *pad, *current_sub, *namespace;
 
     pad = scratchpad_get_current(interpreter);
     g = scratchpad_find(interpreter, pad, name);
     if (!g) {
         current_sub = CONTEXT(interpreter->ctx)->current_sub;
         if (current_sub &&
-                (name_space = PMC_sub(current_sub)->name_space))
+                (namespace = PMC_sub(current_sub)->namespace))
 
-            g = Parrot_find_global_p(interpreter, name_space, name);
+            g = Parrot_find_global_p(interpreter, namespace, name);
     }
     if (!g)
         g = Parrot_find_global(interpreter, NULL, name);
@@ -298,7 +298,7 @@ Parrot_store_global(Interp *interpreter,
 
 static void
 store_sub_in_namespace(Parrot_Interp interpreter, PMC* sub_pmc,
-        PMC *name_space, STRING *sub_name)
+        PMC *namespace, STRING *sub_name)
 {
     PMC *globals = interpreter->globals->stash_hash;
     INTVAL type, class_type;
@@ -306,12 +306,12 @@ store_sub_in_namespace(Parrot_Interp int
 #if DEBUG_GLOBAL
     fprintf(stderr, "PMC_CONST: store_global: name '%s' ns %s\n",
             (char*)sub_name->strstart,
-            name_space ? (char*)PMC_str_val(name_space)->strstart : "(none)");
+            namespace ? (char*)PMC_str_val(namespace)->strstart : "(none)");
 #endif
     /*
      * namespace is either s String or a Key PMC or NULL
      */
-    if (PMC_IS_NULL(name_space)) {
+    if (PMC_IS_NULL(namespace)) {
 global_ns:
         Parrot_store_global(interpreter, NULL, sub_name, sub_pmc);
     }
@@ -319,10 +319,10 @@ global_ns:
         STRING *names;
         PMC * stash = NULL, *part;
 
-        type = name_space->vtable->base_type;
+        type = namespace->vtable->base_type;
         switch (type) {
             case enum_class_String:
-                names = PMC_str_val(name_space);
+                names = PMC_str_val(namespace);
                 if (!string_length(interpreter, names))
                     goto global_ns;
                 /*
@@ -345,7 +345,7 @@ global_ns:
                     Parrot_store_global(interpreter, names, sub_name, sub_pmc);
                 break;
             case enum_class_Key:
-                part = name_space;
+                part = namespace;
                 /*
                  * a nested key can't be handled by add_method
                  */
@@ -398,29 +398,29 @@ Parrot_store_sub_in_namespace(Parrot_Int
 {
     STRING* sub_name;
     PMC *multi_sig;
-    PMC *name_space;
+    PMC *namespace;
     INTVAL func_nr;
     char *c_meth;
 
     sub_name = PMC_sub(sub_pmc)->name;
-    name_space = PMC_sub(sub_pmc)->name_space;
+    namespace = PMC_sub(sub_pmc)->namespace;
     multi_sig = PMC_sub(sub_pmc)->multi_signature;
     if (PMC_IS_NULL(multi_sig)) {
-        store_sub_in_namespace(interpreter, sub_pmc, name_space, sub_name);
+        store_sub_in_namespace(interpreter, sub_pmc, namespace, sub_name);
     }
     else {
         STRING *long_name;
         PMC *multi_sub;
 
-        multi_sub = Parrot_find_global_p(interpreter, name_space, sub_name);
+        multi_sub = Parrot_find_global_p(interpreter, namespace, sub_name);
         if (!multi_sub) {
             multi_sub = pmc_new(interpreter, enum_class_MultiSub);
             store_sub_in_namespace(interpreter, multi_sub,
-                    name_space, sub_name);
+                    namespace, sub_name);
         }
         VTABLE_push_pmc(interpreter, multi_sub, sub_pmc);
         long_name = Parrot_multi_long_name(interpreter, sub_pmc);
-        store_sub_in_namespace(interpreter, sub_pmc, name_space, long_name);
+        store_sub_in_namespace(interpreter, sub_pmc, namespace, long_name);
 
         c_meth = string_to_cstring(interpreter, sub_name);
         if ( (func_nr = Parrot_MMD_method_idx(interpreter, c_meth))  >= 0) {

Modified: trunk/src/mmd.c
==============================================================================
--- trunk/src/mmd.c     (original)
+++ trunk/src/mmd.c     Tue Oct 11 21:50:00 2005
@@ -1962,18 +1962,18 @@ the MMD search should stop.
 static int
 mmd_search_package(Interp *interpreter, STRING *meth, PMC *arg_tuple, PMC *cl)
 {
-    /* STRING *name_space = CONTEXT(interpreter->ctx)->current_package; */
+    /* STRING *namespace = CONTEXT(interpreter->ctx)->current_package; */
     PMC *pmc;
     PMC *current_sub;
-    PMC *name_space;
+    PMC *namespace;
 
     current_sub = CONTEXT(interpreter->ctx)->current_sub;
     if (!current_sub || !VTABLE_defined(interpreter, current_sub))
         return 0;
-    name_space = PMC_sub(current_sub)->name_space;
-    if (!name_space)
+    namespace = PMC_sub(current_sub)->namespace;
+    if (!namespace)
         return 0;
-    pmc = Parrot_find_global_p(interpreter, name_space, meth);
+    pmc = Parrot_find_global_p(interpreter, namespace, meth);
     if (pmc) {
         if (mmd_maybe_candidate(interpreter, pmc, arg_tuple, cl))
             return 1;

Modified: trunk/src/packdump.c
==============================================================================
--- trunk/src/packdump.c        (original)
+++ trunk/src/packdump.c        Tue Oct 11 21:50:00 2005
@@ -119,15 +119,15 @@ PackFile_Constant_dump(Interp *interpret
                             "\tstart_offs => %d,\n"
                             "\tend_offs => %d,\n"
                             "\tname => '%Ss',\n"
-                            "\tname_space => '%Ss'\n",
+                            "\tnamespace => '%Ss'\n",
                             pmc->vtable->whoami,
                             sub->address - code_start,
                             sub->end - code_start,
                             sub->name,
-                            sub->name_space ?
-                                (sub->name_space->vtable->base_type ==
+                            sub->namespace ?
+                                (sub->namespace->vtable->base_type ==
                                     enum_class_String ?
-                                PMC_str_val(sub->name_space) : a_key) :
+                                PMC_str_val(sub->namespace) : a_key) :
                                 null
                             );
                     break;

Modified: trunk/src/sub.c
==============================================================================
--- trunk/src/sub.c     (original)
+++ trunk/src/sub.c     Tue Oct 11 21:50:00 2005
@@ -284,11 +284,11 @@ Parrot_full_sub_name(Interp* interpreter
     if (!sub || !VTABLE_defined(interpreter, sub))
         return NULL;
     s = PMC_sub(sub);
-    if (PMC_IS_NULL(s->name_space)) {
+    if (PMC_IS_NULL(s->namespace)) {
         return s->name;
     } else {
         if (s->name) {
-           STRING* ns = VTABLE_get_string(interpreter, s->name_space);
+           STRING* ns = VTABLE_get_string(interpreter, s->namespace);
 
            ns = string_concat(interpreter, ns,
                string_from_cstring(interpreter, " :: ", 4), 0);
@@ -345,11 +345,11 @@ Parrot_Context_info(Interp *interpreter,
     info->subname = sub->name;
 
     /* set the namespace name and fullname of the sub */
-    if (PMC_IS_NULL(sub->name_space)) {
+    if (PMC_IS_NULL(sub->namespace)) {
        info->nsname = string_from_cstring(interpreter, "", 0);
        info->fullname = info->subname;
     } else {
-       info->nsname = VTABLE_get_string(interpreter, sub->name_space);
+       info->nsname = VTABLE_get_string(interpreter, sub->namespace);
        info->fullname = string_concat(interpreter, info->nsname,
                string_from_cstring(interpreter, " :: ", 4), 0);
        info->fullname = string_concat(interpreter, info->fullname,

Modified: trunk/t/pmc/namespace.t
==============================================================================
--- trunk/t/pmc/namespace.t     (original)
+++ trunk/t/pmc/namespace.t     Tue Oct 11 21:50:00 2005
@@ -50,11 +50,11 @@ ok
 bar
 OUTPUT
 
-pir_output_is(<<'CODE', <<'OUTPUT', "get_name_space Foo::bar");
+pir_output_is(<<'CODE', <<'OUTPUT', "get_namespace Foo::bar");
 .sub 'main' :main
     $P0 = find_global "Foo", "bar"
     print "ok\n"
-    $P1 = $P0."get_name_space"()
+    $P1 = $P0."get_namespace"()
     print $P1
     print "\n"
 .end
@@ -273,7 +273,7 @@ pir_output_is(<<'CODE', <<'OUTPUT', "get
     print "bar\n"
     .include "interpinfo.pasm"
     $P0 = interpinfo .INTERPINFO_CURRENT_SUB
-    $P1 = $P0."get_name_space"()
+    $P1 = $P0."get_namespace"()
     print $P1
     print "\n"
 .end
@@ -298,7 +298,7 @@ pir_output_is(<<'CODE', <<'OUTPUT', "get
     .include "interpinfo.pasm"
     .include "pmctypes.pasm"
     $P0 = interpinfo .INTERPINFO_CURRENT_SUB
-    $P1 = $P0."get_name_space"()
+    $P1 = $P0."get_namespace"()
     typeof $I0, $P1
     if $I0 == .Key goto is_key
     print $P1

Reply via email to