cvs commit: ponie/src/pmc perl5base.pmc perl5cargo_cult.pmc

[email protected] (Nicholas Clark) 28 Apr 2005 10:19:09 -0000
Newsgroups perl.ponie.changes
Message-ID <[email protected]>
cvsuser     05/04/28 03:19:09

  Modified:    src/pmc  perl5base.pmc perl5cargo_cult.pmc
  Log:
  Actually morph PMC types on SvUPGRADE
  
  Revision  Changes    Path
  1.2       +6 -1      ponie/src/pmc/perl5base.pmc
  
  Index: perl5base.pmc
  ===================================================================
  RCS file: /cvs/public/ponie/src/pmc/perl5base.pmc,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- perl5base.pmc	27 Apr 2005 14:07:46 -0000	1.1
  +++ perl5base.pmc	28 Apr 2005 10:19:08 -0000	1.2
  @@ -11,4 +11,9 @@
    */
   
   pmclass Perl5base extends Perl5cargo_cult dynpmc group Perl5_group {
  +
  +    void morph(INTVAL new_type) {
  +        SELF->vtable = Parrot_base_vtables[new_type];
  +    }
  +
   }
  
  
  
  1.48      +13 -4     ponie/src/pmc/perl5cargo_cult.pmc
  
  Index: perl5cargo_cult.pmc
  ===================================================================
  RCS file: /cvs/public/ponie/src/pmc/perl5cargo_cult.pmc,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- perl5cargo_cult.pmc	27 Apr 2005 11:03:07 -0000	1.47
  +++ perl5cargo_cult.pmc	28 Apr 2005 10:19:08 -0000	1.48
  @@ -1105,10 +1105,19 @@
                   = (value & SVTYPEMASK);
               return;
   	case Ponie_I_SV_UPGRADE:
  -            if ((((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags & SVTYPEMASK) < value)
  -                do_upgrade(SELF, value);
  -            return;
  +            if ((((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags & SVTYPEMASK) >= value)
  +                return;
  +            /* Fall through  */
   	case Ponie_I_SV_UPGRADE_func:
  +            /* FIXME - I think that we need two arrays in ponie - 1 to map
  +               traditional SVt_* to PMCs, 1 to map all the PMC types we know
  +               about.  */
  +            /* Heck, do we actually need the latter?  */
  +            if (value < 0 || value >= Ponie_PMC_Perl5_MAX) {
  +                croak ("Out of range or illegal type %d (max is %d) "
  +                       "for sv upgrade", value, Ponie_PMC_Perl5_MAX - 1);
  +            }
  +            DYNSELF.morph(PL_pmcname[value]);
               do_upgrade(SELF, value);
               return;