visitAssertStmt method

  1. @override
Uint8List visitAssertStmt(
  1. AssertStmt stmt
)
override

Implementation

@override
Uint8List visitAssertStmt(AssertStmt stmt) {
  final bytesBuilder = BytesBuilder();
  if (!config.removeAssertion) {
    bytesBuilder.add(_lineInfo(stmt.line, stmt.column));
    final bytes = compileAST(stmt.expr);
    bytesBuilder.add(bytes);
    bytesBuilder.addByte(HTOpCode.assertion);
    final content = stmt.source!.content;
    final text = content.substring(stmt.expr.offset, stmt.expr.end);
    bytesBuilder.add(_parseIdentifier(text.trim()));
    bytesBuilder.addByte(HTOpCode.endOfStmt);
  }
  return bytesBuilder.toBytes();
}