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

Unified Diff: frog/gen.dart

Issue 8828008: Modification to the order that classes are printed out so that the prototype (Closed) Base URL: http://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 | « no previous file | frog/minfrog » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/gen.dart
===================================================================
--- frog/gen.dart (revision 2270)
+++ frog/gen.dart (working copy)
@@ -228,6 +228,15 @@
}
writeType(Type type) {
+ if (type.isWritten) return;
+
+ type.isWritten = true;
+ // Ensure parent has been written before the child. Important ordering for
+ // IE when we're using $inherits, since we don't have __proto__ available.
+ if (type.parent != null && !type.isNative) {
+ writeType(type.parent);
+ }
+
// TODO(jimhug): Workaround for problems with reified generic Array.
if (type.name != null && type is ConcreteType &&
type.library == world.coreimpl &&
@@ -247,6 +256,31 @@
}
}
+ // We need the $inherits function to be declared before factory constructors
+ // so that inheritance ($inherits) will work correctly in IE.
+ if (!type.isTop) {
+ if (type is ConcreteType) {
+ ConcreteType c = type;
+ corejs.ensureInheritsHelper();
+ writer.writeln('\$inherits(${c.jsname}, ${c.genericType.jsname});');
+
+ // Mixin members from concrete specializations of base types too.
+ // TODO(jmesserly): emit this sooner instead of at the end.
+ // But it needs to come after we've emitted both types.
+ // TODO(jmesserly): HACK: using _parent instead of parent so we don't
+ // try to inherit things that we didn't actually use.
+ for (var p = c._parent; p is ConcreteType; p = p._parent) {
+ _ensureInheritMembersHelper();
+ _mixins.writeln('\$inheritsMembers(${c.jsname}, ${p.jsname});');
+ }
+ } else if (!type.isNative) {
+ if (type.parent != null && !type.parent.isObject) {
+ corejs.ensureInheritsHelper();
+ writer.writeln('\$inherits(${type.jsname}, ${type.parent.jsname});');
+ }
+ }
+ }
+
if (type.isTop) {
// no preludes for top type
} else if (type.constructors.length == 0) {
@@ -272,29 +306,6 @@
}
}
- if (!type.isTop) {
- if (type is ConcreteType) {
- ConcreteType c = type;
- corejs.ensureInheritsHelper();
- writer.writeln('\$inherits(${c.jsname}, ${c.genericType.jsname});');
-
- // Mixin members from concrete specializations of base types too.
- // TODO(jmesserly): emit this sooner instead of at the end.
- // But it needs to come after we've emitted both types.
- // TODO(jmesserly): HACK: using _parent instead of parent so we don't
- // try to inherit things that we didn't actually use.
- for (var p = c._parent; p is ConcreteType; p = p._parent) {
- _ensureInheritMembersHelper();
- _mixins.writeln('\$inheritsMembers(${c.jsname}, ${p.jsname});');
- }
- } else if (!type.isNative) {
- if (type.parent != null && !type.parent.isObject) {
- corejs.ensureInheritsHelper();
- writer.writeln('\$inherits(${type.jsname}, ${type.parent.jsname});');
- }
- }
- }
-
// Concrete types (like List<String>) will have this already defined on
// their prototype from the generic type (like List)
if (type is! ConcreteType) {
« no previous file with comments | « no previous file | frog/minfrog » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698