Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: pkg/compiler/lib/src/compile_time_constants.dart

Issue 1917863002: Replace _analyzeElementEagerly with Resolution.ensureResolved (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: dartfmt Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/common/resolution.dart ('k') | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.compile_time_constant_evaluator; 5 library dart2js.compile_time_constant_evaluator;
6 6
7 import 'common.dart'; 7 import 'common.dart';
8 import 'common/resolution.dart' show Resolution; 8 import 'common/resolution.dart' show Resolution;
9 import 'common/tasks.dart' show CompilerTask; 9 import 'common/tasks.dart' show CompilerTask;
10 import 'compiler.dart' show Compiler; 10 import 'compiler.dart' show Compiler;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 /// report an error if [element] does not typecheck. 186 /// report an error if [element] does not typecheck.
187 ConstantExpression internalCompileVariable( 187 ConstantExpression internalCompileVariable(
188 VariableElement element, bool isConst, bool checkType) { 188 VariableElement element, bool isConst, bool checkType) {
189 if (initialVariableValues.containsKey(element.declaration)) { 189 if (initialVariableValues.containsKey(element.declaration)) {
190 ConstantExpression result = initialVariableValues[element.declaration]; 190 ConstantExpression result = initialVariableValues[element.declaration];
191 return result; 191 return result;
192 } 192 }
193 AstElement currentElement = element.analyzableElement; 193 AstElement currentElement = element.analyzableElement;
194 return reporter.withCurrentElement(currentElement, () { 194 return reporter.withCurrentElement(currentElement, () {
195 // TODO(johnniwinther): Avoid this eager analysis. 195 // TODO(johnniwinther): Avoid this eager analysis.
196 _analyzeElementEagerly(compiler, currentElement); 196 compiler.resolution.ensureResolved(currentElement.declaration);
197 197
198 ConstantExpression constant = compileVariableWithDefinitions( 198 ConstantExpression constant = compileVariableWithDefinitions(
199 element, currentElement.resolvedAst.elements, 199 element, currentElement.resolvedAst.elements,
200 isConst: isConst, checkType: checkType); 200 isConst: isConst, checkType: checkType);
201 return constant; 201 return constant;
202 }); 202 });
203 } 203 }
204 204
205 /** 205 /**
206 * Returns the a compile-time constant if the variable could be compiled 206 * Returns the a compile-time constant if the variable could be compiled
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 return createConstructorInvocation(node, type, constructor, callStructure, 840 return createConstructorInvocation(node, type, constructor, callStructure,
841 arguments: node.send.arguments); 841 arguments: node.send.arguments);
842 } 842 }
843 843
844 AstConstant createConstructorInvocation(Node node, InterfaceType type, 844 AstConstant createConstructorInvocation(Node node, InterfaceType type,
845 ConstructorElement constructor, CallStructure callStructure, 845 ConstructorElement constructor, CallStructure callStructure,
846 {Link<Node> arguments, List<AstConstant> normalizedArguments}) { 846 {Link<Node> arguments, List<AstConstant> normalizedArguments}) {
847 // TODO(ahe): This is nasty: we must eagerly analyze the 847 // TODO(ahe): This is nasty: we must eagerly analyze the
848 // constructor to ensure the redirectionTarget has been computed 848 // constructor to ensure the redirectionTarget has been computed
849 // correctly. Find a way to avoid this. 849 // correctly. Find a way to avoid this.
850 _analyzeElementEagerly(compiler, constructor); 850 resolution.ensureResolved(constructor.declaration);
851 851
852 // The redirection chain of this element may not have been resolved through 852 // The redirection chain of this element may not have been resolved through
853 // a post-process action, so we have to make sure it is done here. 853 // a post-process action, so we have to make sure it is done here.
854 compiler.resolver.resolveRedirectionChain(constructor, node); 854 compiler.resolver.resolveRedirectionChain(constructor, node);
855 855
856 bool isInvalid = false; 856 bool isInvalid = false;
857 InterfaceType constructedType = type; 857 InterfaceType constructedType = type;
858 ConstructorElement implementation; 858 ConstructorElement implementation;
859 if (constructor.isRedirectingFactory) { 859 if (constructor.isRedirectingFactory) {
860 if (constructor.isEffectiveTargetMalformed) { 860 if (constructor.isEffectiveTargetMalformed) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 /** 1097 /**
1098 * Documentation wanted -- johnniwinther 1098 * Documentation wanted -- johnniwinther
1099 * 1099 *
1100 * Invariant: [constructor] must be an implementation element. 1100 * Invariant: [constructor] must be an implementation element.
1101 */ 1101 */
1102 ConstructorEvaluator(InterfaceType this.constructedType, 1102 ConstructorEvaluator(InterfaceType this.constructedType,
1103 FunctionElement constructor, ConstantCompiler handler, Compiler compiler) 1103 FunctionElement constructor, ConstantCompiler handler, Compiler compiler)
1104 : this.constructor = constructor, 1104 : this.constructor = constructor,
1105 this.definitions = new Map<Element, AstConstant>(), 1105 this.definitions = new Map<Element, AstConstant>(),
1106 this.fieldValues = new Map<Element, AstConstant>(), 1106 this.fieldValues = new Map<Element, AstConstant>(),
1107 this.resolvedAst = _analyzeElementEagerly(compiler, constructor), 1107 this.resolvedAst =
1108 compiler.resolution.computeResolvedAst(constructor.declaration),
1108 super(handler, null, compiler, isConst: true) { 1109 super(handler, null, compiler, isConst: true) {
1109 assert(invariant(constructor, constructor.isImplementation)); 1110 assert(invariant(constructor, constructor.isImplementation));
1110 } 1111 }
1111 1112
1112 @override 1113 @override
1113 TreeElements get elements => resolvedAst.elements; 1114 TreeElements get elements => resolvedAst.elements;
1114 1115
1115 AstConstant visitSend(Send send) { 1116 AstConstant visitSend(Send send) {
1116 Element element = elements[send]; 1117 Element element = elements[send];
1117 if (Elements.isLocal(element)) { 1118 if (Elements.isLocal(element)) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 class ErroneousAstConstant extends AstConstant { 1330 class ErroneousAstConstant extends AstConstant {
1330 ErroneousAstConstant(Element element, Node node) 1331 ErroneousAstConstant(Element element, Node node)
1331 : super( 1332 : super(
1332 element, 1333 element,
1333 node, 1334 node,
1334 // TODO(johnniwinther): Return a [NonConstantValue] instead. 1335 // TODO(johnniwinther): Return a [NonConstantValue] instead.
1335 new ErroneousConstantExpression(), 1336 new ErroneousConstantExpression(),
1336 new NullConstantValue()); 1337 new NullConstantValue());
1337 } 1338 }
1338 1339
1339 // TODO(johnniwinther): Clean this up.
1340 ResolvedAst _analyzeElementEagerly(Compiler compiler, AstElement element) {
1341 compiler.resolution.computeWorldImpact(element.declaration);
1342 return element.resolvedAst;
1343 }
1344
1345 class _CompilerEnvironment implements Environment { 1340 class _CompilerEnvironment implements Environment {
1346 final Compiler compiler; 1341 final Compiler compiler;
1347 1342
1348 _CompilerEnvironment(this.compiler); 1343 _CompilerEnvironment(this.compiler);
1349 1344
1350 @override 1345 @override
1351 String readFromEnvironment(String name) { 1346 String readFromEnvironment(String name) {
1352 return compiler.fromEnvironment(name); 1347 return compiler.fromEnvironment(name);
1353 } 1348 }
1354 } 1349 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/common/resolution.dart ('k') | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698