Replace Builder by Declaration
Change-Id: I1d9997ab22290e9fc882b64b0934f70c6aed2261
Reviewed-on: https://dart-review.googlesource.com/57505
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
diff --git a/pkg/front_end/lib/src/fasta/builder/builder.dart b/pkg/front_end/lib/src/fasta/builder/builder.dart
index 65fc3cd..914ee9e 100644
--- a/pkg/front_end/lib/src/fasta/builder/builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/builder.dart
@@ -4,14 +4,6 @@
library fasta.builder;
-import '../../base/instrumentation.dart' show Instrumentation;
-
-import '../problems.dart' show unhandled, unsupported;
-
-import 'library_builder.dart' show LibraryBuilder;
-
-import 'class_builder.dart' show ClassBuilder;
-
export '../scope.dart' show AccessErrorBuilder, Scope, ScopeBuilder;
export 'builtin_type_builder.dart' show BuiltinTypeBuilder;
@@ -20,6 +12,8 @@
export 'constructor_reference_builder.dart' show ConstructorReferenceBuilder;
+export 'declaration.dart' show Declaration;
+
export 'dynamic_type_builder.dart' show DynamicTypeBuilder;
export 'enum_builder.dart' show EnumBuilder;
@@ -61,93 +55,3 @@
export 'unresolved_type.dart' show UnresolvedType;
export 'void_type_builder.dart' show VoidTypeBuilder;
-
-abstract class Builder {
- /// Used when multiple things with the same name are declared within the same
- /// parent. Only used for declarations, not for scopes.
- ///
- // TODO(ahe): Move to member builder or something. Then we can make
- // this a const class.
- Builder next;
-
- /// The values of [parent], [charOffset], and [fileUri] aren't stored. We
- /// need to evaluate the memory impact of doing so, but want to ensure the
- /// information is always provided.
- Builder(Builder parent, int charOffset, Uri fileUri);
-
- int get charOffset => -1;
-
- Uri get fileUri => null;
-
- /// Resolve constructors (lookup names in scope) recorded in this builder and
- /// return the number of constructors resolved.
- int resolveConstructors(LibraryBuilder parent) => 0;
-
- Builder get parent => null;
-
- bool get isFinal => false;
-
- bool get isField => false;
-
- bool get isRegularMethod => false;
-
- bool get isGetter => false;
-
- bool get isSetter => false;
-
- bool get isInstanceMember => false;
-
- bool get isStatic => false;
-
- bool get isTopLevel => false;
-
- bool get isTypeDeclaration => false;
-
- bool get isTypeVariable => false;
-
- bool get isConstructor => false;
-
- bool get isFactory => false;
-
- bool get isLocal => false;
-
- bool get isConst => false;
-
- bool get isSynthetic => false;
-
- get target => unsupported("${runtimeType}.target", charOffset, fileUri);
-
- bool get hasProblem => false;
-
- bool get isPatch => this != origin;
-
- Builder get origin => this;
-
- String get fullNameForErrors;
-
- Uri computeLibraryUri() {
- Builder builder = this;
- do {
- if (builder is LibraryBuilder) return builder.uri;
- builder = builder.parent;
- } while (builder != null);
- return unhandled("no library parent", "${runtimeType}", -1, null);
- }
-
- void prepareTopLevelInference(
- covariant LibraryBuilder library, ClassBuilder currentClass) {}
-
- void instrumentTopLevelInference(Instrumentation instrumentation) {}
-
- /// Applies [patch] to this.
- void applyPatch(Builder patch) {
- unsupported("${runtimeType}.applyPatch", charOffset, fileUri);
- }
-
- /// Returns the number of patches that was finished.
- int finishPatch() {
- if (!isPatch) return 0;
- unsupported("${runtimeType}.finishPatch", charOffset, fileUri);
- return 0;
- }
-}
diff --git a/pkg/front_end/lib/src/fasta/builder/class_builder.dart b/pkg/front_end/lib/src/fasta/builder/class_builder.dart
index 6121947..f787b69 100644
--- a/pkg/front_end/lib/src/fasta/builder/class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/class_builder.dart
@@ -8,8 +8,8 @@
import 'builder.dart'
show
- Builder,
ConstructorReferenceBuilder,
+ Declaration,
LibraryBuilder,
MemberBuilder,
MetadataBuilder,
@@ -90,19 +90,19 @@
}
/// Used to lookup a static member of this class.
- Builder findStaticBuilder(
+ Declaration findStaticBuilder(
String name, int charOffset, Uri fileUri, LibraryBuilder accessingLibrary,
{bool isSetter: false}) {
if (accessingLibrary.origin != library.origin && name.startsWith("_")) {
return null;
}
- Builder builder = isSetter
+ Declaration declaration = isSetter
? scope.lookupSetter(name, charOffset, fileUri, isInstanceScope: false)
: scope.lookup(name, charOffset, fileUri, isInstanceScope: false);
- return builder;
+ return declaration;
}
- Builder findConstructorOrFactory(
+ Declaration findConstructorOrFactory(
String name, int charOffset, Uri uri, LibraryBuilder accessingLibrary) {
if (accessingLibrary.origin != library.origin && name.startsWith("_")) {
return null;
@@ -137,14 +137,14 @@
Map<TypeVariableBuilder, TypeBuilder> substitutionMap;
List arguments;
List variables;
- Builder builder;
+ Declaration declaration;
/// If [application] is mixing in [superclass] directly or via other named
/// mixin applications, return it.
NamedTypeBuilder findSuperclass(MixinApplicationBuilder application) {
for (TypeBuilder t in application.mixins) {
if (t is NamedTypeBuilder) {
- if (t.builder == superclass) return t;
+ if (t.declaration == superclass) return t;
} else if (t is MixinApplicationBuilder) {
NamedTypeBuilder s = findSuperclass(t);
if (s != null) return s;
@@ -154,16 +154,16 @@
}
void handleNamedTypeBuilder(NamedTypeBuilder t) {
- builder = t.builder;
+ declaration = t.declaration;
arguments = t.arguments ?? const [];
- if (builder is ClassBuilder) {
- ClassBuilder cls = builder;
+ if (declaration is ClassBuilder) {
+ ClassBuilder cls = declaration;
variables = cls.typeVariables;
supertype = cls.supertype;
}
}
- while (builder != superclass) {
+ while (declaration != superclass) {
variables = null;
if (supertype is NamedTypeBuilder) {
handleNamedTypeBuilder(supertype);
diff --git a/pkg/front_end/lib/src/fasta/builder/constructor_reference_builder.dart b/pkg/front_end/lib/src/fasta/builder/constructor_reference_builder.dart
index d059f88..bc7a3cb 100644
--- a/pkg/front_end/lib/src/fasta/builder/constructor_reference_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/constructor_reference_builder.dart
@@ -8,15 +8,19 @@
import 'builder.dart'
show
- Builder,
ClassBuilder,
+ Declaration,
LibraryBuilder,
PrefixBuilder,
QualifiedName,
Scope,
TypeBuilder;
-class ConstructorReferenceBuilder extends Builder {
+class ConstructorReferenceBuilder {
+ final int charOffset;
+
+ final Uri fileUri;
+
final Object name;
final List<TypeBuilder> typeArguments;
@@ -24,38 +28,38 @@
/// This is the name of a named constructor. As `bar` in `new Foo<T>.bar()`.
final String suffix;
- Builder target;
+ Declaration target;
ConstructorReferenceBuilder(this.name, this.typeArguments, this.suffix,
- Builder parent, int charOffset)
- : super(parent, charOffset, parent.fileUri);
+ Declaration parent, this.charOffset)
+ : fileUri = parent.fileUri;
String get fullNameForErrors => "$name${suffix == null ? '' : '.$suffix'}";
void resolveIn(Scope scope, LibraryBuilder accessingLibrary) {
final name = this.name;
- Builder builder;
+ Declaration declaration;
if (name is QualifiedName) {
String prefix = name.prefix;
String middle = name.suffix;
- builder = scope.lookup(prefix, charOffset, fileUri);
- if (builder is PrefixBuilder) {
- PrefixBuilder prefix = builder;
- builder = prefix.lookup(middle, name.charOffset, fileUri);
- } else if (builder is ClassBuilder) {
- ClassBuilder cls = builder;
- builder = cls.findConstructorOrFactory(
+ declaration = scope.lookup(prefix, charOffset, fileUri);
+ if (declaration is PrefixBuilder) {
+ PrefixBuilder prefix = declaration;
+ declaration = prefix.lookup(middle, name.charOffset, fileUri);
+ } else if (declaration is ClassBuilder) {
+ ClassBuilder cls = declaration;
+ declaration = cls.findConstructorOrFactory(
middle, name.charOffset, fileUri, accessingLibrary);
if (suffix == null) {
- target = builder;
+ target = declaration;
return;
}
}
} else {
- builder = scope.lookup(name, charOffset, fileUri);
+ declaration = scope.lookup(name, charOffset, fileUri);
}
- if (builder is ClassBuilder) {
- target = builder.findConstructorOrFactory(
+ if (declaration is ClassBuilder) {
+ target = declaration.findConstructorOrFactory(
suffix ?? "", charOffset, fileUri, accessingLibrary);
}
if (target == null) {
diff --git a/pkg/front_end/lib/src/fasta/builder/declaration.dart b/pkg/front_end/lib/src/fasta/builder/declaration.dart
new file mode 100644
index 0000000..fa1f97b
--- /dev/null
+++ b/pkg/front_end/lib/src/fasta/builder/declaration.dart
@@ -0,0 +1,93 @@
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library fasta.declaration;
+
+import '../problems.dart' show unhandled, unsupported;
+
+import 'library_builder.dart' show LibraryBuilder;
+
+abstract class Declaration {
+ /// Used when multiple things with the same name are declared within the same
+ /// parent. Only used for top-level and class-member declarations, not for
+ /// block scopes.
+ Declaration next;
+
+ Declaration();
+
+ Declaration get parent;
+
+ Uri get fileUri;
+
+ int get charOffset;
+
+ get target => unsupported("${runtimeType}.target", charOffset, fileUri);
+
+ Declaration get origin => this;
+
+ String get fullNameForErrors;
+
+ bool get hasProblem => false;
+
+ bool get isConst => false;
+
+ bool get isConstructor => false;
+
+ bool get isFactory => false;
+
+ bool get isField => false;
+
+ bool get isFinal => false;
+
+ bool get isGetter => false;
+
+ bool get isInstanceMember => false;
+
+ bool get isLocal => false;
+
+ bool get isPatch => this != origin;
+
+ bool get isRegularMethod => false;
+
+ bool get isSetter => false;
+
+ bool get isStatic => false;
+
+ bool get isSynthetic => false;
+
+ bool get isTopLevel => false;
+
+ bool get isTypeDeclaration => false;
+
+ bool get isTypeVariable => false;
+
+ Uri computeLibraryUri() {
+ Declaration declaration = this;
+ do {
+ if (declaration is LibraryBuilder) return declaration.uri;
+ declaration = declaration.parent;
+ } while (declaration != null);
+ return unhandled("no library parent", "${runtimeType}", -1, null);
+ }
+
+ /// Applies [patch] to this declaration.
+ void applyPatch(Declaration patch) {
+ unsupported("${runtimeType}.applyPatch", charOffset, fileUri);
+ }
+
+ /// Returns the number of patches that was finished.
+ int finishPatch() {
+ if (!isPatch) return 0;
+ unsupported("${runtimeType}.finishPatch", charOffset, fileUri);
+ return 0;
+ }
+
+ /// Resolve constructors (lookup names in scope) recorded in this builder and
+ /// return the number of constructors resolved.
+ int resolveConstructors(covariant Declaration parent) => 0;
+
+ void prepareTopLevelInference(covariant library, covariant currentClass) {}
+
+ void instrumentTopLevelInference(covariant instrumentation) {}
+}
diff --git a/pkg/front_end/lib/src/fasta/builder/library_builder.dart b/pkg/front_end/lib/src/fasta/builder/library_builder.dart
index 304d87f..8d73995 100644
--- a/pkg/front_end/lib/src/fasta/builder/library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/library_builder.dart
@@ -22,8 +22,8 @@
import 'builder.dart'
show
- Builder,
ClassBuilder,
+ Declaration,
ModifierBuilder,
PrefixBuilder,
Scope,
@@ -51,6 +51,9 @@
exportScopeBuilder = new ScopeBuilder(exportScope),
super(null, -1, fileUri);
+ @override
+ Declaration get parent => null;
+
bool get isPart => false;
@override
@@ -66,7 +69,7 @@
Uri get uri;
- Builder addBuilder(String name, Builder builder, int charOffset);
+ Declaration addBuilder(String name, Declaration declaration, int charOffset);
void addExporter(
LibraryBuilder exporter, List<Combinator> combinators, int charOffset) {
@@ -93,16 +96,17 @@
}
/// Returns true if the export scope was modified.
- bool addToExportScope(String name, Builder member) {
+ bool addToExportScope(String name, Declaration member) {
if (name.startsWith("_")) return false;
if (member is PrefixBuilder) return false;
- Map<String, Builder> map =
+ Map<String, Declaration> map =
member.isSetter ? exportScope.setters : exportScope.local;
- Builder existing = map[name];
+ Declaration existing = map[name];
if (existing == member) return false;
if (existing != null) {
- Builder result =
- buildAmbiguousBuilder(name, existing, member, -1, isExport: true);
+ Declaration result = computeAmbiguousDeclaration(
+ name, existing, member, -1,
+ isExport: true);
map[name] = result;
return result != existing;
} else {
@@ -111,10 +115,11 @@
return true;
}
- void addToScope(String name, Builder member, int charOffset, bool isImport);
+ void addToScope(
+ String name, Declaration member, int charOffset, bool isImport);
- Builder buildAmbiguousBuilder(
- String name, Builder builder, Builder other, int charOffset,
+ Declaration computeAmbiguousDeclaration(
+ String name, Declaration declaration, Declaration other, int charOffset,
{bool isExport: false, bool isImport: false});
int finishDeferredLoadTearoffs() => 0;
@@ -135,7 +140,7 @@
/// If [constructorName] is null or the empty string, it's assumed to be an
/// unnamed constructor. it's an error if [constructorName] starts with
/// `"_"`, and [bypassLibraryPrivacy] is false.
- Builder getConstructor(String className,
+ Declaration getConstructor(String className,
{String constructorName, bool bypassLibraryPrivacy: false}) {
constructorName ??= "";
if (constructorName.startsWith("_") && !bypassLibraryPrivacy) {
@@ -145,12 +150,12 @@
-1,
null);
}
- Builder cls = (bypassLibraryPrivacy ? scope : exportScope)
+ Declaration cls = (bypassLibraryPrivacy ? scope : exportScope)
.lookup(className, -1, null);
if (cls is ClassBuilder) {
// TODO(ahe): This code is similar to code in `endNewExpression` in
// `body_builder.dart`, try to share it.
- Builder constructor =
+ Declaration constructor =
cls.findConstructorOrFactory(constructorName, -1, null, this);
if (constructor == null) {
// Fall-through to internal error below.
@@ -182,17 +187,17 @@
void becomeCoreLibrary(dynamicType);
- void forEach(void f(String name, Builder builder)) {
- scope.forEach((String name, Builder builder) {
- if (builder.parent == this) {
- f(name, builder);
+ void forEach(void f(String name, Declaration declaration)) {
+ scope.forEach((String name, Declaration declaration) {
+ if (declaration.parent == this) {
+ f(name, declaration);
}
});
}
/// Don't use for scope lookup. Only use when an element is known to exist
/// (and not a setter).
- Builder operator [](String name) {
+ Declaration operator [](String name) {
return scope.local[name] ??
internalProblem(
templateInternalProblemNotFoundIn.withArguments(name, "$fileUri"),
@@ -200,7 +205,7 @@
fileUri);
}
- Builder lookup(String name, int charOffset, Uri fileUri) {
+ Declaration lookup(String name, int charOffset, Uri fileUri) {
return scope.lookup(name, charOffset, fileUri);
}
diff --git a/pkg/front_end/lib/src/fasta/builder/member_builder.dart b/pkg/front_end/lib/src/fasta/builder/member_builder.dart
index 3ff91f6..827fe5f 100644
--- a/pkg/front_end/lib/src/fasta/builder/member_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/member_builder.dart
@@ -5,13 +5,13 @@
library fasta.member_builder;
import 'builder.dart'
- show Builder, ClassBuilder, LibraryBuilder, ModifierBuilder;
+ show ClassBuilder, Declaration, LibraryBuilder, ModifierBuilder;
abstract class MemberBuilder extends ModifierBuilder {
/// For top-level members, the parent is set correctly during
/// construction. However, for class members, the parent is initially the
/// library and updated later.
- Builder parent;
+ Declaration parent;
String get name;
diff --git a/pkg/front_end/lib/src/fasta/builder/metadata_builder.dart b/pkg/front_end/lib/src/fasta/builder/metadata_builder.dart
index f611658..ca27f7f 100644
--- a/pkg/front_end/lib/src/fasta/builder/metadata_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/metadata_builder.dart
@@ -4,25 +4,24 @@
library fasta.metadata_builder;
-import 'builder.dart' show Builder, TypeBuilder;
+import 'builder.dart' show Declaration, TypeBuilder;
import 'constructor_reference_builder.dart' show ConstructorReferenceBuilder;
-abstract class MetadataBuilder<T extends TypeBuilder> extends Builder {
- MetadataBuilder(Builder parent, int charOffset)
- : super(parent, -1, parent.fileUri);
+abstract class MetadataBuilder<T extends TypeBuilder> {
+ MetadataBuilder(Declaration parent, int charOffset);
factory MetadataBuilder.fromConstructor(
ConstructorReferenceBuilder constructorReference,
List arguments,
- Builder parent,
+ Declaration parent,
int charOffset) {
return new ConstructorMetadataBuilder(
constructorReference, arguments, parent, charOffset);
}
factory MetadataBuilder.fromExpression(
- Object expression, String postfix, Builder parent, int charOffset) {
+ Object expression, String postfix, Declaration parent, int charOffset) {
return new ExpressionMetadataBuilder(
expression, postfix, parent, charOffset);
}
@@ -34,12 +33,9 @@
final List arguments;
- ConstructorMetadataBuilder(
- this.constructorReference, this.arguments, Builder parent, int charOffset)
+ ConstructorMetadataBuilder(this.constructorReference, this.arguments,
+ Declaration parent, int charOffset)
: super(parent, charOffset);
-
- @override
- String get fullNameForErrors => constructorReference.fullNameForErrors;
}
/// Expression metadata (without arguments).
@@ -54,11 +50,6 @@
final String identifier;
ExpressionMetadataBuilder(
- this.qualified, this.identifier, Builder parent, int charOffset)
+ this.qualified, this.identifier, Declaration parent, int charOffset)
: super(parent, charOffset);
-
- @override
- String get fullNameForErrors {
- return identifier == null ? qualified : "$qualified.$identifier";
- }
}
diff --git a/pkg/front_end/lib/src/fasta/builder/modifier_builder.dart b/pkg/front_end/lib/src/fasta/builder/modifier_builder.dart
index 2cb6afa..c229560 100644
--- a/pkg/front_end/lib/src/fasta/builder/modifier_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/modifier_builder.dart
@@ -14,16 +14,17 @@
namedMixinApplicationMask,
staticMask;
-import 'builder.dart' show Builder;
+import 'builder.dart' show Declaration;
-abstract class ModifierBuilder extends Builder {
+abstract class ModifierBuilder extends Declaration {
+ final Declaration parent;
+
final int charOffset;
final Uri fileUri;
- ModifierBuilder(Builder parent, this.charOffset, [Uri fileUri])
- : fileUri = fileUri ?? parent?.fileUri,
- super(parent, charOffset, fileUri ?? parent?.fileUri);
+ ModifierBuilder(this.parent, this.charOffset, [Uri fileUri])
+ : fileUri = fileUri ?? parent?.fileUri;
int get modifiers;
diff --git a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
index fb021d6..a302a71 100644
--- a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
@@ -8,7 +8,7 @@
import 'builder.dart'
show
- Builder,
+ Declaration,
InvalidTypeBuilder,
PrefixBuilder,
QualifiedName,
@@ -21,7 +21,7 @@
List<T> arguments;
- TypeDeclarationBuilder<T, R> builder;
+ TypeDeclarationBuilder<T, R> declaration;
NamedTypeBuilder(this.name, this.arguments);
@@ -29,17 +29,17 @@
[Message message]);
@override
- void bind(TypeDeclarationBuilder builder) {
- this.builder = builder?.origin;
+ void bind(TypeDeclarationBuilder declaration) {
+ this.declaration = declaration?.origin;
}
@override
void resolveIn(Scope scope, int charOffset, Uri fileUri) {
- if (builder != null) return;
+ if (declaration != null) return;
final name = this.name;
- Builder member;
+ Declaration member;
if (name is QualifiedName) {
- var prefix = scope.lookup(name.prefix, charOffset, fileUri);
+ Declaration prefix = scope.lookup(name.prefix, charOffset, fileUri);
if (prefix is PrefixBuilder) {
member = prefix.lookup(name.suffix, name.charOffset, fileUri);
}
@@ -47,10 +47,10 @@
member = scope.lookup(name, charOffset, fileUri);
}
if (member is TypeDeclarationBuilder) {
- builder = member.origin;
+ declaration = member.origin;
return;
}
- builder = buildInvalidType(charOffset, fileUri);
+ declaration = buildInvalidType(charOffset, fileUri);
}
String get debugName => "NamedTypeBuilder";
diff --git a/pkg/front_end/lib/src/fasta/builder/prefix_builder.dart b/pkg/front_end/lib/src/fasta/builder/prefix_builder.dart
index c115f35..75e269a1 100644
--- a/pkg/front_end/lib/src/fasta/builder/prefix_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/prefix_builder.dart
@@ -4,9 +4,9 @@
library fasta.prefix_builder;
-import '../builder/builder.dart' show Builder, LibraryBuilder, Scope;
+import 'builder.dart' show Declaration, LibraryBuilder, Scope;
-class PrefixBuilder extends Builder {
+class PrefixBuilder extends Declaration {
final String name;
final Scope exportScope = new Scope.top();
@@ -18,19 +18,20 @@
@override
final int charOffset;
- PrefixBuilder(this.name, this.deferred, this.parent, this.charOffset)
- : super(parent, charOffset, parent.fileUri);
+ PrefixBuilder(this.name, this.deferred, this.parent, this.charOffset);
- Builder lookup(String name, int charOffset, Uri fileUri) {
+ Uri get fileUri => parent.fileUri;
+
+ Declaration lookup(String name, int charOffset, Uri fileUri) {
return exportScope.lookup(name, charOffset, fileUri);
}
- void addToExportScope(String name, Builder member, int charOffset) {
- Map<String, Builder> map =
+ void addToExportScope(String name, Declaration member, int charOffset) {
+ Map<String, Declaration> map =
member.isSetter ? exportScope.setters : exportScope.local;
- Builder existing = map[name];
+ Declaration existing = map[name];
if (existing != null) {
- map[name] = parent.buildAmbiguousBuilder(
+ map[name] = parent.computeAmbiguousDeclaration(
name, existing, member, charOffset,
isExport: true);
} else {
diff --git a/pkg/front_end/lib/src/fasta/builder/procedure_builder.dart b/pkg/front_end/lib/src/fasta/builder/procedure_builder.dart
index 9fea77d..73020a5 100644
--- a/pkg/front_end/lib/src/fasta/builder/procedure_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/procedure_builder.dart
@@ -11,7 +11,7 @@
import 'builder.dart'
show
- Builder,
+ Declaration,
FormalParameterBuilder,
LibraryBuilder,
MemberBuilder,
@@ -68,7 +68,7 @@
/// Language Specifiction, 4th ed, section 9.2.
Scope computeFormalParameterScope(Scope parent) {
if (formals == null) return parent;
- Map<String, Builder> local = <String, Builder>{};
+ Map<String, Declaration> local = <String, Declaration>{};
for (FormalParameterBuilder formal in formals) {
if (!isConstructor || !formal.hasThis) {
local[formal.name] = formal;
@@ -95,7 +95,7 @@
// parameter initializer scope.
if (formals == null) return parent;
- Map<String, Builder> local = <String, Builder>{};
+ Map<String, Declaration> local = <String, Declaration>{};
for (FormalParameterBuilder formal in formals) {
local[formal.name] = formal.forFormalParameterInitializerScope();
}
@@ -108,7 +108,7 @@
/// to support generic methods.
Scope computeTypeParameterScope(Scope parent) {
if (typeVariables == null) return parent;
- Map<String, Builder> local = <String, Builder>{};
+ Map<String, Declaration> local = <String, Declaration>{};
for (TypeVariableBuilder variable in typeVariables) {
local[variable.name] = variable;
}
diff --git a/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart b/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart
index 12346f1..c8ec2d5 100644
--- a/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart
@@ -5,7 +5,12 @@
library fasta.type_declaration_builder;
import 'builder.dart'
- show Builder, LibraryBuilder, MetadataBuilder, ModifierBuilder, TypeBuilder;
+ show
+ Declaration,
+ LibraryBuilder,
+ MetadataBuilder,
+ ModifierBuilder,
+ TypeBuilder;
abstract class TypeDeclarationBuilder<T extends TypeBuilder, R>
extends ModifierBuilder {
@@ -15,7 +20,7 @@
final String name;
- Builder parent;
+ Declaration parent;
TypeDeclarationBuilder(
this.metadata, this.modifiers, this.name, this.parent, int charOffset,
diff --git a/pkg/front_end/lib/src/fasta/builder/unresolved_type.dart b/pkg/front_end/lib/src/fasta/builder/unresolved_type.dart
index c539213..afe2060 100644
--- a/pkg/front_end/lib/src/fasta/builder/unresolved_type.dart
+++ b/pkg/front_end/lib/src/fasta/builder/unresolved_type.dart
@@ -29,11 +29,11 @@
void checkType() {
TypeBuilder resolvedType = builder;
if (resolvedType is NamedTypeBuilder) {
- TypeDeclarationBuilder declaration = resolvedType.builder;
+ TypeDeclarationBuilder declaration = resolvedType.declaration;
if (declaration is ClassBuilder) {
if (resolvedType.arguments != null &&
resolvedType.arguments.length != declaration.typeVariablesCount) {
- resolvedType.builder = resolvedType.buildInvalidType(
+ resolvedType.declaration = resolvedType.buildInvalidType(
charOffset,
fileUri,
templateTypeArgumentMismatch.withArguments(
@@ -42,7 +42,7 @@
} else if (declaration is FunctionTypeAliasBuilder) {
if (resolvedType.arguments != null &&
resolvedType.arguments.length != declaration.typeVariablesCount) {
- resolvedType.builder = resolvedType.buildInvalidType(
+ resolvedType.declaration = resolvedType.buildInvalidType(
charOffset,
fileUri,
templateTypeArgumentMismatch.withArguments(
@@ -56,7 +56,7 @@
void normalizeType() {
TypeBuilder resolvedType = builder;
if (resolvedType is NamedTypeBuilder) {
- TypeDeclarationBuilder declaration = resolvedType.builder;
+ TypeDeclarationBuilder declaration = resolvedType.declaration;
if (declaration is ClassBuilder) {
if (resolvedType.arguments != null &&
resolvedType.arguments.length != declaration.typeVariablesCount) {
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
index 5a29dbe..78295a0 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
@@ -25,7 +25,7 @@
import '../kernel/kernel_builder.dart'
show
- Builder,
+ Declaration,
DynamicTypeBuilder,
InvalidTypeBuilder,
KernelInvalidTypeBuilder,
@@ -105,22 +105,23 @@
}
}
- Builder addBuilder(String name, Builder builder, int charOffset) {
+ @override
+ Declaration addBuilder(String name, Declaration declaration, int charOffset) {
if (name == null || name.isEmpty) return null;
- bool isSetter = builder.isSetter;
+ bool isSetter = declaration.isSetter;
if (isSetter) {
- scopeBuilder.addSetter(name, builder);
+ scopeBuilder.addSetter(name, declaration);
} else {
- scopeBuilder.addMember(name, builder);
+ scopeBuilder.addMember(name, declaration);
}
if (!name.startsWith("_")) {
if (isSetter) {
- exportScopeBuilder.addSetter(name, builder);
+ exportScopeBuilder.addSetter(name, declaration);
} else {
- exportScopeBuilder.addMember(name, builder);
+ exportScopeBuilder.addMember(name, declaration);
}
}
- return builder;
+ return declaration;
}
void addTypedef(Typedef typedef) {
@@ -129,13 +130,14 @@
}
@override
- void addToScope(String name, Builder member, int charOffset, bool isImport) {
+ void addToScope(
+ String name, Declaration member, int charOffset, bool isImport) {
unimplemented("addToScope", charOffset, fileUri);
}
@override
- Builder buildAmbiguousBuilder(
- String name, Builder builder, Builder other, int charOffset,
+ Declaration computeAmbiguousDeclaration(
+ String name, Declaration builder, Declaration other, int charOffset,
{bool isExport: false, bool isImport: false}) {
if (builder == other) return builder;
if (builder is InvalidTypeBuilder) return builder;
@@ -154,17 +156,17 @@
void finalizeExports() {
unserializableExports?.forEach((String name, String message) {
- Builder builder;
+ Declaration declaration;
switch (name) {
case "dynamic":
case "void":
// TODO(ahe): It's likely that we shouldn't be exporting these types
// from dart:core, and this case can be removed.
- builder = loader.coreLibrary.exportScopeBuilder[name];
+ declaration = loader.coreLibrary.exportScopeBuilder[name];
break;
default:
- builder = new KernelInvalidTypeBuilder(
+ declaration = new KernelInvalidTypeBuilder(
name,
-1,
null,
@@ -172,7 +174,7 @@
? null
: templateUnspecified.withArguments(message));
}
- exportScopeBuilder.addMember(name, builder);
+ exportScopeBuilder.addMember(name, declaration);
});
for (var reference in library.additionalExports) {
@@ -203,22 +205,22 @@
-1,
fileUri);
}
- Builder builder;
+ Declaration declaration;
if (isSetter) {
- builder = library.exportScope.setters[name];
- exportScopeBuilder.addSetter(name, builder);
+ declaration = library.exportScope.setters[name];
+ exportScopeBuilder.addSetter(name, declaration);
} else {
- builder = library.exportScope.local[name];
- exportScopeBuilder.addMember(name, builder);
+ declaration = library.exportScope.local[name];
+ exportScopeBuilder.addMember(name, declaration);
}
- if (builder == null) {
+ if (declaration == null) {
internalProblem(
templateUnspecified.withArguments(
"Exported element '$name' not found in '$libraryUri'."),
-1,
fileUri);
}
- assert(node == builder.target);
+ assert(node == declaration.target);
}
}
}
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart
index 7845ca1..7b54cd3 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart
@@ -9,7 +9,7 @@
import '../kernel/kernel_builder.dart'
show
- Builder,
+ Declaration,
MemberBuilder,
isRedirectingGenerativeConstructorImplementation;
@@ -23,7 +23,7 @@
final Member member;
- DillMemberBuilder(Member member, Builder parent)
+ DillMemberBuilder(Member member, Declaration parent)
: modifiers = computeModifiers(member),
member = member,
super(parent, member.fileOffset);
diff --git a/pkg/front_end/lib/src/fasta/export.dart b/pkg/front_end/lib/src/fasta/export.dart
index 78723ce..2284a12 100644
--- a/pkg/front_end/lib/src/fasta/export.dart
+++ b/pkg/front_end/lib/src/fasta/export.dart
@@ -4,7 +4,7 @@
library fasta.export;
-import 'builder/builder.dart' show Builder, LibraryBuilder;
+import 'builder/builder.dart' show Declaration, LibraryBuilder;
import 'combinator.dart' show Combinator;
@@ -23,7 +23,7 @@
Uri get fileUri => exporter.fileUri;
- bool addToExportScope(String name, Builder member) {
+ bool addToExportScope(String name, Declaration member) {
if (combinators != null) {
for (Combinator combinator in combinators) {
if (combinator.isShow && !combinator.names.contains(name)) return false;
diff --git a/pkg/front_end/lib/src/fasta/import.dart b/pkg/front_end/lib/src/fasta/import.dart
index d48f2a2..e27b1e0 100644
--- a/pkg/front_end/lib/src/fasta/import.dart
+++ b/pkg/front_end/lib/src/fasta/import.dart
@@ -6,7 +6,7 @@
import 'package:kernel/ast.dart' show LibraryDependency;
-import 'builder/builder.dart' show Builder, LibraryBuilder;
+import 'builder/builder.dart' show Declaration, LibraryBuilder;
import 'kernel/kernel_builder.dart' show toKernelCombinators;
@@ -16,8 +16,6 @@
import 'configuration.dart' show Configuration;
-typedef void AddToScope(String name, Builder member);
-
class Import {
/// The library that is importing [imported];
final LibraryBuilder importer;
@@ -60,17 +58,17 @@
void finalizeImports(LibraryBuilder importer) {
if (nativeImportUri != null) return;
- AddToScope add;
+ void Function(String, Declaration) add;
if (prefixBuilder == null) {
- add = (String name, Builder member) {
+ add = (String name, Declaration member) {
importer.addToScope(name, member, charOffset, true);
};
} else {
- add = (String name, Builder member) {
+ add = (String name, Declaration member) {
prefixBuilder.addToExportScope(name, member, charOffset);
};
}
- imported.exportScope.forEach((String name, Builder member) {
+ imported.exportScope.forEach((String name, Declaration member) {
if (combinators != null) {
for (Combinator combinator in combinators) {
if (combinator.isShow && !combinator.names.contains(name)) return;
@@ -80,7 +78,8 @@
add(name, member);
});
if (prefixBuilder != null) {
- Builder existing = importer.addBuilder(prefix, prefixBuilder, charOffset);
+ Declaration existing =
+ importer.addBuilder(prefix, prefixBuilder, charOffset);
if (existing == prefixBuilder) {
importer.addToScope(prefix, prefixBuilder, prefixCharOffset, true);
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 2f2013a..b5eced7 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -321,9 +321,9 @@
Scope outerSwitchScope = pop();
if (switchScope.unclaimedForwardDeclarations != null) {
switchScope.unclaimedForwardDeclarations
- .forEach((String name, Builder builder) {
+ .forEach((String name, Declaration declaration) {
if (outerSwitchScope == null) {
- JumpTarget target = builder;
+ JumpTarget target = declaration;
for (kernel.Statement statement in target.users) {
statement.parent.replaceChild(
statement,
@@ -331,7 +331,7 @@
fasta.templateLabelNotFound.withArguments(name)));
}
} else {
- outerSwitchScope.forwardDeclareLabel(name, builder);
+ outerSwitchScope.forwardDeclareLabel(name, declaration);
}
});
}
@@ -360,7 +360,7 @@
void declareVariable(Object variable, Scope scope) {
String name = forest.getVariableDeclarationName(variable);
- Builder existing = scope.local[name];
+ Declaration existing = scope.local[name];
if (existing != null) {
// This reports an error for duplicated declarations in the same scope:
// `{ var x; var x; }`
@@ -1291,7 +1291,7 @@
// objects directly.
var supertype = builder.supertype;
if (supertype is NamedTypeBuilder) {
- var builder = supertype.builder;
+ var builder = supertype.declaration;
if (builder is ClassBuilder) return builder;
}
return null;
@@ -1350,20 +1350,23 @@
scopeLookup(Scope scope, String name, Token token,
{bool isQualified: false, PrefixBuilder prefix}) {
int charOffset = offsetForToken(token);
- Builder builder = scope.lookup(name, charOffset, uri);
- if (builder == null && prefix == null && (classBuilder?.isPatch ?? false)) {
+ Declaration declaration = scope.lookup(name, charOffset, uri);
+ if (declaration == null &&
+ prefix == null &&
+ (classBuilder?.isPatch ?? false)) {
// The scope of a patched method includes the origin class.
- builder =
+ declaration =
classBuilder.origin.findStaticBuilder(name, charOffset, uri, library);
}
- if (builder != null && member.isField && builder.isInstanceMember) {
+ if (declaration != null && member.isField && declaration.isInstanceMember) {
return new IncompleteErrorGenerator(this, token,
fasta.templateThisAccessInFieldInitializer.withArguments(name));
}
- if (builder == null || (!isInstanceContext && builder.isInstanceMember)) {
+ if (declaration == null ||
+ (!isInstanceContext && declaration.isInstanceMember)) {
Name n = new Name(name, library.library);
if (!isQualified && isInstanceContext) {
- assert(builder == null);
+ assert(declaration == null);
if (constantContext != ConstantContext.none || member.isField) {
return new UnresolvedNameGenerator(this, token, n);
}
@@ -1377,23 +1380,23 @@
} else {
return new UnresolvedNameGenerator(this, token, n);
}
- } else if (builder.isTypeDeclaration) {
+ } else if (declaration.isTypeDeclaration) {
if (constantContext != ConstantContext.none &&
- builder.isTypeVariable &&
+ declaration.isTypeVariable &&
!member.isConstructor) {
deprecated_addCompileTimeError(
charOffset, "Not a constant expression.");
}
TypeUseGenerator<Expression, Statement, Arguments> generator =
new TypeUseGenerator<Expression, Statement, Arguments>(
- this, token, prefix, charOffset, builder, name);
+ this, token, prefix, charOffset, declaration, name);
return (prefix?.deferred == true)
? new DeferredAccessGenerator<Expression, Statement, Arguments>(
this, token, prefix, generator)
: generator;
- } else if (builder.isLocal) {
+ } else if (declaration.isLocal) {
if (constantContext != ConstantContext.none &&
- !builder.isConst &&
+ !declaration.isConst &&
!member.isConstructor) {
deprecated_addCompileTimeError(
charOffset, "Not a constant expression.");
@@ -1402,21 +1405,21 @@
// VariableDeclaration being final. See
// [ProcedureBuilder.computeFormalParameterInitializerScope]. If that
// wasn't the case, we could always use [VariableUseGenerator].
- if (builder.isFinal) {
- var fact =
- typePromoter.getFactForAccess(builder.target, functionNestingLevel);
+ if (declaration.isFinal) {
+ var fact = typePromoter.getFactForAccess(
+ declaration.target, functionNestingLevel);
var scope = typePromoter.currentScope;
return new ReadOnlyAccessGenerator<Expression, Statement, Arguments>(
this,
token,
- toExpression(new ShadowVariableGet(builder.target, fact, scope)
+ toExpression(new ShadowVariableGet(declaration.target, fact, scope)
..fileOffset = charOffset),
name);
} else {
return new VariableUseGenerator<Expression, Statement, Arguments>(
- this, token, builder.target);
+ this, token, declaration.target);
}
- } else if (builder.isInstanceMember) {
+ } else if (declaration.isInstanceMember) {
if (constantContext != ConstantContext.none &&
!inInitializer &&
// TODO(ahe): This is a hack because Fasta sets up the scope
@@ -1430,26 +1433,26 @@
Name n = new Name(name, library.library);
Member getter;
Member setter;
- if (builder is AccessErrorBuilder) {
- setter = builder.parent.target;
+ if (declaration is AccessErrorBuilder) {
+ setter = declaration.parent.target;
getter = lookupInstanceMember(n);
} else {
- getter = builder.target;
+ getter = declaration.target;
setter = lookupInstanceMember(n, isSetter: true);
}
return new ThisPropertyAccessGenerator<Expression, Statement, Arguments>(
this, token, n, getter, setter);
- } else if (builder.isRegularMethod) {
- assert(builder.isStatic || builder.isTopLevel);
+ } else if (declaration.isRegularMethod) {
+ assert(declaration.isStatic || declaration.isTopLevel);
StaticAccessGenerator<Expression, Statement, Arguments> generator =
new StaticAccessGenerator<Expression, Statement, Arguments>(
- this, token, builder.target, null);
+ this, token, declaration.target, null);
return (prefix?.deferred == true)
? new DeferredAccessGenerator<Expression, Statement, Arguments>(
this, token, prefix, generator)
: generator;
- } else if (builder is PrefixBuilder) {
- if (constantContext != ConstantContext.none && builder.deferred) {
+ } else if (declaration is PrefixBuilder) {
+ if (constantContext != ConstantContext.none && declaration.deferred) {
deprecated_addCompileTimeError(
charOffset,
"'$name' can't be used in a constant expression because it's "
@@ -1458,23 +1461,24 @@
"You might try moving the constant to the deferred library, "
"or removing 'deferred' from the import.");
}
- return builder;
- } else if (builder is LoadLibraryBuilder) {
+ return declaration;
+ } else if (declaration is LoadLibraryBuilder) {
return new LoadLibraryGenerator<Expression, Statement, Arguments>(
- this, token, builder);
+ this, token, declaration);
} else {
- if (builder.hasProblem && builder is! AccessErrorBuilder) return builder;
- Builder setter;
- if (builder.isSetter) {
- setter = builder;
- } else if (builder.isGetter) {
+ if (declaration.hasProblem && declaration is! AccessErrorBuilder)
+ return declaration;
+ Declaration setter;
+ if (declaration.isSetter) {
+ setter = declaration;
+ } else if (declaration.isGetter) {
setter = scope.lookupSetter(name, charOffset, uri);
- } else if (builder.isField && !builder.isFinal) {
- setter = builder;
+ } else if (declaration.isField && !declaration.isFinal) {
+ setter = declaration;
}
StaticAccessGenerator<Expression, Statement, Arguments> generator =
new StaticAccessGenerator<Expression, Statement,
- Arguments>.fromBuilder(this, builder, token, setter);
+ Arguments>.fromBuilder(this, declaration, token, setter);
if (constantContext != ConstantContext.none) {
Member readTarget = generator.readTarget;
if (!(readTarget is Field && readTarget.isConst ||
@@ -2846,7 +2850,8 @@
return deprecated_buildCompileTimeError(
"An enum class can't be instantiated.", nameToken.charOffset);
}
- Builder b = type.findConstructorOrFactory(name, charOffset, uri, library);
+ Declaration b =
+ type.findConstructorOrFactory(name, charOffset, uri, library);
Member target;
Member initialTarget;
List<DartType> targetTypeArguments;
@@ -3820,7 +3825,8 @@
[int charOffset = -1]) {
addProblemErrorIfConst(message, charOffset, className.length);
// TODO(ahe): The following doesn't make sense to Analyzer AST.
- Builder constructor = library.loader.getAbstractClassInstantiationError();
+ Declaration constructor =
+ library.loader.getAbstractClassInstantiationError();
return toExpression(new Throw(toKernelExpression(buildStaticInvocation(
constructor.target,
forest.arguments(<Expression>[
@@ -3872,7 +3878,7 @@
@override
Initializer buildFieldInitializer(
bool isSynthetic, String name, int offset, Expression expression) {
- Builder builder =
+ Declaration builder =
classBuilder.scope.local[name] ?? classBuilder.origin.scope.local[name];
if (builder is KernelFieldBuilder && builder.isInstanceMember) {
initializedFields ??= <String, int>{};
@@ -3894,7 +3900,7 @@
.withArguments(name)
.withLocation(uri, builder.charOffset, noLength)
]);
- Builder constructor =
+ Declaration constructor =
library.loader.getDuplicatedFieldInitializerError();
return buildInvalidInitializer(
toExpression(new Throw(toKernelExpression(buildStaticInvocation(
@@ -4218,16 +4224,24 @@
String toString() => "initialized-identifier($name, $initializer)";
}
-class JumpTarget<Statement> extends Builder {
+class JumpTarget<Statement> extends Declaration {
final List<Statement> users = <Statement>[];
final JumpTargetKind kind;
final int functionNestingLevel;
- JumpTarget(this.kind, this.functionNestingLevel, MemberBuilder member,
- int charOffset)
- : super(member, charOffset, member.fileUri);
+ @override
+ final MemberBuilder parent;
+
+ @override
+ final int charOffset;
+
+ JumpTarget(
+ this.kind, this.functionNestingLevel, this.parent, this.charOffset);
+
+ @override
+ Uri get fileUri => parent.fileUri;
bool get isBreakTarget => kind == JumpTargetKind.Break;
@@ -4283,22 +4297,31 @@
String get fullNameForErrors => "<jump-target>";
}
-class LabelTarget<Statement> extends Builder implements JumpTarget<Statement> {
+class LabelTarget<Statement> extends Declaration
+ implements JumpTarget<Statement> {
final List<Object> labels;
+ @override
+ final MemberBuilder parent;
+
final JumpTarget breakTarget;
final JumpTarget continueTarget;
final int functionNestingLevel;
- LabelTarget(this.labels, MemberBuilder member, this.functionNestingLevel,
- int charOffset)
+ @override
+ final int charOffset;
+
+ LabelTarget(
+ this.labels, this.parent, this.functionNestingLevel, this.charOffset)
: breakTarget = new JumpTarget<Statement>(
- JumpTargetKind.Break, functionNestingLevel, member, charOffset),
+ JumpTargetKind.Break, functionNestingLevel, parent, charOffset),
continueTarget = new JumpTarget<Statement>(
- JumpTargetKind.Continue, functionNestingLevel, member, charOffset),
- super(member, charOffset, member.fileUri);
+ JumpTargetKind.Continue, functionNestingLevel, parent, charOffset);
+
+ @override
+ Uri get fileUri => parent.fileUri;
bool get hasUsers => breakTarget.hasUsers || continueTarget.hasUsers;
@@ -4402,18 +4425,18 @@
typeParameters: typeParameters);
}
- Scope computeFormalParameterScope(Scope parent, Builder builder,
+ Scope computeFormalParameterScope(Scope parent, Declaration declaration,
ExpressionGeneratorHelper<dynamic, dynamic, Arguments> helper) {
if (required.length == 0 && optional == null) return parent;
- Map<String, Builder> local = <String, Builder>{};
+ Map<String, Declaration> local = <String, Declaration>{};
for (VariableDeclaration parameter in required) {
if (local[parameter.name] != null) {
helper.deprecated_addCompileTimeError(
parameter.fileOffset, "Duplicated name.");
}
- local[parameter.name] =
- new KernelVariableBuilder(parameter, builder, builder.fileUri);
+ local[parameter.name] = new KernelVariableBuilder(
+ parameter, declaration, declaration.fileUri);
}
if (optional != null) {
for (VariableDeclaration parameter in optional.formals) {
@@ -4421,8 +4444,8 @@
helper.deprecated_addCompileTimeError(
parameter.fileOffset, "Duplicated name.");
}
- local[parameter.name] =
- new KernelVariableBuilder(parameter, builder, builder.fileUri);
+ local[parameter.name] = new KernelVariableBuilder(
+ parameter, declaration, declaration.fileUri);
}
}
return new Scope(local, null, parent, "formals", isModifiable: false);
@@ -4455,7 +4478,7 @@
String getNodeName(Object node) {
if (node is Identifier) {
return node.name;
- } else if (node is Builder) {
+ } else if (node is Declaration) {
return node.fullNameForErrors;
} else if (node is ThisAccessGenerator) {
return node.isSuper ? "super" : "this";
diff --git a/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart b/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
index cd08eb6..ab4d78d 100644
--- a/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
@@ -48,8 +48,8 @@
import 'kernel_builder.dart'
show
AccessErrorBuilder,
- Builder,
BuiltinTypeBuilder,
+ Declaration,
FunctionTypeAliasBuilder,
KernelClassBuilder,
KernelFunctionTypeAliasBuilder,
@@ -455,24 +455,24 @@
factory StaticAccessGenerator.fromBuilder(
ExpressionGeneratorHelper<Expression, Statement, Arguments> helper,
- Builder builder,
+ Declaration declaration,
Token token,
- Builder builderSetter) {
- if (builder is AccessErrorBuilder) {
- AccessErrorBuilder error = builder;
- builder = error.builder;
+ Declaration builderSetter) {
+ if (declaration is AccessErrorBuilder) {
+ AccessErrorBuilder error = declaration;
+ declaration = error.builder;
// We should only see an access error here if we've looked up a setter
// when not explicitly looking for a setter.
- assert(builder.isSetter);
- } else if (builder.target == null) {
+ assert(declaration.isSetter);
+ } else if (declaration.target == null) {
return unhandled(
- "${builder.runtimeType}",
+ "${declaration.runtimeType}",
"StaticAccessGenerator.fromBuilder",
offsetForToken(token),
helper.uri);
}
- Member getter = builder.target.hasGetter ? builder.target : null;
- Member setter = builder.target.hasSetter ? builder.target : null;
+ Member getter = declaration.target.hasGetter ? declaration.target : null;
+ Member setter = declaration.target.hasSetter ? declaration.target : null;
if (setter == null) {
if (builderSetter?.target?.hasSetter ?? false) {
setter = builderSetter.target;
@@ -720,7 +720,8 @@
@override
buildPropertyAccess(
IncompleteSendGenerator send, int operatorOffset, bool isNullAware) {
- return this;
+ return send.withReceiver(buildSimpleRead(), operatorOffset,
+ isNullAware: isNullAware);
}
@override
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
index 2e2c334..d331200 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
@@ -73,9 +73,9 @@
import 'kernel_builder.dart'
show
- Builder,
ClassBuilder,
ConstructorReferenceBuilder,
+ Declaration,
KernelLibraryBuilder,
KernelProcedureBuilder,
KernelRedirectingFactoryBuilder,
@@ -199,20 +199,20 @@
// Copy keys to avoid concurrent modification error.
List<String> names = constructors.keys.toList();
for (String name in names) {
- Builder builder = constructors[name];
- if (builder.parent != this) {
+ Declaration declaration = constructors[name];
+ if (declaration.parent != this) {
unexpected(
- "$fileUri", "${builder.parent.fileUri}", charOffset, fileUri);
+ "$fileUri", "${declaration.parent.fileUri}", charOffset, fileUri);
}
- if (builder is KernelRedirectingFactoryBuilder) {
+ if (declaration is KernelRedirectingFactoryBuilder) {
// Compute the immediate redirection target, not the effective.
ConstructorReferenceBuilder redirectionTarget =
- builder.redirectionTarget;
+ declaration.redirectionTarget;
if (redirectionTarget != null) {
- Builder targetBuilder = redirectionTarget.target;
- addRedirectingConstructor(builder, library);
+ Declaration targetBuilder = redirectionTarget.target;
+ addRedirectingConstructor(declaration, library);
if (targetBuilder is ProcedureBuilder) {
- List<DartType> typeArguments = builder.typeArguments;
+ List<DartType> typeArguments = declaration.typeArguments;
if (typeArguments == null) {
// TODO(32049) If type arguments aren't specified, they should
// be inferred. Currently, the inference is not performed.
@@ -222,10 +222,10 @@
const DynamicType(),
growable: true);
}
- builder.setRedirectingFactoryBody(
+ declaration.setRedirectingFactoryBody(
targetBuilder.target, typeArguments);
} else if (targetBuilder is DillMemberBuilder) {
- List<DartType> typeArguments = builder.typeArguments;
+ List<DartType> typeArguments = declaration.typeArguments;
if (typeArguments == null) {
// TODO(32049) If type arguments aren't specified, they should
// be inferred. Currently, the inference is not performed.
@@ -235,19 +235,19 @@
const DynamicType(),
growable: true);
}
- builder.setRedirectingFactoryBody(
+ declaration.setRedirectingFactoryBody(
targetBuilder.member, typeArguments);
} else {
var message = templateRedirectionTargetNotFound
.withArguments(redirectionTarget.fullNameForErrors);
- if (builder.isConst) {
- addCompileTimeError(message, builder.charOffset, noLength);
+ if (declaration.isConst) {
+ addCompileTimeError(message, declaration.charOffset, noLength);
} else {
- addProblem(message, builder.charOffset, noLength);
+ addProblem(message, declaration.charOffset, noLength);
}
// CoreTypes aren't computed yet, and this is the outline
// phase. So we can't and shouldn't create a method body.
- builder.body = new RedirectingFactoryBody.unresolved(
+ declaration.body = new RedirectingFactoryBody.unresolved(
redirectionTarget.fullNameForErrors);
}
}
@@ -830,24 +830,24 @@
}
@override
- void applyPatch(Builder patch) {
+ void applyPatch(Declaration patch) {
if (patch is KernelClassBuilder) {
patch.actualOrigin = this;
// TODO(ahe): Complain if `patch.supertype` isn't null.
- scope.local.forEach((String name, Builder member) {
- Builder memberPatch = patch.scope.local[name];
+ scope.local.forEach((String name, Declaration member) {
+ Declaration memberPatch = patch.scope.local[name];
if (memberPatch != null) {
member.applyPatch(memberPatch);
}
});
- scope.setters.forEach((String name, Builder member) {
- Builder memberPatch = patch.scope.setters[name];
+ scope.setters.forEach((String name, Declaration member) {
+ Declaration memberPatch = patch.scope.setters[name];
if (memberPatch != null) {
member.applyPatch(memberPatch);
}
});
- constructors.local.forEach((String name, Builder member) {
- Builder memberPatch = patch.constructors.local[name];
+ constructors.local.forEach((String name, Declaration member) {
+ Declaration memberPatch = patch.constructors.local[name];
if (memberPatch != null) {
member.applyPatch(memberPatch);
}
@@ -876,29 +876,29 @@
}
@override
- Builder findStaticBuilder(
+ Declaration findStaticBuilder(
String name, int charOffset, Uri fileUri, LibraryBuilder accessingLibrary,
{bool isSetter: false}) {
- Builder builder = super.findStaticBuilder(
+ Declaration declaration = super.findStaticBuilder(
name, charOffset, fileUri, accessingLibrary,
isSetter: isSetter);
- if (builder == null && isPatch) {
+ if (declaration == null && isPatch) {
return origin.findStaticBuilder(
name, charOffset, fileUri, accessingLibrary,
isSetter: isSetter);
}
- return builder;
+ return declaration;
}
@override
- Builder findConstructorOrFactory(
+ Declaration findConstructorOrFactory(
String name, int charOffset, Uri uri, LibraryBuilder accessingLibrary) {
- Builder builder =
+ Declaration declaration =
super.findConstructorOrFactory(name, charOffset, uri, accessingLibrary);
- if (builder == null && isPatch) {
+ if (declaration == null && isPatch) {
return origin.findConstructorOrFactory(
name, charOffset, uri, accessingLibrary);
}
- return builder;
+ return declaration;
}
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart
index ef2a750..5c4c3d9 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart
@@ -42,7 +42,7 @@
import 'kernel_builder.dart'
show
- Builder,
+ Declaration,
EnumBuilder,
FormalParameterBuilder,
KernelClassBuilder,
@@ -266,7 +266,7 @@
new FieldInitializer(nameField,
new VariableGet(constructor.function.positionalParameters[1]))
..parent = constructor);
- KernelClassBuilder objectClass = objectType.builder;
+ KernelClassBuilder objectClass = objectType.declaration;
MemberBuilder superConstructor = objectClass.findConstructorOrFactory(
"", charOffset, fileUri, libraryBuilder);
if (superConstructor == null || !superConstructor.isConstructor) {
@@ -298,7 +298,7 @@
}
@override
- Builder findConstructorOrFactory(
+ Declaration findConstructorOrFactory(
String name, int charOffset, Uri uri, LibraryBuilder library) {
return null;
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_expression_generator.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_expression_generator.dart
index e026517..97d3930 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_expression_generator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_expression_generator.dart
@@ -110,7 +110,7 @@
import 'kernel_builder.dart'
show
- Builder,
+ Declaration,
KernelClassBuilder,
KernelInvalidTypeBuilder,
LoadLibraryBuilder,
@@ -1304,12 +1304,12 @@
if (declaration is KernelClassBuilder) {
KernelClassBuilder declaration = this.declaration;
- Builder builder = declaration.findStaticBuilder(
+ Declaration member = declaration.findStaticBuilder(
name.name, offsetForToken(token), uri, helper.library);
Generator generator;
- if (builder == null) {
- // If we find a setter, [builder] is an [AccessErrorBuilder], not null.
+ if (member == null) {
+ // If we find a setter, [member] is an [AccessErrorBuilder], not null.
if (send is IncompletePropertyAccessGenerator) {
generator = new UnresolvedNameGenerator(helper, send.token, name);
} else {
@@ -1317,18 +1317,18 @@
arguments, name.name, null, token.charOffset, Constness.implicit);
}
} else {
- Builder setter;
- if (builder.isSetter) {
- setter = builder;
- } else if (builder.isGetter) {
+ Declaration setter;
+ if (member.isSetter) {
+ setter = member;
+ } else if (member.isGetter) {
setter = declaration.findStaticBuilder(
name.name, offsetForToken(token), uri, helper.library,
isSetter: true);
- } else if (builder.isField && !builder.isFinal) {
- setter = builder;
+ } else if (member.isField && !member.isFinal) {
+ setter = member;
}
generator = new StaticAccessGenerator<Expression, Statement,
- Arguments>.fromBuilder(helper, builder, send.token, setter);
+ Arguments>.fromBuilder(helper, member, send.token, setter);
}
return arguments == null
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart
index 4c7ec10..27516bf 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart
@@ -25,7 +25,7 @@
import 'kernel_body_builder.dart' show KernelBodyBuilder;
import 'kernel_builder.dart'
- show Builder, FieldBuilder, KernelTypeBuilder, MetadataBuilder;
+ show Declaration, FieldBuilder, KernelTypeBuilder, MetadataBuilder;
import 'kernel_shadow_ast.dart' show ShadowField;
@@ -41,7 +41,7 @@
this.type,
String name,
int modifiers,
- Builder compilationUnit,
+ Declaration compilationUnit,
int charOffset,
this.initializerTokenForInference,
this.hasInitializer)
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
index c25088e..34ab190 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
@@ -49,10 +49,10 @@
import 'kernel_builder.dart'
show
AccessErrorBuilder,
- Builder,
BuiltinTypeBuilder,
ClassBuilder,
ConstructorReferenceBuilder,
+ Declaration,
DynamicTypeBuilder,
FormalParameterBuilder,
InvalidTypeBuilder,
@@ -233,7 +233,7 @@
}
Map<String, TypeVariableBuilder> checkTypeVariables(
- List<TypeVariableBuilder> typeVariables, Builder owner) {
+ List<TypeVariableBuilder> typeVariables, Declaration owner) {
if (typeVariables?.isEmpty ?? true) return null;
Map<String, TypeVariableBuilder> typeVariablesByName =
<String, TypeVariableBuilder>{};
@@ -479,7 +479,7 @@
typeVariables: typeVariables,
modifiers: modifiers,
interfaces: interfaces);
- checkTypeVariables(typeVariables, supertype.builder);
+ checkTypeVariables(typeVariables, supertype.declaration);
}
@override
@@ -727,34 +727,34 @@
}
@override
- void buildBuilder(Builder builder, LibraryBuilder coreLibrary) {
+ void buildBuilder(Declaration declaration, LibraryBuilder coreLibrary) {
Class cls;
Member member;
Typedef typedef;
- if (builder is SourceClassBuilder) {
- cls = builder.build(this, coreLibrary);
- } else if (builder is KernelFieldBuilder) {
- member = builder.build(this)..isStatic = true;
- } else if (builder is KernelProcedureBuilder) {
- member = builder.build(this)..isStatic = true;
- } else if (builder is KernelFunctionTypeAliasBuilder) {
- typedef = builder.build(this);
- } else if (builder is KernelEnumBuilder) {
- cls = builder.build(this, coreLibrary);
- } else if (builder is PrefixBuilder) {
+ if (declaration is SourceClassBuilder) {
+ cls = declaration.build(this, coreLibrary);
+ } else if (declaration is KernelFieldBuilder) {
+ member = declaration.build(this)..isStatic = true;
+ } else if (declaration is KernelProcedureBuilder) {
+ member = declaration.build(this)..isStatic = true;
+ } else if (declaration is KernelFunctionTypeAliasBuilder) {
+ typedef = declaration.build(this);
+ } else if (declaration is KernelEnumBuilder) {
+ cls = declaration.build(this, coreLibrary);
+ } else if (declaration is PrefixBuilder) {
// Ignored. Kernel doesn't represent prefixes.
return;
- } else if (builder is BuiltinTypeBuilder) {
+ } else if (declaration is BuiltinTypeBuilder) {
// Nothing needed.
return;
} else {
- unhandled("${builder.runtimeType}", "buildBuilder", builder.charOffset,
- builder.fileUri);
+ unhandled("${declaration.runtimeType}", "buildBuilder",
+ declaration.charOffset, declaration.fileUri);
return;
}
- if (builder.isPatch) {
- // The kernel node of a patch is shared with the origin builder. We have
- // two builders: the origin, and the patch, but only one kernel node
+ if (declaration.isPatch) {
+ // The kernel node of a patch is shared with the origin declaration. We
+ // have two builders: the origin, and the patch, but only one kernel node
// (which corresponds to the final output). Consequently, the node
// shouldn't be added to its apparent kernel parent as this would create
// a duplicate entry in the parent's list of children/members.
@@ -770,7 +770,7 @@
}
void addNativeDependency(Uri nativeImportUri) {
- Builder constructor = loader.getNativeAnnotation();
+ Declaration constructor = loader.getNativeAnnotation();
Arguments arguments =
new Arguments(<Expression>[new StringLiteral("$nativeImportUri")]);
Expression annotation;
@@ -865,16 +865,16 @@
}
@override
- Builder buildAmbiguousBuilder(
- String name, Builder builder, Builder other, int charOffset,
+ Declaration computeAmbiguousDeclaration(
+ String name, Declaration declaration, Declaration other, int charOffset,
{bool isExport: false, bool isImport: false}) {
// TODO(ahe): Can I move this to Scope or Prefix?
- if (builder == other) return builder;
- if (builder is InvalidTypeBuilder) return builder;
+ if (declaration == other) return declaration;
+ if (declaration is InvalidTypeBuilder) return declaration;
if (other is InvalidTypeBuilder) return other;
- if (builder is AccessErrorBuilder) {
- AccessErrorBuilder error = builder;
- builder = error.builder;
+ if (declaration is AccessErrorBuilder) {
+ AccessErrorBuilder error = declaration;
+ declaration = error.builder;
}
if (other is AccessErrorBuilder) {
AccessErrorBuilder error = other;
@@ -882,28 +882,28 @@
}
bool isLocal = false;
bool isLoadLibrary = false;
- Builder preferred;
+ Declaration preferred;
Uri uri;
Uri otherUri;
Uri preferredUri;
Uri hiddenUri;
- if (scope.local[name] == builder) {
+ if (scope.local[name] == declaration) {
isLocal = true;
- preferred = builder;
+ preferred = declaration;
hiddenUri = other.computeLibraryUri();
} else {
- uri = builder.computeLibraryUri();
+ uri = declaration.computeLibraryUri();
otherUri = other.computeLibraryUri();
- if (builder is LoadLibraryBuilder) {
+ if (declaration is LoadLibraryBuilder) {
isLoadLibrary = true;
- preferred = builder;
+ preferred = declaration;
preferredUri = otherUri;
} else if (other is LoadLibraryBuilder) {
isLoadLibrary = true;
preferred = other;
preferredUri = uri;
} else if (otherUri?.scheme == "dart" && uri?.scheme != "dart") {
- preferred = builder;
+ preferred = declaration;
preferredUri = uri;
hiddenUri = otherUri;
} else if (uri?.scheme == "dart" && otherUri?.scheme != "dart") {
@@ -930,14 +930,15 @@
}
return preferred;
}
- if (builder.next == null && other.next == null) {
- if (isImport && builder is PrefixBuilder && other is PrefixBuilder) {
+ if (declaration.next == null && other.next == null) {
+ if (isImport && declaration is PrefixBuilder && other is PrefixBuilder) {
// Handles the case where the same prefix is used for different
// imports.
- return builder
+ return declaration
..exportScope.merge(other.exportScope,
- (String name, Builder existing, Builder member) {
- return buildAmbiguousBuilder(name, existing, member, charOffset,
+ (String name, Declaration existing, Declaration member) {
+ return computeAmbiguousDeclaration(
+ name, existing, member, charOffset,
isExport: isExport, isImport: isImport);
});
}
@@ -1022,7 +1023,7 @@
for (var declaration in libraryDeclaration.members.values) {
if (declaration is KernelClassBuilder) {
count += computeDefaultTypesForVariables(declaration.typeVariables);
- declaration.forEach((String name, Builder member) {
+ declaration.forEach((String name, Declaration member) {
if (member is KernelProcedureBuilder) {
count += computeDefaultTypesForVariables(member.typeVariables);
}
@@ -1047,7 +1048,7 @@
@override
void addImportsToScope() {
super.addImportsToScope();
- exportScope.forEach((String name, Builder member) {
+ exportScope.forEach((String name, Declaration member) {
if (member.parent != this) {
switch (name) {
case "dynamic":
@@ -1071,9 +1072,9 @@
@override
void applyPatches() {
if (!isPatch) return;
- origin.forEach((String name, Builder member) {
+ origin.forEach((String name, Declaration member) {
bool isSetter = member.isSetter;
- Builder patch = isSetter ? scope.setters[name] : scope.local[name];
+ Declaration patch = isSetter ? scope.setters[name] : scope.local[name];
if (patch != null) {
// [patch] has the same name as a [member] in [origin] library, so it
// must be a patch to [member].
@@ -1090,7 +1091,7 @@
}
}
});
- forEach((String name, Builder member) {
+ forEach((String name, Declaration member) {
// We need to inject all non-patch members into the origin library. This
// should only apply to private members.
if (member.isPatch) {
@@ -1106,13 +1107,13 @@
int finishPatchMethods() {
if (!isPatch) return 0;
int count = 0;
- forEach((String name, Builder member) {
+ forEach((String name, Declaration member) {
count += member.finishPatch();
});
return count;
}
- void injectMemberFromPatch(String name, Builder member) {
+ void injectMemberFromPatch(String name, Declaration member) {
if (member.isSetter) {
assert(scope.setters[name] == null);
scopeBuilder.addSetter(name, member);
@@ -1122,7 +1123,7 @@
}
}
- void exportMemberFromPatch(String name, Builder member) {
+ void exportMemberFromPatch(String name, Declaration member) {
if (uri.scheme != "dart" || !uri.path.startsWith("_")) {
addCompileTimeError(templatePatchInjectionFailed.withArguments(name, uri),
member.charOffset, noLength, member.fileUri);
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_named_type_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_named_type_builder.dart
index c70f250f..4c3e69c 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_named_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_named_type_builder.dart
@@ -37,7 +37,7 @@
Supertype handleInvalidSupertype(
LibraryBuilder library, int charOffset, Uri fileUri) {
- var template = builder.isTypeVariable
+ var template = declaration.isTypeVariable
? templateSupertypeIsTypeVariable
: templateSupertypeIsIllegal;
library.addCompileTimeError(
@@ -46,12 +46,12 @@
}
DartType build(LibraryBuilder library) {
- return builder.buildType(library, arguments);
+ return declaration.buildType(library, arguments);
}
Supertype buildSupertype(
LibraryBuilder library, int charOffset, Uri fileUri) {
- TypeDeclarationBuilder declaration = builder;
+ TypeDeclarationBuilder declaration = this.declaration;
if (declaration is KernelClassBuilder) {
return declaration.buildSupertype(library, arguments);
} else if (declaration is KernelInvalidTypeBuilder) {
@@ -68,7 +68,7 @@
Supertype buildMixedInType(
LibraryBuilder library, int charOffset, Uri fileUri) {
- TypeDeclarationBuilder declaration = builder;
+ TypeDeclarationBuilder declaration = this.declaration;
if (declaration is KernelClassBuilder) {
return declaration.buildMixedInType(library, arguments);
} else if (declaration is KernelInvalidTypeBuilder) {
@@ -84,9 +84,9 @@
}
TypeBuilder subst(Map<TypeVariableBuilder, TypeBuilder> substitution) {
- TypeBuilder result = substitution[builder];
+ TypeBuilder result = substitution[declaration];
if (result != null) {
- assert(builder is TypeVariableBuilder);
+ assert(declaration is TypeVariableBuilder);
return result;
} else if (arguments != null) {
List<KernelTypeBuilder> arguments;
@@ -100,7 +100,7 @@
i++;
}
if (arguments != null) {
- return new KernelNamedTypeBuilder(name, arguments)..bind(builder);
+ return new KernelNamedTypeBuilder(name, arguments)..bind(declaration);
}
}
return this;
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_procedure_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_procedure_builder.dart
index ed62a8a..11d0dc4 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_procedure_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_procedure_builder.dart
@@ -60,9 +60,9 @@
import 'kernel_builder.dart'
show
- Builder,
ClassBuilder,
ConstructorReferenceBuilder,
+ Declaration,
FormalParameterBuilder,
KernelFormalParameterBuilder,
KernelLibraryBuilder,
@@ -217,7 +217,7 @@
Member build(SourceLibraryBuilder library);
void becomeNative(Loader loader) {
- Builder constructor = loader.getNativeAnnotation();
+ Declaration constructor = loader.getNativeAnnotation();
Arguments arguments =
new Arguments(<Expression>[new StringLiteral(nativeMethodName)]);
Expression annotation;
@@ -244,7 +244,7 @@
return true;
}
- void reportPatchMismatch(Builder patch) {
+ void reportPatchMismatch(Declaration patch) {
library.addCompileTimeError(messagePatchDeclarationMismatch,
patch.charOffset, noLength, patch.fileUri, context: [
messagePatchDeclarationOrigin.withLocation(fileUri, charOffset, noLength)
@@ -385,7 +385,7 @@
}
@override
- void applyPatch(Builder patch) {
+ void applyPatch(Declaration patch) {
if (patch is KernelProcedureBuilder) {
if (checkPatch(patch)) {
patch.actualOrigin = this;
@@ -556,7 +556,7 @@
}
@override
- void applyPatch(Builder patch) {
+ void applyPatch(Declaration patch) {
if (patch is KernelConstructorBuilder) {
if (checkPatch(patch)) {
patch.actualOrigin = this;
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index f76f827..2e03b94 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -76,8 +76,8 @@
import 'kernel_builder.dart'
show
- Builder,
ClassBuilder,
+ Declaration,
InvalidTypeBuilder,
KernelClassBuilder,
KernelLibraryBuilder,
@@ -187,9 +187,9 @@
void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set) {
if (cls == null) return;
forEachDirectSupertype(cls, (NamedTypeBuilder type) {
- Builder builder = type.builder;
- if (builder is ClassBuilder) {
- set.add(builder);
+ Declaration declaration = type.declaration;
+ if (declaration is ClassBuilder) {
+ set.add(declaration);
}
});
}
@@ -199,7 +199,7 @@
List<SourceClassBuilder> result = <SourceClassBuilder>[];
loader.builders.forEach((Uri uri, LibraryBuilder library) {
if (library.loader == loader) {
- library.forEach((String name, Builder member) {
+ library.forEach((String name, Declaration member) {
if (member is SourceClassBuilder && !member.isPatch) {
result.add(member);
}
@@ -273,13 +273,14 @@
return component;
}
- /// Build the kernel representation of the component loaded by this target. The
- /// component will contain full bodies for the code loaded from sources, and
- /// only references to the code loaded by the [DillTarget], which may or may
- /// not include method bodies (depending on what was loaded into that target,
- /// an outline or a full kernel component).
+ /// Build the kernel representation of the component loaded by this
+ /// target. The component will contain full bodies for the code loaded from
+ /// sources, and only references to the code loaded by the [DillTarget],
+ /// which may or may not include method bodies (depending on what was loaded
+ /// into that target, an outline or a full kernel component).
///
- /// If [verify], run the default kernel verification on the resulting component.
+ /// If [verify], run the default kernel verification on the resulting
+ /// component.
@override
Future<Component> buildComponent({bool verify: false}) async {
if (loader.first == null) return null;
@@ -385,12 +386,13 @@
nameRoot: nameRoot, libraries: libraries, uriToSource: uriToSource);
if (loader.first != null) {
// TODO(sigmund): do only for full program
- Builder builder = loader.first.exportScope.lookup("main", -1, null);
- if (builder is KernelProcedureBuilder) {
- component.mainMethod = builder.procedure;
- } else if (builder is DillMemberBuilder) {
- if (builder.member is Procedure) {
- component.mainMethod = builder.member;
+ Declaration declaration =
+ loader.first.exportScope.lookup("main", -1, null);
+ if (declaration is KernelProcedureBuilder) {
+ component.mainMethod = declaration.procedure;
+ } else if (declaration is DillMemberBuilder) {
+ if (declaration.member is Procedure) {
+ component.mainMethod = declaration.member;
}
}
}
@@ -403,21 +405,22 @@
Class objectClass = this.objectClass;
loader.builders.forEach((Uri uri, LibraryBuilder library) {
if (library.loader == loader) {
- library.forEach((String name, Builder builder) {
- while (builder != null) {
- if (builder is SourceClassBuilder) {
- Class cls = builder.target;
+ library.forEach((String name, Declaration declaration) {
+ while (declaration != null) {
+ if (declaration is SourceClassBuilder) {
+ Class cls = declaration.target;
if (cls != objectClass) {
cls.supertype ??= objectClass.asRawSupertype;
- builder.supertype ??= new KernelNamedTypeBuilder("Object", null)
- ..bind(objectClassBuilder);
+ declaration.supertype ??=
+ new KernelNamedTypeBuilder("Object", null)
+ ..bind(objectClassBuilder);
}
- if (builder.isMixinApplication) {
- cls.mixedInType = builder.mixedInType.buildMixedInType(
- library, builder.charOffset, builder.fileUri);
+ if (declaration.isMixinApplication) {
+ cls.mixedInType = declaration.mixedInType.buildMixedInType(
+ library, declaration.charOffset, declaration.fileUri);
}
}
- builder = builder.next;
+ declaration = declaration.next;
}
});
}
@@ -435,7 +438,7 @@
ticker.logMs("Installed default constructors");
}
- KernelClassBuilder get objectClassBuilder => objectType.builder;
+ KernelClassBuilder get objectClassBuilder => objectType.declaration;
Class get objectClass => objectClassBuilder.cls;
@@ -463,7 +466,7 @@
SourceClassBuilder named = supertype;
TypeBuilder type = named.supertype;
if (type is NamedTypeBuilder) {
- supertype = type.builder;
+ supertype = type.declaration;
} else {
unhandled("${type.runtimeType}", "installDefaultConstructor",
builder.charOffset, builder.fileUri);
@@ -620,7 +623,7 @@
Map<Constructor, List<FieldInitializer>> fieldInitializers =
<Constructor, List<FieldInitializer>>{};
Constructor superTarget;
- builder.constructors.forEach((String name, Builder member) {
+ builder.constructors.forEach((String name, Declaration member) {
if (member.isFactory) return;
MemberBuilder constructorBuilder = member;
Constructor constructor = constructorBuilder.target;
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_variable_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_variable_builder.dart
index 65a3f94..fb688d1 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_variable_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_variable_builder.dart
@@ -6,15 +6,18 @@
import 'package:kernel/ast.dart' show VariableDeclaration;
-import 'kernel_builder.dart' show Builder;
+import 'kernel_builder.dart' show Declaration;
-class KernelVariableBuilder extends Builder {
+class KernelVariableBuilder extends Declaration {
+ @override
+ final Declaration parent;
+
+ @override
+ final Uri fileUri;
+
final VariableDeclaration variable;
- KernelVariableBuilder(
- VariableDeclaration variable, Builder parent, Uri fileUri)
- : variable = variable,
- super(parent, variable.fileOffset, fileUri);
+ KernelVariableBuilder(this.variable, this.parent, this.fileUri);
@override
int get charOffset => variable.fileOffset;
diff --git a/pkg/front_end/lib/src/fasta/kernel/load_library_builder.dart b/pkg/front_end/lib/src/fasta/kernel/load_library_builder.dart
index 67a9e22..571d7f9 100644
--- a/pkg/front_end/lib/src/fasta/kernel/load_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/load_library_builder.dart
@@ -16,12 +16,12 @@
ProcedureKind,
ReturnStatement;
-import 'kernel_builder.dart' show Builder, KernelLibraryBuilder;
+import 'kernel_builder.dart' show Declaration, KernelLibraryBuilder;
import 'forest.dart' show Forest;
/// Builder to represent the `deferLibrary.loadLibrary` calls and tear-offs.
-class LoadLibraryBuilder extends Builder {
+class LoadLibraryBuilder extends Declaration {
final KernelLibraryBuilder parent;
final LibraryDependency importDependency;
@@ -33,8 +33,9 @@
/// null, no tear-offs were seen in the code and no method is generated.
Member tearoff;
- LoadLibraryBuilder(this.parent, this.importDependency, this.charOffset)
- : super(parent, charOffset, parent.fileUri);
+ LoadLibraryBuilder(this.parent, this.importDependency, this.charOffset);
+
+ Uri get fileUri => parent.fileUri;
LoadLibrary createLoadLibrary(int charOffset, Forest forest) {
return forest.loadLibrary(importDependency)..fileOffset = charOffset;
diff --git a/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart b/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart
index 1ba0f1e..0f1081f 100644
--- a/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart
@@ -24,11 +24,11 @@
Map<TypeVariableBuilder, KernelTypeBuilder> lowerSubstitution,
{bool isCovariant = true}) {
if (type is KernelNamedTypeBuilder) {
- if (type.builder is KernelTypeVariableBuilder) {
+ if (type.declaration is KernelTypeVariableBuilder) {
if (isCovariant) {
- return upperSubstitution[type.builder] ?? type;
+ return upperSubstitution[type.declaration] ?? type;
}
- return lowerSubstitution[type.builder] ?? type;
+ return lowerSubstitution[type.declaration] ?? type;
}
if (type.arguments == null || type.arguments.length == 0) {
return type;
@@ -45,7 +45,7 @@
}
if (arguments != null) {
return new KernelNamedTypeBuilder(type.name, arguments)
- ..bind(type.builder);
+ ..bind(type.declaration);
}
return type;
}
@@ -201,9 +201,9 @@
void collectReferencesFrom(int index, TypeBuilder type) {
if (type is NamedTypeBuilder) {
- if (type.builder is TypeVariableBuilder &&
- this.variables.contains(type.builder)) {
- edges[variableIndices[type.builder]].add(index);
+ if (type.declaration is TypeVariableBuilder &&
+ this.variables.contains(type.declaration)) {
+ edges[variableIndices[type.declaration]].add(index);
}
if (type.arguments != null) {
for (TypeBuilder argument in type.arguments) {
diff --git a/pkg/front_end/lib/src/fasta/loader.dart b/pkg/front_end/lib/src/fasta/loader.dart
index aaac6e7..f1d940a 100644
--- a/pkg/front_end/lib/src/fasta/loader.dart
+++ b/pkg/front_end/lib/src/fasta/loader.dart
@@ -8,7 +8,7 @@
import 'dart:collection' show Queue;
-import 'builder/builder.dart' show Builder, LibraryBuilder;
+import 'builder/builder.dart' show Declaration, LibraryBuilder;
import 'deprecated_problems.dart' show firstSourceUri;
@@ -263,17 +263,17 @@
return true;
}
- Builder getAbstractClassInstantiationError() {
+ Declaration getAbstractClassInstantiationError() {
return target.getAbstractClassInstantiationError(this);
}
- Builder getCompileTimeError() => target.getCompileTimeError(this);
+ Declaration getCompileTimeError() => target.getCompileTimeError(this);
- Builder getDuplicatedFieldInitializerError() {
+ Declaration getDuplicatedFieldInitializerError() {
return target.getDuplicatedFieldInitializerError(this);
}
- Builder getNativeAnnotation() => target.getNativeAnnotation(this);
+ Declaration getNativeAnnotation() => target.getNativeAnnotation(this);
void recordMessage(Severity severity, Message message, int charOffset,
int length, Uri fileUri,
diff --git a/pkg/front_end/lib/src/fasta/scope.dart b/pkg/front_end/lib/src/fasta/scope.dart
index f6b3309..aae07ff 100644
--- a/pkg/front_end/lib/src/fasta/scope.dart
+++ b/pkg/front_end/lib/src/fasta/scope.dart
@@ -4,7 +4,7 @@
library fasta.scope;
-import 'builder/builder.dart' show Builder, TypeVariableBuilder;
+import 'builder/builder.dart' show Declaration, TypeVariableBuilder;
import 'fasta_codes.dart'
show
@@ -19,10 +19,10 @@
class MutableScope {
/// Names declared in this scope.
- Map<String, Builder> local;
+ Map<String, Declaration> local;
/// Setters declared in this scope.
- Map<String, Builder> setters;
+ Map<String, Declaration> setters;
/// The scope that this scope is nested within, or `null` if this is the top
/// level scope.
@@ -42,28 +42,28 @@
/// succeed.
final bool isModifiable;
- Map<String, Builder> labels;
+ Map<String, Declaration> labels;
- Map<String, Builder> forwardDeclaredLabels;
+ Map<String, Declaration> forwardDeclaredLabels;
Map<String, int> usedNames;
- Scope(Map<String, Builder> local, Map<String, Builder> setters, Scope parent,
- String debugName, {this.isModifiable: true})
- : super(local, setters = setters ?? const <String, Builder>{}, parent,
+ Scope(Map<String, Declaration> local, Map<String, Declaration> setters,
+ Scope parent, String debugName, {this.isModifiable: true})
+ : super(local, setters = setters ?? const <String, Declaration>{}, parent,
debugName);
Scope.top({bool isModifiable: false})
- : this(<String, Builder>{}, <String, Builder>{}, null, "top",
+ : this(<String, Declaration>{}, <String, Declaration>{}, null, "top",
isModifiable: isModifiable);
Scope.immutable()
- : this(const <String, Builder>{}, const <String, Builder>{}, null,
+ : this(const <String, Declaration>{}, const <String, Declaration>{}, null,
"immutable",
isModifiable: false);
Scope.nested(Scope parent, String debugName, {bool isModifiable: true})
- : this(<String, Builder>{}, null, parent, debugName,
+ : this(<String, Declaration>{}, null, parent, debugName,
isModifiable: isModifiable);
Scope copyWithParent(Scope parent, String debugName) {
@@ -122,9 +122,9 @@
}
}
- Builder lookupIn(String name, int charOffset, Uri fileUri,
- Map<String, Builder> map, bool isInstanceScope) {
- Builder builder = map[name];
+ Declaration lookupIn(String name, int charOffset, Uri fileUri,
+ Map<String, Declaration> map, bool isInstanceScope) {
+ Declaration builder = map[name];
if (builder == null) return null;
if (builder.next != null) {
return new AmbiguousBuilder(name, builder, charOffset, fileUri);
@@ -135,10 +135,10 @@
}
}
- Builder lookup(String name, int charOffset, Uri fileUri,
+ Declaration lookup(String name, int charOffset, Uri fileUri,
{bool isInstanceScope: true}) {
recordUse(name, charOffset, fileUri);
- Builder builder =
+ Declaration builder =
lookupIn(name, charOffset, fileUri, local, isInstanceScope);
if (builder != null) return builder;
builder = lookupIn(name, charOffset, fileUri, setters, isInstanceScope);
@@ -152,10 +152,10 @@
return builder ?? parent?.lookup(name, charOffset, fileUri);
}
- Builder lookupSetter(String name, int charOffset, Uri fileUri,
+ Declaration lookupSetter(String name, int charOffset, Uri fileUri,
{bool isInstanceScope: true}) {
recordUse(name, charOffset, fileUri);
- Builder builder =
+ Declaration builder =
lookupIn(name, charOffset, fileUri, setters, isInstanceScope);
if (builder != null) return builder;
builder = lookupIn(name, charOffset, fileUri, local, isInstanceScope);
@@ -171,9 +171,9 @@
bool hasLocalLabel(String name) => labels != null && labels.containsKey(name);
- void declareLabel(String name, Builder target) {
+ void declareLabel(String name, Declaration target) {
if (isModifiable) {
- labels ??= <String, Builder>{};
+ labels ??= <String, Declaration>{};
labels[name] = target;
} else {
internalProblem(
@@ -181,9 +181,9 @@
}
}
- void forwardDeclareLabel(String name, Builder target) {
+ void forwardDeclareLabel(String name, Declaration target) {
declareLabel(name, target);
- forwardDeclaredLabels ??= <String, Builder>{};
+ forwardDeclaredLabels ??= <String, Declaration>{};
forwardDeclaredLabels[name] = target;
}
@@ -196,11 +196,11 @@
return true;
}
- Map<String, Builder> get unclaimedForwardDeclarations {
+ Map<String, Declaration> get unclaimedForwardDeclarations {
return forwardDeclaredLabels;
}
- Builder lookupLabel(String name) {
+ Declaration lookupLabel(String name) {
return (labels == null ? null : labels[name]) ?? parent?.lookupLabel(name);
}
@@ -210,7 +210,7 @@
/// that can be used as context for reporting a compile-time error about
/// [name] being used before its declared. [fileUri] is used to bind the
/// location of this message.
- LocatedMessage declare(String name, Builder builder, Uri fileUri) {
+ LocatedMessage declare(String name, Declaration builder, Uri fileUri) {
if (isModifiable) {
if (usedNames?.containsKey(name) ?? false) {
return templateDuplicatedNamePreviouslyUsedCause
@@ -225,15 +225,17 @@
return null;
}
- void merge(Scope scope,
- buildAmbiguousBuilder(String name, Builder existing, Builder member)) {
- Map<String, Builder> map = local;
+ void merge(
+ Scope scope,
+ Declaration computeAmbiguousDeclaration(
+ String name, Declaration existing, Declaration member)) {
+ Map<String, Declaration> map = local;
- void mergeMember(String name, Builder member) {
- Builder existing = map[name];
+ void mergeMember(String name, Declaration member) {
+ Declaration existing = map[name];
if (existing != null) {
if (existing != member) {
- member = buildAmbiguousBuilder(name, existing, member);
+ member = computeAmbiguousDeclaration(name, existing, member);
}
}
map[name] = member;
@@ -244,7 +246,7 @@
scope.setters.forEach(mergeMember);
}
- void forEach(f(String name, Builder member)) {
+ void forEach(f(String name, Declaration member)) {
local.forEach(f);
setters.forEach(f);
}
@@ -262,10 +264,10 @@
int nestingLevel = (parent?.writeOn(sink) ?? -1) + 1;
String indent = " " * nestingLevel;
sink.writeln("$indent{");
- local.forEach((String name, Builder member) {
+ local.forEach((String name, Declaration member) {
sink.writeln("$indent $name");
});
- setters.forEach((String name, Builder member) {
+ setters.forEach((String name, Declaration member) {
sink.writeln("$indent $name=");
});
return nestingLevel;
@@ -277,24 +279,27 @@
ScopeBuilder(this.scope);
- void addMember(String name, Builder builder) {
+ void addMember(String name, Declaration builder) {
scope.local[name] = builder;
}
- void addSetter(String name, Builder builder) {
+ void addSetter(String name, Declaration builder) {
scope.setters[name] = builder;
}
- Builder operator [](String name) => scope.local[name];
+ Declaration operator [](String name) => scope.local[name];
}
-abstract class ProblemBuilder extends Builder {
+abstract class ProblemBuilder extends Declaration {
final String name;
- final Builder builder;
+ final Declaration builder;
- ProblemBuilder(this.name, this.builder, int charOffset, Uri fileUri)
- : super(null, charOffset, fileUri);
+ final int charOffset;
+
+ final Uri fileUri;
+
+ ProblemBuilder(this.name, this.builder, this.charOffset, this.fileUri);
get target => null;
@@ -309,10 +314,11 @@
/// Represents a [builder] that's being accessed incorrectly. For example, an
/// attempt to write to a final field, or to read from a setter.
class AccessErrorBuilder extends ProblemBuilder {
- AccessErrorBuilder(String name, Builder builder, int charOffset, Uri fileUri)
+ AccessErrorBuilder(
+ String name, Declaration builder, int charOffset, Uri fileUri)
: super(name, builder, charOffset, fileUri);
- Builder get parent => builder;
+ Declaration get parent => builder;
bool get isFinal => builder.isFinal;
@@ -338,8 +344,11 @@
}
class AmbiguousBuilder extends ProblemBuilder {
- AmbiguousBuilder(String name, Builder builder, int charOffset, Uri fileUri)
+ AmbiguousBuilder(
+ String name, Declaration builder, int charOffset, Uri fileUri)
: super(name, builder, charOffset, fileUri);
+ Declaration get parent => null;
+
Message get message => templateDuplicatedName.withArguments(name);
}
diff --git a/pkg/front_end/lib/src/fasta/source/diet_listener.dart b/pkg/front_end/lib/src/fasta/source/diet_listener.dart
index 58f6ebc..a00fc34 100644
--- a/pkg/front_end/lib/src/fasta/source/diet_listener.dart
+++ b/pkg/front_end/lib/src/fasta/source/diet_listener.dart
@@ -211,7 +211,7 @@
String name = pop();
Token metadata = pop();
- Builder typedefBuilder = lookupBuilder(typedefKeyword, null, name);
+ Declaration typedefBuilder = lookupBuilder(typedefKeyword, null, name);
Typedef target = typedefBuilder.target;
var metadataConstants = parseMetadata(typedefBuilder, metadata);
if (metadataConstants != null) {
@@ -569,12 +569,15 @@
void buildFields(int count, Token token, bool isTopLevel) {
List<String> names =
popList(count, new List<String>.filled(count, null, growable: true));
- Builder builder = lookupBuilder(token, null, names.first);
+ Declaration declaration = lookupBuilder(token, null, names.first);
Token metadata = pop();
// TODO(paulberry): don't re-parse the field if we've already parsed it
// for type inference.
- parseFields(createListener(builder, memberScope, builder.isInstanceMember),
- token, metadata, isTopLevel);
+ parseFields(
+ createListener(declaration, memberScope, declaration.isInstanceMember),
+ token,
+ metadata,
+ isTopLevel);
}
@override
@@ -604,7 +607,7 @@
assert(currentClass == null);
assert(memberScope == library.scope);
- Builder classBuilder = lookupBuilder(token, null, name);
+ Declaration classBuilder = lookupBuilder(token, null, name);
Class target = classBuilder.target;
var metadataConstants = parseMetadata(classBuilder, metadata);
if (metadataConstants != null) {
@@ -651,10 +654,10 @@
for (int i = 0; i < metadataAndValues.length; i += 2) {
Token metadata = metadataAndValues[i];
String valueName = metadataAndValues[i + 1];
- Builder builder = enumBuilder.scope.local[valueName];
+ Declaration declaration = enumBuilder.scope.local[valueName];
if (metadata != null) {
- Field field = builder.target;
- for (var annotation in parseMetadata(builder, metadata)) {
+ Field field = declaration.target;
+ for (var annotation in parseMetadata(declaration, metadata)) {
field.addAnnotation(annotation);
}
}
@@ -671,7 +674,7 @@
String name = pop();
Token metadata = pop();
- Builder classBuilder = lookupBuilder(classKeyword, null, name);
+ Declaration classBuilder = lookupBuilder(classKeyword, null, name);
Class target = classBuilder.target;
var metadataConstants = parseMetadata(classBuilder, metadata);
if (metadataConstants != null) {
@@ -754,9 +757,9 @@
listener.checkEmpty(token.charOffset);
}
- Builder lookupBuilder(Token token, Token getOrSet, String name) {
+ Declaration lookupBuilder(Token token, Token getOrSet, String name) {
// TODO(ahe): Can I move this to Scope or ScopeBuilder?
- Builder builder;
+ Declaration declaration;
if (currentClass != null) {
if (uri != currentClass.fileUri) {
unexpected("$uri", "${currentClass.fileUri}", currentClass.charOffset,
@@ -764,22 +767,22 @@
}
if (getOrSet != null && optional("set", getOrSet)) {
- builder = currentClass.scope.setters[name];
+ declaration = currentClass.scope.setters[name];
} else {
- builder = currentClass.scope.local[name];
+ declaration = currentClass.scope.local[name];
}
} else if (getOrSet != null && optional("set", getOrSet)) {
- builder = library.scope.setters[name];
+ declaration = library.scope.setters[name];
} else {
- builder = library.scopeBuilder[name];
+ declaration = library.scopeBuilder[name];
}
- checkBuilder(token, builder, name);
- return builder;
+ checkBuilder(token, declaration, name);
+ return declaration;
}
- Builder lookupConstructor(Token token, Object nameOrQualified) {
+ Declaration lookupConstructor(Token token, Object nameOrQualified) {
assert(currentClass != null);
- Builder builder;
+ Declaration declaration;
String name;
String suffix;
if (nameOrQualified is QualifiedName) {
@@ -789,22 +792,22 @@
name = nameOrQualified;
suffix = name == currentClass.name ? "" : name;
}
- builder = currentClass.constructors.local[suffix];
- checkBuilder(token, builder, nameOrQualified);
- return builder;
+ declaration = currentClass.constructors.local[suffix];
+ checkBuilder(token, declaration, nameOrQualified);
+ return declaration;
}
- void checkBuilder(Token token, Builder builder, Object name) {
- if (builder == null) {
+ void checkBuilder(Token token, Declaration declaration, Object name) {
+ if (declaration == null) {
internalProblem(templateInternalProblemNotFound.withArguments("$name"),
token.charOffset, uri);
}
- if (builder.next != null) {
+ if (declaration.next != null) {
deprecated_inputError(uri, token.charOffset, "Duplicated name: $name");
}
- if (uri != builder.fileUri) {
- unexpected(
- "$uri", "${builder.fileUri}", builder.charOffset, builder.fileUri);
+ if (uri != declaration.fileUri) {
+ unexpected("$uri", "${declaration.fileUri}", declaration.charOffset,
+ declaration.fileUri);
}
}
diff --git a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
index eb8e9c5..3a6d2f1 100644
--- a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
@@ -23,9 +23,9 @@
import '../kernel/kernel_builder.dart'
show
- Builder,
ClassBuilder,
ConstructorReferenceBuilder,
+ Declaration,
KernelClassBuilder,
KernelFieldBuilder,
KernelFunctionBuilder,
@@ -103,29 +103,29 @@
Class get cls => origin.actualCls;
Class build(KernelLibraryBuilder library, LibraryBuilder coreLibrary) {
- void buildBuilders(String name, Builder builder) {
+ void buildBuilders(String name, Declaration declaration) {
do {
- if (builder.parent != this) {
+ if (declaration.parent != this) {
unexpected(
- "$fileUri", "${builder.parent.fileUri}", charOffset, fileUri);
- } else if (builder is KernelFieldBuilder) {
+ "$fileUri", "${declaration.parent.fileUri}", charOffset, fileUri);
+ } else if (declaration is KernelFieldBuilder) {
// TODO(ahe): It would be nice to have a common interface for the
// build method to avoid duplicating these two cases.
- Member field = builder.build(library);
- if (!builder.isPatch) {
+ Member field = declaration.build(library);
+ if (!declaration.isPatch) {
cls.addMember(field);
}
- } else if (builder is KernelFunctionBuilder) {
- Member function = builder.build(library);
- if (!builder.isPatch) {
+ } else if (declaration is KernelFunctionBuilder) {
+ Member function = declaration.build(library);
+ if (!declaration.isPatch) {
cls.addMember(function);
}
} else {
- unhandled("${builder.runtimeType}", "buildBuilders",
- builder.charOffset, builder.fileUri);
+ unhandled("${declaration.runtimeType}", "buildBuilders",
+ declaration.charOffset, declaration.fileUri);
}
- builder = builder.next;
- } while (builder != null);
+ declaration = declaration.next;
+ } while (declaration != null);
}
scope.forEach(buildBuilders);
@@ -148,8 +148,8 @@
}
}
- constructors.forEach((String name, Builder constructor) {
- Builder member = scopeBuilder[name];
+ constructors.forEach((String name, Declaration constructor) {
+ Declaration member = scopeBuilder[name];
if (member == null) return;
// TODO(ahe): Revisit these messages. It seems like the last two should
// be `context` parameter to this message.
@@ -169,8 +169,8 @@
}
});
- scope.setters.forEach((String name, Builder setter) {
- Builder member = scopeBuilder[name];
+ scope.setters.forEach((String name, Declaration setter) {
+ Declaration member = scopeBuilder[name];
if (member == null || !member.isField || member.isFinal) return;
if (member.isInstanceMember == setter.isInstanceMember) {
addProblem(templateConflictsWithMember.withArguments(name),
@@ -203,15 +203,15 @@
@override
void prepareTopLevelInference(
SourceLibraryBuilder library, ClassBuilder currentClass) {
- scope.forEach((name, builder) {
- builder.prepareTopLevelInference(library, this);
+ scope.forEach((name, declaration) {
+ declaration.prepareTopLevelInference(library, this);
});
}
@override
void instrumentTopLevelInference(Instrumentation instrumentation) {
- scope.forEach((name, builder) {
- builder.instrumentTopLevelInference(instrumentation);
+ scope.forEach((name, declaration) {
+ declaration.instrumentTopLevelInference(instrumentation);
});
}
@@ -224,11 +224,11 @@
cls.annotations.forEach((m) => m.fileOffset = origin.cls.fileOffset);
int count = 0;
- scope.forEach((String name, Builder builder) {
- count += builder.finishPatch();
+ scope.forEach((String name, Declaration declaration) {
+ count += declaration.finishPatch();
});
- constructors.forEach((String name, Builder builder) {
- count += builder.finishPatch();
+ constructors.forEach((String name, Declaration declaration) {
+ count += declaration.finishPatch();
});
return count;
}
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index 25be339..2124101 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -14,9 +14,9 @@
import '../builder/builder.dart'
show
- Builder,
ClassBuilder,
ConstructorReferenceBuilder,
+ Declaration,
FormalParameterBuilder,
FunctionTypeBuilder,
LibraryBuilder,
@@ -436,49 +436,49 @@
TypeVariableBuilder addTypeVariable(String name, T bound, int charOffset);
- Builder addBuilder(String name, Builder builder, int charOffset) {
+ Declaration addBuilder(String name, Declaration declaration, int charOffset) {
// TODO(ahe): Set the parent correctly here. Could then change the
// implementation of MemberBuilder.isTopLevel to test explicitly for a
// LibraryBuilder.
if (currentDeclaration == libraryDeclaration) {
- if (builder is MemberBuilder) {
- builder.parent = this;
- } else if (builder is TypeDeclarationBuilder) {
- builder.parent = this;
- } else if (builder is PrefixBuilder) {
- assert(builder.parent == this);
+ if (declaration is MemberBuilder) {
+ declaration.parent = this;
+ } else if (declaration is TypeDeclarationBuilder) {
+ declaration.parent = this;
+ } else if (declaration is PrefixBuilder) {
+ assert(declaration.parent == this);
} else {
return unhandled(
- "${builder.runtimeType}", "addBuilder", charOffset, fileUri);
+ "${declaration.runtimeType}", "addBuilder", charOffset, fileUri);
}
} else {
assert(currentDeclaration.parent == libraryDeclaration);
}
- bool isConstructor = builder is ProcedureBuilder &&
- (builder.isConstructor || builder.isFactory);
+ bool isConstructor = declaration is ProcedureBuilder &&
+ (declaration.isConstructor || declaration.isFactory);
if (!isConstructor &&
- !builder.isSetter &&
+ !declaration.isSetter &&
name == currentDeclaration.name) {
addCompileTimeError(
messageMemberWithSameNameAsClass, charOffset, noLength, fileUri);
}
- Map<String, Builder> members = isConstructor
+ Map<String, Declaration> members = isConstructor
? currentDeclaration.constructors
- : (builder.isSetter
+ : (declaration.isSetter
? currentDeclaration.setters
: currentDeclaration.members);
- Builder existing = members[name];
- builder.next = existing;
- if (builder is PrefixBuilder && existing is PrefixBuilder) {
+ Declaration existing = members[name];
+ declaration.next = existing;
+ if (declaration is PrefixBuilder && existing is PrefixBuilder) {
assert(existing.next == null);
- Builder deferred;
- Builder other;
- if (builder.deferred) {
- deferred = builder;
+ Declaration deferred;
+ Declaration other;
+ if (declaration.deferred) {
+ deferred = declaration;
other = existing;
} else if (existing.deferred) {
deferred = existing;
- other = builder;
+ other = declaration;
}
if (deferred != null) {
addCompileTimeError(
@@ -493,20 +493,21 @@
]);
}
return existing
- ..exportScope.merge(builder.exportScope,
- (String name, Builder existing, Builder member) {
- return buildAmbiguousBuilder(name, existing, member, charOffset);
+ ..exportScope.merge(declaration.exportScope,
+ (String name, Declaration existing, Declaration member) {
+ return computeAmbiguousDeclaration(
+ name, existing, member, charOffset);
});
- } else if (isDuplicatedDefinition(existing, builder)) {
+ } else if (isDuplicatedDefinition(existing, declaration)) {
addCompileTimeError(templateDuplicatedDefinition.withArguments(name),
charOffset, noLength, fileUri);
}
- return members[name] = builder;
+ return members[name] = declaration;
}
- bool isDuplicatedDefinition(Builder existing, Builder other) {
+ bool isDuplicatedDefinition(Declaration existing, Declaration other) {
if (existing == null) return false;
- Builder next = existing.next;
+ Declaration next = existing.next;
if (next == null) {
if (existing.isGetter && other.isSetter) return false;
if (existing.isSetter && other.isGetter) return false;
@@ -523,28 +524,28 @@
return true;
}
- void buildBuilder(Builder builder, LibraryBuilder coreLibrary);
+ void buildBuilder(Declaration declaration, LibraryBuilder coreLibrary);
R build(LibraryBuilder coreLibrary) {
assert(implementationBuilders.isEmpty);
canAddImplementationBuilders = true;
- forEach((String name, Builder builder) {
+ forEach((String name, Declaration declaration) {
do {
- buildBuilder(builder, coreLibrary);
- builder = builder.next;
- } while (builder != null);
+ buildBuilder(declaration, coreLibrary);
+ declaration = declaration.next;
+ } while (declaration != null);
});
for (List list in implementationBuilders) {
String name = list[0];
- Builder builder = list[1];
+ Declaration declaration = list[1];
int charOffset = list[2];
- addBuilder(name, builder, charOffset);
- buildBuilder(builder, coreLibrary);
+ addBuilder(name, declaration, charOffset);
+ buildBuilder(declaration, coreLibrary);
}
canAddImplementationBuilders = false;
- scope.setters.forEach((String name, Builder setter) {
- Builder member = scopeBuilder[name];
+ scope.setters.forEach((String name, Declaration setter) {
+ Declaration member = scopeBuilder[name];
if (member == null || !member.isField || member.isFinal) return;
addCompileTimeError(templateConflictsWithMember.withArguments(name),
setter.charOffset, noLength, fileUri);
@@ -560,9 +561,10 @@
/// Currently, only anonymous mixins are using implementation builders (see
/// [KernelMixinApplicationBuilder]
/// (../kernel/kernel_mixin_application_builder.dart)).
- void addImplementationBuilder(String name, Builder builder, int charOffset) {
+ void addImplementationBuilder(
+ String name, Declaration declaration, int charOffset) {
assert(canAddImplementationBuilders, "$uri");
- implementationBuilders.add([name, builder, charOffset]);
+ implementationBuilders.add([name, declaration, charOffset]);
}
void validatePart() {
@@ -631,14 +633,14 @@
-1, noLength, fileUri);
}
}
- part.forEach((String name, Builder builder) {
- if (builder.next != null) {
+ part.forEach((String name, Declaration declaration) {
+ if (declaration.next != null) {
// TODO(ahe): This shouldn't be necessary as setters have been added to
// their own scope.
- assert(builder.next.next == null);
- addBuilder(name, builder.next, builder.next.charOffset);
+ assert(declaration.next.next == null);
+ addBuilder(name, declaration.next, declaration.next.charOffset);
}
- addBuilder(name, builder, builder.charOffset);
+ addBuilder(name, declaration, declaration.charOffset);
});
types.addAll(part.types);
constructorReferences.addAll(part.constructorReferences);
@@ -660,20 +662,22 @@
import.finalizeImports(this);
}
if (!explicitCoreImport) {
- loader.coreLibrary.exportScope.forEach((String name, Builder member) {
+ loader.coreLibrary.exportScope.forEach((String name, Declaration member) {
addToScope(name, member, -1, true);
});
}
}
@override
- void addToScope(String name, Builder member, int charOffset, bool isImport) {
- Map<String, Builder> map =
+ void addToScope(
+ String name, Declaration member, int charOffset, bool isImport) {
+ Map<String, Declaration> map =
member.isSetter ? importScope.setters : importScope.local;
- Builder existing = map[name];
+ Declaration existing = map[name];
if (existing != null) {
if (existing != member) {
- map[name] = buildAmbiguousBuilder(name, existing, member, charOffset,
+ map[name] = computeAmbiguousDeclaration(
+ name, existing, member, charOffset,
isImport: isImport);
}
} else {
@@ -700,7 +704,7 @@
@override
int resolveConstructors(_) {
int count = 0;
- forEach((String name, Builder member) {
+ forEach((String name, Declaration member) {
count += member.resolveConstructors(this);
});
return count;
@@ -722,7 +726,7 @@
@override
void prepareTopLevelInference(
SourceLibraryBuilder library, ClassBuilder currentClass) {
- forEach((String name, Builder member) {
+ forEach((String name, Declaration member) {
if (member is ClassBuilder) {
// Classes are handled separately, in class hierarchy order.
return;
@@ -733,7 +737,7 @@
@override
void instrumentTopLevelInference(Instrumentation instrumentation) {
- forEach((String name, Builder member) {
+ forEach((String name, Declaration member) {
member.instrumentTopLevelInference(instrumentation);
});
}
@@ -744,11 +748,11 @@
class DeclarationBuilder<T extends TypeBuilder> {
final DeclarationBuilder<T> parent;
- final Map<String, Builder> members;
+ final Map<String, Declaration> members;
- final Map<String, Builder> constructors;
+ final Map<String, Declaration> constructors;
- final Map<String, Builder> setters;
+ final Map<String, Declaration> setters;
final List<UnresolvedType<T>> types = <UnresolvedType<T>>[];
@@ -762,7 +766,8 @@
}
DeclarationBuilder.library()
- : this(<String, Builder>{}, <String, Builder>{}, null, "library", null);
+ : this(<String, Declaration>{}, <String, Declaration>{}, null, "library",
+ null);
DeclarationBuilder createNested(String name, bool hasMembers) {
return new DeclarationBuilder<T>(
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index 7507777..68dffd5 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -34,8 +34,8 @@
import '../builder/builder.dart'
show
- Builder,
ClassBuilder,
+ Declaration,
EnumBuilder,
LibraryBuilder,
NamedTypeBuilder,
@@ -223,9 +223,10 @@
if (token == null) return null;
DietListener dietListener = createDietListener(library);
- Builder parent = library;
+ Declaration parent = library;
if (enclosingClass != null) {
- Builder cls = dietListener.memberScope.lookup(enclosingClass, -1, null);
+ Declaration cls =
+ dietListener.memberScope.lookup(enclosingClass, -1, null);
if (cls is ClassBuilder) {
parent = cls;
dietListener
@@ -304,7 +305,7 @@
wasChanged = false;
for (SourceLibraryBuilder exported in both) {
for (Export export in exported.exporters) {
- exported.exportScope.forEach((String name, Builder member) {
+ exported.exportScope.forEach((String name, Declaration member) {
if (export.addToExportScope(name, member)) {
wasChanged = true;
}
@@ -333,15 +334,15 @@
// TODO(sigmund): should be `covarint SourceLibraryBuilder`.
builders.forEach((Uri uri, dynamic l) {
SourceLibraryBuilder library = l;
- Set<Builder> members = new Set<Builder>();
- library.forEach((String name, Builder member) {
+ Set<Declaration> members = new Set<Declaration>();
+ library.forEach((String name, Declaration member) {
while (member != null) {
members.add(member);
member = member.next;
}
});
List<String> exports = <String>[];
- library.exportScope.forEach((String name, Builder member) {
+ library.exportScope.forEach((String name, Declaration member) {
while (member != null) {
if (!members.contains(member)) {
exports.add(name);
@@ -553,10 +554,11 @@
if (mixedInType != null) {
bool isClassBuilder = false;
if (mixedInType is NamedTypeBuilder) {
- var builder = mixedInType.builder;
+ var builder = mixedInType.declaration;
if (builder is ClassBuilder) {
isClassBuilder = true;
- for (Builder constructory in builder.constructors.local.values) {
+ for (Declaration constructory
+ in builder.constructors.local.values) {
if (constructory.isConstructor && !constructory.isSynthetic) {
cls.addCompileTimeError(
templateIllegalMixinDueToConstructors
diff --git a/pkg/front_end/lib/src/fasta/target_implementation.dart b/pkg/front_end/lib/src/fasta/target_implementation.dart
index 5abbd00..3361321 100644
--- a/pkg/front_end/lib/src/fasta/target_implementation.dart
+++ b/pkg/front_end/lib/src/fasta/target_implementation.dart
@@ -6,7 +6,7 @@
import 'package:kernel/target/targets.dart' as backend show Target;
-import 'builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder;
+import 'builder/builder.dart' show Declaration, ClassBuilder, LibraryBuilder;
import 'compiler_context.dart' show CompilerContext;
@@ -26,12 +26,12 @@
final CompilerContext context = CompilerContext.current;
- Builder cachedAbstractClassInstantiationError;
- Builder cachedCompileTimeError;
- Builder cachedDuplicatedFieldInitializerError;
- Builder cachedFallThroughError;
- Builder cachedNativeAnnotation;
- Builder cachedNativeExtensionAnnotation;
+ Declaration cachedAbstractClassInstantiationError;
+ Declaration cachedCompileTimeError;
+ Declaration cachedDuplicatedFieldInitializerError;
+ Declaration cachedFallThroughError;
+ Declaration cachedNativeAnnotation;
+ Declaration cachedNativeExtensionAnnotation;
TargetImplementation(Ticker ticker, this.uriTranslator, this.backendTarget)
: super(ticker);
@@ -60,7 +60,7 @@
/// [AbstractClassInstantiationError] error. The constructor is expected to
/// accept a single argument of type String, which is the name of the
/// abstract class.
- Builder getAbstractClassInstantiationError(Loader loader) {
+ Declaration getAbstractClassInstantiationError(Loader loader) {
if (cachedAbstractClassInstantiationError != null) {
return cachedAbstractClassInstantiationError;
}
@@ -71,7 +71,7 @@
/// Returns a reference to the constructor used for creating a compile-time
/// error. The constructor is expected to accept a single argument of type
/// String, which is the compile-time error message.
- Builder getCompileTimeError(Loader loader) {
+ Declaration getCompileTimeError(Loader loader) {
if (cachedCompileTimeError != null) return cachedCompileTimeError;
return cachedCompileTimeError = loader.coreLibrary
.getConstructor("_CompileTimeError", bypassLibraryPrivacy: true);
@@ -80,7 +80,7 @@
/// Returns a reference to the constructor used for creating a runtime error
/// when a final field is initialized twice. The constructor is expected to
/// accept a single argument which is the name of the field.
- Builder getDuplicatedFieldInitializerError(Loader loader) {
+ Declaration getDuplicatedFieldInitializerError(Loader loader) {
if (cachedDuplicatedFieldInitializerError != null) {
return cachedDuplicatedFieldInitializerError;
}
@@ -92,7 +92,7 @@
/// Returns a reference to the constructor used for creating `native`
/// annotations. The constructor is expected to accept a single argument of
/// type String, which is the name of the native method.
- Builder getNativeAnnotation(Loader loader) {
+ Declaration getNativeAnnotation(Loader loader) {
if (cachedNativeAnnotation != null) return cachedNativeAnnotation;
LibraryBuilder internal = loader.read(Uri.parse("dart:_internal"), -1);
return cachedNativeAnnotation = internal.getConstructor("ExternalName");
diff --git a/pkg/front_end/testcases/qualified.dart.strong.expect b/pkg/front_end/testcases/qualified.dart.strong.expect
index ead5697..9dceec4 100644
--- a/pkg/front_end/testcases/qualified.dart.strong.expect
+++ b/pkg/front_end/testcases/qualified.dart.strong.expect
@@ -29,7 +29,9 @@
lib.Missing method() {}
^", "pkg/front_end/testcases/qualified.dart:11:19: Error: Type 'lib.Missing' not found.
class Bad extends lib.Missing {
- ^", "pkg/front_end/testcases/qualified.dart: Error: Couldn't find constructor 'WrongName'."]/* from null */;
+ ^", "pkg/front_end/testcases/qualified.dart:13:11: Error: Couldn't find constructor 'WrongName'.
+ factory WrongName() {}
+ ^"]/* from null */;
static method main() → dynamic {
new self::C::•<core::String>();
new self::C::a<core::String>();
diff --git a/pkg/front_end/testcases/qualified.dart.strong.transformed.expect b/pkg/front_end/testcases/qualified.dart.strong.transformed.expect
index 54bc304..2c96429 100644
--- a/pkg/front_end/testcases/qualified.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/qualified.dart.strong.transformed.expect
@@ -35,7 +35,9 @@
lib.Missing method() {}
^", "pkg/front_end/testcases/qualified.dart:11:19: Error: Type 'lib.Missing' not found.
class Bad extends lib.Missing {
- ^", "pkg/front_end/testcases/qualified.dart: Error: Couldn't find constructor 'WrongName'."]/* from null */;
+ ^", "pkg/front_end/testcases/qualified.dart:13:11: Error: Couldn't find constructor 'WrongName'.
+ factory WrongName() {}
+ ^"]/* from null */;
static method main() → dynamic {
new self::C::•<core::String>();
new self::C::a<core::String>();