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.body_builder; | 5 library fasta.body_builder; |
6 | 6 |
7 import '../fasta_codes.dart' | 7 import '../fasta_codes.dart' |
8 show | 8 show |
9 FastaMessage, | 9 FastaMessage, |
10 codeConstFieldWithoutInitializer, | 10 codeConstFieldWithoutInitializer, |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 String errorName = isSuper ? "super.$name" : name; | 870 String errorName = isSuper ? "super.$name" : name; |
871 String message; | 871 String message; |
872 if (isGetter) { | 872 if (isGetter) { |
873 message = "Getter not found: '$errorName'."; | 873 message = "Getter not found: '$errorName'."; |
874 } else if (isSetter) { | 874 } else if (isSetter) { |
875 message = "Setter not found: '$errorName'."; | 875 message = "Setter not found: '$errorName'."; |
876 } else { | 876 } else { |
877 message = "Method not found: '$errorName'."; | 877 message = "Method not found: '$errorName'."; |
878 } | 878 } |
879 if (constantExpressionRequired) { | 879 if (constantExpressionRequired) { |
| 880 // TODO(ahe): Use error below instead of building a compile-time error, |
| 881 // should be: |
| 882 // return library.loader.throwCompileConstantError(error, charOffset); |
880 return buildCompileTimeError(message, charOffset); | 883 return buildCompileTimeError(message, charOffset); |
| 884 } else { |
| 885 Expression error = library.loader.instantiateNoSuchMethodError( |
| 886 receiver, name, arguments, charOffset, |
| 887 isMethod: !isGetter && !isSetter, |
| 888 isGetter: isGetter, |
| 889 isSetter: isSetter, |
| 890 isStatic: isStatic, |
| 891 isTopLevel: !isStatic && !isSuper); |
| 892 warning(message, charOffset); |
| 893 return new Throw(error); |
881 } | 894 } |
882 warning(message, charOffset); | |
883 return new Throw(library.loader.instantiateNoSuchMethodError( | |
884 receiver, name, arguments, charOffset, | |
885 isMethod: !isGetter && !isSetter, | |
886 isGetter: isGetter, | |
887 isSetter: isSetter, | |
888 isStatic: isStatic, | |
889 isTopLevel: !isStatic && !isSuper)); | |
890 } | 895 } |
891 | 896 |
892 @override | 897 @override |
893 Expression invokeSuperNoSuchMethod( | 898 Expression invokeSuperNoSuchMethod( |
894 String name, Arguments arguments, int charOffset, | 899 String name, Arguments arguments, int charOffset, |
895 {bool isGetter: false, bool isSetter: false}) { | 900 {bool isGetter: false, bool isSetter: false}) { |
896 String errorName = "super.$name"; | 901 String errorName = "super.$name"; |
897 String message; | 902 String message; |
898 if (isGetter) { | 903 if (isGetter) { |
899 message = "Getter not found: '$errorName'."; | 904 message = "Getter not found: '$errorName'."; |
(...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2876 return super.handleUnrecoverableError(token, message); | 2881 return super.handleUnrecoverableError(token, message); |
2877 } | 2882 } |
2878 | 2883 |
2879 @override | 2884 @override |
2880 Expression buildCompileTimeError(error, [int charOffset = -1]) { | 2885 Expression buildCompileTimeError(error, [int charOffset = -1]) { |
2881 // TODO(ahe): This method should be passed the erroneous expression, wrap | 2886 // TODO(ahe): This method should be passed the erroneous expression, wrap |
2882 // it in a class (TBD) from which the erroneous expression can be easily | 2887 // it in a class (TBD) from which the erroneous expression can be easily |
2883 // extracted. Similar for statements and initializers. See also [issue | 2888 // extracted. Similar for statements and initializers. See also [issue |
2884 // 29717](https://github.com/dart-lang/sdk/issues/29717) | 2889 // 29717](https://github.com/dart-lang/sdk/issues/29717) |
2885 addCompileTimeError(charOffset, error); | 2890 addCompileTimeError(charOffset, error); |
2886 String message = formatUnexpected(uri, charOffset, error); | 2891 return library.loader.throwCompileConstantError(library.loader |
2887 Builder constructor = library.loader.getCompileTimeError(); | 2892 .buildCompileTimeError( |
2888 return new Throw(buildStaticInvocation(constructor.target, | 2893 formatUnexpected(uri, charOffset, error), charOffset)); |
2889 new KernelArguments(<Expression>[new StringLiteral(message)]), | |
2890 charOffset: charOffset)); | |
2891 } | 2894 } |
2892 | 2895 |
2893 Expression wrapInCompileTimeError(Expression expression, String message) { | 2896 Expression wrapInCompileTimeError(Expression expression, String message) { |
2894 return new Let( | 2897 return new Let( |
2895 new VariableDeclaration.forValue(expression) | 2898 new VariableDeclaration.forValue(expression) |
2896 ..fileOffset = expression.fileOffset, | 2899 ..fileOffset = expression.fileOffset, |
2897 buildCompileTimeError(message, expression.fileOffset)) | 2900 buildCompileTimeError(message, expression.fileOffset)) |
2898 ..fileOffset = expression.fileOffset; | 2901 ..fileOffset = expression.fileOffset; |
2899 } | 2902 } |
2900 | 2903 |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3574 if (starToken == null) { | 3577 if (starToken == null) { |
3575 return AsyncMarker.Async; | 3578 return AsyncMarker.Async; |
3576 } else { | 3579 } else { |
3577 assert(identical(starToken.stringValue, "*")); | 3580 assert(identical(starToken.stringValue, "*")); |
3578 return AsyncMarker.AsyncStar; | 3581 return AsyncMarker.AsyncStar; |
3579 } | 3582 } |
3580 } else { | 3583 } else { |
3581 return internalError("Unknown async modifier: $asyncToken"); | 3584 return internalError("Unknown async modifier: $asyncToken"); |
3582 } | 3585 } |
3583 } | 3586 } |
OLD | NEW |