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

Side by Side Diff: frog/leg/apiimpl.dart

Issue 9873021: Move frog/leg to lib/compiler/implementation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « frog/leg/api.dart ('k') | frog/leg/colors.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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('leg_apiimpl');
6
7 #import('leg.dart', prefix: 'leg');
8 #import('elements/elements.dart', prefix: 'leg');
9 #import('tree/tree.dart', prefix: 'leg');
10 #import('ssa/tracer.dart', prefix: 'ssa');
11 #import('../lang.dart', prefix: 'frog');
12 #import('api.dart');
13 #import('../../lib/uri/uri.dart');
14
15 class Compiler extends leg.Compiler {
16 ReadUriFromString provider;
17 DiagnosticHandler handler;
18 Uri libraryRoot;
19 List<String> options;
20 bool mockableLibraryUsed = false;
21
22 Compiler(this.provider, this.handler, this.libraryRoot, this.options)
23 : super.withCurrentDirectory(null, tracer: new ssa.HTracer());
24
25 leg.LibraryElement scanBuiltinLibrary(String filename) {
26 Uri uri = libraryRoot.resolve(filename);
27 leg.LibraryElement library = scanner.loadLibrary(uri, null);
28 return library;
29 }
30
31 void log(message) {
32 handler(null, null, null, message, false);
33 }
34
35 leg.Script readScript(Uri uri, [leg.ScriptTag node]) {
36 if (uri.scheme == 'dart') {
37 uri = translateDartUri(uri, node);
38 }
39 String text = "";
40 try {
41 // TODO(ahe): We expect the future to be complete and call value
42 // directly. In effect, we don't support truly asynchronous API.
43 text = provider(uri).value;
44 } catch (var exception) {
45 cancel("${uri}: $exception", node: node);
46 }
47 frog.SourceFile sourceFile = new frog.SourceFile(uri.toString(), text);
48 return new leg.Script(uri, sourceFile);
49 }
50
51 translateDartUri(Uri uri, leg.ScriptTag node) {
52 String uriName = uri.toString();
53 // TODO(ahe): Clean this up.
54 if (uriName == 'dart:dom') {
55 mockableLibraryUsed = true;
56 return libraryRoot.resolve('../../../lib/dom/frog/dom_frog.dart');
57 } else if (uriName == 'dart:html') {
58 mockableLibraryUsed = true;
59 return libraryRoot.resolve('../../../lib/html/frog/html_frog.dart');
60 } else if (uriName == 'dart:json') {
61 return libraryRoot.resolve('../../../lib/json/json.dart');
62 } else if (uriName == 'dart:isolate') {
63 return libraryRoot.resolve('../../../lib/isolate/isolate_leg.dart');
64 } else if (uriName == 'dart:io') {
65 mockableLibraryUsed = true;
66 return libraryRoot.resolve('io.dart');
67 } else if (uriName == 'dart:utf') {
68 return libraryRoot.resolve('../../../lib/utf/utf.dart');
69 } else if (uriName == 'dart:uri') {
70 return libraryRoot.resolve('../../../lib/uri/uri.dart');
71 }
72 reportError(node, "library not found $uriName");
73 }
74
75 bool run(Uri uri) {
76 bool success = super.run(uri);
77 for (final task in tasks) {
78 log('${task.name} took ${task.timing}msec');
79 }
80 return success;
81 }
82
83 void reportDiagnostic(leg.SourceSpan span, String message, bool fatal) {
84 if (span === null) {
85 handler(null, null, null, message, fatal);
86 } else {
87 handler(span.uri, span.begin, span.end, message, fatal);
88 }
89 }
90
91 bool get isMockCompilation() {
92 return mockableLibraryUsed
93 && (options.indexOf('--allow-mock-compilation') !== -1);
94 }
95 }
OLDNEW
« no previous file with comments | « frog/leg/api.dart ('k') | frog/leg/colors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698