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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/frog/leg/api.dart ('k') | dart/frog/leg/compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/apiimpl.dart
diff --git a/dart/frog/leg/apiimpl.dart b/dart/frog/leg/apiimpl.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6b29e5c4b9f4c20bf16c8ad077525db1025166c9
--- /dev/null
+++ b/dart/frog/leg/apiimpl.dart
@@ -0,0 +1,58 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library('leg_apiimpl');
+
+#import('leg.dart', prefix: 'leg');
+#import('ssa/tracer.dart', prefix: 'ssa');
+#import('../lang.dart', prefix: 'frog');
+
+class Compiler extends leg.Compiler {
+ ReadUriFromString provider;
+ DiagnosticHandler handler;
+ Uri libraryRoot;
+
+ Compiler(this.provider, this.handler, this.libraryRoot)
+ : super.withCurrentDirectory(null, tracer: new ssa.HTracer());
+
+ LibraryElement scanBuiltinLibrary(String filename) {
+ Uri uri = libraryRoot.resolve(filename);
+ LibraryElement library = scanner.loadLibrary(uri, null);
+ return library;
+ }
+
+ void log(message) {
+ handler(null, null, null, message, false);
+ }
+
+ Script readScript(Uri uri, [ScriptTag node]) {
+ String uriName = uri.toString();
+ // TODO(ahe): Clean this up.
+ if (uriName == 'dart:dom') {
+ uri = libraryRoot.resolve('../../../client/dom/frog/dom_frog.dart');
+ } else if (uriName == 'dart:html') {
+ uri = libraryRoot.resolve('../../../client/html/frog/html_frog.dart');
+ } else if (uriName == 'dart:json') {
+ uri = libraryRoot.resolve('../../../lib/json/json.dart');
+ }
+ String text = "";
+ try {
+ // TODO(ahe): We expect the future to be complete and call value
+ // directly. In effect, we don't support truly asynchronous API.
+ text = provider(uri).value;
+ } catch (var exception) {
+ cancel("${uri.path}: $exception", node: node);
+ }
+ frog.SourceFile sourceFile = new frog.SourceFile(uri.toString(), text);
+ return new leg.Script(uri, sourceFile);
+ }
+
+ bool run(Uri uri) {
+ bool success = super.run(uri);
+ for (final task in tasks) {
+ log('${task.name} took ${task.timing}msec');
+ }
+ return success;
+ }
+}
« 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