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 'dart:io' show File; | 9 import 'dart:io' show File; |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 import '../source/source_class_builder.dart' show SourceClassBuilder; | 49 import '../source/source_class_builder.dart' show SourceClassBuilder; |
50 | 50 |
51 import '../target_implementation.dart' show TargetImplementation; | 51 import '../target_implementation.dart' show TargetImplementation; |
52 | 52 |
53 import '../translate_uri.dart' show TranslateUri; | 53 import '../translate_uri.dart' show TranslateUri; |
54 | 54 |
55 import '../dill/dill_target.dart' show DillTarget; | 55 import '../dill/dill_target.dart' show DillTarget; |
56 | 56 |
57 import '../deprecated_problems.dart' | 57 import '../deprecated_problems.dart' |
58 show | 58 show |
| 59 deprecated_formatUnexpected, |
59 deprecated_InputError, | 60 deprecated_InputError, |
60 deprecated_internalProblem, | 61 deprecated_internalProblem, |
61 reportCrash, | 62 reportCrash, |
62 resetCrashReporting; | 63 resetCrashReporting; |
63 | 64 |
| 65 import '../messages.dart' show LocatedMessage; |
| 66 |
64 import '../util/relativize.dart' show relativizeUri; | 67 import '../util/relativize.dart' show relativizeUri; |
65 | 68 |
66 import '../compiler_context.dart' show CompilerContext; | 69 import '../compiler_context.dart' show CompilerContext; |
67 | 70 |
68 import 'kernel_builder.dart' | 71 import 'kernel_builder.dart' |
69 show | 72 show |
70 Builder, | 73 Builder, |
71 ClassBuilder, | 74 ClassBuilder, |
72 InvalidTypeBuilder, | 75 InvalidTypeBuilder, |
73 KernelClassBuilder, | 76 KernelClassBuilder, |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 ticker.logMs("Wrote deps file"); | 355 ticker.logMs("Wrote deps file"); |
353 } | 356 } |
354 | 357 |
355 /// Adds a synthetic field named `#errors` to the main library that contains | 358 /// Adds a synthetic field named `#errors` to the main library that contains |
356 /// [recoverableErrors] formatted. | 359 /// [recoverableErrors] formatted. |
357 /// | 360 /// |
358 /// If [recoverableErrors] is empty, this method does nothing. | 361 /// If [recoverableErrors] is empty, this method does nothing. |
359 /// | 362 /// |
360 /// If there's no main library, this method uses [erroneousProgram] to | 363 /// If there's no main library, this method uses [erroneousProgram] to |
361 /// replace [program]. | 364 /// replace [program]. |
362 void handleRecoverableErrors(List<deprecated_InputError> recoverableErrors) { | 365 void handleRecoverableErrors(List<LocatedMessage> recoverableErrors) { |
363 if (recoverableErrors.isEmpty) return; | 366 if (recoverableErrors.isEmpty) return; |
364 KernelLibraryBuilder mainLibrary = loader.first; | 367 KernelLibraryBuilder mainLibrary = loader.first; |
365 if (mainLibrary == null) { | 368 if (mainLibrary == null) { |
366 program = erroneousProgram(true); | 369 program = erroneousProgram(true); |
367 return; | 370 return; |
368 } | 371 } |
369 List<Expression> expressions = <Expression>[]; | 372 List<Expression> expressions = <Expression>[]; |
370 for (deprecated_InputError error in recoverableErrors) { | 373 for (LocatedMessage error in recoverableErrors) { |
371 String message = error.deprecated_format(); | 374 String message = deprecated_formatUnexpected( |
| 375 error.uri, error.charOffset, error.message); |
372 errors.add(message); | 376 errors.add(message); |
373 expressions.add(new StringLiteral(message)); | 377 expressions.add(new StringLiteral(message)); |
374 } | 378 } |
375 mainLibrary.library.addMember(new Field(new Name("#errors"), | 379 mainLibrary.library.addMember(new Field(new Name("#errors"), |
376 initializer: new ListLiteral(expressions, isConst: true), | 380 initializer: new ListLiteral(expressions, isConst: true), |
377 isConst: true)); | 381 isConst: true)); |
378 } | 382 } |
379 | 383 |
380 Program erroneousProgram(bool isFullProgram) { | 384 Program erroneousProgram(bool isFullProgram) { |
381 Uri uri = loader.first?.uri ?? Uri.parse("error:error"); | 385 Uri uri = loader.first?.uri ?? Uri.parse("error:error"); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 } | 741 } |
738 for (Constructor constructor in superclass.constructors) { | 742 for (Constructor constructor in superclass.constructors) { |
739 if (constructor.name.name.isEmpty) { | 743 if (constructor.name.name.isEmpty) { |
740 return constructor.function.requiredParameterCount == 0 | 744 return constructor.function.requiredParameterCount == 0 |
741 ? constructor | 745 ? constructor |
742 : null; | 746 : null; |
743 } | 747 } |
744 } | 748 } |
745 return null; | 749 return null; |
746 } | 750 } |
OLD | NEW |