cvs commit: ponie/src/pmc perl5base.pmc perl5cargo_cult.pmc
[email protected] (Nicholas Clark) 30 Apr 2005 10:18:59 -0000
| Newsgroups | perl.ponie.changes |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 05/04/30 03:18:59
Modified: perl embedvar.h perl.c perlapi.h perlvars.h
src/pmc perl5base.pmc perl5cargo_cult.pmc
Log:
Move all the SV upgrade logic into the morph method
Fix a fencepost error on one of the type mapping arrays
Revision Changes Path
1.12 +2 -0 ponie/perl/embedvar.h
Index: embedvar.h
===================================================================
RCS file: /cvs/public/ponie/perl/embedvar.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- embedvar.h 29 Apr 2005 13:26:29 -0000 1.11
+++ embedvar.h 30 Apr 2005 10:18:59 -0000 1.12
@@ -898,6 +898,7 @@
#define PL_op_mutex (PL_Vars.Gop_mutex)
#define PL_patleave (PL_Vars.Gpatleave)
#define PL_pmc_to_type (PL_Vars.Gpmc_to_type)
+#define PL_pmc_to_type_max (PL_Vars.Gpmc_to_type_max)
#define PL_pmcname (PL_Vars.Gpmcname)
#define PL_pmcname_mutex (PL_Vars.Gpmcname_mutex)
#define PL_sh_path (PL_Vars.Gsh_path)
@@ -918,6 +919,7 @@
#define PL_Gop_mutex PL_op_mutex
#define PL_Gpatleave PL_patleave
#define PL_Gpmc_to_type PL_pmc_to_type
+#define PL_Gpmc_to_type_max PL_pmc_to_type_max
#define PL_Gpmcname PL_pmcname
#define PL_Gpmcname_mutex PL_pmcname_mutex
#define PL_Gsh_path PL_sh_path
1.21 +2 -1 ponie/perl/perl.c
Index: perl.c
===================================================================
RCS file: /cvs/public/ponie/perl/perl.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- perl.c 29 Apr 2005 13:26:29 -0000 1.20
+++ perl.c 30 Apr 2005 10:18:59 -0000 1.21
@@ -273,7 +273,7 @@
max_type = type;
}
- temp = malloc(max_type);
+ temp = safesysmalloc(++max_type);
memset (temp, -1, max_type);
/* Build the reverse lookup table. */
@@ -283,6 +283,7 @@
}
PL_pmc_to_type = temp;
+ PL_pmc_to_type_max = max_type;
}
#ifdef USE_ITHREADS
MUTEX_UNLOCK(&PL_pmcname_mutex);
1.12 +2 -0 ponie/perl/perlapi.h
Index: perlapi.h
===================================================================
RCS file: /cvs/public/ponie/perl/perlapi.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- perlapi.h 29 Apr 2005 13:26:29 -0000 1.11
+++ perlapi.h 30 Apr 2005 10:18:59 -0000 1.12
@@ -941,6 +941,8 @@
#define PL_patleave (*Perl_Gpatleave_ptr(NULL))
#undef PL_pmc_to_type
#define PL_pmc_to_type (*Perl_Gpmc_to_type_ptr(NULL))
+#undef PL_pmc_to_type_max
+#define PL_pmc_to_type_max (*Perl_Gpmc_to_type_max_ptr(NULL))
#undef PL_pmcname
#define PL_pmcname (*Perl_Gpmcname_ptr(NULL))
#undef PL_pmcname_mutex
1.6 +2 -0 ponie/perl/perlvars.h
Index: perlvars.h
===================================================================
RCS file: /cvs/public/ponie/perl/perlvars.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- perlvars.h 29 Apr 2005 13:26:29 -0000 1.5
+++ perlvars.h 30 Apr 2005 10:18:59 -0000 1.6
@@ -73,6 +73,8 @@
PERLVARI(Gpmcname[Ponie_PMC_Perl5_MAX], Parrot_Int, {0})
/* A reverse lookup table to convert parrot types back to Perl 5 types. */
PERLVAR(Gpmc_to_type, const signed char *)
+/* size of the lookup table (hence first illegal array index) */
+PERLVAR(Gpmc_to_type_max, int)
#ifndef PERL_USE_SAFE_PUTENV
PERLVARI(Guse_safe_putenv, int, 1)
1.3 +37 -3 ponie/src/pmc/perl5base.pmc
Index: perl5base.pmc
===================================================================
RCS file: /cvs/public/ponie/src/pmc/perl5base.pmc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- perl5base.pmc 28 Apr 2005 10:19:08 -0000 1.2
+++ perl5base.pmc 30 Apr 2005 10:18:59 -0000 1.3
@@ -10,10 +10,44 @@
* References:
*/
+#include "ponie.h"
+
pmclass Perl5base extends Perl5cargo_cult dynpmc group Perl5_group {
void morph(INTVAL new_type) {
- SELF->vtable = Parrot_base_vtables[new_type];
- }
+ /* new_type is a PMC type. */
+ struct Ponie_upgrade_info info;
+
+ /* 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 (new_type >= PL_pmc_to_type_max
+ || ((info.p5_type = PL_pmc_to_type[new_type]) < 0)) {
+ croak ("Out of range or illegal type %d for sv upgrade morph",
+ new_type);
+ }
+ /* This may change the value of p5_type */
+ DYNSELF.set_pointer_keyed_int(Ponie_P_GET_UPGRADE, &info);
+
+ SELF->vtable = Parrot_base_vtables[PL_pmcname[info.p5_type]];
+ ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
+ &= ~SVTYPEMASK;
+ ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
+ |= info.p5_type;
+
+ DYNSELF.set_pointer_keyed_int(Ponie_P_SET_UPGRADE, &info);
+ }
}
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+*/
1.52 +2 -20 ponie/src/pmc/perl5cargo_cult.pmc
Index: perl5cargo_cult.pmc
===================================================================
RCS file: /cvs/public/ponie/src/pmc/perl5cargo_cult.pmc,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- perl5cargo_cult.pmc 29 Apr 2005 23:47:21 -0000 1.51
+++ perl5cargo_cult.pmc 30 Apr 2005 10:18:59 -0000 1.52
@@ -709,29 +709,11 @@
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);
}
- {
- struct Ponie_upgrade_info info;
-
- info.p5_type = value;
- /* This may change the value of p5_type */
- DYNSELF.set_pointer_keyed_int(Ponie_P_GET_UPGRADE, &info);
- DYNSELF.morph(PL_pmcname[info.p5_type]);
-
- ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
- &= ~SVTYPEMASK;
- ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
- |= info.p5_type;
-
- DYNSELF.set_pointer_keyed_int(Ponie_P_SET_UPGRADE, &info);
- }
+ DYNSELF.morph(PL_pmcname[value]);
return;
case Ponie_I_SVf_OK: