| 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 /** | 5 /** |
| 6 * A function element that represents a closure call. The signature is copied | 6 * A function element that represents a closure call. The signature is copied |
| 7 * from the given element. | 7 * from the given element. |
| 8 */ | 8 */ |
| 9 class ClosureInvocationElement extends FunctionElement { | 9 class ClosureInvocationElement extends FunctionElement { |
| 10 ClosureInvocationElement(SourceString name, | 10 ClosureInvocationElement(SourceString name, |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 Element main = compiler.mainApp.find(Compiler.MAIN); | 1219 Element main = compiler.mainApp.find(Compiler.MAIN); |
| 1220 String mainCall = null; | 1220 String mainCall = null; |
| 1221 if (compiler.isolateLibrary != null) { | 1221 if (compiler.isolateLibrary != null) { |
| 1222 Element isolateMain = | 1222 Element isolateMain = |
| 1223 compiler.isolateLibrary.find(Compiler.START_ROOT_ISOLATE); | 1223 compiler.isolateLibrary.find(Compiler.START_ROOT_ISOLATE); |
| 1224 mainCall = buildIsolateSetup(buffer, main, isolateMain); | 1224 mainCall = buildIsolateSetup(buffer, main, isolateMain); |
| 1225 } else { | 1225 } else { |
| 1226 mainCall = '${namer.isolateAccess(main)}()'; | 1226 mainCall = '${namer.isolateAccess(main)}()'; |
| 1227 } | 1227 } |
| 1228 buffer.add(""" | 1228 buffer.add(""" |
| 1229 |
| 1230 // |
| 1231 // BEGIN invoke [main]. |
| 1232 // |
| 1229 if (typeof document != 'undefined' && document.readyState != 'complete') { | 1233 if (typeof document != 'undefined' && document.readyState != 'complete') { |
| 1230 document.addEventListener('readystatechange', function () { | 1234 document.addEventListener('readystatechange', function () { |
| 1231 if (document.readyState == 'complete') { | 1235 if (document.readyState == 'complete') { |
| 1232 ${mainCall}; | 1236 if (typeof dartMainRunner == 'function') { |
| 1237 dartMainRunner(function() { ${mainCall}; }); |
| 1238 } else { |
| 1239 ${mainCall}; |
| 1240 } |
| 1233 } | 1241 } |
| 1234 }, false); | 1242 }, false); |
| 1235 } else { | 1243 } else { |
| 1236 ${mainCall}; | 1244 if (typeof dartMainRunner == 'function') { |
| 1245 dartMainRunner(function() { ${mainCall}; }); |
| 1246 } else { |
| 1247 ${mainCall}; |
| 1248 } |
| 1237 } | 1249 } |
| 1250 // |
| 1251 // END invoke [main]. |
| 1252 // |
| 1253 |
| 1238 """); | 1254 """); |
| 1239 } | 1255 } |
| 1240 | 1256 |
| 1241 String assembleProgram() { | 1257 String assembleProgram() { |
| 1242 measure(() { | 1258 measure(() { |
| 1243 mainBuffer.add('function ${namer.ISOLATE}() {}\n'); | 1259 mainBuffer.add('function ${namer.ISOLATE}() {}\n'); |
| 1244 mainBuffer.add('init();\n\n'); | 1260 mainBuffer.add('init();\n\n'); |
| 1245 // Shorten the code by using "$$" as temporary. | 1261 // Shorten the code by using "$$" as temporary. |
| 1246 classesCollector = @"$$"; | 1262 classesCollector = @"$$"; |
| 1247 mainBuffer.add('var $classesCollector = {};\n'); | 1263 mainBuffer.add('var $classesCollector = {};\n'); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 sourceName = token.slowToString(); | 1329 sourceName = token.slowToString(); |
| 1314 } | 1330 } |
| 1315 sourceMapBuilder.addMapping( | 1331 sourceMapBuilder.addMapping( |
| 1316 sourceFile, token.charOffset, sourceName, offset); | 1332 sourceFile, token.charOffset, sourceName, offset); |
| 1317 }); | 1333 }); |
| 1318 return sourceMapBuilder.build(compiledFile); | 1334 return sourceMapBuilder.build(compiledFile); |
| 1319 } | 1335 } |
| 1320 } | 1336 } |
| 1321 | 1337 |
| 1322 typedef void DefineMemberFunction(String invocationName, CodeBuffer definition); | 1338 typedef void DefineMemberFunction(String invocationName, CodeBuffer definition); |
| OLD | NEW |