Skip to content

Commit

Permalink
Add a set_runcore op to switch to a different runcore.
Browse files Browse the repository at this point in the history
Also support CURRENT_RUNCORE in interpinfo_s() to get the name of the current
runcore.
We need an extra op for the runcore switching, because we need to restart the
runops() loop. This can only be done in an op at the moment.
  • Loading branch information
mlschroe committed Nov 29, 2011
1 parent 6445248 commit 6081fbd
Show file tree
Hide file tree
Showing 7 changed files with 4,104 additions and 4,041 deletions.
2 changes: 2 additions & 0 deletions include/parrot/oplib/core_ops.h
Expand Up @@ -112,6 +112,8 @@ op_lib_t *Parrot_DynOp_core_3_10_0(PARROT_INTERP, long init);
opcode_t * Parrot_errorson_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_errorsoff_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_errorsoff_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_set_runcore_s(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_set_runcore_sc(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_runinterp_p_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_runinterp_p_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_getinterp_p(opcode_t *, PARROT_INTERP);
Expand Down
2,020 changes: 1,011 additions & 1,009 deletions include/parrot/oplib/ops.h

Large diffs are not rendered by default.

2,020 changes: 1,011 additions & 1,009 deletions include/parrot/opsenum.h

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/interp/inter_misc.c
Expand Up @@ -443,6 +443,8 @@ interpinfo_s(PARROT_INTERP, INTVAL what)
Parrot_warn_experimental(interp, "GC_SYS_NAME option is experimental");
return name;
}
case CURRENT_RUNCORE:
return interp->run_core->name;
default:
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
"illegal argument in interpinfo");
Expand Down
15 changes: 14 additions & 1 deletion src/ops/core.ops
Expand Up @@ -1035,7 +1035,7 @@ CURRENT_SUB, CURRENT_CONT, CURRENT_OBJECT, CURRENT_LEXPAD

=item B<interpinfo>(out STR, in INT)

EXECUTABLE_FULLNAME, EXECUTABLE_BASENAME, RUNTIME_PREFIX
EXECUTABLE_FULLNAME, EXECUTABLE_BASENAME, RUNTIME_PREFIX, CURRENT_RUNCORE

=back

Expand Down Expand Up @@ -1130,6 +1130,19 @@ inline op errorsoff(in INT) {
PARROT_ERRORS_off(interp, $1);
}

=item B<set_runcore>(in STR)

Switch the current runcore to the one with the specified name.
Needs to be an op, as we need to restart the runops() call.
You can get the name of the current runcore with the interpinfo op.

=cut

inline op set_runcore(in STR) {
Parrot_runcore_switch(interp, $1);
restart NEXT();
}

########################################

=item B<runinterp>(invar PMC, in LABEL)
Expand Down
4,084 changes: 2,063 additions & 2,021 deletions src/ops/core_ops.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion t/compilers/opsc/06-opsfile.t
Expand Up @@ -21,7 +21,7 @@ my @ops := $f.ops;
say( "# Parsed " ~ +@ops);
# There is more than 200 ops in this 2 files.
# Feel free to update number if you change them.
ok(+@ops == 271, "Ops parsed correctly");
ok(+@ops == 273, "Ops parsed correctly");
say('# ' ~ +@ops);

my $op := @ops[0];
Expand Down

0 comments on commit 6081fbd

Please sign in to comment.