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

Unified Diff: pkg/fletchc/lib/src/fletch_compiler.dart

Issue 918613002: Refactor implementation to address review comments and API design suggestions from Luke. (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Created 5 years, 10 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: pkg/fletchc/lib/src/fletch_compiler.dart
diff --git a/pkg/fletchc/lib/src/fletch_compiler.dart b/pkg/fletchc/lib/src/fletch_compiler.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e5b7b424cb537f384a71a2e5577a5fcc022dac59
--- /dev/null
+++ b/pkg/fletchc/lib/src/fletch_compiler.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2015, the Fletch 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.md file.
+
+library fletchc.fletch_compiler;
+
+import 'package:compiler/compiler.dart' as api;
+
+import 'package:compiler/src/apiimpl.dart' as apiimpl;
+
+import 'package:sharedfrontend/elements.dart' as elements;
+
+import 'fletch_context.dart';
+
+part 'fletch_compiler_hack.dart';
+
+const EXTRA_DART2JS_OPTIONS = const <String>[
+ // TODO(ahe): This doesn't completely disable type inference. Investigate.
+ '--disable-type-inference',
+ '--output-type=dart',
+];
+
+class FletchCompiler extends FletchCompilerHack {
+ FletchContext internalContext;
+
+ FletchCompiler(
+ api.CompilerInputProvider provider,
+ api.CompilerOutputProvider outputProvider,
+ api.DiagnosticHandler handler,
+ Uri libraryRoot,
+ Uri packageRoot,
+ List<String> options,
+ Map<String, dynamic> environment)
+ : super(
+ provider, outputProvider, handler, libraryRoot, packageRoot,
+ EXTRA_DART2JS_OPTIONS.toList()..addAll(options), environment);
+
+ FletchContext get context {
+ if (internalContext == null) {
+ internalContext = new FletchContext(this);
+ }
+ return internalContext;
+ }
+
+ void computeMain() {
+ if (mainApp == null) return;
+
+ mainFunction = mainApp.findLocal("_entry");
+ }
+
+ void onLibraryCreated(elements.LibraryElement library) {
+ // TODO(ahe): Remove this.
+ library.canUseNative = true;
+ super.onLibraryCreated(library);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698