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

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

Issue 132193002: Port Try Dart! to SDK 1.0. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r31735. Created 6 years, 11 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
« no previous file with comments | « dart/site/try/app.yaml ('k') | dart/site/try/deploy.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:uri'; 10 import 'dart:convert' show JSON;
11 import 'dart:json' show parse;
12 11
13 import '../sdk/lib/_internal/compiler/compiler.dart' as compiler; 12 import '../../sdk/lib/_internal/compiler/compiler.dart' as compiler;
14 13
15 const bool THROW_ON_ERROR = false; 14 const bool THROW_ON_ERROR = false;
16 15
17 final cachedSources = new Map<Uri, String>(); 16 final cachedSources = new Map<Uri, String>();
18 17
19 Uri sdkLocation; 18 Uri sdkLocation;
20 List options = []; 19 List options = [];
21 20
22 compile(source, SendPort replyTo) { 21 compile(source, SendPort replyTo) {
23 if (sdkLocation == null) { 22 if (sdkLocation == null) {
24 // The first message received gives us the URI of this web app. 23 // The first message received gives us the URI of this web app.
25 if (source.endsWith('/sdk.dart')) { 24 if (source.endsWith('/sdk.json')) {
26 var request = new HttpRequest(); 25 var request = new HttpRequest();
27 request.open('GET', source, async: false); 26 request.open('GET', source, async: false);
28 request.send(null); 27 request.send(null);
28 if (request.status != 200) {
29 throw 'SDK not found at $source';
30 }
29 sdkLocation = Uri.parse('sdk:/sdk/'); 31 sdkLocation = Uri.parse('sdk:/sdk/');
30 parse(request.responseText).forEach((file, content) { 32 JSON.decode(request.responseText).forEach((file, content) {
31 cachedSources[Uri.parse('sdk:/$file')] = content; 33 cachedSources[Uri.parse(file)] = content;
32 }); 34 });
33 } else { 35 } else {
34 sdkLocation = Uri.parse(source); 36 sdkLocation = Uri.parse(source);
35 } 37 }
36 replyTo.send(null); 38 replyTo.send(null);
37 return; 39 return;
38 } 40 }
39 if (source is List) { 41 if (source is List) {
40 String messageType = (source.length > 0) ? source[0] : null; 42 String messageType = (source.length > 0) ? source[0] : null;
41 var data = (source.length > 1) ? source[1] : null; 43 var data = (source.length > 1) ? source[1] : null;
(...skipping 30 matching lines...) Expand all
72 String message, compiler.Diagnostic kind) { 74 String message, compiler.Diagnostic kind) {
73 replyTo.send(['diagnostic', { 'uri': '$uri', 75 replyTo.send(['diagnostic', { 'uri': '$uri',
74 'begin': begin, 76 'begin': begin,
75 'end': end, 77 'end': end,
76 'message': message, 78 'message': message,
77 'kind': kind.name }]); 79 'kind': kind.name }]);
78 if (THROW_ON_ERROR && kind == compiler.Diagnostic.ERROR) { 80 if (THROW_ON_ERROR && kind == compiler.Diagnostic.ERROR) {
79 throw new Exception('Throw on error'); 81 throw new Exception('Throw on error');
80 } 82 }
81 } 83 }
82 compiler.compile(new Uri('memory:/main.dart'), 84 compiler.compile(Uri.parse('memory:/main.dart'),
83 sdkLocation, 85 sdkLocation,
84 null, 86 null,
85 inputProvider, 87 inputProvider,
86 handler, 88 handler,
87 options).then((js) { 89 options).then((js) {
88 try { 90 try {
89 if (js == null) { 91 if (js == null) {
90 if (!options.contains('--analyze-only')) replyTo.send('failed'); 92 if (!options.contains('--analyze-only')) replyTo.send('failed');
91 } else { 93 } else {
92 var url; 94 var url;
(...skipping 16 matching lines...) Expand all
109 } else { 111 } else {
110 replyTo.send(['code', js]); 112 replyTo.send(['code', js]);
111 } 113 }
112 } 114 }
113 } catch (e, trace) { 115 } catch (e, trace) {
114 replyTo.send(['crash', '$e, $trace']); 116 replyTo.send(['crash', '$e, $trace']);
115 } 117 }
116 replyTo.send('done'); 118 replyTo.send('done');
117 }); 119 });
118 } 120 }
OLDNEW
« no previous file with comments | « dart/site/try/app.yaml ('k') | dart/site/try/deploy.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698