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 Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'package:kernel/ast.dart' | 9 import 'package:kernel/ast.dart' |
10 show | 10 show |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 program = erroneousProgram(true); | 310 program = erroneousProgram(true); |
311 return; | 311 return; |
312 } | 312 } |
313 List<Expression> expressions = <Expression>[]; | 313 List<Expression> expressions = <Expression>[]; |
314 for (LocatedMessage error in recoverableErrors) { | 314 for (LocatedMessage error in recoverableErrors) { |
315 errors.add(error); | 315 errors.add(error); |
316 expressions.add(new StringLiteral(context.format(error, Severity.error))); | 316 expressions.add(new StringLiteral(context.format(error, Severity.error))); |
317 } | 317 } |
318 mainLibrary.library.addMember(new Field(new Name("#errors"), | 318 mainLibrary.library.addMember(new Field(new Name("#errors"), |
319 initializer: new ListLiteral(expressions, isConst: true), | 319 initializer: new ListLiteral(expressions, isConst: true), |
320 isConst: true)); | 320 isConst: true, |
| 321 isStatic: true)); |
321 } | 322 } |
322 | 323 |
323 Program erroneousProgram(bool isFullProgram) { | 324 Program erroneousProgram(bool isFullProgram) { |
324 Uri uri = loader.first?.uri ?? Uri.parse("error:error"); | 325 Uri uri = loader.first?.uri ?? Uri.parse("error:error"); |
325 Uri fileUri = loader.first?.fileUri ?? uri; | 326 Uri fileUri = loader.first?.fileUri ?? uri; |
326 KernelLibraryBuilder library = | 327 KernelLibraryBuilder library = |
327 new KernelLibraryBuilder(uri, fileUri, loader, false); | 328 new KernelLibraryBuilder(uri, fileUri, loader, false); |
328 loader.first = library; | 329 loader.first = library; |
329 if (isFullProgram) { | 330 if (isFullProgram) { |
330 // If this is an outline, we shouldn't add an executable main | 331 // If this is an outline, we shouldn't add an executable main |
331 // method. Similarly considerations apply to separate compilation. It | 332 // method. Similarly considerations apply to separate compilation. It |
332 // could also make sense to add a way to mark .dill files as having | 333 // could also make sense to add a way to mark .dill files as having |
333 // compile-time errors. | 334 // compile-time errors. |
334 KernelProcedureBuilder mainBuilder = new KernelProcedureBuilder( | 335 KernelProcedureBuilder mainBuilder = new KernelProcedureBuilder( |
335 null, | 336 null, |
336 null, | 337 null, |
337 0, | 338 0, |
338 null, | 339 null, |
339 "main", | 340 "#main", |
340 null, | 341 null, |
341 null, | 342 null, |
342 ProcedureKind.Method, | 343 ProcedureKind.Method, |
343 library, | 344 library, |
344 -1, | 345 -1, |
345 -1, | 346 -1, |
346 -1); | 347 -1); |
347 library.addBuilder(mainBuilder.name, mainBuilder, -1); | 348 library.addBuilder(mainBuilder.name, mainBuilder, -1); |
348 mainBuilder.body = new Block(new List<Statement>.from(errors.map( | 349 mainBuilder.body = new Block(new List<Statement>.from(errors.map( |
349 (LocatedMessage message) => new ExpressionStatement(new Throw( | 350 (LocatedMessage message) => new ExpressionStatement(new Throw( |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 } | 671 } |
671 for (Constructor constructor in superclass.constructors) { | 672 for (Constructor constructor in superclass.constructors) { |
672 if (constructor.name.name.isEmpty) { | 673 if (constructor.name.name.isEmpty) { |
673 return constructor.function.requiredParameterCount == 0 | 674 return constructor.function.requiredParameterCount == 0 |
674 ? constructor | 675 ? constructor |
675 : null; | 676 : null; |
676 } | 677 } |
677 } | 678 } |
678 return null; | 679 return null; |
679 } | 680 } |
OLD | NEW |