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

Unified Diff: utils/kernel-service/kernel-service.dart

Issue 2880453005: Build up and pass MemoryFileSystem to fasta frontend. (Closed)
Patch Set: Use integer division 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/vm.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/kernel-service/kernel-service.dart
diff --git a/utils/kernel-service/kernel-service.dart b/utils/kernel-service/kernel-service.dart
index 072697b961e0216f5ab3563863070a7d2f173847..ec7e2aa2ae1a022c1b83d3433b516790f3980d4d 100644
--- a/utils/kernel-service/kernel-service.dart
+++ b/utils/kernel-service/kernel-service.dart
@@ -24,14 +24,17 @@ import 'dart:async';
import 'dart:io';
import 'dart:isolate';
+import 'package:front_end/memory_file_system.dart';
+import 'package:front_end/physical_file_system.dart';
import 'package:front_end/src/fasta/vm.dart'
- show CompilationResult, Status, parseScript;
+ show CompilationResult, Status, parseScriptInFileSystem;
const bool verbose = const bool.fromEnvironment('DFE_VERBOSE');
const bool strongMode = const bool.fromEnvironment('DFE_STRONG_MODE');
-Future<CompilationResult> _processLoadRequestImpl(String inputFilePathOrUri) {
+Future<CompilationResult> _processLoadRequestImpl(
+ String inputFilePathOrUri, FileSystem fileSystem) {
Uri scriptUri = Uri.parse(inputFilePathOrUri);
// Because we serve both Loader and bootstrapping requests we need to
@@ -48,8 +51,8 @@ Future<CompilationResult> _processLoadRequestImpl(String inputFilePathOrUri) {
return new Future<CompilationResult>.value(new CompilationResult.error(
"Expected 'file' scheme for a script uri: got ${scriptUri.scheme}"));
}
-
- return parseScript(scriptUri, verbose: verbose, strongMode: strongMode);
+ return parseScriptInFileSystem(scriptUri, fileSystem,
+ verbose: verbose, strongMode: strongMode);
}
// Process a request from the runtime. See KernelIsolate::CompileToKernel in
@@ -64,10 +67,13 @@ Future _processLoadRequest(request) async {
int tag = request[0];
final SendPort port = request[1];
final String inputFileUrl = request[2];
+ FileSystem fileSystem = request.length > 3
+ ? _buildMemoryFileSystem(request[3])
+ : PhysicalFileSystem.instance;
CompilationResult result;
try {
- result = await _processLoadRequestImpl(inputFileUrl);
+ result = await _processLoadRequestImpl(inputFileUrl, fileSystem);
} catch (error, stack) {
result = new CompilationResult.crash(error, stack);
}
@@ -90,6 +96,20 @@ Future _processLoadRequest(request) async {
}
}
+// Given namedSources list of interleaved file name string and
+// raw file content Uint8List this function builds up and returns
+// MemoryFileSystem instance that can be used instead of
+// PhysicalFileSystem.instance by the frontend.
+FileSystem _buildMemoryFileSystem(List namedSources) {
+ FileSystem fileSystem = new MemoryFileSystem(Uri.parse('file:///'));
+ for (int i = 0; i < namedSources.length ~/ 2; i++) {
+ fileSystem
+ .entityForUri(Uri.parse(namedSources[i * 2]))
+ .writeAsBytesSync(namedSources[i * 2 + 1]);
+ }
+ return fileSystem;
+}
+
train(String scriptUri) {
// TODO(28532): Enable on Windows.
if (Platform.isWindows) return;
« no previous file with comments | « pkg/front_end/lib/src/fasta/vm.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698