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..b2635298980bfd5520e49792c3de2d67e2ae8c30 100644 |
| --- a/pkg/compiler/lib/src/elements/modelx.dart |
| +++ b/pkg/compiler/lib/src/elements/modelx.dart |
| @@ -225,9 +225,38 @@ 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 get fixedBackendName { |
| + if (_fixedBackendName != null) return _fixedBackendName; |
| + if (isJsInterop) { |
| + String nameHelper(e) { |
| + if (e._jsInteropName != null && e._jsInteropName.isNotEmpty) |
| + return e._jsInteropName; |
| + return e.isLibrary ? 'self' : e.name; |
| + } |
| + |
| + var sb = new StringBuffer(); |
| + if (!isLibrary && !isInstanceMember) { |
| + sb..write(nameHelper(library))..write('.'); |
| + if (enclosingClass != null && enclosingClass != this) { |
| + sb.write(nameHelper(enclosingClass)); |
| + if (!isConstructor) sb.write('.'); |
| + } |
| + } |
| + if (!isConstructor) sb.write(nameHelper(this)); |
|
Siggi Cherem (dart-lang)
2015/09/18 20:34:10
are named constructors not supported?
Jacob
2015/10/01 00:47:33
they are supported.
Suppose you have a JavaScript
|
| + return sb.toString(); |
| + } |
| + return null; |
| + } |
| + |
| // Marks this element as a native element. |
| void setNative(String name) { |
| _isNative = true; |
| @@ -1802,6 +1831,18 @@ 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 (super.isJsInterop) return true; |
|
Siggi Cherem (dart-lang)
2015/09/18 20:34:10
are there any cases where this is true if the two
Jacob
2015/10/01 00:47:33
yes. super.isJsInterop checks whether the member i
|
| + if (isClassMember) return contextClass.isJsInterop && isExternal; |
|
Siggi Cherem (dart-lang)
2015/09/18 20:34:10
it might be worth checking for isExternal upfront,
Jacob
2015/10/01 00:47:33
done.
|
| + if (isTopLevel) return library.isJsInterop && isExternal; |
| + return false; |
| + } |
| + |
| List<ParameterElement> get parameters { |
| // TODO(johnniwinther): Store the list directly, possibly by using List |
| // instead of Link in FunctionSignature. |
| @@ -2419,7 +2460,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 |