Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 class OldEmitter implements Emitter { | 8 class OldEmitter implements Emitter { |
| 9 final Compiler compiler; | 9 final Compiler compiler; |
| 10 final CodeEmitterTask task; | 10 final CodeEmitterTask task; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 | 150 |
| 151 String get finishIsolateConstructorName | 151 String get finishIsolateConstructorName |
| 152 => '${namer.isolateName}.\$finishIsolateConstructor'; | 152 => '${namer.isolateName}.\$finishIsolateConstructor'; |
| 153 String get isolatePropertiesName | 153 String get isolatePropertiesName |
| 154 => '${namer.isolateName}.${namer.isolatePropertiesName}'; | 154 => '${namer.isolateName}.${namer.isolatePropertiesName}'; |
| 155 String get lazyInitializerProperty | 155 String get lazyInitializerProperty |
| 156 => r'$lazy'; | 156 => r'$lazy'; |
| 157 String get lazyInitializerName | 157 String get lazyInitializerName |
| 158 => '${namer.isolateName}.${lazyInitializerProperty}'; | 158 => '${namer.isolateName}.${lazyInitializerProperty}'; |
| 159 String get initName => 'init'; | 159 String get initName => 'init'; |
| 160 // TODO(zarah): Rename this when renaming reflection_data_parser.dart. | |
| 161 String get parseReflectionDataName => 'parseReflectionData'; | |
| 160 String get makeConstListProperty | 162 String get makeConstListProperty |
| 161 => namer.getMappedInstanceName('makeConstantList'); | 163 => namer.getMappedInstanceName('makeConstantList'); |
| 162 | 164 |
| 163 /// The name of the property that contains all field names. | 165 /// The name of the property that contains all field names. |
| 164 /// | 166 /// |
| 165 /// This property is added to constructors when isolate support is enabled. | 167 /// This property is added to constructors when isolate support is enabled. |
| 166 static const String FIELD_NAMES_PROPERTY_NAME = r"$__fields__"; | 168 static const String FIELD_NAMES_PROPERTY_NAME = r"$__fields__"; |
| 167 | 169 |
| 168 /// For deferred loading we communicate the initializers via this global var. | 170 /// For deferred loading we communicate the initializers via this global var. |
| 169 final String deferredInitializers = r"$dart_deferred_initializers"; | 171 final String deferredInitializers = r"$dart_deferred_initializers"; |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1493 mainBuffer.write('${globalsHolder}.$globalObject$_=${_}'); | 1495 mainBuffer.write('${globalsHolder}.$globalObject$_=${_}'); |
| 1494 } | 1496 } |
| 1495 mainBuffer.write('new dart$N'); | 1497 mainBuffer.write('new dart$N'); |
| 1496 } | 1498 } |
| 1497 | 1499 |
| 1498 mainBuffer.write('function ${namer.isolateName}()$_{}\n'); | 1500 mainBuffer.write('function ${namer.isolateName}()$_{}\n'); |
| 1499 if (isProgramSplit) { | 1501 if (isProgramSplit) { |
| 1500 mainBuffer | 1502 mainBuffer |
| 1501 .write('${globalsHolder}.${namer.isolateName}$_=$_' | 1503 .write('${globalsHolder}.${namer.isolateName}$_=$_' |
| 1502 '${namer.isolateName}$N' | 1504 '${namer.isolateName}$N' |
| 1503 '${globalsHolder}.$initName$_=${_}$initName$N'); | 1505 '${globalsHolder}.$initName$_=${_}$initName$N' |
| 1506 '${globalsHolder}.$parseReflectionDataName$_=$_' | |
| 1507 '$parseReflectionDataName$N'); | |
|
floitsch
2015/01/05 13:46:19
indent that line.
zarah
2015/01/05 14:00:26
OK, then I'm also indenting the one two lines abov
floitsch
2015/01/05 14:41:07
or even better:
mainBuffer.write(
'${globalsH
zarah
2015/01/06 11:45:07
Done.
| |
| 1504 } | 1508 } |
| 1505 mainBuffer.write('init()$N$n'); | 1509 mainBuffer.write('init()$N$n'); |
| 1506 mainBuffer.write('$isolateProperties$_=$_$isolatePropertiesName$N'); | 1510 mainBuffer.write('$isolateProperties$_=$_$isolatePropertiesName$N'); |
| 1507 | 1511 |
| 1508 emitStaticFunctions(task.outputStaticLists[mainOutputUnit]); | 1512 emitStaticFunctions(task.outputStaticLists[mainOutputUnit]); |
| 1509 | 1513 |
| 1510 List<ClassElement> classes = task.outputClassLists[mainOutputUnit]; | 1514 List<ClassElement> classes = task.outputClassLists[mainOutputUnit]; |
| 1511 if (classes != null) { | 1515 if (classes != null) { |
| 1512 for (ClassElement element in classes) { | 1516 for (ClassElement element in classes) { |
| 1513 generateClass(element, getElementDescriptor(element)); | 1517 generateClass(element, getElementDescriptor(element)); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1528 | 1532 |
| 1529 checkEverythingEmitted(elementDescriptors.keys); | 1533 checkEverythingEmitted(elementDescriptors.keys); |
| 1530 | 1534 |
| 1531 CodeBuffer libraryBuffer = new CodeBuffer(); | 1535 CodeBuffer libraryBuffer = new CodeBuffer(); |
| 1532 for (LibraryElement library in Elements.sortedByPosition(libraries)) { | 1536 for (LibraryElement library in Elements.sortedByPosition(libraries)) { |
| 1533 writeLibraryDescriptors(libraryBuffer, library); | 1537 writeLibraryDescriptors(libraryBuffer, library); |
| 1534 elementDescriptors.remove(library); | 1538 elementDescriptors.remove(library); |
| 1535 } | 1539 } |
| 1536 | 1540 |
| 1537 mainBuffer | 1541 mainBuffer |
| 1538 ..write('(') | |
| 1539 ..write( | 1542 ..write( |
| 1540 jsAst.prettyPrint( | 1543 jsAst.prettyPrint( |
| 1541 getReflectionDataParser(this, backend), | 1544 getReflectionDataParser(this, backend), |
| 1542 compiler)) | 1545 compiler)) |
| 1543 ..write(')') | 1546 ..write(n); |
| 1544 ..write('([$n') | 1547 |
| 1545 ..write(libraryBuffer) | 1548 mainBuffer..write('$parseReflectionDataName([$n') |
| 1546 ..write('])$N'); | 1549 ..write(libraryBuffer) |
| 1550 ..write('])$N'); | |
| 1547 } | 1551 } |
| 1548 | 1552 |
| 1549 interceptorEmitter.emitGetInterceptorMethods(mainBuffer); | 1553 interceptorEmitter.emitGetInterceptorMethods(mainBuffer); |
| 1550 interceptorEmitter.emitOneShotInterceptors(mainBuffer); | 1554 interceptorEmitter.emitOneShotInterceptors(mainBuffer); |
| 1551 | 1555 |
| 1552 if (task.outputContainsConstantList) { | 1556 if (task.outputContainsConstantList) { |
| 1553 emitMakeConstantList(mainBuffer); | 1557 emitMakeConstantList(mainBuffer); |
| 1554 } | 1558 } |
| 1555 | 1559 |
| 1556 // Constants in checked mode call into RTI code to set type information | 1560 // Constants in checked mode call into RTI code to set type information |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1968 outputBuffer..write(buildGeneratedBy()) | 1972 outputBuffer..write(buildGeneratedBy()) |
| 1969 ..write('${deferredInitializers}.current$_=$_' | 1973 ..write('${deferredInitializers}.current$_=$_' |
| 1970 'function$_(${globalsHolder}) {$N'); | 1974 'function$_(${globalsHolder}) {$N'); |
| 1971 for (String globalObject in Namer.reservedGlobalObjectNames) { | 1975 for (String globalObject in Namer.reservedGlobalObjectNames) { |
| 1972 outputBuffer | 1976 outputBuffer |
| 1973 .write('var $globalObject$_=$_' | 1977 .write('var $globalObject$_=$_' |
| 1974 '${globalsHolder}.$globalObject$N'); | 1978 '${globalsHolder}.$globalObject$N'); |
| 1975 } | 1979 } |
| 1976 outputBuffer | 1980 outputBuffer |
| 1977 ..write('var init$_=$_${globalsHolder}.init$N') | 1981 ..write('var init$_=$_${globalsHolder}.init$N') |
| 1982 ..write('var $parseReflectionDataName$_=$_' | |
| 1983 '$globalsHolder.$parseReflectionDataName$N') | |
| 1978 ..write('var ${namer.isolateName}$_=$_' | 1984 ..write('var ${namer.isolateName}$_=$_' |
| 1979 '${globalsHolder}.${namer.isolateName}$N'); | 1985 '${globalsHolder}.${namer.isolateName}$N'); |
| 1980 if (libraryDescriptorBuffer != null) { | 1986 if (libraryDescriptorBuffer != null) { |
| 1981 // TODO(ahe): This defines a lot of properties on the | 1987 // TODO(ahe): This defines a lot of properties on the |
| 1982 // Isolate.prototype object. We know this will turn it into a | 1988 // Isolate.prototype object. We know this will turn it into a |
| 1983 // slow object in V8, so instead we should do something similar | 1989 // slow object in V8, so instead we should do something similar |
| 1984 // to Isolate.$finishIsolateConstructor. | 1990 // to Isolate.$finishIsolateConstructor. |
| 1985 outputBuffer | 1991 outputBuffer |
| 1986 ..write('var ${namer.currentIsolate}$_=$_$isolatePropertiesName;$n') | 1992 ..write('var ${namer.currentIsolate}$_=$_$isolatePropertiesName$N') |
| 1987 ..write('(') | 1993 ..write('$parseReflectionDataName([$n') |
| 1988 ..write( | |
| 1989 jsAst.prettyPrint( | |
| 1990 getReflectionDataParser(this, backend), | |
| 1991 compiler, monitor: compiler.dumpInfoTask)) | |
| 1992 ..write(')') | |
| 1993 ..write('([$n') | |
| 1994 ..addBuffer(libraryDescriptorBuffer) | 1994 ..addBuffer(libraryDescriptorBuffer) |
| 1995 ..write('])$N'); | 1995 ..write('])$N'); |
| 1996 | 1996 |
| 1997 } | 1997 } |
| 1998 | 1998 |
| 1999 // Set the currentIsolate variable to the current isolate (which is | 1999 // Set the currentIsolate variable to the current isolate (which is |
| 2000 // provided as second argument). | 2000 // provided as second argument). |
| 2001 // We need to do this, because we use the same variable for setting up | 2001 // We need to do this, because we use the same variable for setting up |
| 2002 // the isolate-properties and for storing the current isolate. During | 2002 // the isolate-properties and for storing the current isolate. During |
| 2003 // the setup (the code above this lines) we must set the variable to | 2003 // the setup (the code above this lines) we must set the variable to |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2094 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2094 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2095 if (element.isInstanceMember) { | 2095 if (element.isInstanceMember) { |
| 2096 cachedClassBuilders.remove(element.enclosingClass); | 2096 cachedClassBuilders.remove(element.enclosingClass); |
| 2097 | 2097 |
| 2098 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2098 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2099 | 2099 |
| 2100 } | 2100 } |
| 2101 } | 2101 } |
| 2102 } | 2102 } |
| 2103 } | 2103 } |
| OLD | NEW |