visitNamespaceDecl method

  1. @override
Uint8List visitNamespaceDecl(
  1. NamespaceDecl stmt
)
override

Implementation

@override
Uint8List visitNamespaceDecl(NamespaceDecl stmt) {
  final bytesBuilder = BytesBuilder();
  bytesBuilder.addByte(HTOpCode.namespaceDecl);
  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);
  final bytes = visitBlockStmt(stmt.definition);
  bytesBuilder.add(bytes);
  bytesBuilder.addByte(HTOpCode.namespaceDeclEnd);
  return bytesBuilder.toBytes();
}