[svn:parrot] r44866 - trunk/src/ops
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Thu Mar 11 06:52:07 UTC 2010
Author: chromatic
Date: Thu Mar 11 06:52:06 2010
New Revision: 44866
URL: https://trac.parrot.org/parrot/changeset/44866
Log:
[ops] Fixed the experimental new PPI op to use the init_int VTABLE directly
instead of trying to go through the associated PMCProxy instantiate.
Modified:
trunk/src/ops/experimental.ops
Modified: trunk/src/ops/experimental.ops
==============================================================================
--- trunk/src/ops/experimental.ops Thu Mar 11 06:17:07 2010 (r44865)
+++ trunk/src/ops/experimental.ops Thu Mar 11 06:52:06 2010 (r44866)
@@ -271,23 +271,32 @@
op new(out PMC, in PMC, in INT) {
- PMC * const name_key = $2;
- PMC * const _class = Parrot_oo_get_class(interp, name_key);
+ PMC * const name_key = $2;
- if (!PMC_IS_NULL(_class)) {
- PMC *initial = Parrot_pmc_new(interp, Parrot_get_ctx_HLL_type(interp, enum_class_Integer));
- VTABLE_set_integer_native(interp, initial, $3);
- $1 = VTABLE_instantiate(interp, _class, initial);
- }
- else {
- const INTVAL type = Parrot_pmc_get_type(interp, name_key);
- if (type <= 0) {
- opcode_t *dest = Parrot_ex_throw_from_op_args(interp, expr NEXT(),
- EXCEPTION_NO_CLASS,
- "Class '%Ss' not found", VTABLE_get_repr(interp, name_key));
- goto ADDRESS(dest);
+ /* get_class() returns a PMCProxy for core types, so check for core PMCs */
+ const INTVAL type = Parrot_pmc_get_type(interp, name_key);
+
+ /* if it's clearly a PIR-level PMC */
+ if (type > enum_class_core_max) {
+ PMC * const _class = Parrot_oo_get_class(interp, name_key);
+ if (!PMC_IS_NULL(_class)) {
+ PMC *initial = Parrot_pmc_new(interp,
+ Parrot_get_ctx_HLL_type(interp, enum_class_Integer));
+ VTABLE_set_integer_native(interp, initial, $3);
+ $1 = VTABLE_instantiate(interp, _class, initial);
}
+ }
+
+ /* if it's a core PMC */
+ else if (type > enum_class_default )
$1 = Parrot_pmc_new_init_int(interp, type, $3);
+
+ /* it's a typo */
+ else {
+ opcode_t *dest = Parrot_ex_throw_from_op_args(interp, expr NEXT(),
+ EXCEPTION_NO_CLASS,
+ "Class '%Ss' not found", VTABLE_get_repr(interp, name_key));
+ goto ADDRESS(dest);
}
}
More information about the parrot-commits
mailing list