visitWhileStmt method
Implementation
@override
Uint8List visitWhileStmt(WhileStmt stmt) {
final bytesBuilder = BytesBuilder();
bytesBuilder.add(_lineInfo(stmt.line, stmt.column));
bytesBuilder.addByte(HTOpCode.loopPoint);
final condition = compileAST(stmt.condition);
final loop = compileAST(stmt.loop);
final loopLength = condition.length + loop.length + 4;
bytesBuilder.add(_uint16(0)); // while loop continue ip
bytesBuilder.add(_uint16(loopLength)); // while loop break ip
bytesBuilder.add(condition);
bytesBuilder.addByte(HTOpCode.whileStmt);
bytesBuilder.add(loop);
bytesBuilder.addByte(HTOpCode.skip);
bytesBuilder.add(_int16(-loopLength));
return bytesBuilder.toBytes();
}