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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/outline_builder.dart

Issue 2680323002: Handle operators correctly. (Closed)
Patch Set: Rename Operator.index to Operator.indexGet. Created 3 years, 10 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 | « pkg/front_end/lib/src/fasta/operator.dart ('k') | pkg/front_end/test/fasta/compile.status » ('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.outline_builder; 5 library fasta.outline_builder;
6 6
7 import 'package:kernel/ast.dart' show 7 import 'package:kernel/ast.dart' show
8 AsyncMarker, 8 AsyncMarker,
9 ProcedureKind; 9 ProcedureKind;
10 10
(...skipping 26 matching lines...) Expand all
37 Unhandled, 37 Unhandled,
38 UnhandledListener; 38 UnhandledListener;
39 39
40 import '../parser/error_kind.dart' show 40 import '../parser/error_kind.dart' show
41 ErrorKind; 41 ErrorKind;
42 42
43 import '../parser/dart_vm_native.dart' show 43 import '../parser/dart_vm_native.dart' show
44 removeNativeClause, 44 removeNativeClause,
45 skipNativeClause; 45 skipNativeClause;
46 46
47 import '../operator.dart' show
48 Operator,
49 operatorFromString,
50 operatorToString;
51
47 enum MethodBody { 52 enum MethodBody {
48 Abstract, 53 Abstract,
49 Regular, 54 Regular,
50 RedirectingFactoryBody, 55 RedirectingFactoryBody,
51 } 56 }
52 57
53 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) { 58 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) {
54 if (asyncToken == null || identical(asyncToken.stringValue, "sync")) { 59 if (asyncToken == null || identical(asyncToken.stringValue, "sync")) {
55 if (starToken == null) { 60 if (starToken == null) {
56 return AsyncMarker.Sync; 61 return AsyncMarker.Sync;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 debugEvent("Part"); 154 debugEvent("Part");
150 String uri = pop(); 155 String uri = pop();
151 List<MetadataBuilder> metadata = pop(); 156 List<MetadataBuilder> metadata = pop();
152 library.addPart(metadata, uri); 157 library.addPart(metadata, uri);
153 checkEmpty(); 158 checkEmpty();
154 } 159 }
155 160
156 @override 161 @override
157 void handleOperatorName(Token operatorKeyword, Token token) { 162 void handleOperatorName(Token operatorKeyword, Token token) {
158 debugEvent("OperatorName"); 163 debugEvent("OperatorName");
159 push(token.stringValue); 164 push(operatorFromString(token.stringValue));
160 } 165 }
161 166
162 @override 167 @override
163 void endIdentifierList(int count) { 168 void endIdentifierList(int count) {
164 debugEvent("endIdentifierList"); 169 debugEvent("endIdentifierList");
165 push(popList(count) ?? NullValue.IdentifierList); 170 push(popList(count) ?? NullValue.IdentifierList);
166 } 171 }
167 172
168 @override 173 @override
169 void handleQualified(Token period) { 174 void handleQualified(Token period) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 240
236 @override 241 @override
237 void handleFunctionBodySkipped(Token token) { 242 void handleFunctionBodySkipped(Token token) {
238 debugEvent("handleFunctionBodySkipped"); 243 debugEvent("handleFunctionBodySkipped");
239 push(MethodBody.Regular); 244 push(MethodBody.Regular);
240 } 245 }
241 246
242 @override 247 @override
243 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 248 void endMethod(Token getOrSet, Token beginToken, Token endToken) {
244 debugEvent("Method"); 249 debugEvent("Method");
245 MethodBody kind = pop(); 250 MethodBody bodyKind = pop();
246 if (kind == MethodBody.RedirectingFactoryBody) { 251 if (bodyKind == MethodBody.RedirectingFactoryBody) {
247 // This will cause an error later. 252 // This will cause an error later.
248 pop(); 253 pop();
249 } 254 }
250 AsyncMarker asyncModifier = pop(); 255 AsyncMarker asyncModifier = pop();
251 List<FormalParameterBuilder> formals = pop(); 256 List<FormalParameterBuilder> formals = pop();
252 List<TypeVariableBuilder> typeVariables = pop(); 257 List<TypeVariableBuilder> typeVariables = pop();
253 String name = pop(); 258 dynamic nameOrOperator = pop();
254 if (identical("-", name) && formals == null) { 259 if (Operator.subtract == nameOrOperator && formals == null) {
255 name = "unary-"; 260 nameOrOperator = Operator.unaryMinus;
261 }
262 String name;
263 ProcedureKind kind;
264 if (nameOrOperator is Operator) {
265 name = operatorToString(nameOrOperator);
266 kind = ProcedureKind.Operator;
267 } else {
268 name = nameOrOperator;
269 kind = computeProcedureKind(getOrSet);
256 } 270 }
257 TypeBuilder returnType = pop(); 271 TypeBuilder returnType = pop();
258 int modifiers = Modifier.validate(pop(), 272 int modifiers = Modifier.validate(pop(),
259 isAbstract: kind == MethodBody.Abstract); 273 isAbstract: bodyKind == MethodBody.Abstract);
260 List<MetadataBuilder> metadata = pop(); 274 List<MetadataBuilder> metadata = pop();
261 library.addProcedure(metadata, modifiers, returnType, name, typeVariables, 275 library.addProcedure(metadata, modifiers, returnType, name, typeVariables,
262 formals, asyncModifier, computeProcedureKind(getOrSet)); 276 formals, asyncModifier, kind);
263 } 277 }
264 278
265 @override 279 @override
266 void endMixinApplication() { 280 void endMixinApplication() {
267 debugEvent("MixinApplication"); 281 debugEvent("MixinApplication");
268 List<TypeBuilder> mixins = pop(); 282 List<TypeBuilder> mixins = pop();
269 TypeBuilder supertype = pop(); 283 TypeBuilder supertype = pop();
270 push(library.addMixinApplication(supertype, mixins)); 284 push(library.addMixinApplication(supertype, mixins));
271 } 285 }
272 286
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 Link<Token> handleMemberName(Link<Token> identifiers) { 565 Link<Token> handleMemberName(Link<Token> identifiers) {
552 if (!isDartLibrary || identifiers.isEmpty) return identifiers; 566 if (!isDartLibrary || identifiers.isEmpty) return identifiers;
553 return removeNativeClause(identifiers); 567 return removeNativeClause(identifiers);
554 } 568 }
555 569
556 @override 570 @override
557 void debugEvent(String name) { 571 void debugEvent(String name) {
558 // printEvent(name); 572 // printEvent(name);
559 } 573 }
560 } 574 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/operator.dart ('k') | pkg/front_end/test/fasta/compile.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698