| 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 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 program = await kernelTarget.writeProgram(null); | 178 program = await kernelTarget.writeProgram(null); |
| 179 if (kernelTarget.errors.isNotEmpty) { | 179 if (kernelTarget.errors.isNotEmpty) { |
| 180 return new CompilationResult.errors(kernelTarget.errors | 180 return new CompilationResult.errors(kernelTarget.errors |
| 181 .map((err) => err.toString()) | 181 .map((err) => err.toString()) |
| 182 .toList(growable: false)); | 182 .toList(growable: false)); |
| 183 } | 183 } |
| 184 } on InputError catch (e) { | 184 } on InputError catch (e) { |
| 185 return new CompilationResult.error(e.format()); | 185 return new CompilationResult.error(e.format()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 if (program.mainMethod == null) { |
| 189 return new CompilationResult.error("No 'main' method found."); |
| 190 } |
| 191 |
| 188 // Perform target-specific transformations. | 192 // Perform target-specific transformations. |
| 189 target.performModularTransformations(program); | 193 target.performModularTransformations(program); |
| 190 target.performGlobalTransformations(program); | 194 target.performGlobalTransformations(program); |
| 191 | 195 |
| 192 // Write the program to a list of bytes and return it. | 196 // Write the program to a list of bytes and return it. |
| 193 var sink = new ByteSink(); | 197 var sink = new ByteSink(); |
| 194 new BinaryPrinter(sink).writeProgramFile(program); | 198 new BinaryPrinter(sink).writeProgramFile(program); |
| 195 return new CompilationResult.ok(sink.builder.takeBytes()); | 199 return new CompilationResult.ok(sink.builder.takeBytes()); |
| 196 } catch (e, s) { | 200 } catch (e, s) { |
| 197 return reportCrash(e, s, fileName); | 201 return reportCrash(e, s, fileName); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 final BytesBuilder builder = new BytesBuilder(); | 248 final BytesBuilder builder = new BytesBuilder(); |
| 245 | 249 |
| 246 void add(List<int> data) { | 250 void add(List<int> data) { |
| 247 builder.add(data); | 251 builder.add(data); |
| 248 } | 252 } |
| 249 | 253 |
| 250 void close() { | 254 void close() { |
| 251 // Nothing to do. | 255 // Nothing to do. |
| 252 } | 256 } |
| 253 } | 257 } |
| OLD | NEW |