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

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

Issue 9639012: Implement the compiler API and use it in frog_leg.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments and created separate implementation library Created 8 years, 9 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/frog/leg/api.dart ('k') | dart/frog/leg/compiler.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('ssa/tracer.dart', prefix: 'ssa');
9 #import('../lang.dart', prefix: 'frog');
10
11 class Compiler extends leg.Compiler {
12 ReadUriFromString provider;
13 DiagnosticHandler handler;
14 Uri libraryRoot;
15
16 Compiler(this.provider, this.handler, this.libraryRoot)
17 : super.withCurrentDirectory(null, tracer: new ssa.HTracer());
18
19 LibraryElement scanBuiltinLibrary(String filename) {
20 Uri uri = libraryRoot.resolve(filename);
21 LibraryElement library = scanner.loadLibrary(uri, null);
22 return library;
23 }
24
25 void log(message) {
26 handler(null, null, null, message, false);
27 }
28
29 Script readScript(Uri uri, [ScriptTag node]) {
30 String uriName = uri.toString();
31 // TODO(ahe): Clean this up.
32 if (uriName == 'dart:dom') {
33 uri = libraryRoot.resolve('../../../client/dom/frog/dom_frog.dart');
34 } else if (uriName == 'dart:html') {
35 uri = libraryRoot.resolve('../../../client/html/frog/html_frog.dart');
36 } else if (uriName == 'dart:json') {
37 uri = libraryRoot.resolve('../../../lib/json/json.dart');
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.path}: $exception", node: node);
46 }
47 frog.SourceFile sourceFile = new frog.SourceFile(uri.toString(), text);
48 return new leg.Script(uri, sourceFile);
49 }
50
51 bool run(Uri uri) {
52 bool success = super.run(uri);
53 for (final task in tasks) {
54 log('${task.name} took ${task.timing}msec');
55 }
56 return success;
57 }
58 }
OLDNEW
« no previous file with comments | « dart/frog/leg/api.dart ('k') | dart/frog/leg/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698