[svn:parrot] r45985 - in trunk: src t/oo
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Sat Apr 24 14:33:00 UTC 2010
Author: NotFound
Date: Sat Apr 24 14:33:00 2010
New Revision: 45985
URL: https://trac.parrot.org/parrot/changeset/45985
Log:
get_class_p_s and get_class_p_p return PMCNULL on NULL argument, TT #1107
Modified:
trunk/src/oo.c
trunk/t/oo/ops.t
Modified: trunk/src/oo.c
==============================================================================
--- trunk/src/oo.c Sat Apr 24 13:13:58 2010 (r45984)
+++ trunk/src/oo.c Sat Apr 24 14:33:00 2010 (r45985)
@@ -169,49 +169,51 @@
ASSERT_ARGS(Parrot_oo_get_class)
PMC *classobj = PMCNULL;
- if (PObj_is_class_TEST(key))
- classobj = key;
- else {
- /* Fast select of behavior based on type of the lookup key */
- switch (key->vtable->base_type) {
- case enum_class_NameSpace:
- classobj = VTABLE_get_class(interp, key);
- break;
- case enum_class_String:
- case enum_class_Key:
- case enum_class_ResizableStringArray:
- {
- PMC * const hll_ns = VTABLE_get_pmc_keyed_int(interp,
- interp->HLL_namespace,
- Parrot_pcc_get_HLL(interp, CURRENT_CONTEXT(interp)));
- PMC * const ns = Parrot_get_namespace_keyed(interp,
- hll_ns, key);
+ if (!PMC_IS_NULL(key)) {
+ if (PObj_is_class_TEST(key))
+ classobj = key;
+ else {
+ /* Fast select of behavior based on type of the lookup key */
+ switch (key->vtable->base_type) {
+ case enum_class_NameSpace:
+ classobj = VTABLE_get_class(interp, key);
+ break;
+ case enum_class_String:
+ case enum_class_Key:
+ case enum_class_ResizableStringArray:
+ {
+ PMC * const hll_ns = VTABLE_get_pmc_keyed_int(interp,
+ interp->HLL_namespace,
+ Parrot_pcc_get_HLL(interp, CURRENT_CONTEXT(interp)));
+ PMC * const ns = Parrot_get_namespace_keyed(interp,
+ hll_ns, key);
- if (!PMC_IS_NULL(ns))
- classobj = VTABLE_get_class(interp, ns);
+ if (!PMC_IS_NULL(ns))
+ classobj = VTABLE_get_class(interp, ns);
+ }
+ default:
+ break;
}
- default:
- break;
}
- }
- /* If the PMCProxy doesn't exist yet for the given key, we look up the
- type ID here and create a new one */
- if (PMC_IS_NULL(classobj)) {
- INTVAL type;
- const INTVAL base_type = key->vtable->base_type;
-
- /* This is a hack! All PMCs should be able to be handled through
- a single codepath, and all of them should be able to avoid
- stringification because it's so imprecise. */
- if (base_type == enum_class_Key
- || base_type == enum_class_ResizableStringArray
- || base_type == enum_class_String)
- type = Parrot_pmc_get_type(interp, key);
- else
- type = Parrot_pmc_get_type_str(interp, VTABLE_get_string(interp, key));
+ /* If the PMCProxy doesn't exist yet for the given key, we look up the
+ type ID here and create a new one */
+ if (PMC_IS_NULL(classobj)) {
+ INTVAL type;
+ const INTVAL base_type = key->vtable->base_type;
+
+ /* This is a hack! All PMCs should be able to be handled through
+ a single codepath, and all of them should be able to avoid
+ stringification because it's so imprecise. */
+ if (base_type == enum_class_Key
+ || base_type == enum_class_ResizableStringArray
+ || base_type == enum_class_String)
+ type = Parrot_pmc_get_type(interp, key);
+ else
+ type = Parrot_pmc_get_type_str(interp, VTABLE_get_string(interp, key));
- classobj = get_pmc_proxy(interp, type);
+ classobj = get_pmc_proxy(interp, type);
+ }
}
return classobj;
Modified: trunk/t/oo/ops.t
==============================================================================
--- trunk/t/oo/ops.t Sat Apr 24 13:13:58 2010 (r45984)
+++ trunk/t/oo/ops.t Sat Apr 24 14:33:00 2010 (r45985)
@@ -20,7 +20,7 @@
.include 'except_types.pasm'
.include 'test_more.pir'
- plan(18)
+ plan(20)
op_addrole_p_p()
op_inspect_p_p()
@@ -89,6 +89,10 @@
$P3 = $P2.'inspect'('name')
is ($P3, 'Monkey', 'got name of found class')
+ null $S0
+ $P5 = get_class $S0
+ $I2 = isnull $P5
+ is ($I2, 1, 'null p gives null p')
.end
.sub op_get_class_p_p
@@ -113,6 +117,11 @@
$I1 = isa $P2 , 'Class'
ok ($I1, 'get_class with a namespace found a class')
is ($P3, 'Monkey', 'got name of found class')
+
+ null $P5
+ $P6 = get_class $P5
+ $I2 = isnull $P6
+ is ($I2, 1, 'null s gives null p')
.end
.sub op_addattribute_p_s
More information about the parrot-commits
mailing list