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_codegen; | 5 library dev_compiler.src.codegen.js_codegen; |
6 | 6 |
7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; | 7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; |
8 | 8 |
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; | 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; |
(...skipping 3405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3416 name = 'set'; | 3416 name = 'set'; |
3417 } else if (name == '-' && unary) { | 3417 } else if (name == '-' && unary) { |
3418 name = 'unary-'; | 3418 name = 'unary-'; |
3419 } else if (name == 'constructor' || name == 'prototype') { | 3419 } else if (name == 'constructor' || name == 'prototype') { |
3420 // This uses an illegal (in Dart) character for a member, avoiding the | 3420 // This uses an illegal (in Dart) character for a member, avoiding the |
3421 // conflict. We could use practically any character for this. | 3421 // conflict. We could use practically any character for this. |
3422 name = '+$name'; | 3422 name = '+$name'; |
3423 } | 3423 } |
3424 | 3424 |
3425 // Dart "extension" methods. Used for JS Array, Boolean, Number, String. | 3425 // Dart "extension" methods. Used for JS Array, Boolean, Number, String. |
| 3426 var baseType = type; |
| 3427 while (baseType is TypeParameterType) { |
| 3428 baseType = baseType.element.bound; |
| 3429 } |
3426 if (allowExtensions && | 3430 if (allowExtensions && |
3427 _extensionTypes.contains(type.element) && | 3431 _extensionTypes.contains(baseType.element) && |
3428 !_isObjectProperty(name)) { | 3432 !_isObjectProperty(name)) { |
3429 return js.call('dartx.#', _propertyName(name)); | 3433 return js.call('dartx.#', _propertyName(name)); |
3430 } | 3434 } |
3431 | 3435 |
3432 return _propertyName(name); | 3436 return _propertyName(name); |
3433 } | 3437 } |
3434 | 3438 |
3435 bool _externalOrNative(node) => | 3439 bool _externalOrNative(node) => |
3436 node.externalKeyword != null || _functionBody(node) is NativeFunctionBody; | 3440 node.externalKeyword != null || _functionBody(node) is NativeFunctionBody; |
3437 | 3441 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3616 | 3620 |
3617 /// A special kind of element created by the compiler, signifying a temporary | 3621 /// A special kind of element created by the compiler, signifying a temporary |
3618 /// variable. These objects use instance equality, and should be shared | 3622 /// variable. These objects use instance equality, and should be shared |
3619 /// everywhere in the tree where they are treated as the same variable. | 3623 /// everywhere in the tree where they are treated as the same variable. |
3620 class TemporaryVariableElement extends LocalVariableElementImpl { | 3624 class TemporaryVariableElement extends LocalVariableElementImpl { |
3621 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); | 3625 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); |
3622 | 3626 |
3623 int get hashCode => identityHashCode(this); | 3627 int get hashCode => identityHashCode(this); |
3624 bool operator ==(Object other) => identical(this, other); | 3628 bool operator ==(Object other) => identical(this, other); |
3625 } | 3629 } |
OLD | NEW |