visitWhileLoopStmt method
Implementation
@override
Object? visitWhileLoopStmt(WhileLoopStmt whileLoopStmt) {
while (true) {
final prevScope = scope;
pushScope();
try {
final cond = switch (whileLoopStmt.expr.accept(this)) {
final List ls => ls.firstOrNull?.isTruthy,
final Object? o => o.isTruthy,
};
if (!cond) break;
for (Stmt stmt in whileLoopStmt.body) {
try {
stmt.accept(this);
} on LuaBreakStmtException {
rethrow;
} catch (e) {
addError(e.toString());
}
}
} on LuaBreakStmtException {
break;
} catch (e) {
rethrow;
} finally {
restoreScope(prevScope);
}
}
return null;
}