Author: allison
Date: Thu Oct 4 20:48:58 2007
New Revision: 21862
Modified:
branches/pdd15oo/src/oo.c
branches/pdd15oo/src/pmc.c
branches/pdd15oo/src/pmc/default.pmc
Log:
[pdd15oo] Dynamic PMCs have type numbers higher than the core set of
PMCs, so we have to check the "is_class" flag to decide whether to
call VTABLE_instantiate instead of creating a raw PMC header. (Fixes
failing dynpmc tests.)
Modified: branches/pdd15oo/src/oo.c
==============================================================================
--- branches/pdd15oo/src/oo.c (original)
+++ branches/pdd15oo/src/oo.c Thu Oct 4 20:48:58 2007
@@ -147,7 +147,7 @@
/* Look up a low-level class and create a proxy */
INTVAL type = pmc_type(interp, VTABLE_get_string(interp, key));
/* Reject invalid type numbers */
- if (type > interp->n_vtable_max || type < 0) {
+ if (type > interp->n_vtable_max || type <= 0) {
return PMCNULL;
}
else {
Modified: branches/pdd15oo/src/pmc.c
==============================================================================
--- branches/pdd15oo/src/pmc.c (original)
+++ branches/pdd15oo/src/pmc.c Thu Oct 4 20:48:58 2007
@@ -63,15 +63,13 @@
pmc_new(PARROT_INTERP, INTVAL base_type)
{
PMC *pmc;
- if (base_type < enum_class_core_max) {
+ PMC *const classobj = interp->vtables[base_type]->pmc_class;
+ if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj))
+ pmc = VTABLE_instantiate(interp, classobj, PMCNULL);
+ else {
pmc = get_new_pmc_header(interp, base_type, 0);
VTABLE_init(interp, pmc);
}
- else
- {
- PMC *classobj = interp->vtables[base_type]->pmc_class;
- pmc = VTABLE_instantiate(interp, classobj, PMCNULL);
- }
return pmc;
}
@@ -277,13 +275,11 @@
pmc_new_noinit(PARROT_INTERP, INTVAL base_type)
{
PMC *pmc;
- if (base_type < enum_class_core_max)
- pmc = get_new_pmc_header(interp, base_type, 0);
- else
- {
- PMC *classobj = interp->vtables[base_type]->pmc_class;
+ PMC *const classobj = interp->vtables[base_type]->pmc_class;
+ if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj))
pmc = VTABLE_instantiate(interp, classobj, PMCNULL);
- }
+ else
+ pmc = get_new_pmc_header(interp, base_type, 0);
return pmc;
}
@@ -344,15 +340,13 @@
pmc_new_init(PARROT_INTERP, INTVAL base_type, NULLOK(PMC *init))
{
PMC *pmc;
- if (base_type < enum_class_core_max) {
+ PMC *const classobj = interp->vtables[base_type]->pmc_class;
+ if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj))
+ pmc = VTABLE_instantiate(interp, classobj, init);
+ else {
pmc = get_new_pmc_header(interp, base_type, 0);
VTABLE_init_pmc(interp, pmc, init);
}
- else
- {
- PMC *classobj = interp->vtables[base_type]->pmc_class;
- pmc = VTABLE_instantiate(interp, classobj, init);
- }
return pmc;
}
Modified: branches/pdd15oo/src/pmc/default.pmc
==============================================================================
--- branches/pdd15oo/src/pmc/default.pmc (original)
+++ branches/pdd15oo/src/pmc/default.pmc Thu Oct 4 20:48:58 2007
@@ -313,11 +313,11 @@
*/
PMC *instantiate(PMC *init) {
- const INTVAL type = SELF->vtable->base_type;
+ const INTVAL type = VTABLE_type(INTERP, SELF);
/* Ensure no looping, as pmc_new calls the instantiate vtable entry for
- * non-core types. */
- if (type >= enum_class_core_max)
+ * classes. */
+ if (PObj_is_class_TEST(SELF))
real_exception(interp, NULL, 1,
"All high-level classes should override instantiate");