Author: allison
Date: Mon Oct 1 22:53:32 2007
New Revision: 21736
Modified:
branches/pdd15oo/src/ops/pmc.ops
branches/pdd15oo/src/pmc/class.pmc
branches/pdd15oo/src/pmc/object.pmc
Log:
[pdd15oo] Store more information about the type number of new metamodel
classes, so they will work better with MMD.
Modified: branches/pdd15oo/src/ops/pmc.ops
==============================================================================
--- branches/pdd15oo/src/ops/pmc.ops (original)
+++ branches/pdd15oo/src/ops/pmc.ops Mon Oct 1 22:53:32 2007
@@ -180,10 +180,6 @@
}
inline op typeof(out INT, invar PMC) {
- if (VTABLE_isa(interp, $2, string_from_literal(interp, "Object")))
- real_exception(interp, NULL, INVALID_OPERATION,
- "Numeric 'typeof' will not be supported in new object model");
- else
$1 = $2->vtable->type(interp, $2);
goto NEXT();
}
Modified: branches/pdd15oo/src/pmc/class.pmc
==============================================================================
--- branches/pdd15oo/src/pmc/class.pmc (original)
+++ branches/pdd15oo/src/pmc/class.pmc Mon Oct 1 22:53:32 2007
@@ -205,10 +205,9 @@
parrot_realloc_vtables(interp);
/* set entry in name->type hash */
- item = pmc_new(interp, enum_class_Integer);
- PMC_int_val(item) = type;
+ VTABLE_set_integer_keyed_str(interp, classname_hash,
+ VTABLE_get_string(interp, name), type);
- VTABLE_set_pmc_keyed(interp, classname_hash, name, item);
UNLOCK_INTERPRETER(interp);
return type;
@@ -277,6 +276,8 @@
new_vtable = Parrot_clone_vtable(interp, self->vtable);
new_vtable->base_type = type_num;
new_vtable->pmc_class = self;
+ new_vtable->whoami = new_name;
+ _class->id = type_num;
/* Store the class's vtable in the global table */
interp->vtables[type_num] = new_vtable;
@@ -519,6 +520,7 @@
/* Set up the object. */
PMC_data(SELF) = _class;
+ _class->id = 0;
_class->name = CONST_STRING(interp, "");
_class->_namespace = PMCNULL;
_class->instantiated = 0;
@@ -901,6 +903,10 @@
found = pmc_new(interp, enum_class_String);
VTABLE_set_string_native(interp, found, _class->name);
}
+ if (string_equal(interp, what, CONST_STRING(interp, "id")) == 0) {
+ found = pmc_new(interp, enum_class_Integer);
+ VTABLE_set_integer_native(interp, found, _class->id);
+ }
else if (string_equal(interp, what, CONST_STRING(interp, "namespace"))
== 0) {
/* Should not clone this. */
return _class->_namespace;
@@ -1240,6 +1246,23 @@
return VTABLE_isa_pmc(interp, SELF, string_pmc);
}
+/*
+
+=item C<INTVAL type()>
+
+Returns the integer type of the class.
+
+=cut
+
+*/
+
+
+ INTVAL type() {
+ Parrot_Class *_class = PARROT_CLASS(SELF);
+ return _class->id;
+ }
+
+
/* **********************************************************************
* Below here are non-vtable methods that eventually will go in a role
* that is composed into here to optionally give a nice interface from
@@ -1599,6 +1622,7 @@
PCCRETURN(INTVAL isa);
}
+
} /* END pmclass */
/*
Modified: branches/pdd15oo/src/pmc/object.pmc
==============================================================================
--- branches/pdd15oo/src/pmc/object.pmc (original)
+++ branches/pdd15oo/src/pmc/object.pmc Mon Oct 1 22:53:32 2007
@@ -400,6 +400,22 @@
return VTABLE_isa(interp, _class, classname);
}
+
+/*
+
+=item C<INTVAL type()>
+
+Returns the integer type of the object's class.
+
+=cut
+
+*/
+
+ INTVAL type() {
+ PMC *class = VTABLE_get_class(interp, SELF);
+ return VTABLE_type(interp, class);
+ }
+
}
/*