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 | 8 |
9 import '../js/js_ast.dart'; | 9 import '../js/js_ast.dart'; |
10 | 10 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 case "public": | 280 case "public": |
281 case "static": | 281 case "static": |
282 case "yield": | 282 case "yield": |
283 return strictMode; | 283 return strictMode; |
284 } | 284 } |
285 return false; | 285 return false; |
286 } | 286 } |
287 | 287 |
288 /// Returns true for invalid static field names in strict mode. | 288 /// Returns true for invalid static field names in strict mode. |
289 /// In particular, "caller" "callee" and "arguments" cannot be used. | 289 /// In particular, "caller" "callee" and "arguments" cannot be used. |
290 bool invalidStaticFieldName(String name) { | 290 /// |
| 291 /// [closureCompiler] marks some names as invalid for the purpose of ES6->ES5 |
| 292 /// lowering with the Closure Compiler. |
| 293 bool invalidStaticFieldName(String name, {bool closureCompiler: false}) { |
291 switch (name) { | 294 switch (name) { |
292 case "arguments": | 295 case "arguments": |
293 case "caller": | 296 case "caller": |
294 case "callee": | 297 case "callee": |
295 return true; | 298 return true; |
| 299 // Workarounds for Closure: |
| 300 // (see https://github.com/google/closure-compiler/issues/1460) |
| 301 case "name": |
| 302 case "length": |
| 303 return closureCompiler; |
296 } | 304 } |
297 return false; | 305 return false; |
298 } | 306 } |
OLD | NEW |