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 FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; | 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; |
9 | 9 |
10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional; | 10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional; |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 push(receiver); | 605 push(receiver); |
606 } else { | 606 } else { |
607 push(finishSend(receiver, arguments, beginToken.charOffset)); | 607 push(finishSend(receiver, arguments, beginToken.charOffset)); |
608 } | 608 } |
609 } | 609 } |
610 | 610 |
611 @override | 611 @override |
612 finishSend(Object receiver, Arguments arguments, int charOffset) { | 612 finishSend(Object receiver, Arguments arguments, int charOffset) { |
613 bool isIdentical(Object receiver) { | 613 bool isIdentical(Object receiver) { |
614 return receiver is StaticAccessor && | 614 return receiver is StaticAccessor && |
615 receiver.readTarget == | 615 receiver.readTarget == coreTypes.identicalProcedure; |
616 coreTypes.tryGetTopLevelMember("dart:core", null, "identical"); | |
617 } | 616 } |
618 | 617 |
619 if (receiver is FastaAccessor) { | 618 if (receiver is FastaAccessor) { |
620 if (constantExpressionRequired && | 619 if (constantExpressionRequired && |
621 !isIdentical(receiver) && | 620 !isIdentical(receiver) && |
622 !receiver.isInitializer) { | 621 !receiver.isInitializer) { |
623 addCompileTimeError(charOffset, "Not a constant expression."); | 622 addCompileTimeError(charOffset, "Not a constant expression."); |
624 } | 623 } |
625 return receiver.doInvocation(charOffset, arguments); | 624 return receiver.doInvocation(charOffset, arguments); |
626 } else { | 625 } else { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 } else if (isSetter) { | 776 } else if (isSetter) { |
778 message = "Setter not found: '$errorName'."; | 777 message = "Setter not found: '$errorName'."; |
779 } else { | 778 } else { |
780 message = "Method not found: '$errorName'."; | 779 message = "Method not found: '$errorName'."; |
781 } | 780 } |
782 if (constantExpressionRequired) { | 781 if (constantExpressionRequired) { |
783 return buildCompileTimeError(message, charOffset); | 782 return buildCompileTimeError(message, charOffset); |
784 } | 783 } |
785 warning(message, charOffset); | 784 warning(message, charOffset); |
786 Constructor constructor = | 785 Constructor constructor = |
787 coreTypes.getClass("dart:core", "NoSuchMethodError").constructors.first; | 786 coreTypes.noSuchMethodErrorClass.constructors.first; |
788 return new Throw(new ConstructorInvocation( | 787 return new Throw(new ConstructorInvocation( |
789 constructor, | 788 constructor, |
790 astFactory.arguments(<Expression>[ | 789 astFactory.arguments(<Expression>[ |
791 astFactory.nullLiteral(null), | 790 astFactory.nullLiteral(null), |
792 new SymbolLiteral(name), | 791 new SymbolLiteral(name), |
793 new ListLiteral(arguments.positional), | 792 new ListLiteral(arguments.positional), |
794 new MapLiteral(arguments.named.map((arg) { | 793 new MapLiteral(arguments.named.map((arg) { |
795 return new MapEntry(new SymbolLiteral(arg.name), arg.value); | 794 return new MapEntry(new SymbolLiteral(arg.name), arg.value); |
796 }).toList()), | 795 }).toList()), |
797 astFactory.nullLiteral(null) | 796 astFactory.nullLiteral(null) |
(...skipping 2369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3167 if (starToken == null) { | 3166 if (starToken == null) { |
3168 return AsyncMarker.Async; | 3167 return AsyncMarker.Async; |
3169 } else { | 3168 } else { |
3170 assert(identical(starToken.stringValue, "*")); | 3169 assert(identical(starToken.stringValue, "*")); |
3171 return AsyncMarker.AsyncStar; | 3170 return AsyncMarker.AsyncStar; |
3172 } | 3171 } |
3173 } else { | 3172 } else { |
3174 return internalError("Unknown async modifier: $asyncToken"); | 3173 return internalError("Unknown async modifier: $asyncToken"); |
3175 } | 3174 } |
3176 } | 3175 } |
OLD | NEW |