Unify code for ending compiler.

There's now a single code path for the end of a chunk of bytecode, so
we can eventually put code there for capturing closures.
This commit is contained in:
Bob Nystrom
2013-12-01 14:59:56 -08:00
parent 19811143a0
commit e4043d69b4
3 changed files with 78 additions and 27 deletions
+2 -3
View File
@@ -554,7 +554,7 @@ Value interpret(WrenVM* vm, ObjFn* fn)
{
int type = instruction;
int symbol = READ_ARG();
int constant = READ_ARG();
Value method = POP();
ObjClass* classObj = AS_CLASS(PEEK());
switch (type)
@@ -576,8 +576,7 @@ Value interpret(WrenVM* vm, ObjFn* fn)
break;
}
ObjFn* body = AS_FN(frame->fn->constants[constant]);
classObj->methods[symbol].fn = body;
classObj->methods[symbol].fn = AS_FN(method);
DISPATCH();
}