cvsuser     04/12/15 06:14:33

  Modified:    classes  default.pmc delegate.pmc
               src      packfile.c
               .        vtable.tbl
  Log:
  stub in object vtables - add_method, namespace_name
  
  Revision  Changes    Path
  1.108     +18 -1     parrot/classes/default.pmc
  
  Index: default.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/default.pmc,v
  retrieving revision 1.107
  retrieving revision 1.108
  diff -u -r1.107 -r1.108
  --- default.pmc       15 Dec 2004 12:52:38 -0000      1.107
  +++ default.pmc       15 Dec 2004 14:14:30 -0000      1.108
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: default.pmc,v 1.107 2004/12/15 12:52:38 leo Exp $
  +$Id: default.pmc,v 1.108 2004/12/15 14:14:30 leo Exp $
   
   =head1 NAME
   
  @@ -358,6 +358,10 @@
   
   Returns the name of the PMC.
   
  +=item C<STRING *namespace_name()>
  +
  +Returns the namespace name of the PMC.
  +
   =cut
   
   */
  @@ -366,6 +370,11 @@
           return SELF->vtable->whoami;
       }
   
  +    STRING* namespace_name () {
  +        return SELF->vtable->whoami;
  +    }
  +
  +
   /*
   
   =item C<PMC *find_method(STRING *method_name)>
  @@ -373,6 +382,10 @@
   Looks up the method for C<*method_name> and returns it. If no method is
   found then C<NULL> is returned.
   
  +=item C<void add_method(STRING *method_name, PMC *sub)>
  +
  +Store the method as a global in the namespace of this class.
  +
   =cut
   
   */
  @@ -382,6 +395,10 @@
           return Parrot_find_method_with_cache(INTERP, SELF, method_name);
       }
   
  +    void add_method(STRING *method_name, PMC *sub_pmc) {
  +        STRING *names = DYNSELF.namespace_name();
  +        Parrot_store_global(interpreter, names, method_name, sub_pmc);
  +    }
   /*
   
   =item C<INTVAL get_integer_keyed_int(INTVAL key)>
  
  
  
  1.36      +13 -1     parrot/classes/delegate.pmc
  
  Index: delegate.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/delegate.pmc,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- delegate.pmc      12 Dec 2004 23:03:45 -0000      1.35
  +++ delegate.pmc      15 Dec 2004 14:14:30 -0000      1.36
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2003 The Perl Foundation.  All Rights Reserved.
  -$Id: delegate.pmc,v 1.35 2004/12/12 23:03:45 chromatic Exp $
  +$Id: delegate.pmc,v 1.36 2004/12/15 14:14:30 leo Exp $
   
   =head1 NAME
   
  @@ -178,6 +178,10 @@
           /* don't delegate destroy */
       }
   
  +    void mark() {
  +        /* don't mark destroy */
  +    }
  +
       PMC* instantiate() {
           STRING *meth = const_string(interpreter,
                   PARROT_VTABLE_INSTANTIATE_METHNAME);
  @@ -189,6 +193,14 @@
           }
           return (PMC*) Parrot_run_meth_fromc(interpreter, sub, SELF, meth);
       }
  +
  +    void add_method(STRING *method_name, PMC *sub_pmc) {
  +        SUPER(method_name, sub_pmc);
  +    }
  +
  +    STRING* namespace_name () {
  +        return SUPER();
  +    }
   }
   
   /*
  
  
  
  1.187     +24 -3     parrot/src/packfile.c
  
  Index: packfile.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/packfile.c,v
  retrieving revision 1.186
  retrieving revision 1.187
  diff -u -r1.186 -r1.187
  --- packfile.c        30 Nov 2004 10:28:54 -0000      1.186
  +++ packfile.c        15 Dec 2004 14:14:31 -0000      1.187
  @@ -2,7 +2,7 @@
   Copyright (C) 2001-2002 Gregor N. Purdy. All rights reserved.
   This program is free software. It is subject to the same license as
   Parrot itself.
  -$Id: packfile.c,v 1.186 2004/11/30 10:28:54 leo Exp $
  +$Id: packfile.c,v 1.187 2004/12/15 14:14:31 leo Exp $
   
   =head1 NAME
   
  @@ -2882,7 +2882,8 @@
   store_sub_in_namespace(Parrot_Interp interpreter, struct PackFile *pf,
           PMC* sub_pmc, STRING* key, int ns)
   {
  -    PMC * globals = interpreter->globals->stash_hash;
  +    PMC *globals = interpreter->globals->stash_hash;
  +    INTVAL type;
   
   #if TRACE_PACKFILE_PMC
       fprintf(stderr, "PMC_CONST: store_global: name '%s' ns %d\n",
  @@ -2914,10 +2915,30 @@
                   names = pfc_const->u.string;
                   if (!string_length(interpreter, names))
                       goto global_ns;
  -                Parrot_store_global(interpreter, names, key, sub_pmc);
  +                /*
  +                 * if the namespace is a class, call add_method
  +                 * on that class PMC
  +                 */
  +                type = pmc_type(interpreter, names);
  +                if (type > enum_type_undef) {
  +                    PMC *class;
  +                    VTABLE *vtable;
  +                    vtable = Parrot_base_vtables[type];
  +                    if (!vtable)
  +                        internal_exception(1, "empty vtable '%Ss'", names);
  +                    class = (PMC*)vtable->data;
  +                    if (!class)
  +                        internal_exception(1, "empty class '%Ss'", names);
  +                    VTABLE_add_method(interpreter, class, key, sub_pmc);
  +                }
  +                else
  +                    Parrot_store_global(interpreter, names, key, sub_pmc);
                   break;
               case PFC_KEY:
                   part = pfc_const->u.key;
  +                /*
  +                 * TODO handle nested keys too with add_method
  +                 */
                   for (; part; part = PMC_data(part)) {
                       STRING *s = key_string(interpreter, part);
   #if TRACE_PACKFILE_PMC
  
  
  
  1.74      +2 -2      parrot/vtable.tbl
  
  Index: vtable.tbl
  ===================================================================
  RCS file: /cvs/public/parrot/vtable.tbl,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- vtable.tbl        15 Dec 2004 10:36:27 -0000      1.73
  +++ vtable.tbl        15 Dec 2004 14:14:33 -0000      1.74
  @@ -1,4 +1,4 @@
  -# $Id: vtable.tbl,v 1.73 2004/12/15 10:36:27 leo Exp $
  +# $Id: vtable.tbl,v 1.74 2004/12/15 14:14:33 leo Exp $
   # [MAIN] #default section name
   
   void init()
  @@ -277,7 +277,7 @@
   void add_parent(PMC* parent)
   void become_parent(PMC* class)
   INTVAL class_type()
  -void add_method(STRING* method)
  +void add_method(STRING* method, PMC* sub_pmc)
   void remove_method(STRING* method)
   STRING* namespace_name()
   PMC* new_singleton()
  
  
  

Reply via email to