Chromium Code Reviews| Index: lib/src/codegen/js_codegen.dart |
| diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart |
| index 2945606b06a61249cd4b4e7c6db9a9710e7d6b50..ac2bb2f63da5ef881d927785e4f1d91446087e45 100644 |
| --- a/lib/src/codegen/js_codegen.dart |
| +++ b/lib/src/codegen/js_codegen.dart |
| @@ -1172,7 +1172,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { |
| return _getTemp(element, '${name.substring(1)}'); |
| } |
| - if (_isTemporary(element)) { |
| + if (element is TemporaryVariableElement) { |
| if (name[0] == '#') { |
| return new JS.InterpolatedExpression(name.substring(1)); |
| } else { |
| @@ -1775,7 +1775,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { |
| // * create a new subtype of LocalVariableElementImpl to mark a temp. |
| var id = |
| new SimpleIdentifier(new StringToken(TokenType.IDENTIFIER, name, -1)); |
| - id.staticElement = new LocalVariableElementImpl.forNode(id); |
| + id.staticElement = new TemporaryVariableElement.forNode(id); |
| id.staticType = type; |
| return id; |
| } |
| @@ -1802,8 +1802,6 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { |
| return value; |
| } |
| - bool _isTemporary(Element node) => node.nameOffset == -1; |
| - |
| /// Returns a new expression, which can be be used safely *once* on the |
| /// left hand side, and *once* on the right side of an assignment. |
| /// For example: `expr1[expr2] += y` can be compiled as |
| @@ -2619,3 +2617,12 @@ bool _isJsPeerInterface(DartObjectImpl value) => |
| // but we don't have summary support yet. |
| // bool _supportJsExtensionMethod(AnnotatedNode node) => |
| // _getAnnotation(node, "SupportJsExtensionMethod") != null; |
| + |
| +/// A special kind of element created by the compiler, signifying a temporary |
| +/// variable. These objects use instance equality, and should be shared |
| +/// everywhere in the tree where they are treated as the same variable. |
| +class TemporaryVariableElement extends LocalVariableElementImpl { |
| + TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); |
|
Jennifer Messerly
2015/05/11 23:36:49
just realized I should add hashCode too
|
| + |
| + operator ==(Object other) => identical(this, other); |
|
vsm
2015/05/11 23:30:34
Should LocalVariableElementImpl just do the same t
Jennifer Messerly
2015/05/11 23:36:49
maybe ... it definitely surprised me that name/off
|
| +} |