visitClassDecl method
Implementation
@override
Uint8List visitClassDecl(ClassDecl stmt) {
final bytesBuilder = BytesBuilder();
bytesBuilder.addByte(HTOpCode.classDecl);
final docs = stmt.documentation;
if (docs.isNotEmpty && !config.removeDocumentation) {
bytesBuilder.addByte(1); // bool: has doc
bytesBuilder.add(_utf8String(docs));
} else {
bytesBuilder.addByte(0); // bool: has doc
}
bytesBuilder.add(_parseIdentifier(stmt.id.id));
// TODO: generic param
bytesBuilder.addByte(stmt.isExternal ? 1 : 0);
bytesBuilder.addByte(stmt.isAbstract ? 1 : 0);
bytesBuilder.addByte(stmt.isTopLevel ? 1 : 0);
bytesBuilder.addByte(stmt.hasUserDefinedConstructor ? 1 : 0);
Uint8List? superType;
if (stmt.superType != null) {
superType = compileAST(stmt.superType!);
bytesBuilder.addByte(1); // bool: has super class
bytesBuilder.add(superType);
} else {
bytesBuilder.addByte(0); // bool: has super class
}
bytesBuilder.addByte(0); // bool: is enum
// TODO: deal with implements and mixins
final classDefinition = visitBlockStmt(stmt.definition);
bytesBuilder.add(classDefinition);
bytesBuilder.addByte(HTOpCode.classDeclEnd);
return bytesBuilder.toBytes();
}