More fiber tests.

This commit is contained in:
Bob Nystrom
2014-02-14 07:16:56 -08:00
parent ca4f4d6660
commit edd360a934
4 changed files with 34 additions and 13 deletions
+8 -10
View File
@@ -883,14 +883,20 @@ static bool runInterpreter(WrenVM* vm)
Value result = POP();
fiber->numFrames--;
// Close any upvalues still in scope.
Value* firstValue = &fiber->stack[frame->stackStart];
while (fiber->openUpvalues != NULL &&
fiber->openUpvalues->value >= firstValue)
{
closeUpvalue(fiber);
}
// If the fiber is complete, end it.
if (fiber->numFrames == 0)
{
// If this is the main fiber, we're done.
if (fiber->caller == NULL) return true;
// TODO: Do we need to close upvalues here?
// We have a calling fiber to resume.
fiber = fiber->caller;
@@ -899,14 +905,6 @@ static bool runInterpreter(WrenVM* vm)
}
else
{
// Close any upvalues still in scope.
Value* firstValue = &fiber->stack[frame->stackStart];
while (fiber->openUpvalues != NULL &&
fiber->openUpvalues->value >= firstValue)
{
closeUpvalue(fiber);
}
// Store the result of the block in the first slot, which is where the
// caller expects it.
fiber->stack[frame->stackStart] = result;