Chromium Code Reviews| 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.kernel_target; | 5 library fasta.kernel_target; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 Future; | 8 Future; |
| 9 | 9 |
| 10 import 'dart:io' show | 10 import 'dart:io' show |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 builder.interfaces = null; | 200 builder.interfaces = null; |
| 201 } | 201 } |
| 202 | 202 |
| 203 Future<Program> handleInputError(Uri uri, InputError error, | 203 Future<Program> handleInputError(Uri uri, InputError error, |
| 204 {bool isFullProgram}) { | 204 {bool isFullProgram}) { |
| 205 if (error != null) { | 205 if (error != null) { |
| 206 String message = error.format(); | 206 String message = error.format(); |
| 207 print(message); | 207 print(message); |
| 208 errors.add(message); | 208 errors.add(message); |
| 209 } | 209 } |
| 210 program = erroneousProgram(); | 210 program = erroneousProgram(isFullProgram); |
| 211 return uri == null | 211 return uri == null |
| 212 ? new Future<Program>.value(program) | 212 ? new Future<Program>.value(program) |
| 213 : writeLinkedProgram(uri, program, isFullProgram: isFullProgram); | 213 : writeLinkedProgram(uri, program, isFullProgram: isFullProgram); |
| 214 } | 214 } |
| 215 | 215 |
| 216 Future<Program> writeProgram(Uri uri, AstKind astKind) async { | 216 Future<Program> writeProgram(Uri uri, AstKind astKind) async { |
| 217 if (loader.first == null) return null; | 217 if (loader.first == null) return null; |
| 218 if (errors.isNotEmpty) { | 218 if (errors.isNotEmpty) { |
| 219 return handleInputError(uri, null, isFullProgram: true); | 219 return handleInputError(uri, null, isFullProgram: true); |
| 220 } | 220 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 program = link(new List<Library>.from(loader.libraries)); | 258 program = link(new List<Library>.from(loader.libraries)); |
| 259 if (uri == null) return program; | 259 if (uri == null) return program; |
| 260 return await writeLinkedProgram(uri, program, isFullProgram: false); | 260 return await writeLinkedProgram(uri, program, isFullProgram: false); |
| 261 } on InputError catch (e) { | 261 } on InputError catch (e) { |
| 262 return handleInputError(uri, e, isFullProgram: false); | 262 return handleInputError(uri, e, isFullProgram: false); |
| 263 } catch (e, s) { | 263 } catch (e, s) { |
| 264 return reportCrash(e, s, loader?.currentUriForCrashReporting); | 264 return reportCrash(e, s, loader?.currentUriForCrashReporting); |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 | 267 |
| 268 Program erroneousProgram() { | 268 Program erroneousProgram(bool isFullProgram) { |
| 269 Uri uri = loader.first?.uri ?? Uri.parse("error:error"); | 269 Uri uri = loader.first?.uri ?? Uri.parse("error:error"); |
| 270 KernelLibraryBuilder library = new KernelLibraryBuilder(uri, loader); | 270 KernelLibraryBuilder library = new KernelLibraryBuilder(uri, loader); |
| 271 KernelProcedureBuilder mainBuilder = new KernelProcedureBuilder(null, 0, | |
| 272 null, "main", null, null, AsyncMarker.Sync, ProcedureKind.Method); | |
| 273 library.addBuilder(mainBuilder.name, mainBuilder); | |
| 274 loader.first = library; | 271 loader.first = library; |
| 275 mainBuilder.body = new ExpressionStatement( | 272 if (isFullProgram) { |
|
ahe
2017/02/03 14:37:12
If we're generated an outline, we shouldn't add an
Siggi Cherem (dart-lang)
2017/02/03 18:16:57
makes sense - same thing in the future when genera
ahe
2017/02/03 19:34:14
Good point. I should turn this into a comment. Als
ahe
2017/02/03 20:03:36
Done.
| |
| 276 new Throw(new StringLiteral("${errors.join('\n')}"))); | 273 KernelProcedureBuilder mainBuilder = new KernelProcedureBuilder(null, 0, |
| 274 null, "main", null, null, AsyncMarker.Sync, ProcedureKind.Method); | |
| 275 library.addBuilder(mainBuilder.name, mainBuilder); | |
| 276 mainBuilder.body = new ExpressionStatement( | |
| 277 new Throw(new StringLiteral("${errors.join('\n')}"))); | |
| 278 } | |
| 277 library.build(); | 279 library.build(); |
| 278 return link(<Library>[library.library]); | 280 return link(<Library>[library.library]); |
| 279 } | 281 } |
| 280 | 282 |
| 281 /// Creates a program by combining [libraries] with the libraries of | 283 /// Creates a program by combining [libraries] with the libraries of |
| 282 /// `dillTarget.loader.program`. | 284 /// `dillTarget.loader.program`. |
| 283 Program link(List<Library> libraries) { | 285 Program link(List<Library> libraries) { |
| 284 Map<String, Source> uriToSource = <String, Source>{}; | 286 Map<String, Source> uriToSource = <String, Source>{}; |
| 285 | 287 |
| 286 // for (Library library in libraries) { | 288 // for (Library library in libraries) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 579 superclass = superclass.superclass; | 581 superclass = superclass.superclass; |
| 580 } | 582 } |
| 581 for (Constructor constructor in superclass.constructors) { | 583 for (Constructor constructor in superclass.constructors) { |
| 582 if (constructor.name.name.isEmpty) { | 584 if (constructor.name.name.isEmpty) { |
| 583 return constructor.function.requiredParameterCount == 0 ? | 585 return constructor.function.requiredParameterCount == 0 ? |
| 584 constructor : null; | 586 constructor : null; |
| 585 } | 587 } |
| 586 } | 588 } |
| 587 return null; | 589 return null; |
| 588 } | 590 } |
| OLD | NEW |