Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Top level generator object for writing code and keeping track of | 6 * Top level generator object for writing code and keeping track of |
| 7 * dependencies. | 7 * dependencies. |
| 8 * | 8 * |
| 9 * Should have two compilation models, but only one implemented so far. | 9 * Should have two compilation models, but only one implemented so far. |
| 10 * | 10 * |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 var filename = basename(file.filename); | 158 var filename = basename(file.filename); |
| 159 writer.comment('// ********** Natives $filename **************'); | 159 writer.comment('// ********** Natives $filename **************'); |
| 160 writer.writeln(file.text); | 160 writer.writeln(file.text); |
| 161 } | 161 } |
| 162 lib.topType.markUsed(); // TODO(jimhug): EGREGIOUS HACK | 162 lib.topType.markUsed(); // TODO(jimhug): EGREGIOUS HACK |
| 163 | 163 |
| 164 for (var type in _orderValues(lib.types)) { | 164 for (var type in _orderValues(lib.types)) { |
| 165 // TODO(jmesserly): we can't accurately track if DOM types are | 165 // TODO(jmesserly): we can't accurately track if DOM types are |
| 166 // created or not, so we need to prepare to handle them. | 166 // created or not, so we need to prepare to handle them. |
| 167 // This should be fixed by tightening up the return types in DOM. | 167 // This should be fixed by tightening up the return types in DOM. |
| 168 if ((type.isUsed || type.isHiddenNativeType) && type.isClass) { | 168 if ((type.isUsed || type.library == world.dom |
|
sra1
2011/12/08 22:04:32
I assume isUsed get set when a subclass is used?
Jennifer Messerly
2011/12/08 22:17:48
Maybe. The "hidden" bit isn't really related, thou
| |
| 169 || type.isHiddenNativeType) && type.isClass) { | |
| 169 writeType(type); | 170 writeType(type); |
| 170 | 171 |
| 171 if (type.isGeneric) { | 172 if (type.isGeneric) { |
| 172 for (var ct in _orderValues(type._concreteTypes)) { | 173 for (var ct in _orderValues(type._concreteTypes)) { |
| 173 writeType(ct); | 174 writeType(ct); |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 } else if (type.isFunction && type.varStubs.length > 0) { | 177 } else if (type.isFunction && type.varStubs.length > 0) { |
| 177 // Emit stubs on "Function" or hidden types if needed | 178 // Emit stubs on "Function" or hidden types if needed |
| 178 writer.comment('// ********** Code for ${type.jsname} **************'); | 179 writer.comment('// ********** Code for ${type.jsname} **************'); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 _ensureInheritMembersHelper(); | 274 _ensureInheritMembersHelper(); |
| 274 _mixins.writeln('\$inheritsMembers(${c.jsname}, ${p.jsname});'); | 275 _mixins.writeln('\$inheritsMembers(${c.jsname}, ${p.jsname});'); |
| 275 } | 276 } |
| 276 } else if (!type.isNative) { | 277 } else if (!type.isNative) { |
| 277 if (type.parent != null && !type.parent.isObject) { | 278 if (type.parent != null && !type.parent.isObject) { |
| 278 corejs.ensureInheritsHelper(); | 279 corejs.ensureInheritsHelper(); |
| 279 writer.writeln('\$inherits(${type.jsname}, ${type.parent.jsname});'); | 280 writer.writeln('\$inherits(${type.jsname}, ${type.parent.jsname});'); |
| 280 } | 281 } |
| 281 } | 282 } |
| 282 } | 283 } |
| 283 | 284 |
| 284 if (type.isTop) { | 285 if (type.isTop) { |
| 285 // no preludes for top type | 286 // no preludes for top type |
| 286 } else if (type.constructors.length == 0) { | 287 } else if (type.constructors.length == 0) { |
| 287 if (!type.isNative) { | 288 if (!type.isNative) { |
| 288 // TODO(jimhug): More guards to guarantee staticness | 289 // TODO(jimhug): More guards to guarantee staticness |
| 289 writer.writeln('function ${type.jsname}() {}'); | 290 writer.writeln('function ${type.jsname}() {}'); |
| 290 } | 291 } |
| 291 } else { | 292 } else { |
| 292 Member standardConstructor = type.constructors['']; | 293 Member standardConstructor = type.constructors['']; |
| 293 if (standardConstructor == null || | 294 if (standardConstructor == null || |
| (...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2498 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); | 2499 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); |
| 2499 } | 2500 } |
| 2500 for (int i = bareCount; i < length; i++) { | 2501 for (int i = bareCount; i < length; i++) { |
| 2501 var name = getName(i); | 2502 var name = getName(i); |
| 2502 if (name == null) name = '\$$i'; | 2503 if (name == null) name = '\$$i'; |
| 2503 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); | 2504 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); |
| 2504 } | 2505 } |
| 2505 return new Arguments(nodes, result); | 2506 return new Arguments(nodes, result); |
| 2506 } | 2507 } |
| 2507 } | 2508 } |
| OLD | NEW |