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; | 7 import 'dart:collection' show HashSet, HashMap; |
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 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1040 // Get the original declaring element. If we had a property accessor, this | 1040 // Get the original declaring element. If we had a property accessor, this |
1041 // indirects back to a (possibly synthetic) field. | 1041 // indirects back to a (possibly synthetic) field. |
1042 var element = accessor; | 1042 var element = accessor; |
1043 if (element is PropertyAccessorElement) element = accessor.variable; | 1043 if (element is PropertyAccessorElement) element = accessor.variable; |
1044 var name = element.name; | 1044 var name = element.name; |
1045 | 1045 |
1046 // library member | 1046 // library member |
1047 if (element.enclosingElement is CompilationUnitElement && | 1047 if (element.enclosingElement is CompilationUnitElement && |
1048 (element.library != libraryInfo.library || | 1048 (element.library != libraryInfo.library || |
1049 element is TopLevelVariableElement && !element.isConst)) { | 1049 element is TopLevelVariableElement && !element.isConst)) { |
1050 return js.call('#.#', [_libraryName(element.library), name]); | 1050 dynamic memberName = name; |
vsm
2015/04/24 00:12:11
Note: this is to map exports._foo as exports[_foo]
Jennifer Messerly
2015/04/24 00:43:14
Interesting, how is that used? Would anybody have
vsm
2015/04/24 13:25:44
Yes, I was hitting this in angular (application.js
Jennifer Messerly
2015/04/24 21:23:23
Aha, lazy top-level field. Interesting. I suppose
vsm
2015/05/01 17:24:12
Not sure I still need this with your recent change
| |
1051 if (name.startsWith('_')) { | |
Jennifer Messerly
2015/04/24 21:23:23
in the if body:
assert(element.library == current
Jennifer Messerly
2015/04/24 21:25:13
Maybe won't need with emitMemberName suggestion th
| |
1052 memberName = _privateNames.putIfAbsent( | |
Jennifer Messerly
2015/04/24 21:23:23
Maybe should go through emitMemberName then, with
| |
1053 name, () => _initSymbol(new JSTemporary(name))); | |
1054 } | |
1055 return js.call('#.#', [_libraryName(element.library), memberName]); | |
1051 } | 1056 } |
1052 | 1057 |
1053 // Unqualified class member. This could mean implicit-this, or implicit | 1058 // Unqualified class member. This could mean implicit-this, or implicit |
1054 // call to a static from the same class. | 1059 // call to a static from the same class. |
1055 if (element is ClassMemberElement && element is! ConstructorElement) { | 1060 if (element is ClassMemberElement && element is! ConstructorElement) { |
1056 bool isStatic = element.isStatic; | 1061 bool isStatic = element.isStatic; |
1057 var type = element.enclosingElement.type; | 1062 var type = element.enclosingElement.type; |
1058 var member = _emitMemberName(name, isStatic: isStatic, type: type); | 1063 var member = _emitMemberName(name, isStatic: isStatic, type: type); |
1059 | 1064 |
1060 // For static methods, we add the raw type name, without generics or | 1065 // For static methods, we add the raw type name, without generics or |
(...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2508 // TODO(jmesserly): validate the library. See issue #135. | 2513 // TODO(jmesserly): validate the library. See issue #135. |
2509 bool _isJsNameAnnotation(DartObjectImpl value) => value.type.name == 'JsName'; | 2514 bool _isJsNameAnnotation(DartObjectImpl value) => value.type.name == 'JsName'; |
2510 | 2515 |
2511 bool _isJsPeerInterface(DartObjectImpl value) => | 2516 bool _isJsPeerInterface(DartObjectImpl value) => |
2512 value.type.name == 'JsPeerInterface'; | 2517 value.type.name == 'JsPeerInterface'; |
2513 | 2518 |
2514 // TODO(jacobr): we would like to do something like the following | 2519 // TODO(jacobr): we would like to do something like the following |
2515 // but we don't have summary support yet. | 2520 // but we don't have summary support yet. |
2516 // bool _supportJsExtensionMethod(AnnotatedNode node) => | 2521 // bool _supportJsExtensionMethod(AnnotatedNode node) => |
2517 // _getAnnotation(node, "SupportJsExtensionMethod") != null; | 2522 // _getAnnotation(node, "SupportJsExtensionMethod") != null; |
OLD | NEW |