| OLD | NEW |
| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 String getName(Identifier node) { | 67 String getName(Identifier node) { |
| 68 var rename = scope.renames[identifierKey(node)]; | 68 var rename = scope.renames[identifierKey(node)]; |
| 69 if (rename != null) return rename; | 69 if (rename != null) return rename; |
| 70 return node.name; | 70 return node.name; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void enterScope(FunctionExpression node) { | 73 void enterScope(FunctionExpression node) { |
| 74 scope = scope.functions[node]; | 74 scope = scope.functions[node]; |
| 75 } | 75 } |
| 76 |
| 76 void leaveScope() { | 77 void leaveScope() { |
| 77 scope = scope.parent; | 78 scope = scope.parent; |
| 78 } | 79 } |
| 79 } | 80 } |
| 80 | 81 |
| 81 /// Represents a complete function scope in JS. | 82 /// Represents a complete function scope in JS. |
| 82 /// | 83 /// |
| 83 /// We don't currently track ES6 block scopes, because we don't represent them | 84 /// We don't currently track ES6 block scopes, because we don't represent them |
| 84 /// in js_ast yet. | 85 /// in js_ast yet. |
| 85 class _FunctionScope { | 86 class _FunctionScope { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 /// In particular, "caller" "callee" and "arguments" cannot be used. | 276 /// In particular, "caller" "callee" and "arguments" cannot be used. |
| 276 bool invalidStaticFieldName(String name) { | 277 bool invalidStaticFieldName(String name) { |
| 277 switch (name) { | 278 switch (name) { |
| 278 case "arguments": | 279 case "arguments": |
| 279 case "caller": | 280 case "caller": |
| 280 case "callee": | 281 case "callee": |
| 281 return true; | 282 return true; |
| 282 } | 283 } |
| 283 return false; | 284 return false; |
| 284 } | 285 } |
| OLD | NEW |