cvsuser 04/04/04 07:18:22
Modified: ops object.ops
src objects.c
Log:
stricter type checking for object ops
Revision Changes Path
1.43 +3 -0 parrot/ops/object.ops
Index: object.ops
===================================================================
RCS file: /cvs/public/parrot/ops/object.ops,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -w -r1.42 -r1.43
--- object.ops 3 Apr 2004 20:44:37 -0000 1.42
+++ object.ops 4 Apr 2004 14:18:18 -0000 1.43
@@ -291,6 +291,9 @@
inline op classname(out STR, in PMC) :object_base {
PMC* classname_pmc;
+ if (!(PObj_get_FLAGS($2) & (PObj_is_class_FLAG|PObj_is_object_FLAG))) {
+ internal_exception(NO_CLASS, "PMC is neither class nor object");
+ }
classname_pmc = get_attrib_num((Buffer *)PMC_data($2), PCD_CLASS_NAME);
if (classname_pmc) {
$1 = VTABLE_get_string(interpreter, classname_pmc);
1.77 +27 -26 parrot/src/objects.c
Index: objects.c
===================================================================
RCS file: /cvs/public/parrot/src/objects.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -w -r1.76 -r1.77
--- objects.c 4 Apr 2004 07:49:32 -0000 1.76
+++ objects.c 4 Apr 2004 14:18:21 -0000 1.77
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-$Id: objects.c,v 1.76 2004/04/04 07:49:32 leo Exp $
+$Id: objects.c,v 1.77 2004/04/04 14:18:21 leo Exp $
=head1 NAME
@@ -566,6 +566,11 @@
INTVAL current_size;
INTVAL already_in = 0;
+ if (!PObj_is_class_TEST(current_class_obj))
+ internal_exception(1, "Class isn't a ParrotClass");
+ if (!PObj_is_class_TEST(add_on_class_obj))
+ internal_exception(1, "Parent isn't a ParrotClass");
+
/* Grab the useful stuff from the guts of the class PMC */
current_class = PMC_data(current_class_obj);
@@ -1049,8 +1054,13 @@
Parrot_get_attrib_by_num(Parrot_Interp interpreter, PMC *object, INTVAL attrib)
{
SLOTTYPE *attrib_array;
- if (PObj_is_object_TEST(object)) {
INTVAL attrib_count;
+
+ /*
+ * this is called from ParrotObject's vtable now, so
+ * their is no need for checking object being a valid
+ * object PMC
+ */
attrib_array = PMC_data(object);
attrib_count = ATTRIB_COUNT(object);
if (attrib >= attrib_count || attrib < POD_FIRST_ATTRIB) {
@@ -1058,12 +1068,6 @@
}
return get_attrib_num(attrib_array, attrib);
}
- else {
- internal_exception(INTERNAL_NOT_IMPLEMENTED,
- "Can't get non-core object attribs yet");
- }
- return NULL;
-}
static INTVAL
attr_str_2_num(Parrot_Interp interpreter, PMC *object, STRING *attr)
@@ -1120,8 +1124,8 @@
INTVAL attrib, PMC *value)
{
SLOTTYPE *attrib_array;
- if (PObj_is_object_TEST(object)) {
INTVAL attrib_count;
+
attrib_array = PMC_data(object);
attrib_count = ATTRIB_COUNT(object);
if (attrib >= attrib_count || attrib < POD_FIRST_ATTRIB) {
@@ -1129,11 +1133,6 @@
}
set_attrib_num(attrib_array, attrib, value);
}
- else {
- internal_exception(INTERNAL_NOT_IMPLEMENTED,
- "Can't set non-core object attribs yet");
- }
-}
void
Parrot_set_attrib_by_str(Parrot_Interp interpreter, PMC *object,
@@ -1153,6 +1152,8 @@
INTVAL offset;
HashBucket *b;
+ if (!PObj_is_object_TEST(object))
+ internal_exception(1, "Not an object");
class_pmc = GET_CLASS((SLOTTYPE *)PMC_data(object), object);
offset_hash = get_attrib_num((SLOTTYPE *)PMC_data(class_pmc),
PCD_ATTRIB_OFFS);