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

Unified Diff: dart/pkg/dart2js_incremental/lib/dart2js_incremental.dart

Issue 355563004: Create package for incremental compilation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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
Index: dart/pkg/dart2js_incremental/lib/dart2js_incremental.dart
diff --git a/dart/pkg/dart2js_incremental/lib/dart2js_incremental.dart b/dart/pkg/dart2js_incremental/lib/dart2js_incremental.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6e49c02f4d91695d90f34a2cb1f944135aaad28f
--- /dev/null
+++ b/dart/pkg/dart2js_incremental/lib/dart2js_incremental.dart
@@ -0,0 +1,83 @@
+// Copyright (c) 2014, 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 dart2js_incremental;
+
+import 'dart:async' show
+ Future;
+
+import 'dart:profiler' show
+ UserTag;
+
+import 'package:compiler/implementation/apiimpl.dart' show
+ Compiler;
+
+import 'package:compiler/compiler.dart' show
+ CompilerInputProvider,
+ CompilerOutputProvider,
+ Diagnostic,
+ DiagnosticHandler;
+
+import 'package:compiler/implementation/dart2jslib.dart' show
+ NullSink;
+
+import 'package:compiler/implementation/js_backend/js_backend.dart' show
+ JavaScriptBackend;
+
+import 'package:compiler/implementation/elements/elements.dart' show
+ LibraryElement;
+
+part 'caching_compiler.dart';
+
+const List<String> INCREMENTAL_OPTIONS = const <String>[
+ '--disable-type-inference',
+ '--incremental-support',
+ '--no-source-maps', // TODO(ahe): Remove this.
+];
+
+class IncrementalCompiler {
+ final Uri libraryRoot;
+ final Uri packageRoot;
+ final CompilerInputProvider inputProvider;
+ final DiagnosticHandler diagnosticHandler;
+ final List<String> options;
+ final CompilerOutputProvider outputProvider;
+ final Map<String, dynamic> environment;
+
+ Compiler _compiler;
+
+ IncrementalCompiler({
+ this.libraryRoot,
+ this.packageRoot,
+ this.inputProvider,
+ this.diagnosticHandler,
+ this.options,
+ this.outputProvider,
+ this.environment}) {
+ if (libraryRoot == null) {
+ throw new ArgumentError('libraryRoot is null.');
+ }
+ if (inputProvider == null) {
+ throw new ArgumentError('inputProvider is null.');
+ }
+ if (diagnosticHandler == null) {
+ throw new ArgumentError('diagnosticHandler is null.');
+ }
+ }
+
+ Future<bool> compile(Uri script) {
+ List<String> options = new List<String>.from(this.options);
+ options.addAll(INCREMENTAL_OPTIONS);
+ _compiler = reuseCompiler(
+ cachedCompiler: _compiler,
+ libraryRoot: libraryRoot,
+ packageRoot: packageRoot,
+ inputProvider: inputProvider,
+ diagnosticHandler: diagnosticHandler,
+ options: options,
+ outputProvider: outputProvider,
+ environment: environment);
+ return _compiler.run(script);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698