Skip to content

Commit

Permalink
refactor: recursively await value
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Jul 23, 2023
1 parent 9f6ec7a commit 77eee1b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/beize_vm/lib/vm/interpreter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,15 @@ class BeizeInterpreter {
frame.ip++;
switch (opCode) {
case BeizeOpCodes.opAwait:
final BeizeValue value = stack.pop();
if (value is BeizeUnawaitedValue) {
BeizeValue value = stack.pop();
while (value is BeizeUnawaitedValue) {
final BeizeInterpreterResult result = await value.execute(frame);
if (result.isFailure) {
return handleExceptionAsync(result.error);
}
stack.push(result.value);
} else {
stack.push(value);
value = result.value;
}
stack.push(value);
break;

default:
Expand Down

0 comments on commit 77eee1b

Please sign in to comment.