Skip to content

Commit

Permalink
simplify op execution loop a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
cotto committed Jun 10, 2011
1 parent 14ba3e8 commit febedca
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/m0/perl5/m0_interp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ sub run_ops {
m0_say "PC is $cf->[PC], chunk is '$cf->[CHUNK]'";
my $init_pc = $cf->[PC];
my $instr_count = scalar(@{$cf->[BCS]});
if ($cf->[PC] >= $instr_count){
if ($init_pc >= $instr_count){
exit;
}
my $op_num = $cf->[BCS][$init_pc][0];
Expand All @@ -201,13 +201,8 @@ sub run_ops {
my $a3 = $cf->[BCS][$init_pc][3];
&$op_func(\$cf, $a1, $a2, $a3);

# allow ops to change control flow and call frame
if ($init_pc == $cf->[PC]) {
$cf->[PC]++;
}
else {
m0_say "PC manipulated by M0";
}
# If an op hasn't changed the PC, increment it.
$cf->[PC]++ if ($init_pc == $cf->[PC]);
}
}

Expand Down

0 comments on commit febedca

Please sign in to comment.