Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: site/try/src/compiler_isolate.dart

Issue 408783002: Enable Try Dart to run on IE11. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 compiler_isolate; 5 library compiler_isolate;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:convert' show JSON; 10 import 'dart:convert' show JSON;
11 11
12 import 'compilation.dart' show PRIVATE_SCHEME; 12 import 'compilation.dart' show PRIVATE_SCHEME;
13 13
14 import 'package:compiler/compiler.dart' as compiler; 14 import 'package:compiler/compiler.dart' as compiler;
15 15
16 import 'package:dart2js_incremental/dart2js_incremental.dart' show 16 import 'package:dart2js_incremental/dart2js_incremental.dart' show
17 reuseCompiler; 17 reuseCompiler;
18 18
19 const bool THROW_ON_ERROR = false; 19 const bool THROW_ON_ERROR = false;
ahe 2014/07/21 08:15:59 Undo this :-)
aam-me 2014/07/21 12:20:38 Done.
20 20
21 final cachedSources = new Map<Uri, Future<String>>(); 21 final cachedSources = new Map<Uri, Future<String>>();
22 22
23 Uri sdkLocation; 23 Uri sdkLocation;
24 List options = []; 24 List options = [];
25 25
26 var communicateViaBlobs;
27
26 var cachedCompiler; 28 var cachedCompiler;
27 29
28 void notifyDartHtml(SendPort port) { 30 void notifyDartHtml(SendPort port) {
29 // Notify the controlling isolate (Try Dart UI) that the program imports 31 // Notify the controlling isolate (Try Dart UI) that the program imports
30 // dart:html. This is used to determine how to run the program: in an iframe 32 // dart:html. This is used to determine how to run the program: in an iframe
31 // or in a worker. 33 // or in a worker.
32 port.send('dart:html'); 34 port.send('dart:html');
33 } 35 }
34 36
35 compile(source, SendPort replyTo) { 37 compile(source, SendPort replyTo) {
(...skipping 14 matching lines...) Expand all
50 sdkLocation = Uri.parse(source); 52 sdkLocation = Uri.parse(source);
51 } 53 }
52 replyTo.send(null); 54 replyTo.send(null);
53 return; 55 return;
54 } 56 }
55 if (source is List) { 57 if (source is List) {
56 String messageType = (source.length > 0) ? source[0] : null; 58 String messageType = (source.length > 0) ? source[0] : null;
57 var data = (source.length > 1) ? source[1] : null; 59 var data = (source.length > 1) ? source[1] : null;
58 if (messageType == 'options') { 60 if (messageType == 'options') {
59 options = data as List; 61 options = data as List;
62 } if (messageType == 'communicateViaBlobs') {
63 communicateViaBlobs = data as bool;
60 } 64 }
61 return; 65 return;
62 } 66 }
63 int charactersRead = 0; 67 int charactersRead = 0;
64 Future<String> inputProvider(Uri uri) { 68 Future<String> inputProvider(Uri uri) {
65 Future<String> future; 69 Future<String> future;
66 if (uri.scheme == 'sdk') { 70 if (uri.scheme == 'sdk') {
67 if (uri.path.endsWith('/lib/html/dart2js/html_dart2js.dart')) { 71 if (uri.path.endsWith('/lib/html/dart2js/html_dart2js.dart')) {
68 notifyDartHtml(replyTo); 72 notifyDartHtml(replyTo);
69 } 73 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 125 }
122 String js = cachedCompiler.assembledCode; 126 String js = cachedCompiler.assembledCode;
123 if (js == null) { 127 if (js == null) {
124 if (!options.contains('--analyze-only')) replyTo.send('failed'); 128 if (!options.contains('--analyze-only')) replyTo.send('failed');
125 } else { 129 } else {
126 var url; 130 var url;
127 handler(null, 0, 0, 131 handler(null, 0, 0,
128 'Compiled ${source.length}/${charactersRead} characters Dart' 132 'Compiled ${source.length}/${charactersRead} characters Dart'
129 ' -> ${js.length} characters.', 133 ' -> ${js.length} characters.',
130 compiler.Diagnostic.VERBOSE_INFO); 134 compiler.Diagnostic.VERBOSE_INFO);
131 try { 135 if (communicateViaBlobs) {
132 // At least Safari and Firefox do not support creating an 136 try {
133 // object URL from a web worker. MDN claims that it will be 137 // At least Safari and Firefox do not support creating an
134 // supported in Firefox 21. 138 // object URL from a web worker. MDN claims that it will be
135 url = Url.createObjectUrl(new Blob([js], 'application/javascript')); 139 // supported in Firefox 21.
136 } catch (_) { 140 url = Url.createObjectUrl(new Blob([js], 'application/javascript'));
137 // Ignored. 141 } catch (_) {
142 // Ignored.
143 }
144 } else {
145 url = null;
138 } 146 }
139 if (url != null) { 147 if (url != null) {
140 replyTo.send(['url', url]); 148 replyTo.send(['url', url]);
141 } else { 149 } else {
142 replyTo.send(['code', js]); 150 replyTo.send(['code', js]);
143 } 151 }
144 } 152 }
145 }).catchError((e, trace) { 153 }).catchError((e, trace) {
146 replyTo.send(['crash', '$e, $trace']); 154 replyTo.send(['crash', '$e, $trace']);
147 }).whenComplete(() { 155 }).whenComplete(() {
148 replyTo.send('done'); 156 replyTo.send('done');
149 }); 157 });
150 } 158 }
151 159
152 void main(List<String> arguments, SendPort port) { 160 void main(List<String> arguments, SendPort port) {
153 ReceivePort replyTo = new ReceivePort(); 161 ReceivePort replyTo = new ReceivePort();
154 port.send(replyTo.sendPort); 162 port.send(replyTo.sendPort);
155 replyTo.listen((message) { 163 replyTo.listen((message) {
156 try { 164 try {
157 List list = message as List; 165 List list = message as List;
158 compile(list[0], list[1]); 166 compile(list[0], list[1]);
159 } catch (exception, stack) { 167 } catch (exception, stack) {
160 port.send('$exception\n$stack'); 168 port.send('$exception\n$stack');
161 } 169 }
162 }); 170 });
163 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698