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 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 915 js.statement(r'''#.# = function(list) { | 915 js.statement(r'''#.# = function(list) { |
| 916 list.immutable$list = Array; | 916 list.immutable$list = Array; |
| 917 list.fixed$length = Array; | 917 list.fixed$length = Array; |
| 918 return list; | 918 return list; |
| 919 }''', | 919 }''', |
| 920 [namer.isolateName, makeConstListProperty]), | 920 [namer.isolateName, makeConstListProperty]), |
| 921 compiler, monitor: compiler.dumpInfoTask)); | 921 compiler, monitor: compiler.dumpInfoTask)); |
| 922 output.add(N); | 922 output.add(N); |
| 923 } | 923 } |
| 924 | 924 |
| 925 void emitFunctionThatReturnsNull(CodeOutput output) { | |
| 926 output.addBuffer( | |
| 927 jsAst.prettyPrint( | |
| 928 js.statement('#.# = function() {}', | |
| 929 [backend.namer.isolateName, | |
| 930 backend.rti.getFunctionThatReturnsNullName]), | |
| 931 compiler, monitor: compiler.dumpInfoTask)); | |
| 932 } | |
| 933 | |
| 934 jsAst.Expression generateFunctionThatReturnsNull() { | |
|
karlklose
2015/01/20 10:37:32
This generates code to access the function, not th
| |
| 935 return js("#.#", [backend.namer.isolateName, | |
| 936 backend.rti.getFunctionThatReturnsNullName]); | |
| 937 } | |
| 938 | |
| 925 /// Returns the code equivalent to: | 939 /// Returns the code equivalent to: |
| 926 /// `function(args) { $.startRootIsolate(X.main$closure(), args); }` | 940 /// `function(args) { $.startRootIsolate(X.main$closure(), args); }` |
| 927 jsAst.Expression buildIsolateSetupClosure(Element appMain, | 941 jsAst.Expression buildIsolateSetupClosure(Element appMain, |
| 928 Element isolateMain) { | 942 Element isolateMain) { |
| 929 jsAst.Expression mainAccess = isolateStaticClosureAccess(appMain); | 943 jsAst.Expression mainAccess = isolateStaticClosureAccess(appMain); |
| 930 // Since we pass the closurized version of the main method to | 944 // Since we pass the closurized version of the main method to |
| 931 // the isolate method, we must make sure that it exists. | 945 // the isolate method, we must make sure that it exists. |
| 932 return js('function(a){ #(#, a); }', | 946 return js('function(a){ #(#, a); }', |
| 933 [backend.emitter.staticFunctionAccess(isolateMain), mainAccess]); | 947 [backend.emitter.staticFunctionAccess(isolateMain), mainAccess]); |
| 934 } | 948 } |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1452 if (isProgramSplit) { | 1466 if (isProgramSplit) { |
| 1453 mainOutput.add( | 1467 mainOutput.add( |
| 1454 '${globalsHolder}.${namer.isolateName}$_=$_${namer.isolateName}$N' | 1468 '${globalsHolder}.${namer.isolateName}$_=$_${namer.isolateName}$N' |
| 1455 '${globalsHolder}.$initName$_=${_}$initName$N' | 1469 '${globalsHolder}.$initName$_=${_}$initName$N' |
| 1456 '${globalsHolder}.$parseReflectionDataName$_=$_' | 1470 '${globalsHolder}.$parseReflectionDataName$_=$_' |
| 1457 '$parseReflectionDataName$N'); | 1471 '$parseReflectionDataName$N'); |
| 1458 } | 1472 } |
| 1459 mainOutput.add('init()$N$n'); | 1473 mainOutput.add('init()$N$n'); |
| 1460 mainOutput.add('$isolateProperties$_=$_$isolatePropertiesName$N'); | 1474 mainOutput.add('$isolateProperties$_=$_$isolatePropertiesName$N'); |
| 1461 | 1475 |
| 1476 emitFunctionThatReturnsNull(mainOutput); | |
| 1477 | |
| 1462 emitStaticFunctions(task.outputStaticLists[mainOutputUnit]); | 1478 emitStaticFunctions(task.outputStaticLists[mainOutputUnit]); |
| 1463 | 1479 |
| 1464 List<ClassElement> classes = task.outputClassLists[mainOutputUnit]; | 1480 List<ClassElement> classes = task.outputClassLists[mainOutputUnit]; |
| 1465 if (classes != null) { | 1481 if (classes != null) { |
| 1466 for (ClassElement element in classes) { | 1482 for (ClassElement element in classes) { |
| 1467 generateClass(element, getElementDescriptor(element)); | 1483 generateClass(element, getElementDescriptor(element)); |
| 1468 } | 1484 } |
| 1469 } | 1485 } |
| 1470 | 1486 |
| 1471 if (compiler.enableMinification) { | 1487 if (compiler.enableMinification) { |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2092 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2108 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2093 if (element.isInstanceMember) { | 2109 if (element.isInstanceMember) { |
| 2094 cachedClassBuilders.remove(element.enclosingClass); | 2110 cachedClassBuilders.remove(element.enclosingClass); |
| 2095 | 2111 |
| 2096 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2112 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2097 | 2113 |
| 2098 } | 2114 } |
| 2099 } | 2115 } |
| 2100 } | 2116 } |
| 2101 } | 2117 } |
| OLD | NEW |