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

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1139673005: fix temps that have the same name to have different Elements (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: 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 | lib/src/codegen/js_names.dart » ('j') | test/codegen/expect/try_catch.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
+}
« no previous file with comments | « no previous file | lib/src/codegen/js_names.dart » ('j') | test/codegen/expect/try_catch.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698