Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2764303002: Move throwNoSuchMethodError to BodyBuilder. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/builder_accessors.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 20 matching lines...) Expand all
31 show JumpTargetKind, NullValue, ScopeListener; 31 show JumpTargetKind, NullValue, ScopeListener;
32 32
33 import '../builder/scope.dart' show ProblemBuilder, Scope; 33 import '../builder/scope.dart' show ProblemBuilder, Scope;
34 34
35 import '../source/outline_builder.dart' show asyncMarkerFromTokens; 35 import '../source/outline_builder.dart' show asyncMarkerFromTokens;
36 36
37 import 'builder_accessors.dart'; 37 import 'builder_accessors.dart';
38 38
39 import 'frontend_accessors.dart' show buildIsNull, makeBinary, makeLet; 39 import 'frontend_accessors.dart' show buildIsNull, makeBinary, makeLet;
40 40
41 import 'builder_accessors.dart' as builder_accessors
42 show throwNoSuchMethodError;
43
44 import '../quote.dart' 41 import '../quote.dart'
45 show 42 show
46 Quote, 43 Quote,
47 analyzeQuote, 44 analyzeQuote,
48 unescape, 45 unescape,
49 unescapeFirstStringPart, 46 unescapeFirstStringPart,
50 unescapeLastStringPart, 47 unescapeLastStringPart,
51 unescapeString; 48 unescapeString;
52 49
53 import '../modifier.dart' show Modifier, constMask, finalMask; 50 import '../modifier.dart' show Modifier, constMask, finalMask;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 83
87 class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { 84 class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
88 final KernelLibraryBuilder library; 85 final KernelLibraryBuilder library;
89 86
90 final MemberBuilder member; 87 final MemberBuilder member;
91 88
92 final KernelClassBuilder classBuilder; 89 final KernelClassBuilder classBuilder;
93 90
94 final ClassHierarchy hierarchy; 91 final ClassHierarchy hierarchy;
95 92
96 @override
97 final CoreTypes coreTypes; 93 final CoreTypes coreTypes;
98 94
99 final bool isInstanceMember; 95 final bool isInstanceMember;
100 96
101 final Map<String, FieldInitializer> fieldInitializers = 97 final Map<String, FieldInitializer> fieldInitializers =
102 <String, FieldInitializer>{}; 98 <String, FieldInitializer>{};
103 99
104 final Scope enclosingScope; 100 final Scope enclosingScope;
105 101
106 final bool isDartLibrary; 102 final bool isDartLibrary;
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 receiver = new SuperPropertyGet(node.name, target); 669 receiver = new SuperPropertyGet(node.name, target);
674 return buildMethodInvocation( 670 return buildMethodInvocation(
675 receiver, callName, node.arguments, node.fileOffset); 671 receiver, callName, node.arguments, node.fileOffset);
676 } 672 }
677 673
678 bool areArgumentsCompatible(FunctionNode function, Arguments arguments) { 674 bool areArgumentsCompatible(FunctionNode function, Arguments arguments) {
679 // TODO(ahe): Implement this. 675 // TODO(ahe): Implement this.
680 return true; 676 return true;
681 } 677 }
682 678
679 @override
683 Expression throwNoSuchMethodError( 680 Expression throwNoSuchMethodError(
684 String name, Arguments arguments, int charOffset, 681 String name, Arguments arguments, int charOffset,
685 {bool isSuper: false, isGetter: false, isSetter: false}) { 682 {bool isSuper: false, isGetter: false, isSetter: false}) {
686 return builder_accessors.throwNoSuchMethodError( 683 String errorName = isSuper ? "super.$name" : name;
687 name, arguments, uri, charOffset, coreTypes, 684 if (isGetter) {
688 isSuper: isSuper, isGetter: isGetter, isSetter: isSetter); 685 warning("Getter not found: '$errorName'.", charOffset);
ahe 2017/03/22 12:23:23 Note: before I used printUnexpected. This would re
686 } else if (isSetter) {
687 warning("Setter not found: '$errorName'.", charOffset);
688 } else {
689 warning("Method not found: '$errorName'.", charOffset);
ahe 2017/03/22 12:23:23 Note: changed to use errorName.
690 }
691 Constructor constructor =
692 coreTypes.getClass("dart:core", "NoSuchMethodError").constructors.first;
693 return new Throw(new ConstructorInvocation(
694 constructor,
695 new Arguments(<Expression>[
696 new NullLiteral(),
697 new SymbolLiteral(name),
698 new ListLiteral(arguments.positional),
699 new MapLiteral(arguments.named.map((arg) {
700 return new MapEntry(new SymbolLiteral(arg.name), arg.value);
701 }).toList()),
702 new NullLiteral()
703 ])));
689 } 704 }
690 705
691 @override 706 @override
692 Member lookupSuperMember(Name name, {bool isSetter: false}) { 707 Member lookupSuperMember(Name name, {bool isSetter: false}) {
693 Class superclass = classBuilder.cls.superclass; 708 Class superclass = classBuilder.cls.superclass;
694 return superclass == null 709 return superclass == null
695 ? null 710 ? null
696 : hierarchy.getDispatchTarget(superclass, name, setter: isSetter); 711 : hierarchy.getDispatchTarget(superclass, name, setter: isSetter);
697 } 712 }
698 713
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 void handleLiteralBool(Token token) { 1113 void handleLiteralBool(Token token) {
1099 debugEvent("LiteralBool"); 1114 debugEvent("LiteralBool");
1100 bool value = optional("true", token); 1115 bool value = optional("true", token);
1101 assert(value || optional("false", token)); 1116 assert(value || optional("false", token));
1102 push(new BoolLiteral(value)..fileOffset = token.charOffset); 1117 push(new BoolLiteral(value)..fileOffset = token.charOffset);
1103 } 1118 }
1104 1119
1105 @override 1120 @override
1106 void handleLiteralDouble(Token token) { 1121 void handleLiteralDouble(Token token) {
1107 debugEvent("LiteralDouble"); 1122 debugEvent("LiteralDouble");
1108 push(new DoubleLiteral(double.parse(token.lexeme))..fileOffset = token.charO ffset); 1123 push(new DoubleLiteral(double.parse(token.lexeme))
1124 ..fileOffset = token.charOffset);
1109 } 1125 }
1110 1126
1111 @override 1127 @override
1112 void handleLiteralNull(Token token) { 1128 void handleLiteralNull(Token token) {
1113 debugEvent("LiteralNull"); 1129 debugEvent("LiteralNull");
1114 push(new NullLiteral()..fileOffset = token.charOffset); 1130 push(new NullLiteral()..fileOffset = token.charOffset);
1115 } 1131 }
1116 1132
1117 @override 1133 @override
1118 void handleLiteralMap( 1134 void handleLiteralMap(
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
2782 } else if (node is PrefixBuilder) { 2798 } else if (node is PrefixBuilder) {
2783 return node.name; 2799 return node.name;
2784 } else if (node is ThisAccessor) { 2800 } else if (node is ThisAccessor) {
2785 return node.isSuper ? "super" : "this"; 2801 return node.isSuper ? "super" : "this";
2786 } else if (node is BuilderAccessor) { 2802 } else if (node is BuilderAccessor) {
2787 return node.plainNameForRead; 2803 return node.plainNameForRead;
2788 } else { 2804 } else {
2789 return internalError("Unhandled: ${node.runtimeType}"); 2805 return internalError("Unhandled: ${node.runtimeType}");
2790 } 2806 }
2791 } 2807 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/builder_accessors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698