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 '../parser/parser.dart' show FormalParameterType, optional; | 7 import '../parser/parser.dart' show FormalParameterType, optional; |
8 | 8 |
9 import '../parser/error_kind.dart' show ErrorKind; | 9 import '../parser/error_kind.dart' show ErrorKind; |
10 | 10 |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 push(receiver); | 512 push(receiver); |
513 } else { | 513 } else { |
514 push(finishSend(receiver, arguments, beginToken.charOffset)); | 514 push(finishSend(receiver, arguments, beginToken.charOffset)); |
515 } | 515 } |
516 } | 516 } |
517 | 517 |
518 @override | 518 @override |
519 finishSend(Object receiver, Arguments arguments, int charOffset) { | 519 finishSend(Object receiver, Arguments arguments, int charOffset) { |
520 if (receiver is BuilderAccessor) { | 520 if (receiver is BuilderAccessor) { |
521 if (constantExpressionRequired) { | 521 if (constantExpressionRequired) { |
522 addCompileTimeError(charOffset, "Not a constant expression."); | 522 if (!(receiver is StaticAccessor && |
karlklose
2017/03/24 08:42:30
Maybe move the checks in l. 523-525 to a helper ca
ahe
2017/03/24 13:14:35
Done.
| |
523 receiver.readTarget == | |
524 coreTypes.tryGetTopLevelMember( | |
525 "dart:core", null, "identical"))) { | |
526 addCompileTimeError(charOffset, "Not a constant expression."); | |
527 } | |
523 } | 528 } |
524 return receiver.doInvocation(charOffset, arguments); | 529 return receiver.doInvocation(charOffset, arguments); |
525 } else if (receiver is UnresolvedIdentifier) { | 530 } else if (receiver is UnresolvedIdentifier) { |
526 return throwNoSuchMethodError( | 531 return throwNoSuchMethodError( |
527 receiver.name.name, arguments, receiver.fileOffset); | 532 receiver.name.name, arguments, receiver.fileOffset); |
528 } else { | 533 } else { |
529 return buildMethodInvocation( | 534 return buildMethodInvocation( |
530 toValue(receiver), callName, arguments, charOffset); | 535 toValue(receiver), callName, arguments, charOffset); |
531 } | 536 } |
532 } | 537 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
792 setter = builder; | 797 setter = builder; |
793 } else if (builder.isGetter) { | 798 } else if (builder.isGetter) { |
794 setter = scope.lookupSetter(name, charOffset, uri); | 799 setter = scope.lookupSetter(name, charOffset, uri); |
795 } else if (builder.isField && !builder.isFinal) { | 800 } else if (builder.isField && !builder.isFinal) { |
796 setter = builder; | 801 setter = builder; |
797 } | 802 } |
798 StaticAccessor accessor = | 803 StaticAccessor accessor = |
799 new StaticAccessor.fromBuilder(this, builder, charOffset, setter); | 804 new StaticAccessor.fromBuilder(this, builder, charOffset, setter); |
800 if (constantExpressionRequired) { | 805 if (constantExpressionRequired) { |
801 Member readTarget = accessor.readTarget; | 806 Member readTarget = accessor.readTarget; |
802 if (!(readTarget is Field && readTarget.isConst)) { | 807 if (!(readTarget is Field && readTarget.isConst || |
808 // Static tear-offs are also compile time constants. | |
809 readTarget is Procedure)) { | |
803 addCompileTimeError(charOffset, "Not a constant expression."); | 810 addCompileTimeError(charOffset, "Not a constant expression."); |
804 } | 811 } |
805 } | 812 } |
806 return accessor; | 813 return accessor; |
807 } | 814 } |
808 } | 815 } |
809 | 816 |
810 @override | 817 @override |
811 void handleQualified(Token period) { | 818 void handleQualified(Token period) { |
812 debugEvent("Qualified"); | 819 debugEvent("Qualified"); |
(...skipping 2037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2850 } else if (node is PrefixBuilder) { | 2857 } else if (node is PrefixBuilder) { |
2851 return node.name; | 2858 return node.name; |
2852 } else if (node is ThisAccessor) { | 2859 } else if (node is ThisAccessor) { |
2853 return node.isSuper ? "super" : "this"; | 2860 return node.isSuper ? "super" : "this"; |
2854 } else if (node is BuilderAccessor) { | 2861 } else if (node is BuilderAccessor) { |
2855 return node.plainNameForRead; | 2862 return node.plainNameForRead; |
2856 } else { | 2863 } else { |
2857 return internalError("Unhandled: ${node.runtimeType}"); | 2864 return internalError("Unhandled: ${node.runtimeType}"); |
2858 } | 2865 } |
2859 } | 2866 } |
OLD | NEW |