| Index: pkg/compiler/lib/src/resolution/resolution.dart
|
| diff --git a/pkg/compiler/lib/src/resolution/resolution.dart b/pkg/compiler/lib/src/resolution/resolution.dart
|
| index 90e6ad267db066a43ad2854397d4e19b97760807..619f748c5fb6afd3fe0ad4a047472ed78b2c738b 100644
|
| --- a/pkg/compiler/lib/src/resolution/resolution.dart
|
| +++ b/pkg/compiler/lib/src/resolution/resolution.dart
|
| @@ -9,10 +9,9 @@ import 'dart:collection' show Queue;
|
| import '../common.dart';
|
| import '../common/names.dart' show Identifiers;
|
| import '../common/resolution.dart'
|
| - show Feature, ParsingContext, Resolution, ResolutionImpact;
|
| -import '../common/tasks.dart' show CompilerTask;
|
| + show Feature, ParsingContext, Resolution, ResolutionImpact, Target;
|
| +import '../common/tasks.dart' show CompilerTask, Measurer;
|
| import '../compile_time_constants.dart' show ConstantCompiler;
|
| -import '../compiler.dart' show Compiler;
|
| import '../constants/expressions.dart'
|
| show
|
| ConstantExpression,
|
| @@ -36,6 +35,8 @@ import '../elements/modelx.dart'
|
| ParameterMetadataAnnotation,
|
| SetterElementX,
|
| TypedefElementX;
|
| +import '../enqueue.dart';
|
| +import '../options.dart';
|
| import '../tokens/token.dart'
|
| show
|
| isBinaryOperator,
|
| @@ -48,36 +49,35 @@ import '../universe/call_structure.dart' show CallStructure;
|
| import '../universe/use.dart' show StaticUse, TypeUse;
|
| import '../universe/world_impact.dart' show WorldImpact;
|
| import '../util/util.dart' show Link, Setlet;
|
| +import '../world.dart';
|
| import 'class_hierarchy.dart';
|
| import 'class_members.dart' show MembersCreator;
|
| import 'constructors.dart';
|
| import 'members.dart';
|
| import 'registry.dart';
|
| import 'resolution_result.dart';
|
| -import 'scope.dart' show MutableScope;
|
| import 'signatures.dart';
|
| import 'tree_elements.dart';
|
| import 'typedefs.dart';
|
|
|
| class ResolverTask extends CompilerTask {
|
| final ConstantCompiler constantCompiler;
|
| - final Compiler compiler;
|
| + final Resolution resolution;
|
| + final World world;
|
|
|
| - ResolverTask(Compiler compiler, this.constantCompiler)
|
| - : compiler = compiler,
|
| - super(compiler.measurer);
|
| + ResolverTask(
|
| + this.resolution, this.constantCompiler, this.world, Measurer measurer)
|
| + : super(measurer);
|
|
|
| String get name => 'Resolver';
|
|
|
| - DiagnosticReporter get reporter => compiler.reporter;
|
| -
|
| - Resolution get resolution => compiler.resolution;
|
| -
|
| - ParsingContext get parsingContext => compiler.parsingContext;
|
| -
|
| - CoreClasses get coreClasses => compiler.coreClasses;
|
| -
|
| - CoreTypes get coreTypes => compiler.coreTypes;
|
| + DiagnosticReporter get reporter => resolution.reporter;
|
| + Target get target => resolution.target;
|
| + CoreTypes get coreTypes => resolution.coreTypes;
|
| + CoreClasses get coreClasses => resolution.coreClasses;
|
| + ParsingContext get parsingContext => resolution.parsingContext;
|
| + CompilerOptions get options => resolution.options;
|
| + ResolutionEnqueuer get enqueuer => resolution.enqueuer;
|
|
|
| ResolutionImpact resolve(Element element) {
|
| return measure(() {
|
| @@ -115,7 +115,7 @@ class ResolverTask extends CompilerTask {
|
| return processMetadata(resolveTypedef(typdef));
|
| }
|
|
|
| - compiler.unimplemented(element, "resolve($element)");
|
| + reporter.internalError(element, "resolve($element) not implemented.");
|
| });
|
| }
|
|
|
| @@ -142,15 +142,14 @@ class ResolverTask extends CompilerTask {
|
| }
|
| }
|
|
|
| - static void processAsyncMarker(Compiler compiler,
|
| + static void processAsyncMarker(Resolution resolution,
|
| BaseFunctionElementX element, ResolutionRegistry registry) {
|
| - DiagnosticReporter reporter = compiler.reporter;
|
| - Resolution resolution = compiler.resolution;
|
| - CoreClasses coreClasses = compiler.coreClasses;
|
| + DiagnosticReporter reporter = resolution.reporter;
|
| + CoreClasses coreClasses = resolution.coreClasses;
|
| FunctionExpression functionExpression = element.node;
|
| AsyncModifier asyncModifier = functionExpression.asyncModifier;
|
| if (asyncModifier != null) {
|
| - if (!compiler.backend.supportsAsyncAwait) {
|
| + if (!resolution.target.supportsAsyncAwait) {
|
| reporter.reportErrorMessage(functionExpression.asyncModifier,
|
| MessageKind.ASYNC_AWAIT_NOT_SUPPORTED);
|
| } else {
|
| @@ -207,7 +206,7 @@ class ResolverTask extends CompilerTask {
|
| bool _isNativeClassOrExtendsNativeClass(ClassElement classElement) {
|
| assert(classElement != null);
|
| while (classElement != null) {
|
| - if (compiler.backend.isNative(classElement)) return true;
|
| + if (target.isNative(classElement)) return true;
|
| classElement = classElement.superclass;
|
| }
|
| return false;
|
| @@ -239,7 +238,7 @@ class ResolverTask extends CompilerTask {
|
| ResolutionRegistry registry = visitor.registry;
|
| registry.defineFunction(tree, element);
|
| visitor.setupFunction(tree, element); // Modifies the scope.
|
| - processAsyncMarker(compiler, element, registry);
|
| + processAsyncMarker(resolution, element, registry);
|
|
|
| if (element.isGenerativeConstructor) {
|
| // Even if there is no initializer list we still have to do the
|
| @@ -248,7 +247,7 @@ class ResolverTask extends CompilerTask {
|
| new InitializerResolver(visitor, element, tree);
|
| FunctionElement redirection = resolver.resolveInitializers(
|
| enableInitializingFormalAccess:
|
| - compiler.options.enableInitializingFormalAccess);
|
| + options.enableInitializingFormalAccess);
|
| if (redirection != null) {
|
| resolveRedirectingConstructor(resolver, tree, element, redirection);
|
| }
|
| @@ -257,8 +256,7 @@ class ResolverTask extends CompilerTask {
|
| tree, MessageKind.FUNCTION_WITH_INITIALIZER);
|
| }
|
|
|
| - if (!compiler.options.analyzeSignaturesOnly ||
|
| - tree.isRedirectingFactory) {
|
| + if (!options.analyzeSignaturesOnly || tree.isRedirectingFactory) {
|
| // We need to analyze the redirecting factory bodies to ensure that
|
| // we can analyze compile-time constants.
|
| visitor.visit(tree.body);
|
| @@ -274,7 +272,7 @@ class ResolverTask extends CompilerTask {
|
| if (enclosingClass != null) {
|
| // TODO(johnniwinther): Find another way to obtain mixin uses.
|
| Iterable<MixinApplicationElement> mixinUses =
|
| - compiler.world.allMixinUsesOf(enclosingClass);
|
| + world.allMixinUsesOf(enclosingClass);
|
| ClassElement mixin = enclosingClass;
|
| for (MixinApplicationElement mixinApplication in mixinUses) {
|
| checkMixinSuperUses(resolutionTree, mixinApplication, mixin);
|
| @@ -298,7 +296,7 @@ class ResolverTask extends CompilerTask {
|
| WorldImpact resolveMethodElement(FunctionElementX element) {
|
| assert(invariant(element, element.isDeclaration));
|
| return reporter.withCurrentElement(element, () {
|
| - if (compiler.enqueuer.resolution.hasBeenProcessed(element)) {
|
| + if (enqueuer.hasBeenProcessed(element)) {
|
| // TODO(karlklose): Remove the check for [isConstructor]. [elememts]
|
| // should never be non-null, not even for constructors.
|
| assert(invariant(element, element.isConstructor,
|
| @@ -309,7 +307,7 @@ class ResolverTask extends CompilerTask {
|
| if (element.isSynthesized) {
|
| if (element.isGenerativeConstructor) {
|
| ResolutionRegistry registry =
|
| - new ResolutionRegistry(compiler, _ensureTreeElements(element));
|
| + new ResolutionRegistry(this.target, _ensureTreeElements(element));
|
| ConstructorElement constructor = element.asFunctionElement();
|
| ConstructorElement target = constructor.definingConstructor;
|
| // Ensure the signature of the synthesized element is
|
| @@ -331,7 +329,7 @@ class ResolverTask extends CompilerTask {
|
| element.computeType(resolution);
|
| FunctionElementX implementation = element;
|
| if (element.isExternal) {
|
| - implementation = compiler.backend.resolveExternalFunction(element);
|
| + implementation = target.resolveExternalFunction(element);
|
| }
|
| return resolveMethodElementImplementation(
|
| implementation, implementation.node);
|
| @@ -346,8 +344,8 @@ class ResolverTask extends CompilerTask {
|
| /// This method should only be used by this library (or tests of
|
| /// this library).
|
| ResolverVisitor visitorFor(Element element, {bool useEnclosingScope: false}) {
|
| - return new ResolverVisitor(compiler, element,
|
| - new ResolutionRegistry(compiler, _ensureTreeElements(element)),
|
| + return new ResolverVisitor(resolution, element,
|
| + new ResolutionRegistry(target, _ensureTreeElements(element)),
|
| useEnclosingScope: useEnclosingScope);
|
| }
|
|
|
| @@ -538,7 +536,7 @@ class ResolverTask extends CompilerTask {
|
| // TODO(ahe): Cache the node in cls.
|
| cls
|
| .parseNode(parsingContext)
|
| - .accept(new ClassSupertypeResolver(compiler, cls));
|
| + .accept(new ClassSupertypeResolver(resolution, cls));
|
| if (cls.supertypeLoadState != STATE_DONE) {
|
| cls.supertypeLoadState = STATE_DONE;
|
| }
|
| @@ -603,8 +601,8 @@ class ResolverTask extends CompilerTask {
|
| TreeElements resolveClass(BaseClassElementX element) {
|
| return _resolveTypeDeclaration(element, () {
|
| // TODO(johnniwinther): Store the mapping in the resolution enqueuer.
|
| - ResolutionRegistry registry =
|
| - new ResolutionRegistry(compiler, _ensureTreeElements(element));
|
| + ResolutionRegistry registry = new ResolutionRegistry(
|
| + resolution.target, _ensureTreeElements(element));
|
| resolveClassInternal(element, registry);
|
| return element.treeElements;
|
| });
|
| @@ -630,10 +628,10 @@ class ResolverTask extends CompilerTask {
|
| loadSupertypes(element, tree);
|
|
|
| ClassResolverVisitor visitor =
|
| - new ClassResolverVisitor(compiler, element, registry);
|
| + new ClassResolverVisitor(resolution, element, registry);
|
| visitor.visit(tree);
|
| element.resolutionState = STATE_DONE;
|
| - compiler.onClassResolved(element);
|
| + resolution.onClassResolved(element);
|
| pendingClassesToBePostProcessed.add(element);
|
| }));
|
| if (element.isPatched) {
|
| @@ -664,8 +662,8 @@ class ResolverTask extends CompilerTask {
|
| for (MetadataAnnotation metadata in element.implementation.metadata) {
|
| metadata.ensureResolved(resolution);
|
| ConstantValue value =
|
| - compiler.constants.getConstantValue(metadata.constant);
|
| - if (!element.isProxy && compiler.isProxyConstant(value)) {
|
| + resolution.constants.getConstantValue(metadata.constant);
|
| + if (!element.isProxy && resolution.isProxyConstant(value)) {
|
| element.isProxy = true;
|
| }
|
| }
|
| @@ -753,7 +751,7 @@ class ResolverTask extends CompilerTask {
|
| // mixin application has been performed.
|
| // TODO(johnniwinther): Obtain the [TreeElements] for [member]
|
| // differently.
|
| - if (compiler.enqueuer.resolution.hasBeenProcessed(member)) {
|
| + if (resolution.enqueuer.hasBeenProcessed(member)) {
|
| if (member.resolvedAst.kind == ResolvedAstKind.PARSED) {
|
| checkMixinSuperUses(
|
| member.resolvedAst.elements, mixinApplication, mixin);
|
| @@ -1002,13 +1000,14 @@ class ResolverTask extends CompilerTask {
|
| return reporter.withCurrentElement(element, () {
|
| FunctionExpression node = element.parseNode(parsingContext);
|
| return measure(() => SignatureResolver.analyze(
|
| - compiler,
|
| + resolution,
|
| element.enclosingElement.buildScope(),
|
| node.typeVariables,
|
| node.parameters,
|
| node.returnType,
|
| element,
|
| - new ResolutionRegistry(compiler, _ensureTreeElements(element)),
|
| + new ResolutionRegistry(
|
| + resolution.target, _ensureTreeElements(element)),
|
| defaultValuesError: defaultValuesError,
|
| createRealParameters: true));
|
| });
|
| @@ -1016,17 +1015,17 @@ class ResolverTask extends CompilerTask {
|
|
|
| WorldImpact resolveTypedef(TypedefElementX element) {
|
| if (element.isResolved) return const ResolutionImpact();
|
| - compiler.world.allTypedefs.add(element);
|
| + world.allTypedefs.add(element);
|
| return _resolveTypeDeclaration(element, () {
|
| - ResolutionRegistry registry =
|
| - new ResolutionRegistry(compiler, _ensureTreeElements(element));
|
| + ResolutionRegistry registry = new ResolutionRegistry(
|
| + resolution.target, _ensureTreeElements(element));
|
| return reporter.withCurrentElement(element, () {
|
| return measure(() {
|
| assert(element.resolutionState == STATE_NOT_STARTED);
|
| element.resolutionState = STATE_STARTED;
|
| Typedef node = element.parseNode(parsingContext);
|
| TypedefResolverVisitor visitor =
|
| - new TypedefResolverVisitor(compiler, element, registry);
|
| + new TypedefResolverVisitor(resolution, element, registry);
|
| visitor.visit(node);
|
| element.resolutionState = STATE_DONE;
|
| return registry.worldImpact;
|
|
|