visitTypeAliasDecl method

  1. @override
Uint8List visitTypeAliasDecl(
  1. TypeAliasDecl stmt
)
override

Implementation

@override
Uint8List visitTypeAliasDecl(TypeAliasDecl stmt) {
  final bytesBuilder = BytesBuilder();
  bytesBuilder.addByte(HTOpCode.typeAliasDecl);
  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));
  if (stmt.classId != null) {
    bytesBuilder.addByte(1); // bool: has class id
    bytesBuilder.add(_parseIdentifier(stmt.classId!));
  } else {
    bytesBuilder.addByte(0); // bool: has class id
  }
  bytesBuilder.addByte(stmt.isTopLevel ? 1 : 0);
  // do not use visitTypeExpr here because the value could be a function type
  final bytes = compileAST(stmt.typeValue);
  bytesBuilder.add(bytes);
  return bytesBuilder.toBytes();
}