Skip to content

Commit

Permalink
Port 3 more 6pe ops; 11/14 tests passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jan 23, 2015
1 parent 2c3db63 commit 5feb90a
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/vm/parrot/ops/nqp.ops
Expand Up @@ -4464,13 +4464,46 @@ inline op nqp_parameterizetype(out PMC, invar PMC, invar PMC) {
}

inline op nqp_typeparameterized(out PMC, invar PMC) {
$1 = PMCNULL;
PMC *type = decontainerize(interp, $2);
if (type->vtable->base_type == smo_id) {
STable *st = STABLE(type);
if (st->mode_flags & SM_PARAMETERIZED_TYPE)
$1 = st->paramet.erized.parametric_type;
else
$1 = PMCNULL;
}
else {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Can only use typeparameterized on a SixModelObject");
}
}

inline op nqp_typeparameters(out PMC, invar PMC) {
$1 = PMCNULL;
PMC *type = decontainerize(interp, $2);
if (type->vtable->base_type == smo_id) {
STable *st = STABLE(type);
if (!(st->mode_flags & SM_PARAMETERIZED_TYPE))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"This type is not parameterized");
$1 = st->paramet.erized.parameters;
}
else {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Can only use typeparameters on a SixModelObject");
}
}

inline op nqp_typeparameterat(out PMC, invar PMC, in INT) {
$1 = PMCNULL;
PMC *type = decontainerize(interp, $2);
if (type->vtable->base_type == smo_id) {
STable *st = STABLE(type);
if (!(st->mode_flags & SM_PARAMETERIZED_TYPE))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"This type is not parameterized");
$1 = VTABLE_get_pmc_keyed_int(interp, st->paramet.erized.parameters, $3);
}
else {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Can only use typeparameters on a SixModelObject");
}
}

0 comments on commit 5feb90a

Please sign in to comment.