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

Unified Diff: pkg/compiler/lib/src/compile_time_constants.dart

Issue 1146813009: Introduce WorldImpact (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/compile_time_constants.dart
diff --git a/pkg/compiler/lib/src/compile_time_constants.dart b/pkg/compiler/lib/src/compile_time_constants.dart
index 6273efa4f519c62bc2993ae10981500b37e2e51a..9e62d27d1fdfceaf60a36255660b7cd3971825b5 100644
--- a/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/pkg/compiler/lib/src/compile_time_constants.dart
@@ -9,7 +9,7 @@ import 'constants/constant_system.dart';
import 'constants/expressions.dart';
import 'constants/values.dart';
import 'dart_types.dart';
-import 'dart2jslib.dart' show Compiler, CompilerTask, MessageKind, invariant;
+import 'dart2jslib.dart' show Compiler, CompilerTask, MessageKind, WorldImpact, invariant;
import 'elements/elements.dart';
import 'elements/modelx.dart' show FunctionElementX;
import 'helpers/helpers.dart';
@@ -136,7 +136,9 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
}
AstElement currentElement = element.analyzableElement;
return compiler.withCurrentElement(currentElement, () {
- compiler.analyzeElement(currentElement.declaration);
+ // TODO(johnniwinther): Avoid this eager analysis.
+ _analyzeElementEagerly(compiler, currentElement);
+
ConstantExpression constant = compileVariableWithDefinitions(
element, currentElement.resolvedAst.elements, isConst: isConst);
return constant;
@@ -758,7 +760,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
// TODO(ahe): This is nasty: we must eagerly analyze the
// constructor to ensure the redirectionTarget has been computed
// correctly. Find a way to avoid this.
- compiler.analyzeElement(constructor.declaration);
+ _analyzeElementEagerly(compiler, constructor);
// The redirection chain of this element may not have been resolved through
// a post-process action, so we have to make sure it is done here.
@@ -1004,7 +1006,7 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator {
this.definitions = new Map<Element, AstConstant>(),
this.fieldValues = new Map<Element, AstConstant>(),
super(handler,
- compiler.resolver.resolveMethodElement(constructor.declaration),
+ _analyzeElementEagerly(compiler, constructor),
compiler,
isConst: true) {
assert(invariant(constructor, constructor.isImplementation));
@@ -1140,7 +1142,7 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator {
ClassElement superClass = enclosingClass.superclass;
if (enclosingClass != compiler.objectClass) {
assert(superClass != null);
- assert(superClass.resolutionState == STATE_DONE);
+ assert(superClass.isResolved);
FunctionElement targetConstructor =
superClass.lookupDefaultConstructor();
@@ -1225,3 +1227,10 @@ class ErroneousAstConstant extends AstConstant {
ErroneousAstConstant(Element element, Node node)
: super(element, node, new ErroneousConstantExpression());
}
+
+// TODO(johnniwinther): Avoid the need for this hack.
+TreeElements _analyzeElementEagerly(Compiler compiler, AstElement element) {
+ WorldImpact worldImpact = compiler.analyzeElement(element.declaration);
+ compiler.enqueuer.resolution.applyImpact(element.declaration, worldImpact);
+ return element.resolvedAst.elements;
+}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698