Make method_call benchmark use inheritance.

This also fixes a bug where constructors weren't being bound
correctly, and eliminates some unneeded instructions when
compiling ifs.

I also tweaked the other method_call languages to match Wren's.
Since Wren needs to do a super call to get to the parent _count,
the other languages do now too.

This is nice too because it means we're benchmarking super 
calls.
This commit is contained in:
Bob Nystrom
2013-12-18 07:37:41 -08:00
parent caafa96252
commit e7cf8ffe2e
7 changed files with 62 additions and 61 deletions
+13 -8
View File
@@ -1805,20 +1805,25 @@ void statement(Compiler* compiler)
// Compile the then branch.
block(compiler);
// Jump over the else branch when the if branch is taken.
emit(compiler, CODE_JUMP);
int elseJump = emit(compiler, 255);
patchJump(compiler, ifJump);
// Compile the else branch if there is one.
if (match(compiler, TOKEN_ELSE))
{
// Jump over the else branch when the if branch is taken.
emit(compiler, CODE_JUMP);
int elseJump = emit(compiler, 255);
patchJump(compiler, ifJump);
block(compiler);
// Patch the jump over the else.
patchJump(compiler, elseJump);
}
else
{
patchJump(compiler, ifJump);
}
// Patch the jump over the else.
patchJump(compiler, elseJump);
return;
}