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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/apiimpl.dart

Issue 27510003: Scanner for UTF-8 byte arrays (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixes compiler tests Created 7 years, 2 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) 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 library leg_apiimpl; 5 library leg_apiimpl;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../compiler.dart' as api; 9 import '../compiler.dart' as api;
10 import 'dart2jslib.dart' as leg; 10 import 'dart2jslib.dart' as leg;
11 import 'tree/tree.dart' as tree; 11 import 'tree/tree.dart' as tree;
12 import 'elements/elements.dart' as elements; 12 import 'elements/elements.dart' as elements;
13 import 'ssa/tracer.dart' as ssa; 13 import 'ssa/tracer.dart' as ssa;
14 import '../../libraries.dart'; 14 import '../../libraries.dart';
15 import 'source_file.dart'; 15 import 'source_file.dart';
16 16
17 class Compiler extends leg.Compiler { 17 class Compiler extends leg.Compiler {
18 api.ReadStringFromUri provider; 18 api.CompilerInputProvider provider;
19 api.DiagnosticHandler handler; 19 api.DiagnosticHandler handler;
20 final Uri libraryRoot; 20 final Uri libraryRoot;
21 final Uri packageRoot; 21 final Uri packageRoot;
22 List<String> options; 22 List<String> options;
23 bool mockableLibraryUsed = false; 23 bool mockableLibraryUsed = false;
24 final Set<String> allowedLibraryCategories; 24 final Set<String> allowedLibraryCategories;
25 25
26 Compiler(this.provider, 26 Compiler(this.provider,
27 api.CompilerOutputProvider outputProvider, 27 api.CompilerOutputProvider outputProvider,
28 this.handler, 28 this.handler,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 leg.MessageKind.READ_SCRIPT_ERROR, 169 leg.MessageKind.READ_SCRIPT_ERROR,
170 {'uri': readableUri, 'exception': exception}); 170 {'uri': readableUri, 'exception': exception});
171 }); 171 });
172 } 172 }
173 173
174 Uri resourceUri = translateUri(readableUri, node); 174 Uri resourceUri = translateUri(readableUri, node);
175 // TODO(johnniwinther): Wrap the result from [provider] in a specialized 175 // TODO(johnniwinther): Wrap the result from [provider] in a specialized
176 // [Future] to ensure that we never execute an asynchronous action without s etting 176 // [Future] to ensure that we never execute an asynchronous action without s etting
177 // up the current element of the compiler. 177 // up the current element of the compiler.
178 return new Future.sync(() => callUserProvider(resourceUri)) 178 return new Future.sync(() => callUserProvider(resourceUri))
179 .then((String text) { 179 .then((data) {
ngeoffray 2013/10/18 10:19:37 Fits in previous line?
lukas 2013/10/24 16:48:36 Done.
180 SourceFile sourceFile = new SourceFile(resourceUri.toString(), text); 180 SourceFile sourceFile;
181 String resourceUriString = resourceUri.toString();
182 if (data is List<int>) {
183 sourceFile = new Utf8BytesSourceFile(resourceUriString, data);
184 } else if (data is String) {
185 sourceFile = new StringSourceFile(resourceUriString, data);
186 } else {
187 String message = "Expected a 'String' or a 'List<int>' from the input "
188 "provider, but got: ${Error.safeToString(data)}.";
189 reportReadError(message);
190 }
181 // We use [readableUri] as the URI for the script since need to preserve 191 // We use [readableUri] as the URI for the script since need to preserve
182 // the scheme in the script because [Script.uri] is used for resolving 192 // the scheme in the script because [Script.uri] is used for resolving
183 // relative URIs mentioned in the script. See the comment on 193 // relative URIs mentioned in the script. See the comment on
184 // [LibraryLoader] for more details. 194 // [LibraryLoader] for more details.
185 return new leg.Script(readableUri, sourceFile); 195 return new leg.Script(readableUri, sourceFile);
186 }).catchError((error) { 196 }).catchError((error) {
187 reportReadError(error); 197 reportReadError(error);
188 return null; 198 return null;
189 }); 199 });
190 } 200 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 rethrow; 324 rethrow;
315 } 325 }
316 } 326 }
317 327
318 void diagnoseCrashInUserCode(String message, exception, stackTrace) { 328 void diagnoseCrashInUserCode(String message, exception, stackTrace) {
319 hasCrashed = true; 329 hasCrashed = true;
320 print('$message: ${tryToString(exception)}'); 330 print('$message: ${tryToString(exception)}');
321 print(tryToString(stackTrace)); 331 print(tryToString(stackTrace));
322 } 332 }
323 } 333 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698