Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: pkg/compiler/lib/src/js_backend/namer.dart

Issue 1318043005: Support user generated custom native JS classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: ptal Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/js_backend/namer.dart
diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart
index 14a399cd8aa583160559ad3e438647b9e1f8f7ee..43ba0e16bc7003373a0c68d8180091e3dad59a2a 100644
--- a/pkg/compiler/lib/src/js_backend/namer.dart
+++ b/pkg/compiler/lib/src/js_backend/namer.dart
@@ -634,6 +634,26 @@ class Namer {
return invocationName(new Selector.fromElement(method));
}
+ String _jsNameHelper(Element e) {
+ if (e.jsInteropName != null && e.jsInteropName.isNotEmpty)
+ return e.jsInteropName;
+ return e.isLibrary ? 'self' : e.name;
+ }
+
+ String fixedBackendPath(Element element) {
Siggi Cherem (dart-lang) 2015/10/06 22:38:02 + dartdoc?
Jacob 2015/10/13 01:19:23 Done.
+ if (!element.isJsInterop) return null;
+ if (element.isInstanceMember) return 'this';
+ if (element.isConstructor) return fixedBackendPath(element.enclosingClass);
+ if (element.isLibrary) return 'self';
+ var sb = new StringBuffer();
+ sb..write(_jsNameHelper(element.library));
+
+ if (element.enclosingClass != null && element.enclosingClass != element) {
+ sb..write('.')..write(_jsNameHelper(element.enclosingClass));
+ }
+ return sb.toString();
+ }
+
/// Returns the annotated name for a variant of `call`.
/// The result has the form:
///
@@ -765,6 +785,7 @@ class Namer {
if (element.hasFixedBackendName) {
// Certain native fields must be given a specific name. Native names must
// not contain '$'. We rely on this to avoid clashes.
+ // TODO(jacobr): we need to relax this constraint.
Siggi Cherem (dart-lang) 2015/10/06 22:38:02 please file a bug to refer to it here.
Jacob 2015/10/13 01:19:23 synced with sra and we decided this assert can be
assert(enclosingClass.isNative &&
!element.fixedBackendName.contains(r'$'));

Powered by Google App Engine
This is Rietveld 408576698