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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1050203002: Begin making copies of AST nodes for constants during resolution. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments and switch to using mixins. Created 5 years, 9 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
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index afeac824e31052b60c620d4ec51c3c2d70a27e25..177bff3b20b7d675bd65eef4af8955f2beb58bc3 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -2846,6 +2846,14 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
}
@override
+ Object visitInstanceCreationExpression(InstanceCreationExpression node) {
+ if (node.isConst) {
+ node.constantHandle = new ConstantInstanceCreationHandle();
+ }
+ return super.visitInstanceCreationExpression(node);
+ }
+
+ @override
Object visitLabeledStatement(LabeledStatement node) {
bool onSwitchStatement = node.statement is SwitchStatement;
for (Label label in node.labels) {
@@ -3064,7 +3072,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
SimpleIdentifier variableName = node.name;
LocalVariableElementImpl variable;
if (isConst && hasInitializer) {
- variable = new ConstLocalVariableElementImpl(variableName);
+ variable = new ConstLocalVariableElementImpl.forNode(variableName);
} else {
variable = new LocalVariableElementImpl.forNode(variableName);
}
@@ -10716,6 +10724,9 @@ class ResolverVisitor extends ScopedVisitor {
} finally {
_enclosingFunction = outerFunction;
}
+ ConstructorElementImpl constructor = node.element;
+ constructor.constantInitializers =
+ new ConstantAstCloner().cloneNodeList(node.initializers);
return null;
}
@@ -11158,6 +11169,16 @@ class ResolverVisitor extends ScopedVisitor {
Object visitTypeName(TypeName node) => null;
@override
+ Object visitVariableDeclaration(VariableDeclaration node) {
+ super.visitVariableDeclaration(node);
+ if (node.element.isConst && node.initializer != null) {
+ (node.element as ConstVariableElement).constantInitializer =
+ new ConstantAstCloner().cloneNode(node.initializer);
+ }
+ return null;
+ }
+
+ @override
Object visitWhileStatement(WhileStatement node) {
// Note: since we don't call the base class, we have to maintain
// _implicitLabelScope ourselves.
@@ -15359,7 +15380,8 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
String name = element.name;
if (name != null) {
for (int index = name.length - 1; index >= 0; --index) {
- if (name.codeUnitAt(index) != 0x5F) { // 0x5F => '_'
+ if (name.codeUnitAt(index) != 0x5F) {
+ // 0x5F => '_'
return false;
}
}

Powered by Google App Engine
This is Rietveld 408576698