| 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/file_system.dart'; | 21 import 'package:front_end/file_system.dart'; |
| 22 import 'package:front_end/physical_file_system.dart'; | 22 import 'package:front_end/physical_file_system.dart'; |
| 23 import 'package:front_end/src/fasta/kernel/utils.dart'; | 23 import 'package:front_end/src/fasta/kernel/utils.dart'; |
| 24 import 'package:kernel/ast.dart' show Source, Library; | 24 import 'package:kernel/ast.dart' show Source, Library; |
| 25 import 'package:kernel/target/targets.dart' show TargetFlags; |
| 25 | 26 |
| 26 import 'package:front_end/src/fasta/builder/builder.dart' show LibraryBuilder; | 27 import 'package:front_end/src/fasta/builder/builder.dart' show LibraryBuilder; |
| 27 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; | 28 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; |
| 28 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; | 29 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; |
| 29 import 'package:front_end/src/fasta/fasta.dart' show CompileTask; | 30 import 'package:front_end/src/fasta/fasta.dart' show CompileTask; |
| 30 import 'package:front_end/src/fasta/kernel/kernel_target.dart' | 31 import 'package:front_end/src/fasta/kernel/kernel_target.dart' |
| 31 show KernelTarget; | 32 show KernelTarget; |
| 32 import 'package:front_end/src/fasta/loader.dart' show Loader; | 33 import 'package:front_end/src/fasta/loader.dart' show Loader; |
| 33 import 'package:front_end/src/fasta/parser/parser.dart' show optional; | 34 import 'package:front_end/src/fasta/parser/parser.dart' show optional; |
| 34 import 'package:front_end/src/fasta/source/source_loader.dart' | 35 import 'package:front_end/src/fasta/source/source_loader.dart' |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 83 } |
| 83 } | 84 } |
| 84 | 85 |
| 85 /// Specializes [KernelTarget] to build kernel for dart2js: no transformations | 86 /// Specializes [KernelTarget] to build kernel for dart2js: no transformations |
| 86 /// are run, JS-specific libraries are included in the SDK, and native clauses | 87 /// are run, JS-specific libraries are included in the SDK, and native clauses |
| 87 /// have no string parameter. | 88 /// have no string parameter. |
| 88 class KernelTargetForDart2js extends KernelTarget { | 89 class KernelTargetForDart2js extends KernelTarget { |
| 89 KernelTargetForDart2js( | 90 KernelTargetForDart2js( |
| 90 DillTarget target, TranslateUri uriTranslator, bool strongMode, | 91 DillTarget target, TranslateUri uriTranslator, bool strongMode, |
| 91 [Map<String, Source> uriToSource]) | 92 [Map<String, Source> uriToSource]) |
| 92 : super(PhysicalFileSystem.instance, target, uriTranslator, strongMode, | 93 : super(PhysicalFileSystem.instance, target, uriTranslator, uriToSource); |
| 93 uriToSource); | |
| 94 @override | 94 @override |
| 95 SourceLoader<Library> createLoader() => | 95 SourceLoader<Library> createLoader() => |
| 96 new SourceLoaderForDart2js<Library>(fileSystem, this); | 96 new SourceLoaderForDart2js<Library>(fileSystem, this); |
| 97 | 97 |
| 98 @override | 98 @override |
| 99 bool enableNative(LibraryBuilder library) => maybeEnableNative(library.uri); | 99 bool enableNative(LibraryBuilder library) => maybeEnableNative(library.uri); |
| 100 | 100 |
| 101 @override | 101 @override |
| 102 Token skipNativeClause(Token token) => _skipNative(token); | 102 Token skipNativeClause(Token token) => _skipNative(token); |
| 103 | 103 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 132 bool canImplementRestrictedTypes(LibraryBuilder library) => | 132 bool canImplementRestrictedTypes(LibraryBuilder library) => |
| 133 library == coreLibrary || library == interceptorsLibrary; | 133 library == coreLibrary || library == interceptorsLibrary; |
| 134 | 134 |
| 135 SourceLoaderForDart2js(FileSystem fs, KernelTarget target) | 135 SourceLoaderForDart2js(FileSystem fs, KernelTarget target) |
| 136 : super(fs, target); | 136 : super(fs, target); |
| 137 } | 137 } |
| 138 | 138 |
| 139 /// Specializes [DillTarget] to build kernel for dart2js: JS-specific libraries | 139 /// Specializes [DillTarget] to build kernel for dart2js: JS-specific libraries |
| 140 /// are included in the SDK, and native clauses have no string parameter. | 140 /// are included in the SDK, and native clauses have no string parameter. |
| 141 class DillTargetForDart2js extends DillTarget { | 141 class DillTargetForDart2js extends DillTarget { |
| 142 DillTargetForDart2js(Ticker ticker, TranslateUri uriTranslator) | 142 DillTargetForDart2js(Ticker ticker, TranslateUri uriTranslator, |
| 143 : super(ticker, uriTranslator, "none"); | 143 {TargetFlags flags}) |
| 144 : super(ticker, uriTranslator, "none", flags: flags); |
| 144 | 145 |
| 145 @override | 146 @override |
| 146 Token skipNativeClause(Token token) => _skipNative(token); | 147 Token skipNativeClause(Token token) => _skipNative(token); |
| 147 | 148 |
| 148 @override | 149 @override |
| 149 String extractNativeMethodName(Token token) => ""; | 150 String extractNativeMethodName(Token token) => ""; |
| 150 | 151 |
| 151 @override | 152 @override |
| 152 void loadExtraRequiredLibraries(Loader loader) => _loadExtras(loader); | 153 void loadExtraRequiredLibraries(Loader loader) => _loadExtras(loader); |
| 153 } | 154 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 'dart:html_common', | 193 'dart:html_common', |
| 193 'dart:indexed_db', | 194 'dart:indexed_db', |
| 194 'dart:js', | 195 'dart:js', |
| 195 'dart:js_util', | 196 'dart:js_util', |
| 196 'dart:mirrors', | 197 'dart:mirrors', |
| 197 'dart:svg', | 198 'dart:svg', |
| 198 'dart:web_audio', | 199 'dart:web_audio', |
| 199 'dart:web_gl', | 200 'dart:web_gl', |
| 200 'dart:web_sql', | 201 'dart:web_sql', |
| 201 ]; | 202 ]; |
| OLD | NEW |