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

Side by Side Diff: pkg/compiler/lib/src/kernel/fasta_support.dart

Issue 2865843002: Use FileSystem to read files in SourceLoader and TranslateUri. (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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:kernel/ast.dart' show Source; 22 import 'package:kernel/ast.dart' show Source;
22 23
23 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; 24 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext;
24 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; 25 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget;
25 import 'package:front_end/src/fasta/fasta.dart' show CompileTask; 26 import 'package:front_end/src/fasta/fasta.dart' show CompileTask;
26 import 'package:front_end/src/fasta/kernel/kernel_target.dart' 27 import 'package:front_end/src/fasta/kernel/kernel_target.dart'
27 show KernelTarget; 28 show KernelTarget;
28 import 'package:front_end/src/fasta/loader.dart' show Loader; 29 import 'package:front_end/src/fasta/loader.dart' show Loader;
29 import 'package:front_end/src/fasta/parser/parser.dart' show optional; 30 import 'package:front_end/src/fasta/parser/parser.dart' show optional;
30 import 'package:front_end/src/fasta/scanner/token.dart' show Token; 31 import 'package:front_end/src/fasta/scanner/token.dart' show Token;
31 import 'package:front_end/src/fasta/ticker.dart' show Ticker; 32 import 'package:front_end/src/fasta/ticker.dart' show Ticker;
32 import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri; 33 import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri;
33 34
34 /// Generates a platform.dill file containing the compiled Kernel IR of the 35 /// Generates a platform.dill file containing the compiled Kernel IR of the
35 /// dart2js SDK. 36 /// dart2js SDK.
36 Future compilePlatform(Uri patchedSdk, Uri output, {Uri packages}) async { 37 Future compilePlatform(Uri patchedSdk, Uri output, {Uri packages}) async {
37 Uri deps = Uri.base.resolveUri(new Uri.file("${output.toFilePath()}.d")); 38 Uri deps = Uri.base.resolveUri(new Uri.file("${output.toFilePath()}.d"));
38 TranslateUri uriTranslator = await TranslateUri.parse(patchedSdk, packages); 39 TranslateUri uriTranslator = await TranslateUri.parse(
40 PhysicalFileSystem.instance, patchedSdk, packages);
39 var ticker = new Ticker(isVerbose: false); 41 var ticker = new Ticker(isVerbose: false);
40 var dillTarget = new DillTargetForDart2js(ticker, uriTranslator); 42 var dillTarget = new DillTargetForDart2js(ticker, uriTranslator);
41 var kernelTarget = 43 var kernelTarget =
42 new KernelTargetForDart2js(dillTarget, uriTranslator, false); 44 new KernelTargetForDart2js(dillTarget, uriTranslator, false);
43 45
44 kernelTarget.read(Uri.parse("dart:core")); 46 kernelTarget.read(Uri.parse("dart:core"));
45 await dillTarget.writeOutline(null); 47 await dillTarget.writeOutline(null);
46 await kernelTarget.writeOutline(output); 48 await kernelTarget.writeOutline(output);
47 49
48 if (exitCode != 0) return null; 50 if (exitCode != 0) return null;
(...skipping 19 matching lines...) Expand all
68 } 70 }
69 } 71 }
70 72
71 /// Specializes [KernelTarget] to build kernel for dart2js: no transformations 73 /// Specializes [KernelTarget] to build kernel for dart2js: no transformations
72 /// are run, JS-specific libraries are included in the SDK, and native clauses 74 /// are run, JS-specific libraries are included in the SDK, and native clauses
73 /// have no string parameter. 75 /// have no string parameter.
74 class KernelTargetForDart2js extends KernelTarget { 76 class KernelTargetForDart2js extends KernelTarget {
75 KernelTargetForDart2js( 77 KernelTargetForDart2js(
76 DillTarget target, TranslateUri uriTranslator, bool strongMode, 78 DillTarget target, TranslateUri uriTranslator, bool strongMode,
77 [Map<String, Source> uriToSource]) 79 [Map<String, Source> uriToSource])
78 : super(target, uriTranslator, strongMode, uriToSource); 80 : super(PhysicalFileSystem.instance, target, uriTranslator, strongMode,
81 uriToSource);
79 82
80 @override 83 @override
81 Token skipNativeClause(Token token) => _skipNative(token); 84 Token skipNativeClause(Token token) => _skipNative(token);
82 85
83 @override 86 @override
84 String extractNativeMethodName(Token token) => null; 87 String extractNativeMethodName(Token token) => null;
85 88
86 @override 89 @override
87 void loadExtraRequiredLibraries(Loader loader) => _loadExtras(loader); 90 void loadExtraRequiredLibraries(Loader loader) => _loadExtras(loader);
88 91
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 'dart:_native_typed_data', 142 'dart:_native_typed_data',
140 'dart:_internal', 143 'dart:_internal',
141 'dart:_js_helper', 144 'dart:_js_helper',
142 'dart:_interceptors', 145 'dart:_interceptors',
143 'dart:_foreign_helper', 146 'dart:_foreign_helper',
144 'dart:_js_mirrors', 147 'dart:_js_mirrors',
145 'dart:_js_names', 148 'dart:_js_names',
146 'dart:_js_embedded_names', 149 'dart:_js_embedded_names',
147 'dart:_isolate_helper', 150 'dart:_isolate_helper',
148 ]; 151 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698