Chromium Code Reviews| Index: pkg/compiler/lib/src/elements/modelx.dart |
| diff --git a/pkg/compiler/lib/src/elements/modelx.dart b/pkg/compiler/lib/src/elements/modelx.dart |
| index ded05a0bbc428553a272cdba120a6f83f3d34f0f..95c97fac0bbde9ac2d1dd05b2574c9e656267ac9 100644 |
| --- a/pkg/compiler/lib/src/elements/modelx.dart |
| +++ b/pkg/compiler/lib/src/elements/modelx.dart |
| @@ -1473,6 +1473,7 @@ abstract class VariableElementX extends ElementX |
| final Token token; |
| final VariableList variables; |
| VariableDefinitions definitionsCache; |
| + Expression definitionCache; |
| Expression initializerCache; |
| Modifiers get modifiers => variables.modifiers; |
| @@ -1505,6 +1506,16 @@ abstract class VariableElementX extends ElementX |
| return definitionsCache; |
| } |
| + /// Returns the node that defines this field. |
| + /// |
| + /// For instance in `var a, b = true`, the definitions nodes for fields 'a' |
| + /// and 'b' are the nodes for `a` and `b = true`, respectively. |
| + Expression get definition { |
| + assert(invariant(this, definitionCache != null, |
| + message: "Definition node has not been computed for $this.")); |
| + return definitionCache; |
| + } |
| + |
| Expression get initializer { |
| assert(invariant(this, definitionsCache != null, |
| message: "Initializer has not been computed for $this.")); |
| @@ -1522,7 +1533,6 @@ abstract class VariableElementX extends ElementX |
| void createDefinitions(VariableDefinitions definitions) { |
| assert(invariant(this, definitionsCache == null, |
| message: "VariableDefinitions has already been computed for $this.")); |
| - Expression node; |
| int count = 0; |
| for (Link<Node> link = definitions.definitions.nodes; |
| !link.isEmpty; |
| @@ -1533,28 +1543,17 @@ abstract class VariableElementX extends ElementX |
| SendSet sendSet = initializedIdentifier.asSendSet(); |
| identifier = sendSet.selector.asIdentifier(); |
| if (identical(name, identifier.source)) { |
| - node = initializedIdentifier; |
| + definitionCache = initializedIdentifier; |
| initializerCache = sendSet.arguments.first; |
| } |
| } else if (identical(name, identifier.source)) { |
| - node = initializedIdentifier; |
| + definitionCache = initializedIdentifier; |
| } |
| count++; |
|
Siggi Cherem (dart-lang)
2016/08/16 15:14:39
dead variable now?
Johnni Winther
2016/08/17 08:04:01
Removed.
|
| } |
| - invariant(definitions, node != null, message: "Could not find '$name'."); |
| - if (count == 1) { |
| - definitionsCache = definitions; |
| - } else { |
| - // Create a [VariableDefinitions] node for the single definition of |
| - // [node]. |
| - definitionsCache = new VariableDefinitions( |
| - definitions.type, |
| - definitions.modifiers, |
| - new NodeList( |
| - definitions.definitions.beginToken, |
| - const Link<Node>().prepend(node), |
| - definitions.definitions.endToken)); |
| - } |
| + invariant(definitions, definitionCache != null, |
| + message: "Could not find '$name'."); |
| + definitionsCache = definitions; |
| } |
| DartType computeType(Resolution resolution) { |
| @@ -1659,6 +1658,14 @@ class ErroneousFieldElementX extends ElementX |
| Token get token => node.getBeginToken(); |
| + get definitionCache { |
| + throw new UnsupportedError("definitionCache"); |
| + } |
| + |
| + set definitionCache(_) { |
| + throw new UnsupportedError("definitionCache="); |
| + } |
| + |
| get initializerCache { |
| throw new UnsupportedError("initializerCache"); |
| } |
| @@ -1673,6 +1680,8 @@ class ErroneousFieldElementX extends ElementX |
| get initializer => null; |
| + get definition => null; |
| + |
| bool get isMalformed => true; |
| get nestedClosures { |
| @@ -3016,6 +3025,7 @@ class EnumFieldElementX extends FieldElementX { |
| definitionsCache = new VariableDefinitions( |
| null, variableList.modifiers, new NodeList.singleton(definition)); |
| initializerCache = initializer; |
| + definitionCache = definition; |
| } |
| @override |