visitBlockStmt method

  1. @override
Uint8List visitBlockStmt(
  1. BlockStmt block
)
override

Implementation

@override
Uint8List visitBlockStmt(BlockStmt block) {
  final bytesBuilder = BytesBuilder();
  bytesBuilder.add(_lineInfo(block.line, block.column));
  if (block.isCodeBlock) {
    bytesBuilder.addByte(HTOpCode.codeBlock);
    if (block.id != null) {
      bytesBuilder.add(_parseIdentifier(block.id!));
    } else {
      bytesBuilder.add(_parseIdentifier(InternalIdentifier.anonymousBlock));
    }
  }
  for (final stmt in block.statements) {
    final bytes = compileAST(stmt);
    bytesBuilder.add(bytes);
  }
  if (block.isCodeBlock) {
    bytesBuilder.addByte(HTOpCode.endOfCodeBlock);
  }
  return bytesBuilder.toBytes();
}