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

Side by Side Diff: lib/src/codegen/js_names.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 unified diff | Download patch
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/expect/try_catch.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dev_compiler.src.codegen.js_names; 5 library dev_compiler.src.codegen.js_names;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'package:dev_compiler/src/js/js_ast.dart'; 8 import 'package:dev_compiler/src/js/js_ast.dart';
9 9
10 /// Unique instance for temporary variables. Will be renamed consistently 10 /// Unique instance for temporary variables. Will be renamed consistently
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 _RenameVisitor.build(Node root) { 79 _RenameVisitor.build(Node root) {
80 scope = rootScope; 80 scope = rootScope;
81 root.accept(this); 81 root.accept(this);
82 _finishFunctions(); 82 _finishFunctions();
83 _finishNames(); 83 _finishNames();
84 } 84 }
85 85
86 declare(Identifier node) { 86 declare(Identifier node) {
87 var id = identifierKey(node); 87 var id = identifierKey(node);
88 scope.declared.add(id); 88 var notAlreadyDeclared = scope.declared.add(id);
89 // Normal identifiers can be declared multiple times, because we don't
90 // implement block scope yet. However temps should only be declared once.
91 assert(notAlreadyDeclared || node is! TemporaryId);
89 _markUsed(node, id, scope); 92 _markUsed(node, id, scope);
90 } 93 }
91 94
92 visitIdentifier(Identifier node) { 95 visitIdentifier(Identifier node) {
93 var id = identifierKey(node); 96 var id = identifierKey(node);
94 97
95 // Find where the node was declared. 98 // Find where the node was declared.
96 var declScope = scope; 99 var declScope = scope;
97 while (declScope != null && !declScope.declared.contains(id)) { 100 while (declScope != null && !declScope.declared.contains(id)) {
98 declScope = declScope.parent; 101 declScope = declScope.parent;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 /// In particular, "caller" "callee" and "arguments" cannot be used. 238 /// In particular, "caller" "callee" and "arguments" cannot be used.
236 bool invalidStaticFieldName(String name) { 239 bool invalidStaticFieldName(String name) {
237 switch (name) { 240 switch (name) {
238 case "arguments": 241 case "arguments":
239 case "caller": 242 case "caller":
240 case "callee": 243 case "callee":
241 return true; 244 return true;
242 } 245 }
243 return false; 246 return false;
244 } 247 }
OLDNEW
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/expect/try_catch.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698