| 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 /// This is an interface to the Dart Kernel parser and Kernel binary generator. | 5 /// This is an interface to the Dart Kernel parser and Kernel binary generator. |
| 6 /// | 6 /// |
| 7 /// It is used by the kernel-isolate to load Dart source code and generate | 7 /// It is used by the kernel-isolate to load Dart source code and generate |
| 8 /// Kernel binary format. | 8 /// Kernel binary format. |
| 9 /// | 9 /// |
| 10 /// This is either invoked as the root script of the Kernel isolate when used | 10 /// This is either invoked as the root script of the Kernel isolate when used |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 var errors = <String>[]; | 73 var errors = <String>[]; |
| 74 var options = new CompilerOptions() | 74 var options = new CompilerOptions() |
| 75 ..strongMode = strongMode | 75 ..strongMode = strongMode |
| 76 ..fileSystem = fileSystem | 76 ..fileSystem = fileSystem |
| 77 ..target = new VmFastaTarget(new TargetFlags(strongMode: strongMode)) | 77 ..target = new VmFastaTarget(new TargetFlags(strongMode: strongMode)) |
| 78 ..packagesFileUri = packagesUri | 78 ..packagesFileUri = packagesUri |
| 79 ..sdkSummary = sdkSummary | 79 ..sdkSummary = sdkSummary |
| 80 ..verbose = verbose | 80 ..verbose = verbose |
| 81 ..onError = (CompilationError e) => errors.add(e.message); | 81 ..throwOnErrors = false |
| 82 ..reportMessages = true |
| 83 ..onError = (CompilationMessage e) { |
| 84 if (e.severity == Severity.error) { |
| 85 // TODO(sigmund): support emitting code with errors as long as they are |
| 86 // handled in the generated code (issue #30194). |
| 87 errors.add(e.message); |
| 88 } |
| 89 }; |
| 82 | 90 |
| 83 CompilationResult result; | 91 CompilationResult result; |
| 84 try { | 92 try { |
| 85 Program program = await kernelForProgram(script, options); | 93 Program program = await kernelForProgram(script, options); |
| 86 if (errors.isNotEmpty) { | 94 if (errors.isNotEmpty) { |
| 95 // TODO(sigmund): the compiler prints errors to the console, so we |
| 96 // shouldn't print those messages again here. |
| 87 result = new CompilationResult.errors(errors); | 97 result = new CompilationResult.errors(errors); |
| 88 } else { | 98 } else { |
| 89 // We serialize the program excluding platform.dill because the VM has | 99 // We serialize the program excluding platform.dill because the VM has |
| 90 // these sources built-in. Everything loaded as a summary in | 100 // these sources built-in. Everything loaded as a summary in |
| 91 // [kernelForProgram] is marked `external`, so we can use that bit to | 101 // [kernelForProgram] is marked `external`, so we can use that bit to |
| 92 // decide what to excluce. | 102 // decide what to excluce. |
| 93 // TODO(sigmund): remove the following line (Issue #30111) | 103 // TODO(sigmund): remove the following line (Issue #30111) |
| 94 program.libraries.forEach((e) => e.isExternal = false); | 104 program.libraries.forEach((e) => e.isExternal = false); |
| 95 result = new CompilationResult.ok( | 105 result = new CompilationResult.ok( |
| 96 serializeProgram(program, filter: (lib) => !lib.isExternal)); | 106 serializeProgram(program, filter: (lib) => !lib.isExternal)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 _CompilationCrash(this.exception, this.stack); | 251 _CompilationCrash(this.exception, this.stack); |
| 242 | 252 |
| 243 @override | 253 @override |
| 244 Status get status => Status.crash; | 254 Status get status => Status.crash; |
| 245 | 255 |
| 246 @override | 256 @override |
| 247 String get errorString => "${exception}\n${stack}"; | 257 String get errorString => "${exception}\n${stack}"; |
| 248 | 258 |
| 249 String toString() => "_CompilationCrash(${errorString})"; | 259 String toString() => "_CompilationCrash(${errorString})"; |
| 250 } | 260 } |
| OLD | NEW |