diff --git a/pkg/dart2bytecode/lib/bytecode_generator.dart b/pkg/dart2bytecode/lib/bytecode_generator.dart index 963bee78821..31dcb526964 100644 --- a/pkg/dart2bytecode/lib/bytecode_generator.dart +++ b/pkg/dart2bytecode/lib/bytecode_generator.dart @@ -348,7 +348,7 @@ class BytecodeGenerator extends RecursiveVisitor { flags |= ClassDeclaration.hasSourcePositionsFlag; position = library.fileOffset; } - Annotations annotations = getLibraryAnnotations(library); + Annotations annotations = getAnnotations(library.annotations); if (annotations.object != null) { flags |= ClassDeclaration.hasAnnotationsFlag; if (annotations.hasPragma) { @@ -441,67 +441,6 @@ class BytecodeGenerator extends RecursiveVisitor { return new Annotations(functionDecl, hasPragma); } - // Insert annotations for library and its dependencies into the - // annotations section. Returns annotations for the library only. - // Bytecode reader will implicitly find library dependencies by reading - // an extra object after reading library annotations. - Annotations getLibraryAnnotations(Library library) { - Annotations annotations = getAnnotations(library.annotations); - final bool emitDependencies = - options.emitAnnotations && library.dependencies.isNotEmpty; - if (annotations.object == null && !emitDependencies) { - return annotations; - } - - // We need to emit both annotations and dependencies objects, appending - // null if an object is missing. - if (annotations.object == null) { - final annotationsDecl = new AnnotationsDeclaration(null); - bytecodeComponent.annotations.add(annotationsDecl); - annotations = new Annotations(annotationsDecl, false); - } - if (!emitDependencies) { - bytecodeComponent.annotations.add(new AnnotationsDeclaration(null)); - return annotations; - } - - // Create a constant object representing library dependencies. - // These objects are used by dart:mirrors and vm-service implementation. - final deps = []; - for (var dependency in library.dependencies) { - final dependencyName = dependency.name; - final prefix = dependencyName != null - ? StringConstant(dependencyName) - : NullConstant(); - final showNames = dependency.combinators - .where((c) => c.isShow) - .expand((c) => c.names) - .map((name) => StringConstant(name)) - .toList(); - final hideNames = dependency.combinators - .where((c) => c.isHide) - .expand((c) => c.names) - .map((name) => StringConstant(name)) - .toList(); - final depAnnots = dependency.annotations.map(_getConstant).toList(); - deps.add(ListConstant(const DynamicType(), [ - StringConstant(dependency.targetLibrary.importUri.toString()), - BoolConstant(dependency.isExport), - BoolConstant(dependency.isDeferred), - prefix, - ListConstant(const DynamicType(), showNames), - ListConstant(const DynamicType(), hideNames), - ListConstant(const DynamicType(), depAnnots), - ])); - } - final ObjectHandle dependenciesObject = - objectTable.getHandle(ListConstant(const DynamicType(), deps))!; - final dependenciesDecl = new AnnotationsDeclaration(dependenciesObject); - bytecodeComponent.annotations.add(dependenciesDecl); - - return annotations; - } - FieldDeclaration getFieldDeclaration(Field field, Code? initializer) { int flags = 0; Constant? value;