Index: pkg/compiler/lib/src/resolution/members.dart |
diff --git a/pkg/compiler/lib/src/resolution/members.dart b/pkg/compiler/lib/src/resolution/members.dart |
index b1b7744a37b3339a2f95dd55e05a6b1f2e6aceec..97f59bc7f3360263734a49176ff5ed49bac64bce 100644 |
--- a/pkg/compiler/lib/src/resolution/members.dart |
+++ b/pkg/compiler/lib/src/resolution/members.dart |
@@ -6,8 +6,8 @@ library dart2js.resolution.members; |
import '../common.dart'; |
import '../common/names.dart' show Selectors; |
-import '../common/resolution.dart' show Feature; |
-import '../compiler.dart' show Compiler; |
+import '../common/resolution.dart' show Feature, Resolution; |
+import '../compile_time_constants.dart'; |
import '../constants/constructors.dart' |
show RedirectingFactoryConstantConstructor; |
import '../constants/expressions.dart'; |
@@ -27,6 +27,7 @@ import '../elements/modelx.dart' |
ParameterElementX, |
VariableElementX, |
VariableList; |
+import '../options.dart'; |
import '../tokens/token.dart' show isUserDefinableOperator; |
import '../tree/tree.dart'; |
import '../universe/call_structure.dart' show CallStructure; |
@@ -142,7 +143,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
r')$'); |
ResolverVisitor( |
- Compiler compiler, Element element, ResolutionRegistry registry, |
+ Resolution resolution, Element element, ResolutionRegistry registry, |
{Scope scope, bool useEnclosingScope: false}) |
: this.enclosingElement = element, |
// When the element is a field, we are actually resolving its |
@@ -159,7 +160,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
: element.buildScope()), |
// The type annotations on a typedef do not imply type checks. |
// TODO(karlklose): clean this up (dartbug.com/8870). |
- inCheckContext = compiler.options.enableTypeAssertions && |
+ inCheckContext = resolution.options.enableTypeAssertions && |
!element.isLibrary && |
!element.isTypedef && |
!element.enclosingElement.isTypedef, |
@@ -167,11 +168,13 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
constantState = element.isConst |
? ConstantState.CONSTANT |
: ConstantState.NON_CONSTANT, |
- super(compiler, registry); |
+ super(resolution, registry); |
- CoreClasses get coreClasses => compiler.coreClasses; |
- |
- CoreTypes get coreTypes => compiler.coreTypes; |
+ CoreClasses get coreClasses => resolution.coreClasses; |
+ CoreTypes get coreTypes => resolution.coreTypes; |
+ ConstantEnvironment get constants => resolution.constants; |
+ ResolverTask get resolver => resolution.resolver; |
+ CompilerOptions get options => resolution.options; |
AsyncMarker get currentAsyncMarker { |
if (enclosingElement is FunctionElement) { |
@@ -450,7 +453,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
addDeferredAction(enclosingElement, () { |
functionSignature.forEachOptionalParameter((ParameterElementX parameter) { |
parameter.constant = |
- compiler.resolver.constantCompiler.compileConstant(parameter); |
+ resolver.constantCompiler.compileConstant(parameter); |
}); |
}); |
functionSignature.forEachParameter((ParameterElement element) { |
@@ -459,7 +462,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
} |
ResolutionResult visitAssert(Assert node) { |
- if (!compiler.options.enableAssertMessage) { |
+ if (!options.enableAssertMessage) { |
if (node.hasMessage) { |
reporter.reportErrorMessage( |
node, MessageKind.EXPERIMENTAL_ASSERT_MESSAGE); |
@@ -566,9 +569,9 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
} |
LocalFunctionElementX function = new LocalFunctionElementX( |
name, node, ElementKind.FUNCTION, Modifiers.EMPTY, enclosingElement); |
- ResolverTask.processAsyncMarker(compiler, function, registry); |
+ ResolverTask.processAsyncMarker(resolution, function, registry); |
function.functionSignature = SignatureResolver.analyze( |
- compiler, |
+ resolution, |
scope, |
node.typeVariables, |
node.parameters, |
@@ -2010,7 +2013,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
ResolutionResult handleConstantTypeLiteralUpdate(SendSet node, Name name, |
TypeDeclarationElement element, DartType type, ConstantAccess semantics) { |
// TODO(johnniwinther): Remove this when all constants are evaluated. |
- compiler.resolver.constantCompiler.evaluate(semantics.constant); |
+ resolver.constantCompiler.evaluate(semantics.constant); |
ErroneousElement error; |
if (node.isIfNullAssignment) { |
@@ -2562,7 +2565,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
semantics = new StaticAccess.parameter(element); |
} |
} else if (element.isInitializingFormal && |
- compiler.options.enableInitializingFormalAccess) { |
+ options.enableInitializingFormalAccess) { |
error = reportAndCreateErroneousElement(node.selector, name.text, |
MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER, {'name': name}); |
semantics = new StaticAccess.finalParameter(element); |
@@ -2620,12 +2623,12 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
// of parse errors to make [element] erroneous. Fix this! |
member.computeType(resolution); |
- if (member == compiler.mirrorSystemGetNameFunction && |
- !compiler.mirrorUsageAnalyzerTask.hasMirrorUsage(enclosingElement)) { |
+ if (member == resolution.mirrorSystemGetNameFunction && |
+ !resolution.mirrorUsageAnalyzerTask.hasMirrorUsage(enclosingElement)) { |
reporter |
.reportHintMessage(node.selector, MessageKind.STATIC_FUNCTION_BLOAT, { |
- 'class': compiler.mirrorSystemClass.name, |
- 'name': compiler.mirrorSystemGetNameFunction.name |
+ 'class': resolution.mirrorSystemClass.name, |
+ 'name': resolution.mirrorSystemGetNameFunction.name |
}); |
} |
@@ -2651,7 +2654,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
registry.registerStaticUse( |
new StaticUse.staticInvoke(semantics.element, callStructure)); |
handleForeignCall(node, semantics.element, callStructure); |
- if (method == compiler.identicalFunction && |
+ if (method == resolution.identicalFunction && |
argumentsResult.isValidAsConstant) { |
result = new ConstantResult( |
node, |
@@ -3021,7 +3024,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
// TODO(johnniwinther): Move this to the backend resolution callbacks. |
void handleForeignCall( |
Send node, Element target, CallStructure callStructure) { |
- if (target != null && compiler.backend.isForeign(target)) { |
+ if (target != null && resolution.target.isForeign(target)) { |
registry.registerForeignCall(node, target, callStructure, this); |
} |
} |
@@ -3570,7 +3573,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
} |
ResolutionResult visitYield(Yield node) { |
- if (!compiler.backend.supportsAsyncAwait) { |
+ if (!resolution.target.supportsAsyncAwait) { |
reporter.reportErrorMessage( |
node.yieldToken, MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
} else { |
@@ -3611,7 +3614,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
// Register a post process to check for cycles in the redirection chain |
// and set the actual generative constructor at the end of the chain. |
addDeferredAction(constructor, () { |
- compiler.resolver.resolveRedirectionChain(constructor, node); |
+ resolver.resolveRedirectionChain(constructor, node); |
}); |
break; |
case ConstructorResultKind.ABSTRACT: |
@@ -3649,7 +3652,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
.subst(type.typeArguments, targetClass.typeVariables); |
FunctionType constructorType = constructor.computeType(resolution); |
bool isSubtype = |
- compiler.types.isSubtype(targetConstructorType, constructorType); |
+ resolution.types.isSubtype(targetConstructorType, constructorType); |
if (!isSubtype) { |
reporter.reportWarningMessage(node, MessageKind.NOT_ASSIGNABLE, |
{'fromType': targetConstructorType, 'toType': constructorType}); |
@@ -3674,7 +3677,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
registry.registerTypeUse(new TypeUse.instantiation(redirectionTarget |
.enclosingClass.thisType |
.subst(type.typeArguments, targetClass.typeVariables))); |
- if (enclosingElement == compiler.symbolConstructor) { |
+ if (enclosingElement == resolution.symbolConstructor) { |
registry.registerFeature(Feature.SYMBOL_CONSTRUCTOR); |
} |
if (isValidAsConstant) { |
@@ -3708,7 +3711,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
} |
ResolutionResult visitAwait(Await node) { |
- if (!compiler.backend.supportsAsyncAwait) { |
+ if (!resolution.target.supportsAsyncAwait) { |
reporter.reportErrorMessage( |
node.awaitToken, MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
} else { |
@@ -3730,7 +3733,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
} |
VariableList variables = new VariableList.node(node, type); |
VariableDefinitionsVisitor visitor = |
- new VariableDefinitionsVisitor(compiler, node, this, variables); |
+ new VariableDefinitionsVisitor(resolution, node, this, variables); |
Modifiers modifiers = node.modifiers; |
void reportExtraModifier(String modifier) { |
@@ -3763,7 +3766,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
} |
if (node.metadata != null) { |
variables.metadataInternal = |
- compiler.resolver.resolveMetadata(enclosingElement, node); |
+ resolver.resolveMetadata(enclosingElement, node); |
} |
visitor.visit(node.definitions); |
return const NoneResult(); |
@@ -3883,11 +3886,11 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
if (node.isConst) { |
bool isValidAsConstant = !isInvalid && constructor.isConst; |
- if (constructor == compiler.symbolConstructor) { |
+ if (constructor == resolution.symbolConstructor) { |
Node argumentNode = node.send.arguments.head; |
- ConstantExpression constant = compiler.resolver.constantCompiler |
+ ConstantExpression constant = resolver.constantCompiler |
.compileNode(argumentNode, registry.mapping); |
- ConstantValue name = compiler.constants.getConstantValue(constant); |
+ ConstantValue name = resolution.constants.getConstantValue(constant); |
if (!name.isString) { |
DartType type = name.getType(coreTypes); |
reporter.reportErrorMessage( |
@@ -3899,8 +3902,8 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
registry.registerConstSymbol(nameString); |
} |
} |
- } else if (constructor == compiler.mirrorsUsedConstructor) { |
- compiler.mirrorUsageAnalyzerTask.validate(node, registry.mapping); |
+ } else if (constructor == resolution.mirrorsUsedConstructor) { |
+ resolution.mirrorUsageAnalyzerTask.validate(node, registry.mapping); |
} |
analyzeConstantDeferred(node); |
@@ -3959,8 +3962,9 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
analyzeConstantDeferred(node, onAnalyzed: onAnalyzed); |
} else { |
// Not constant. |
- if (constructor == compiler.symbolConstructor && |
- !compiler.mirrorUsageAnalyzerTask.hasMirrorUsage(enclosingElement)) { |
+ if (constructor == resolution.symbolConstructor && |
+ !resolution.mirrorUsageAnalyzerTask |
+ .hasMirrorUsage(enclosingElement)) { |
reporter.reportHintMessage(node.newToken, MessageKind.NON_CONST_BLOAT, |
{'name': coreClasses.symbolClass.name}); |
} |
@@ -3991,15 +3995,15 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
} |
void analyzeConstant(Node node, {enforceConst: true}) { |
- ConstantExpression constant = compiler.resolver.constantCompiler |
+ ConstantExpression constant = resolver.constantCompiler |
.compileNode(node, registry.mapping, enforceConst: enforceConst); |
if (constant == null) { |
- assert(invariant(node, compiler.compilationFailed)); |
+ assert(invariant(node, reporter.hasReportedError)); |
return; |
} |
- ConstantValue value = compiler.constants.getConstantValue(constant); |
+ ConstantValue value = resolution.constants.getConstantValue(constant); |
if (value.isMap) { |
checkConstMapKeysDontOverrideEquals(node, value); |
} |
@@ -4040,13 +4044,13 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
* [:null:], if there is no corresponding constructor, class or library. |
*/ |
ConstructorResult resolveConstructor(NewExpression node) { |
- return node.accept( |
- new ConstructorResolver(compiler, this, inConstContext: node.isConst)); |
+ return node.accept(new ConstructorResolver(resolution, this, |
+ inConstContext: node.isConst)); |
} |
ConstructorResult resolveRedirectingFactory(RedirectingFactoryBody node, |
{bool inConstContext: false}) { |
- return node.accept(new ConstructorResolver(compiler, this, |
+ return node.accept(new ConstructorResolver(resolution, this, |
inConstContext: inConstContext)); |
} |
@@ -4233,7 +4237,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
} |
ResolutionResult visitAsyncForIn(AsyncForIn node) { |
- if (!compiler.backend.supportsAsyncAwait) { |
+ if (!resolution.target.supportsAsyncAwait) { |
reporter.reportErrorMessage( |
node.awaitToken, MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
} else { |
@@ -4321,7 +4325,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
} |
} else { |
// The selector may only be null if we reported an error. |
- assert(invariant(declaration, compiler.compilationFailed)); |
+ assert(invariant(declaration, reporter.hasReportedError)); |
} |
if (loopVariable != null) { |
// loopVariable may be null if it could not be resolved. |
@@ -4484,7 +4488,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
assert(invariant(node, constant != null, |
message: 'No constant computed for $node')); |
- ConstantValue value = compiler.constants.getConstantValue(constant); |
+ ConstantValue value = resolution.constants.getConstantValue(constant); |
DartType caseType = value.getType(coreTypes); //typeOfConstant(value); |
if (firstCaseType == null) { |