Chromium Code Reviews| 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'$')); |