OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Fletch 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.md file. |
| 4 |
| 5 library fletchc.fletch_compiler; |
| 6 |
| 7 import 'package:compiler/compiler.dart' as api; |
| 8 |
| 9 import 'package:compiler/src/apiimpl.dart' as apiimpl; |
| 10 |
| 11 import 'package:sharedfrontend/elements.dart' as elements; |
| 12 |
| 13 import 'fletch_context.dart'; |
| 14 |
| 15 part 'fletch_compiler_hack.dart'; |
| 16 |
| 17 const EXTRA_DART2JS_OPTIONS = const <String>[ |
| 18 // TODO(ahe): This doesn't completely disable type inference. Investigate. |
| 19 '--disable-type-inference', |
| 20 '--output-type=dart', |
| 21 ]; |
| 22 |
| 23 class FletchCompiler extends FletchCompilerHack { |
| 24 FletchContext internalContext; |
| 25 |
| 26 FletchCompiler( |
| 27 api.CompilerInputProvider provider, |
| 28 api.CompilerOutputProvider outputProvider, |
| 29 api.DiagnosticHandler handler, |
| 30 Uri libraryRoot, |
| 31 Uri packageRoot, |
| 32 List<String> options, |
| 33 Map<String, dynamic> environment) |
| 34 : super( |
| 35 provider, outputProvider, handler, libraryRoot, packageRoot, |
| 36 EXTRA_DART2JS_OPTIONS.toList()..addAll(options), environment); |
| 37 |
| 38 FletchContext get context { |
| 39 if (internalContext == null) { |
| 40 internalContext = new FletchContext(this); |
| 41 } |
| 42 return internalContext; |
| 43 } |
| 44 |
| 45 void computeMain() { |
| 46 if (mainApp == null) return; |
| 47 |
| 48 mainFunction = mainApp.findLocal("_entry"); |
| 49 } |
| 50 |
| 51 void onLibraryCreated(elements.LibraryElement library) { |
| 52 // TODO(ahe): Remove this. |
| 53 library.canUseNative = true; |
| 54 super.onLibraryCreated(library); |
| 55 } |
| 56 } |
OLD | NEW |