Chromium Code Reviews| Index: frog/gen.dart |
| =================================================================== |
| --- frog/gen.dart (revision 2156) |
| +++ frog/gen.dart (working copy) |
| @@ -228,6 +228,14 @@ |
| } |
| writeType(Type type) { |
| + if (type.isWritten) return; |
| + |
| + type.isWritten = true; |
| + // Ensure parent has been written before the child. Important ordering for |
| + // IE. |
|
Jennifer Messerly
2011/12/08 18:43:52
might want to add a note that this is for the $inh
|
| + if (type.parent != null && !type.isNative) |
|
Jennifer Messerly
2011/12/08 18:43:52
style nit: add { } around the body unless the enti
|
| + 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 +255,29 @@ |
| } |
| } |
| + if (!type.isTop) { |
|
Jennifer Messerly
2011/12/08 18:43:52
maybe add a note here that $inherits needs to come
|
| + 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 +303,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) { |