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

Unified Diff: frog/world.dart

Issue 8985010: Move tests using frog 'native' extension from tests/language to frog/tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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
« no previous file with comments | « frog/tests/frog/src/NativePropertyFrogTest.dart ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/world.dart
diff --git a/frog/world.dart b/frog/world.dart
index 0d633d06e3b9f291c375196c1f255b7233a2cccd..77876c051bfe234de35441cecd6632029744cee9 100644
--- a/frog/world.dart
+++ b/frog/world.dart
@@ -162,6 +162,49 @@ class World {
}
_addTopName(Element named) {
+ // What makes this method so complicated is that it is incremental. It
+ // would me much simpler if the names could be added in priority order,
+ // e.g. native classes, library classes and finally user code.
+
+ if (named.isNative && named is Type) {
+ // Hidden native classes have two names: a native name that should be
+ // avoided since it might not actually be hidden, and a jsname that is
+ // used for class data, e.g. static members.
+ //
+ // Consider:
+ //
+ // #library('public');
+ // interface DOMWindow { ... }
+ // #library('impl');
+ // class DOMWindow implements public.DOMWindow native '*DOMWindow' { }
+ // #library('proxy');
+ // class DOMWindow implements public.DOMWindow { ... }
+ //
+ // The global name 'DOMWindow' is reserved for the native implementation,
+ // so the others all need to be renamed to avoid conflict.
+
+ Type namedType = named;
+ if (namedType.isHiddenNativeType) {
+ var nativeName = namedType.definition.nativeType.name;
+ var existing = _topNames[nativeName];
+ if (existing != null) {
+ if (existing.isNative) {
+ world.internalError('conflicting native names "${named.jsname}" '
+ + '(already defined in ${existing.span.locationText})',
+ named.span);
+ } else {
+ _addJavascriptTopName(existing); // Rename conflicting type.
+ }
+ }
+ _topNames[nativeName] = named;
+ if (nativeName == named.jsname) {
+ // class X native '*X' {} - need to rename the jsname.
+ _addJavascriptTopName(named);
+ return;
+ }
+ }
+ }
+
var existing = _topNames[named.jsname];
if (existing != null) {
info('mangling matching top level name "${named.jsname}" in '
« no previous file with comments | « frog/tests/frog/src/NativePropertyFrogTest.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698