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 f1d4c5bb04fe6dd1ea4afdecb656901fe57a8e12..129b2c37858b929ee234e43bcd9e4ed3ec3d4323 100644 |
| --- a/pkg/compiler/lib/src/elements/modelx.dart |
| +++ b/pkg/compiler/lib/src/elements/modelx.dart |
| @@ -241,9 +241,45 @@ 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 _isJsInterop = false; |
| + bool get isJsInterop => _isJsInterop; |
|
Siggi Cherem (dart-lang)
2015/10/06 22:38:01
+ dartdoc
Jacob
2015/10/13 01:19:23
Done.
|
| + String get jsInteropName => _jsInteropName; |
|
Siggi Cherem (dart-lang)
2015/10/06 22:38:01
+ dartdoc
Jacob
2015/10/13 01:19:23
Done.
|
| + |
| + void setHasJsInterop() { |
|
Siggi Cherem (dart-lang)
2015/10/06 22:38:01
setIsJsInterop? (to match the field name)
markAsJ
Jacob
2015/10/13 01:19:22
Done.
|
| + _isJsInterop = true; |
| + } |
| + |
| + void setJsInteropName(String name) { |
| + assert(invariant(this, |
| + _isJsInterop, |
| + message: 'Element is not js interop but given a js interop name.')); |
| + _jsInteropName = name; |
| + } |
| + |
| + bool get isNative => _isNative || isJsInterop; |
|
Siggi Cherem (dart-lang)
2015/10/06 22:38:01
questions/comments here:
- now that this is more
Jacob
2015/10/13 01:19:23
There are a ton of places where the code paths are
|
| + bool get hasFixedBackendName => fixedBackendName != null || isJsInterop; |
| + |
| + String _jsNameHelper(Element e) { |
| + if (e.jsInteropName != null && e.jsInteropName.isNotEmpty) |
|
Siggi Cherem (dart-lang)
2015/10/06 22:38:01
style nit: add braces
Jacob
2015/10/13 01:19:22
Done.
|
| + return e.jsInteropName; |
| + return e.isLibrary ? 'self' : e.name; |
| + } |
| + |
| + String get fixedBackendName { |
| + if (_fixedBackendName != null) return _fixedBackendName; |
| + if (isJsInterop) { |
| + // If an element isJsInterop but _isJsInterop is false that means it is |
| + // considered interop as the parent class is interop. |
| + assert(invariant(this, |
| + !(_isJsInterop && _jsInteropName == null), |
|
Siggi Cherem (dart-lang)
2015/10/06 22:38:01
should the check here also involve isConstructor l
Jacob
2015/10/13 01:19:23
done.
|
| + message: 'Element is js interop but js interop name has not yet been' |
| + 'computed.')); |
|
sra1
2015/10/06 21:42:17
I'd try and indent this like
message:
' cccc
Jacob
2015/10/13 01:19:22
Done.
|
| + return _jsNameHelper(isConstructor ? enclosingClass : this); |
|
Siggi Cherem (dart-lang)
2015/10/06 22:38:01
could we memoize the result by writting _fixedBack
Jacob
2015/10/13 01:19:22
might as well. done.
|
| + } |
| + return null; |
| + } |
| + |
| // Marks this element as a native element. |
| void setNative(String name) { |
| _isNative = true; |
| @@ -1986,6 +2022,20 @@ abstract class BaseFunctionElementX |
| return functionSignatureCache; |
| } |
| + /** |
|
Siggi Cherem (dart-lang)
2015/10/06 22:38:01
nit, let's use /// (dart2js has both, but I'm tryi
Jacob
2015/10/13 01:19:22
Done.
|
| + * 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. |
|
Siggi Cherem (dart-lang)
2015/10/06 22:38:01
consider splitting the sentence into a set of bull
Jacob
2015/10/13 01:19:22
Done.
|
| + */ |
| + 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. |
| @@ -2605,7 +2655,7 @@ abstract class BaseClassElementX extends ElementX |
| return asInstanceOf(compiler.functionClass) != null || callType != null; |
| } |
| - bool get isNative => nativeTagInfo != null; |
| + bool get isNative => nativeTagInfo != null || isJsInterop; |
|
Siggi Cherem (dart-lang)
2015/10/06 22:38:01
same here
Jacob
2015/10/13 01:19:23
The comment for the superclass still applies here
|
| void setNative(String name) { |
| // TODO(johnniwinther): Assert that this is only called once. The memory |