Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Additions to Fasta for generating .dill (Kernel IR) files with dart2js patch | 5 /// Additions to Fasta for generating .dill (Kernel IR) files with dart2js patch |
| 6 /// files and native hooks. | 6 /// files and native hooks. |
| 7 library compiler.src.kernel.fasta_support; | 7 library compiler.src.kernel.fasta_support; |
| 8 | 8 |
| 9 // TODO(sigmund): get rid of this file. Fasta should be agnostic of the | 9 // TODO(sigmund): get rid of this file. Fasta should be agnostic of the |
| 10 // target platform, at which point this should not be necessary. In particular, | 10 // target platform, at which point this should not be necessary. In particular, |
| 11 // we need to: | 11 // we need to: |
| 12 // - add a fasta flag to configure the platform library location. | 12 // - add a fasta flag to configure the platform library location. |
| 13 // - add a fasta flag to specify which sdk libraries should be built-in | 13 // - add a fasta flag to specify which sdk libraries should be built-in |
| 14 // (that would replace `loadExtraRequiredLibraries`). | 14 // (that would replace `loadExtraRequiredLibraries`). |
| 15 // - add flags to fasta to turn on various transformations. | 15 // - add flags to fasta to turn on various transformations. |
| 16 // - get rid of `native` in dart2js patches or unify the syntax with the VM. | 16 // - get rid of `native` in dart2js patches or unify the syntax with the VM. |
| 17 | 17 |
| 18 import 'dart:async' show Future; | 18 import 'dart:async' show Future; |
| 19 import 'dart:io' show exitCode; | 19 import 'dart:io' show exitCode; |
| 20 | 20 |
| 21 import 'package:front_end/physical_file_system.dart'; | 21 import 'package:front_end/physical_file_system.dart'; |
| 22 import 'package:front_end/src/fasta/kernel/utils.dart'; | |
| 22 import 'package:kernel/ast.dart' show Source; | 23 import 'package:kernel/ast.dart' show Source; |
| 23 | 24 |
| 24 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; | 25 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; |
| 25 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; | 26 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; |
| 26 import 'package:front_end/src/fasta/fasta.dart' show CompileTask; | 27 import 'package:front_end/src/fasta/fasta.dart' show CompileTask; |
| 27 import 'package:front_end/src/fasta/kernel/kernel_target.dart' | 28 import 'package:front_end/src/fasta/kernel/kernel_target.dart' |
| 28 show KernelTarget; | 29 show KernelTarget; |
| 29 import 'package:front_end/src/fasta/loader.dart' show Loader; | 30 import 'package:front_end/src/fasta/loader.dart' show Loader; |
| 30 import 'package:front_end/src/fasta/parser/parser.dart' show optional; | 31 import 'package:front_end/src/fasta/parser/parser.dart' show optional; |
| 31 import 'package:front_end/src/scanner/token.dart' show Token; | 32 import 'package:front_end/src/scanner/token.dart' show Token; |
| 32 import 'package:front_end/src/fasta/ticker.dart' show Ticker; | 33 import 'package:front_end/src/fasta/ticker.dart' show Ticker; |
| 33 import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri; | 34 import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri; |
| 34 | 35 |
| 35 /// Generates a platform.dill file containing the compiled Kernel IR of the | 36 /// Generates a platform.dill file containing the compiled Kernel IR of the |
| 36 /// dart2js SDK. | 37 /// dart2js SDK. |
| 37 Future compilePlatform(Uri patchedSdk, Uri fullOutput, | 38 Future compilePlatform(Uri patchedSdk, Uri fullOutput, |
| 38 {Uri outlineOutput, Uri packages}) async { | 39 {Uri outlineOutput, Uri packages}) async { |
| 39 Uri deps = Uri.base.resolveUri(new Uri.file("${fullOutput.toFilePath()}.d")); | 40 Uri deps = Uri.base.resolveUri(new Uri.file("${fullOutput.toFilePath()}.d")); |
| 40 TranslateUri uriTranslator = await TranslateUri.parse( | 41 TranslateUri uriTranslator = await TranslateUri.parse( |
| 41 PhysicalFileSystem.instance, patchedSdk, packages); | 42 PhysicalFileSystem.instance, patchedSdk, packages); |
| 42 var ticker = new Ticker(isVerbose: false); | 43 var ticker = new Ticker(isVerbose: false); |
| 43 var dillTarget = new DillTargetForDart2js(ticker, uriTranslator); | 44 var dillTarget = new DillTargetForDart2js(ticker, uriTranslator); |
| 44 var kernelTarget = | 45 var kernelTarget = |
| 45 new KernelTargetForDart2js(dillTarget, uriTranslator, false); | 46 new KernelTargetForDart2js(dillTarget, uriTranslator, false); |
| 46 | 47 |
| 47 kernelTarget.read(Uri.parse("dart:core")); | 48 kernelTarget.read(Uri.parse("dart:core")); |
| 48 await dillTarget.buildOutlines(); | 49 await dillTarget.buildOutlines(); |
| 49 await kernelTarget.buildOutlines(); | 50 var outline = await kernelTarget.buildOutlines(); |
| 50 await kernelTarget.writeOutline(outlineOutput); | 51 if (outlineOutput != null) { |
|
Siggi Cherem (dart-lang)
2017/05/17 22:01:34
I'd remove this extra check, you don't seem to hav
scheglov
2017/05/17 22:16:04
Thanks.
I was not sure that it is called in dart2j
| |
| 52 await writeProgramToFileUri(ticker, outlineOutput, outline, | |
| 53 isFullProgram: false); | |
| 54 } | |
| 51 | 55 |
| 52 if (exitCode != 0) return null; | 56 if (exitCode != 0) return null; |
| 53 await kernelTarget.buildProgram(); | 57 var program = await kernelTarget.buildProgram(); |
| 54 await kernelTarget.writeProgram(fullOutput); | 58 await writeProgramToFileUri(ticker, fullOutput, program, isFullProgram: true); |
| 55 await kernelTarget.writeDepsFile(fullOutput, deps); | 59 await kernelTarget.writeDepsFile(fullOutput, deps); |
| 56 } | 60 } |
| 57 | 61 |
| 58 /// Extends the internal fasta [CompileTask] to use a dart2js-aware [DillTarget] | 62 /// Extends the internal fasta [CompileTask] to use a dart2js-aware [DillTarget] |
| 59 /// and [KernelTarget]. | 63 /// and [KernelTarget]. |
| 60 class Dart2jsCompileTask extends CompileTask { | 64 class Dart2jsCompileTask extends CompileTask { |
| 61 Dart2jsCompileTask(CompilerContext c, Ticker ticker) : super(c, ticker); | 65 Dart2jsCompileTask(CompilerContext c, Ticker ticker) : super(c, ticker); |
| 62 | 66 |
| 63 @override | 67 @override |
| 64 DillTarget createDillTarget(TranslateUri uriTranslator) { | 68 DillTarget createDillTarget(TranslateUri uriTranslator) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 'dart:html_common', | 159 'dart:html_common', |
| 156 'dart:indexed_db', | 160 'dart:indexed_db', |
| 157 'dart:js', | 161 'dart:js', |
| 158 'dart:js_util', | 162 'dart:js_util', |
| 159 'dart:mirrors', | 163 'dart:mirrors', |
| 160 'dart:svg', | 164 'dart:svg', |
| 161 'dart:web_audio', | 165 'dart:web_audio', |
| 162 'dart:web_gl', | 166 'dart:web_gl', |
| 163 'dart:web_sql', | 167 'dart:web_sql', |
| 164 ]; | 168 ]; |
| OLD | NEW |