Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Generates the code for all used classes in the program. Static fields (even | 8 * Generates the code for all used classes in the program. Static fields (even |
| 9 * in classes) are ignored, since they can be treated as non-class elements. | 9 * in classes) are ignored, since they can be treated as non-class elements. |
| 10 * | 10 * |
| (...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1497 ConstantHandler handler = compiler.constantHandler; | 1497 ConstantHandler handler = compiler.constantHandler; |
| 1498 List<Constant> constants = handler.getConstantsForEmission(); | 1498 List<Constant> constants = handler.getConstantsForEmission(); |
| 1499 for (Constant constant in constants) { | 1499 for (Constant constant in constants) { |
| 1500 if (constant is TypeConstant) { | 1500 if (constant is TypeConstant) { |
| 1501 TypeConstant typeConstant = constant; | 1501 TypeConstant typeConstant = constant; |
| 1502 Element element = typeConstant.representedType.element; | 1502 Element element = typeConstant.representedType.element; |
| 1503 if (element is ClassElement) { | 1503 if (element is ClassElement) { |
| 1504 ClassElement classElement = element; | 1504 ClassElement classElement = element; |
| 1505 elements.add(backend.emitter.constantReference(constant)); | 1505 elements.add(backend.emitter.constantReference(constant)); |
| 1506 elements.add(js(namer.isolateAccess(classElement))); | 1506 elements.add(js(namer.isolateAccess(classElement))); |
| 1507 | |
| 1508 // Create JavaScript Object map for by-name lookup of generative | |
|
kasperl
2013/10/04 11:08:43
Can we avoid this if document.register isn't being
sra1
2013/10/04 20:21:28
It would be slightly more complicated than that -
| |
| 1509 // constructors. | |
| 1510 var properties = []; | |
| 1511 classElement.forEachMember( | |
| 1512 (ClassElement enclosingClass, Element member) { | |
| 1513 if (member.isGenerativeConstructor()) { | |
| 1514 properties.add( | |
| 1515 new jsAst.Property( | |
| 1516 js.string(member.name.slowToString()), | |
| 1517 new jsAst.VariableUse( | |
| 1518 backend.namer.isolateAccess(member)))); | |
| 1519 } | |
| 1520 }, | |
| 1521 includeBackendMembers: false, | |
| 1522 includeSuperAndInjectedMembers: false); | |
| 1523 | |
| 1524 var map = new jsAst.ObjectInitializer(properties); | |
| 1525 elements.add(map); | |
| 1507 } | 1526 } |
| 1508 } | 1527 } |
| 1509 } | 1528 } |
| 1510 | 1529 |
| 1511 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer.from(elements); | 1530 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer.from(elements); |
| 1512 String name = | 1531 String name = |
| 1513 backend.namer.getNameOfGlobalField(backend.mapTypeToInterceptor); | 1532 backend.namer.getNameOfGlobalField(backend.mapTypeToInterceptor); |
| 1514 jsAst.Expression assignment = js('$isolateProperties.$name = #', array); | 1533 jsAst.Expression assignment = js('$isolateProperties.$name = #', array); |
| 1515 | 1534 |
| 1516 buffer.write(jsAst.prettyPrint(assignment, compiler)); | 1535 buffer.write(jsAst.prettyPrint(assignment, compiler)); |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2112 return compiler.deferredLoadTask.isDeferred(element); | 2131 return compiler.deferredLoadTask.isDeferred(element); |
| 2113 } | 2132 } |
| 2114 | 2133 |
| 2115 bool get areAnyElementsDeferred { | 2134 bool get areAnyElementsDeferred { |
| 2116 return compiler.deferredLoadTask.areAnyElementsDeferred; | 2135 return compiler.deferredLoadTask.areAnyElementsDeferred; |
| 2117 } | 2136 } |
| 2118 } | 2137 } |
| 2119 | 2138 |
| 2120 // TODO(ahe): Move code for interceptors to own file. | 2139 // TODO(ahe): Move code for interceptors to own file. |
| 2121 // TODO(ahe): Move code for reifying metadata/types to own file. | 2140 // TODO(ahe): Move code for reifying metadata/types to own file. |
| OLD | NEW |