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 import 'dart:collection'; | 5 import 'dart:collection'; |
6 | 6 |
7 import '../js/js_ast.dart'; | 7 import '../js/js_ast.dart'; |
| 8 import 'package:dev_compiler/src/options.dart'; |
8 | 9 |
9 /// Unique instance for temporary variables. Will be renamed consistently | 10 /// Unique instance for temporary variables. Will be renamed consistently |
10 /// across the entire file. Different instances will be named differently | 11 /// across the entire file. Different instances will be named differently |
11 /// even if they have the same name, this makes it safe to use in code | 12 /// even if they have the same name, this makes it safe to use in code |
12 /// generation without needing global knowledge. See [JSNamer]. | 13 /// generation without needing global knowledge. See [JSNamer]. |
13 /// | 14 /// |
14 // TODO(jmesserly): move into js_ast? add a boolean to Identifier? | 15 // TODO(jmesserly): move into js_ast? add a boolean to Identifier? |
15 class TemporaryId extends Identifier { | 16 class TemporaryId extends Identifier { |
16 TemporaryId(String name) : super(name); | 17 TemporaryId(String name) : super(name); |
17 } | 18 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 /// In particular, "caller" "callee" and "arguments" cannot be used. | 288 /// In particular, "caller" "callee" and "arguments" cannot be used. |
288 bool invalidStaticFieldName(String name) { | 289 bool invalidStaticFieldName(String name) { |
289 switch (name) { | 290 switch (name) { |
290 case "arguments": | 291 case "arguments": |
291 case "caller": | 292 case "caller": |
292 case "callee": | 293 case "callee": |
293 return true; | 294 return true; |
294 } | 295 } |
295 return false; | 296 return false; |
296 } | 297 } |
| 298 |
| 299 /// We cannot destructure named params that clash with JS reserved names: |
| 300 /// see discussion in https://github.com/dart-lang/dev_compiler/issues/392. |
| 301 bool canDestructureNamedParams(Iterable<String> names, CodegenOptions options) { |
| 302 return options.destructureNamedParams && !names.any(invalidVariableName); |
| 303 } |
OLD | NEW |