| OLD | NEW |
| 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; | 5 library fasta; |
| 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 BytesBuilder, Directory, File, exitCode; | 11 import 'dart:io' show BytesBuilder, Directory, File, exitCode; |
| 12 | 12 |
| 13 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter; | 13 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter; |
| 14 | 14 |
| 15 import 'package:kernel/kernel.dart' show Program; | 15 import 'package:kernel/kernel.dart' show Program; |
| 16 | 16 |
| 17 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; | 17 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; |
| 18 | 18 |
| 19 import 'kernel/verifier.dart' show verifyProgram; | |
| 20 | |
| 21 import 'compiler_command_line.dart' show CompilerCommandLine; | 19 import 'compiler_command_line.dart' show CompilerCommandLine; |
| 22 | 20 |
| 23 import 'compiler_context.dart' show CompilerContext; | 21 import 'compiler_context.dart' show CompilerContext; |
| 24 | 22 |
| 25 import 'errors.dart' show InputError, formatUnexpected, inputError, reportCrash; | 23 import 'errors.dart' show InputError, formatUnexpected, inputError, reportCrash; |
| 26 | 24 |
| 27 import 'kernel/kernel_target.dart' show KernelTarget; | 25 import 'kernel/kernel_target.dart' show KernelTarget; |
| 28 | 26 |
| 29 import 'dill/dill_target.dart' show DillTarget; | 27 import 'dill/dill_target.dart' show DillTarget; |
| 30 | 28 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 if (c.options.dumpIr && output != null) { | 135 if (c.options.dumpIr && output != null) { |
| 138 kernelTarget.dumpIr(); | 136 kernelTarget.dumpIr(); |
| 139 } | 137 } |
| 140 return kernelTarget; | 138 return kernelTarget; |
| 141 } | 139 } |
| 142 | 140 |
| 143 Future<Uri> compile() async { | 141 Future<Uri> compile() async { |
| 144 KernelTarget kernelTarget = await buildOutline(); | 142 KernelTarget kernelTarget = await buildOutline(); |
| 145 if (exitCode != 0) return null; | 143 if (exitCode != 0) return null; |
| 146 Uri uri = c.options.output; | 144 Uri uri = c.options.output; |
| 147 await kernelTarget.writeProgram(uri); | 145 await kernelTarget.writeProgram(uri, |
| 148 if (c.options.dumpIr) { | 146 dumpIr: c.options.dumpIr, verify: c.options.verify); |
| 149 kernelTarget.dumpIr(); | |
| 150 } | |
| 151 if (c.options.verify) { | |
| 152 try { | |
| 153 verifyProgram(kernelTarget.program); | |
| 154 ticker.logMs("Verified program"); | |
| 155 } catch (e, s) { | |
| 156 exitCode = 1; | |
| 157 print("Verification of program failed: $e"); | |
| 158 if (s != null && c.options.verbose) { | |
| 159 print(s); | |
| 160 } | |
| 161 } | |
| 162 } | |
| 163 return uri; | 147 return uri; |
| 164 } | 148 } |
| 165 } | 149 } |
| 166 | 150 |
| 167 Future<CompilationResult> parseScript( | 151 Future<CompilationResult> parseScript( |
| 168 Uri fileName, Uri packages, Uri patchedSdk, bool verbose) async { | 152 Uri fileName, Uri packages, Uri patchedSdk, bool verbose) async { |
| 169 try { | 153 try { |
| 170 if (!await new File.fromUri(fileName).exists()) { | 154 if (!await new File.fromUri(fileName).exists()) { |
| 171 return new CompilationResult.error( | 155 return new CompilationResult.error( |
| 172 formatUnexpected(fileName, -1, "No such file.")); | 156 formatUnexpected(fileName, -1, "No such file.")); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 final BytesBuilder builder = new BytesBuilder(); | 201 final BytesBuilder builder = new BytesBuilder(); |
| 218 | 202 |
| 219 void add(List<int> data) { | 203 void add(List<int> data) { |
| 220 builder.add(data); | 204 builder.add(data); |
| 221 } | 205 } |
| 222 | 206 |
| 223 void close() { | 207 void close() { |
| 224 // Nothing to do. | 208 // Nothing to do. |
| 225 } | 209 } |
| 226 } | 210 } |
| OLD | NEW |