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

Side by Side Diff: pkg/front_end/lib/src/fasta/outline.dart

Issue 2738253003: Move most of kernel-service.dart to package:front_end. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/vm.dart » ('j') | pkg/front_end/lib/src/vm.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library fasta.outline; 5 library fasta.outline;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:convert' show JSON; 9 import 'dart:convert' show JSON;
10 10
11 import 'dart:io' show exitCode; 11 import 'dart:io' show BytesBuilder, FileSystemEntity, exitCode;
12
13 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
14
15 import 'package:kernel/kernel.dart' show Program;
16
17 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget;
18
19 import '../vm.dart' show CompilationResult;
12 20
13 import 'kernel/verifier.dart' show verifyProgram; 21 import 'kernel/verifier.dart' show verifyProgram;
14 22
15 import 'compiler_command_line.dart' show CompilerCommandLine; 23 import 'compiler_command_line.dart' show CompilerCommandLine;
16 24
17 import 'compiler_context.dart' show CompilerContext; 25 import 'compiler_context.dart' show CompilerContext;
18 26
19 import 'errors.dart' show InputError, inputError; 27 import 'errors.dart' show InputError, inputError;
20 28
21 import 'kernel/kernel_target.dart' show KernelTarget; 29 import 'kernel/kernel_target.dart' show KernelTarget;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 exitCode = 1; 156 exitCode = 1;
149 print("Verification of program failed: $e"); 157 print("Verification of program failed: $e");
150 if (s != null && c.options.verbose) { 158 if (s != null && c.options.verbose) {
151 print(s); 159 print(s);
152 } 160 }
153 } 161 }
154 } 162 }
155 return uri; 163 return uri;
156 } 164 }
157 } 165 }
166
167 Future<CompilationResult> parseScript(
168 Uri fileName, Uri packages, Uri patchedSdk, bool verbose) async {
169 if (!FileSystemEntity.isFileSync(fileName.toFilePath())) {
170 throw "Input file '${fileName.toFilePath()}' does not exist.";
171 }
172
173 if (!FileSystemEntity.isDirectorySync(patchedSdk.toFilePath())) {
174 throw "Patched sdk directory not found at ${patchedSdk.toFilePath()}";
175 }
176
177 Target target = getTarget("vm", new TargetFlags(strongMode: false));
178
179 Program program;
180 final uriTranslator = await TranslateUri.parse(null, packages);
181 final Ticker ticker = new Ticker(isVerbose: verbose);
182 final DillTarget dillTarget = new DillTarget(ticker, uriTranslator);
183 dillTarget.read(patchedSdk.resolve('platform.dill'));
184 final KernelTarget kernelTarget = new KernelTarget(dillTarget, uriTranslator);
185 try {
186 kernelTarget.read(fileName);
187 await dillTarget.writeOutline(null);
188 program = await kernelTarget.writeOutline(null);
189 program = await kernelTarget.writeProgram(null);
190 if (kernelTarget.errors.isNotEmpty) {
191 return new CompilationResult.error(kernelTarget.errors
192 .map((err) => err.toString())
193 .toList(growable: false));
194 }
195 } on InputError catch (e) {
196 return new CompilationResult.error(<String>[e.format()]);
197 }
198
199 // Perform target-specific transformations.
200 target.performModularTransformations(program);
201 target.performGlobalTransformations(program);
202
203 // Write the program to a list of bytes and return it.
204 var sink = new ByteSink();
205 new BinaryPrinter(sink).writeProgramFile(program);
206 return new CompilationResult.ok(sink.builder.takeBytes());
207 }
208
209 // TODO(ahe): https://github.com/dart-lang/sdk/issues/29027
Vyacheslav Egorov (Google) 2017/03/10 09:58:15 I have filed this issue before as #28316
ahe 2017/03/10 12:05:49 Done.
210 class ByteSink implements Sink<List<int>> {
211 final BytesBuilder builder = new BytesBuilder();
212
213 void add(List<int> data) {
214 builder.add(data);
215 }
216
217 void close() {
218 // Nothing to do.
219 }
220 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/vm.dart » ('j') | pkg/front_end/lib/src/vm.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698