Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Be explicit about what is the mainline.
  • Loading branch information
jnthn committed Feb 28, 2013
1 parent f631cb7 commit f0e8ea9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -2484,6 +2484,12 @@ class QAST::CompilerJAST {
$hll_meth.append(JAST::Instruction.new( :op('areturn') ));
$*JCLASS.add_method($hll_meth);

# Add method that returns the mainline block.
my $mainline_meth := JAST::Method.new( :name('mainlineIdx'), :returns('Integer'), :static(0) );
$mainline_meth.append(JAST::PushIndex.new( :value($*CODEREFS.cuid_to_idx($cu[0].cuid)) ));
$mainline_meth.append(JAST::Instruction.new( :op('ireturn') ));
$*JCLASS.add_method($mainline_meth);

return $*JCLASS;
}

Expand Down
7 changes: 7 additions & 0 deletions src/org/perl6/nqp/runtime/CompilationUnit.java
Expand Up @@ -171,4 +171,11 @@ public int deserializeIdx() {
public int loadIdx() {
return -1;
}

/**
* Code generation overrides this with the mainline blcok.
*/
public int mainlineIdx() {
return -1;
}
}
2 changes: 1 addition & 1 deletion src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -3186,7 +3186,7 @@ public static long iscompunit(SixModelObject obj, ThreadContext tc) {
}
public static SixModelObject compunitmainline(SixModelObject obj, ThreadContext tc) {
EvalResult res = (EvalResult)obj;
return res.cu.codeRefs[0];
return res.cu.codeRefs[res.cu.mainlineIdx()];
}
public static SixModelObject compunitcodes(SixModelObject obj, ThreadContext tc) {
EvalResult res = (EvalResult)obj;
Expand Down

0 comments on commit f0e8ea9

Please sign in to comment.