Put the class name on the stack instead of as an arg.

This commit is contained in:
Bob Nystrom
2014-01-29 07:47:09 -08:00
parent 5c2cf641ae
commit a5e65faf0d
3 changed files with 11 additions and 13 deletions
+2 -4
View File
@@ -2420,7 +2420,7 @@ static void classDefinition(Compiler* compiler)
int nameConstant = addConstant(compiler, wrenNewString(compiler->parser->vm,
compiler->parser->previous.start, compiler->parser->previous.length));
wrenByteBufferClear(compiler->parser->vm, &compiler->parser->string);
emitShort(compiler, CODE_CONSTANT, nameConstant);
// Load the superclass (if there is one).
if (match(compiler, TOKEN_IS))
@@ -2433,12 +2433,10 @@ static void classDefinition(Compiler* compiler)
emit(compiler, CODE_NULL);
}
emitShort(compiler, CODE_CLASS, nameConstant);
// Store a placeholder for the number of fields argument. We don't know
// the value until we've compiled all the methods to see which fields are
// used.
int numFieldsInstruction = emit(compiler, 255);
int numFieldsInstruction = emitByte(compiler, CODE_CLASS, 255);
// Store it in its name.
defineVariable(compiler, symbol);