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 compilerIsolate(port) { | 5 compilerIsolate(port) { |
6 Runner runner = new Runner(); | 6 Runner runner = new Runner(); |
7 runner.init(); | 7 runner.init(); |
8 | 8 |
9 port.receive((msg, replyTo) { | 9 port.receive((msg, replyTo) { |
10 replyTo.send(runner.update(msg)); | 10 replyTo.send(runner.update(msg)); |
11 }); | 11 }); |
12 } | 12 } |
13 | 13 |
14 main() { | 14 main() { |
15 dom.document.getElementById('status').innerHTML = 'Initializing compiler'; | 15 dom.document.getElementById('status').innerHTML = 'Initializing compiler'; |
16 final iframe = dom.document.getElementById('isolate'); | 16 final iframe = dom.document.getElementById('isolate'); |
17 setOutline(msg, _) { | 17 setOutline(msg) { |
18 dom.document.getElementById('out').innerHTML = msg; | 18 dom.document.getElementById('out').innerHTML = msg; |
19 } | 19 } |
20 dom.spawnDomIsolate(iframe.contentWindow, 'compilerIsolate').then((sendPort) { | 20 dom.spawnDomIsolate(iframe.contentWindow, 'compilerIsolate').then((sendPort) { |
21 update(_) { | 21 update(_) { |
22 String text = dom.document.getElementById('code').innerText; | 22 String text = dom.document.getElementById('code').innerText; |
23 sendPort.call(text).receive(setOutline); | 23 sendPort.call(text).then(setOutline); |
24 dom.document.getElementById('status').innerHTML = 'Ready'; | 24 dom.document.getElementById('status').innerHTML = 'Ready'; |
25 } | 25 } |
26 update(null); | 26 update(null); |
27 final code = dom.document.getElementById('code'); | 27 final code = dom.document.getElementById('code'); |
28 code.addEventListener('DOMSubtreeModified', update); | 28 code.addEventListener('DOMSubtreeModified', update); |
29 }); | 29 }); |
30 } | 30 } |
31 | 31 |
32 class Runner { | 32 class Runner { |
33 final LeapCompiler compiler; | 33 final LeapCompiler compiler; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 mainApp = new LibraryElement(script); | 189 mainApp = new LibraryElement(script); |
190 | 190 |
191 universe.libraries.remove(script.uri.toString()); | 191 universe.libraries.remove(script.uri.toString()); |
192 Element element; | 192 Element element; |
193 withCurrentElement(mainApp, () { | 193 withCurrentElement(mainApp, () { |
194 scanner.scan(mainApp); | 194 scanner.scan(mainApp); |
195 }); | 195 }); |
196 return mainApp; | 196 return mainApp; |
197 } | 197 } |
198 } | 198 } |
OLD | NEW |