Skip to content

Commit

Permalink
Add root_new dynop.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed May 20, 2009
1 parent 01ec2a7 commit b516413
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/ops/perl6.ops
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,52 @@ inline op get_next_candidate_info(out PMC, out PMC, out PMC) :base_core {
goto NEXT();
}

/*

=item B<root_new>(out PMC, in PMC)

Instantiate a new object from the key given by $2; the first component
of the key is the hll namespace.

=cut

*/
inline op root_new(out PMC, in PMC) {
PMC * const key = $2;
PMC * const root_ns = interp->root_namespace;
PMC * const ns = Parrot_get_namespace_keyed(interp, root_ns, key);
PMC * classobj = PMCNULL;

if (!PMC_IS_NULL(ns))
classobj = Parrot_oo_get_class(interp, ns);
if (!PMC_IS_NULL(classobj))
$1 = VTABLE_instantiate(interp, classobj, PMCNULL);
else {
opcode_t *dest = Parrot_ex_throw_from_op_args(interp, expr NEXT(),
EXCEPTION_NO_CLASS,
"Class '%Ss' not found", VTABLE_get_repr(interp, key));
goto ADDRESS(dest);
}
}

inline op root_new(out PMC, in PMC, in PMC) {
PMC * const key = $2;
PMC * const root_ns = interp->root_namespace;
PMC * const ns = Parrot_get_namespace_keyed(interp, root_ns, key);
PMC * classobj = PMCNULL;

if (!PMC_IS_NULL(ns))
classobj = Parrot_oo_get_class(interp, ns);
if (!PMC_IS_NULL(classobj))
$1 = VTABLE_instantiate(interp, classobj, $3);
else {
opcode_t *dest = Parrot_ex_throw_from_op_args(interp, expr NEXT(),
EXCEPTION_NO_CLASS,
"Class '%Ss' not found", VTABLE_get_repr(interp, key));
goto ADDRESS(dest);
}
}

/*
* Local variables:
* c-file-style: "parrot"
Expand Down

0 comments on commit b516413

Please sign in to comment.