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_ast/js_ast.dart'; |
8 import 'package:dev_compiler/src/options.dart'; | |
9 | 8 |
10 /// Unique instance for temporary variables. Will be renamed consistently | 9 /// Unique instance for temporary variables. Will be renamed consistently |
11 /// across the entire file. Different instances will be named differently | 10 /// across the entire file. Different instances will be named differently |
12 /// even if they have the same name, this makes it safe to use in code | 11 /// even if they have the same name, this makes it safe to use in code |
13 /// generation without needing global knowledge. See [JSNamer]. | 12 /// generation without needing global knowledge. See [TemporaryNamer]. |
14 /// | |
15 // TODO(jmesserly): move into js_ast? add a boolean to Identifier? | 13 // TODO(jmesserly): move into js_ast? add a boolean to Identifier? |
16 class TemporaryId extends Identifier { | 14 class TemporaryId extends Identifier { |
17 TemporaryId(String name) : super(name); | 15 TemporaryId(String name) : super(name); |
18 } | 16 } |
19 | 17 |
20 /// Creates a qualified identifier, without determining for sure if it needs to | 18 /// Creates a qualified identifier, without determining for sure if it needs to |
21 /// be qualified until [setQualified] is called. | 19 /// be qualified until [setQualified] is called. |
22 /// | 20 /// |
23 /// This expression is transparent to visiting after [setQualified]. | 21 /// This expression is transparent to visiting after [setQualified]. |
24 class MaybeQualifiedId extends Expression { | 22 class MaybeQualifiedId extends Expression { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 /// In particular, "caller" "callee" and "arguments" cannot be used. | 286 /// In particular, "caller" "callee" and "arguments" cannot be used. |
289 bool invalidStaticFieldName(String name) { | 287 bool invalidStaticFieldName(String name) { |
290 switch (name) { | 288 switch (name) { |
291 case "arguments": | 289 case "arguments": |
292 case "caller": | 290 case "caller": |
293 case "callee": | 291 case "callee": |
294 return true; | 292 return true; |
295 } | 293 } |
296 return false; | 294 return false; |
297 } | 295 } |
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 |