| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library trydart.compilation; | 5 library trydart.compilation; |
| 6 | 6 |
| 7 import 'dart:html' show | 7 import 'dart:html' show |
| 8 Blob, | 8 Blob, |
| 9 Element, | 9 Element, |
| 10 ErrorEvent, | 10 ErrorEvent, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 makeOutputFrame; | 26 makeOutputFrame; |
| 27 | 27 |
| 28 import 'ui.dart' show | 28 import 'ui.dart' show |
| 29 buildButton, | 29 buildButton, |
| 30 interaction, | 30 interaction, |
| 31 outputDiv, | 31 outputDiv, |
| 32 outputFrame; | 32 outputFrame; |
| 33 | 33 |
| 34 import 'settings.dart' show | 34 import 'settings.dart' show |
| 35 alwaysRunInWorker, | 35 alwaysRunInWorker, |
| 36 alwaysRunInIframe, |
| 37 communicateViaBlobs, |
| 36 incrementalCompilation, | 38 incrementalCompilation, |
| 37 minified, | 39 minified, |
| 38 onlyAnalyze, | 40 onlyAnalyze, |
| 39 verboseCompiler; | 41 verboseCompiler; |
| 40 | 42 |
| 41 import 'iframe_error_handler.dart' show | 43 import 'iframe_error_handler.dart' show |
| 42 errorStream; | 44 errorStream; |
| 43 | 45 |
| 44 /** | 46 /** |
| 45 * Scheme for recognizing files stored in memory. | 47 * Scheme for recognizing files stored in memory. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 '--no-source-maps', | 105 '--no-source-maps', |
| 104 ]; | 106 ]; |
| 105 if (verboseCompiler) options.add('--verbose'); | 107 if (verboseCompiler) options.add('--verbose'); |
| 106 if (minified) options.add('--minify'); | 108 if (minified) options.add('--minify'); |
| 107 if (onlyAnalyze) options.add('--analyze-only'); | 109 if (onlyAnalyze) options.add('--analyze-only'); |
| 108 if (incrementalCompilation.value) { | 110 if (incrementalCompilation.value) { |
| 109 options.addAll(['--incremental-support', '--disable-type-inference']); | 111 options.addAll(['--incremental-support', '--disable-type-inference']); |
| 110 } | 112 } |
| 111 interaction.compilationStarting(); | 113 interaction.compilationStarting(); |
| 112 compilerPort.send([['options', options], receivePort.sendPort]); | 114 compilerPort.send([['options', options], receivePort.sendPort]); |
| 115 compilerPort.send([['communicateViaBlobs', communicateViaBlobs], |
| 116 receivePort.sendPort]); |
| 113 receivePort.listen(onMessage); | 117 receivePort.listen(onMessage); |
| 114 compilerPort.send([source, receivePort.sendPort]); | 118 compilerPort.send([source, receivePort.sendPort]); |
| 115 } | 119 } |
| 116 | 120 |
| 117 void dispose() { | 121 void dispose() { |
| 118 if (worker != null) worker.terminate(); | 122 if (worker != null) worker.terminate(); |
| 119 objectUrls.forEach(Url.revokeObjectUrl); | 123 objectUrls.forEach(Url.revokeObjectUrl); |
| 120 } | 124 } |
| 121 | 125 |
| 122 onMessage(message) { | 126 onMessage(message) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 outputFrame = frame; | 211 outputFrame = frame; |
| 208 errorStream(frame).listen(interaction.onIframeError); | 212 errorStream(frame).listen(interaction.onIframeError); |
| 209 } | 213 } |
| 210 void onError(String errorMessage) { | 214 void onError(String errorMessage) { |
| 211 interaction.consolePrintLine(errorMessage); | 215 interaction.consolePrintLine(errorMessage); |
| 212 console | 216 console |
| 213 ..append(buildButton('Try in iframe', (_) => retryInIframe())) | 217 ..append(buildButton('Try in iframe', (_) => retryInIframe())) |
| 214 ..appendText('\n'); | 218 ..appendText('\n'); |
| 215 } | 219 } |
| 216 interaction.aboutToRun(); | 220 interaction.aboutToRun(); |
| 217 if (usesDartHtml && !alwaysRunInWorker) { | 221 if (alwaysRunInIframe || |
| 222 usesDartHtml && !alwaysRunInWorker) { |
| 218 retryInIframe(); | 223 retryInIframe(); |
| 219 } else { | 224 } else { |
| 220 runInWorker(url, onError); | 225 runInWorker(url, onError); |
| 221 } | 226 } |
| 222 } | 227 } |
| 223 | 228 |
| 224 void runInWorker(String url, void onError(String errorMessage)) { | 229 void runInWorker(String url, void onError(String errorMessage)) { |
| 225 worker = new Worker(url) | 230 worker = new Worker(url) |
| 226 ..onMessage.listen((MessageEvent event) { | 231 ..onMessage.listen((MessageEvent event) { |
| 227 interaction.consolePrintLine(event.data); | 232 interaction.consolePrintLine(event.data); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 255 if (seenMessages.add('$begin:$end: [$kind] $message')) { | 260 if (seenMessages.add('$begin:$end: [$kind] $message')) { |
| 256 // Guard against duplicated messages. | 261 // Guard against duplicated messages. |
| 257 addDiagnostic(kind, message, begin, end); | 262 addDiagnostic(kind, message, begin, end); |
| 258 } | 263 } |
| 259 } | 264 } |
| 260 | 265 |
| 261 onCrash(data) { | 266 onCrash(data) { |
| 262 interaction.onCompilerCrash(data); | 267 interaction.onCompilerCrash(data); |
| 263 } | 268 } |
| 264 } | 269 } |
| OLD | NEW |