cvsuser     04/02/23 14:07:21

  Modified:    src      objects.c
               t/pmc    object-meths.t
  Log:
  Simple split namespaces now implemented, with method searching working
  
  Revision  Changes    Path
  1.32      +33 -33    parrot/src/objects.c
  
  Index: objects.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/objects.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -w -r1.31 -r1.32
  --- objects.c 23 Feb 2004 19:39:01 -0000      1.31
  +++ objects.c 23 Feb 2004 22:07:19 -0000      1.32
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: objects.c,v 1.31 2004/02/23 19:39:01 dan Exp $
  +$Id: objects.c,v 1.32 2004/02/23 22:07:19 dan Exp $
   
   =head1 NAME
   
  @@ -24,7 +24,7 @@
   /*
   
   =item C<static PMC *
  -find_global(Parrot_Interp interpreter, STRING *globalname)>
  +find_global(Parrot_Interp interpreter, STRING *class, STRING *globalname)>
   
   This should be public, but for right now it's internal.
   
  @@ -33,14 +33,26 @@
   */
   
   static PMC *
  -find_global(Parrot_Interp interpreter, STRING *globalname) {
  +find_global(Parrot_Interp interpreter, STRING *class, STRING *globalname) {
  +    PMC *stash;
  +    if (NULL != class) {
       if (!VTABLE_exists_keyed_str(interpreter,
  -                interpreter->globals->stash_hash, globalname)) {
  +                                     interpreter->globals->stash_hash,
  +                                     class)) {
  +            return NULL;
  +        }
  +        stash = VTABLE_get_pmc_keyed_str(interpreter,
  +                                         interpreter->globals->stash_hash,
  +                                         class);
  +    }
  +    else {
  +        stash = interpreter->globals->stash_hash;
  +    }
  +    if (!VTABLE_exists_keyed_str(interpreter, stash, globalname)) {
           return NULL;
       }
  -
       return VTABLE_get_pmc_keyed_str(interpreter,
  -            interpreter->globals->stash_hash, globalname);
  +            stash, globalname);
   }
   
   /*
  @@ -460,24 +472,14 @@
       INTVAL searchoffset = 0; /* Where in that array we are */
       INTVAL classcount = 0;   /* The number of classes we need to
                                   search */
  -    STRING *FQ_method;   /* The fully qualified name of the method
  -                            that we're going to look for, rebuilt for
  -                            each class we search */
  -    STRING *shortcut_name; /* The method name with the separator
  -                              prepended */
   
       /* if its a non-classes, just return the sub */
       if (!PObj_is_class_TEST(class)) {
  -        return find_global(interpreter, method_name);
  +        return find_global(interpreter,
  +                           NULL,
  +                           method_name);
       }
   
  -    /* We're going to make this over and over, so get it once and
  -       skip the repeated string makes */
  -    shortcut_name = string_concat(interpreter,
  -            string_from_cstring(interpreter, PARROT_NAMESPACE_SEPARATOR,
  -                PARROT_NAMESPACE_SEPARATOR_LENGTH),
  -            method_name, 0);
  -
       /* The order of operations:
        *
        * - Look for the method in the class we were passed
  @@ -488,12 +490,10 @@
        */
   
       /* See if we get lucky and its in the class of the PMC */
  -    FQ_method = string_concat(interpreter,
  +    method = find_global(interpreter,
               VTABLE_get_string_keyed_int(interpreter,
                       (PMC *)PMC_data(class), PCD_CLASS_NAME),
  -            shortcut_name, 0);
  -
  -    method = find_global(interpreter, FQ_method);
  +                         method_name);
   
       /* Bail immediately if we got something */
       if (NULL != method) {
  @@ -510,13 +510,13 @@
               searchoffset++) {
           curclass = VTABLE_get_pmc_keyed_int(interpreter,
                   classsearch_array, searchoffset);
  -
  -        FQ_method = string_concat(interpreter,
  +        method = find_global(interpreter,
                   VTABLE_get_string_keyed_int(interpreter,
                           (PMC *)PMC_data(curclass), PCD_CLASS_NAME),
  -                shortcut_name, 0);
  -        method = find_global(interpreter, FQ_method);
  +                             method_name);
  +        if (method) {
           Parrot_note_method_offset(interpreter, searchoffset, method);
  +        }
       }
       return method;
   }
  
  
  
  1.4       +4 -4      parrot/t/pmc/object-meths.t
  
  Index: object-meths.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/object-meths.t,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- object-meths.t    22 Feb 2004 22:55:29 -0000      1.3
  +++ object-meths.t    23 Feb 2004 22:07:21 -0000      1.4
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: object-meths.t,v 1.3 2004/02/22 22:55:29 mikescott Exp $
  +# $Id: object-meths.t,v 1.4 2004/02/23 22:07:21 dan Exp $
   
   =head1 NAME
   
  @@ -36,7 +36,7 @@
       # cant mangle method names yet
       find_global P3, "meth"
       # so store ref to the sub with the real name
  -    store_global "Foo\x0meth", P3
  +    store_global "Foo", "meth", P3
   
       print "main\n"
       callmethcc
  @@ -62,7 +62,7 @@
   
       new P3, .Sub
       # store the sub with the real name
  -    store_global "Foo\x0meth", P3
  +    store_global "Foo", "meth", P3
   
       can I0, P2, "meth"
       print I0
  @@ -85,7 +85,7 @@
   
       new P3, .Sub
       # store the sub with the real name
  -    store_global "Foo\x0meth", P3
  +    store_global "Foo", "meth", P3
   
       can I0, P2, "meth"
       print I0
  
  
  

Reply via email to