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

Side by Side Diff: lib/dartdoc/frog/frog_leg.dart

Issue 10696191: Frog removed from dartdoc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #library('frog_leg');
6
7 #import('dart:io');
8 #import('dart:uri');
9
10 #import('lang.dart', prefix: 'frog');
11 #import('../../compiler/compiler.dart', prefix: 'compiler');
12 #import('../../compiler/implementation/filenames.dart');
13 #import('../../compiler/implementation/util/uri_extras.dart');
14
15 bool compile(frog.World world) {
16 final throwOnError = frog.options.throwOnErrors;
17 final showWarnings = frog.options.showWarnings;
18 final allowMockCompilation = frog.options.allowMockCompilation;
19 Uri cwd = getCurrentDirectory();
20 Uri uri = cwd.resolve(nativeToUriPath(frog.options.dartScript));
21 String frogLibDir = nativeToUriPath(frog.options.libDir);
22 if (!frogLibDir.endsWith("/")) frogLibDir = "$frogLibDir/";
23 Uri frogLib = new Uri(scheme: 'file', path: frogLibDir);
24 Uri libraryRoot = frogLib.resolve('../../');
25 Map<String, frog.SourceFile> sourceFiles = <frog.SourceFile>{};
26
27 Future<String> provider(Uri uri) {
28 if (uri.scheme != 'file') {
29 throw new IllegalArgumentException(uri);
30 }
31 String source = world.files.readAll(uriPathToNative(uri.path));
32 world.dartBytesRead += source.length;
33 sourceFiles[uri.toString()] =
34 new frog.SourceFile(relativize(cwd, uri), source);
35 Completer<String> completer = new Completer<String>();
36 completer.complete(source);
37 return completer.future;
38 }
39
40 void handler(Uri uri, int begin, int end, String message, bool fatal) {
41 if (uri === null && !fatal) {
42 world.info('[leg] $message');
43 return;
44 }
45 if (uri === null) {
46 assert(fatal);
47 print(message);
48 } else if (fatal || showWarnings) {
49 frog.SourceFile file = sourceFiles[uri.toString()];
50 print(file.getLocationMessage(message, begin, end, true));
51 }
52 if (fatal && throwOnError) throw new AbortLeg(message);
53 }
54
55 List<String> options = new List<String>();
56 if (allowMockCompilation) options.add('--allow-mock-compilation');
57
58 // TODO(ahe): We expect the future to be complete and call value
59 // directly. In effect, we don't support truly asynchronous API.
60 String code =
61 compiler.compile(uri, libraryRoot, provider, handler, options).value;
62 if (code === null) return false;
63 world.legCode = code;
64 world.jsBytesWritten = code.length;
65 return true;
66 }
67
68 class AbortLeg {
69 final message;
70 AbortLeg(this.message);
71 toString() => 'Aborted due to --throw-on-error: $message';
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698