| 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 /// API for compiling Dart source code to .dill (Kernel IR) files. | 5 /// API for compiling Dart source code to .dill (Kernel IR) files. |
| 6 library front_end.vm; | 6 library front_end.vm; |
| 7 // TODO(ahe): Move this to lib/ once the API has matured. | 7 // TODO(ahe): Move this to lib/ once the API has matured. |
| 8 | 8 |
| 9 import 'dart:async' show Future; | 9 import 'dart:async' show Future; |
| 10 | 10 |
| 11 import 'dart:io' show File, Platform; | 11 import 'dart:io' show File, Platform; |
| 12 | 12 |
| 13 import 'dart:typed_data' show Uint8List; | 13 import 'dart:typed_data' show Uint8List; |
| 14 | 14 |
| 15 import 'outline.dart' as fasta; | 15 import 'fasta.dart' as fasta; |
| 16 | 16 |
| 17 /// Compilation status codes. | 17 /// Compilation status codes. |
| 18 /// | 18 /// |
| 19 /// Note: The [index] property of these constants must match | 19 /// Note: The [index] property of these constants must match |
| 20 /// `Dart_KernelCompilationStatus` in | 20 /// `Dart_KernelCompilationStatus` in |
| 21 /// [dart_api.h](../../../../runtime/include/dart_api.h). | 21 /// [dart_api.h](../../../../runtime/include/dart_api.h). |
| 22 enum Status { | 22 enum Status { |
| 23 /// Compilation was successful. | 23 /// Compilation was successful. |
| 24 ok, | 24 ok, |
| 25 | 25 |
| 26 /// Compilation failed with a compile time error. | 26 /// Compilation failed with a compile time error. |
| 27 error, | 27 error, |
| 28 | 28 |
| 29 /// Compiler crashed. | 29 /// Compiler crashed. |
| 30 crash, | 30 crash, |
| 31 } | 31 } |
| 32 | 32 |
| 33 abstract class CompilationResult { | 33 abstract class CompilationResult { |
| 34 CompilationResult._(); | 34 CompilationResult._(); |
| 35 | 35 |
| 36 factory CompilationResult.ok(Uint8List bytes) = _CompilationOk; | 36 factory CompilationResult.ok(Uint8List bytes) = _CompilationOk; |
| 37 | 37 |
| 38 factory CompilationResult.error(List<String> errors) = _CompilationError; | 38 factory CompilationResult.errors(List<String> errors) = _CompilationError; |
| 39 |
| 40 factory CompilationResult.error(String error) { |
| 41 return new _CompilationError(<String>[error]); |
| 42 } |
| 39 | 43 |
| 40 factory CompilationResult.crash(Object exception, StackTrace stack) = | 44 factory CompilationResult.crash(Object exception, StackTrace stack) = |
| 41 _CompilationCrash; | 45 _CompilationCrash; |
| 42 | 46 |
| 43 Status get status; | 47 Status get status; |
| 44 | 48 |
| 45 get payload; | 49 get payload; |
| 46 | 50 |
| 47 List toResponse() => [status.index, payload]; | 51 List toResponse() => [status.index, payload]; |
| 48 } | 52 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 if (await new File.fromUri(packagesFile).exists()) { | 139 if (await new File.fromUri(packagesFile).exists()) { |
| 136 return packagesFile; | 140 return packagesFile; |
| 137 } | 141 } |
| 138 if (dir.parent.path == dir.path) { | 142 if (dir.parent.path == dir.path) { |
| 139 break; | 143 break; |
| 140 } | 144 } |
| 141 dir = dir.parent; | 145 dir = dir.parent; |
| 142 } | 146 } |
| 143 return null; | 147 return null; |
| 144 } | 148 } |
| OLD | NEW |