Chromium Code Reviews| Index: pkg/compiler/lib/src/elements/modelx.dart |
| diff --git a/pkg/compiler/lib/src/elements/modelx.dart b/pkg/compiler/lib/src/elements/modelx.dart |
| index 65742316c66ff25e990a162e3b8f69e1f1b68f9f..7898653b4e676ffafb619600c7f7b2818b8edfc3 100644 |
| --- a/pkg/compiler/lib/src/elements/modelx.dart |
| +++ b/pkg/compiler/lib/src/elements/modelx.dart |
| @@ -225,9 +225,43 @@ abstract class ElementX extends Element with ElementCommon { |
| String _fixedBackendName = null; |
| bool _isNative = false; |
| - bool get isNative => _isNative; |
| - bool get hasFixedBackendName => _fixedBackendName != null; |
| - String get fixedBackendName => _fixedBackendName; |
| + String _jsInteropName = null; |
| + |
| + bool get isJsInterop => _jsInteropName != null; |
| + |
| + void setJsInterop(String name) { _jsInteropName = name; } |
| + |
| + bool get isNative => _isNative || isJsInterop; |
| + bool get hasFixedBackendName => fixedBackendName != null || isJsInterop; |
| + |
| + String _jsNameHelper(e) { |
|
sra1
2015/10/01 20:55:27
Element e
or some more specific type.
Jacob
2015/10/02 20:08:15
Done.
|
| + if (e._jsInteropName != null && e._jsInteropName.isNotEmpty) |
| + return e._jsInteropName; |
| + return e.isLibrary ? 'self' : e.name; |
| + } |
| + |
| + String get fixedBackendName { |
| + if (_fixedBackendName != null) return _fixedBackendName; |
| + if (isJsInterop) { |
| + return _jsNameHelper(isConstructor ? enclosingClass : this); |
| + } |
| + return null; |
| + } |
| + |
| + String get fixedBackendReceiver { |
|
sra1
2015/10/01 20:55:27
All this 'backend' logic must be in the js_backend
Jacob
2015/10/02 20:08:15
moved to js_backend/namer.dart
|
| + if (!isJsInterop) return null; |
| + if (isInstanceMember) return 'this'; |
| + if (isConstructor) return enclosingClass.fixedBackendReceiver; |
| + if (isLibrary) return 'self'; |
| + var sb = new StringBuffer(); |
| + sb..write(_jsNameHelper(library)); |
| + |
| + if (enclosingClass != null && enclosingClass != this) { |
| + sb..write('.')..write(_jsNameHelper(enclosingClass)); |
| + } |
| + return sb.toString(); |
|
sra1
2015/10/01 20:55:27
So what is this computing?
Jacob
2015/10/02 20:08:15
discussed offline and changed name to
fixedBacken
|
| + } |
| + |
| // Marks this element as a native element. |
| void setNative(String name) { |
| _isNative = true; |
| @@ -1802,6 +1836,20 @@ abstract class BaseFunctionElementX |
| return functionSignatureCache; |
| } |
| + /** |
| + * An function is part of JsInterop if it has a jsInteropName annotation or it |
| + * is an external class or top level member of a class or library tagged as |
| + * JsInterop. |
| + */ |
| + bool get isJsInterop { |
| + if (!isExternal) return false; |
| + |
| + if (super.isJsInterop) return true; |
| + if (isClassMember) return contextClass.isJsInterop; |
| + if (isTopLevel) return library.isJsInterop; |
| + return false; |
| + } |
| + |
| List<ParameterElement> get parameters { |
| // TODO(johnniwinther): Store the list directly, possibly by using List |
| // instead of Link in FunctionSignature. |
| @@ -2419,7 +2467,7 @@ abstract class BaseClassElementX extends ElementX |
| return asInstanceOf(compiler.functionClass) != null || callType != null; |
| } |
| - bool get isNative => nativeTagInfo != null; |
| + bool get isNative => nativeTagInfo != null || isJsInterop; |
| void setNative(String name) { |
| // TODO(johnniwinther): Assert that this is only called once. The memory |