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

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

Issue 2845723002: Simplify BodyBuilder's Identifier class. (Closed)
Patch Set: Created 3 years, 7 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 | no next file » | 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 '../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, optional; 10 import '../parser/parser.dart' show FormalParameterType, optional;
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 } else { 1351 } else {
1352 return internalError("Unhandled: ${name.runtimeType}"); 1352 return internalError("Unhandled: ${name.runtimeType}");
1353 } 1353 }
1354 } 1354 }
1355 1355
1356 @override 1356 @override
1357 void endLiteralSymbol(Token hashToken, int identifierCount) { 1357 void endLiteralSymbol(Token hashToken, int identifierCount) {
1358 debugEvent("LiteralSymbol"); 1358 debugEvent("LiteralSymbol");
1359 String value; 1359 String value;
1360 if (identifierCount == 1) { 1360 if (identifierCount == 1) {
1361 value = symbolPartToString(popForValue()); 1361 value = symbolPartToString(pop());
1362 } else { 1362 } else {
1363 List parts = popList(identifierCount); 1363 List parts = popList(identifierCount);
1364 value = symbolPartToString(parts.first); 1364 value = symbolPartToString(parts.first);
1365 for (int i = 1; i < parts.length; i++) { 1365 for (int i = 1; i < parts.length; i++) {
1366 value += ".${symbolPartToString(parts[i])}"; 1366 value += ".${symbolPartToString(parts[i])}";
1367 } 1367 }
1368 } 1368 }
1369 push(new SymbolLiteral(value)); 1369 push(new SymbolLiteral(value));
1370 } 1370 }
1371 1371
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 if (fieldDependencies != null && readTarget is KernelField) { 2659 if (fieldDependencies != null && readTarget is KernelField) {
2660 var fieldNode = _typeInferrer.getFieldNodeForReadTarget(readTarget); 2660 var fieldNode = _typeInferrer.getFieldNodeForReadTarget(readTarget);
2661 if (fieldNode != null) { 2661 if (fieldNode != null) {
2662 fieldDependencies.add(fieldNode); 2662 fieldDependencies.add(fieldNode);
2663 } 2663 }
2664 } 2664 }
2665 return astFactory.staticGet(readTarget, offset); 2665 return astFactory.staticGet(readTarget, offset);
2666 } 2666 }
2667 } 2667 }
2668 2668
2669 // TODO(ahe): Shouldn't need to be an expression. 2669 class Identifier {
2670 class Identifier extends InvalidExpression {
2671 final String name; 2670 final String name;
2671 final int fileOffset;
2672 2672
2673 Identifier(this.name, int charOffset) { 2673 Identifier(this.name, int charOffset) : fileOffset = charOffset;
2674 fileOffset = charOffset;
2675 }
2676 2674
2677 Expression get initializer => null; 2675 Expression get initializer => null;
2678 2676
2679 String toString() => "identifier($name)"; 2677 String toString() => "identifier($name)";
2680 } 2678 }
2681 2679
2682 // TODO(ahe): Shouldn't need to be an expression. 2680 // TODO(ahe): Shouldn't need to be an expression.
2683 class Operator extends InvalidExpression { 2681 class Operator extends InvalidExpression {
2684 final String name; 2682 final String name;
2685 2683
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
3125 } else if (node is PrefixBuilder) { 3123 } else if (node is PrefixBuilder) {
3126 return node.name; 3124 return node.name;
3127 } else if (node is ThisAccessor) { 3125 } else if (node is ThisAccessor) {
3128 return node.isSuper ? "super" : "this"; 3126 return node.isSuper ? "super" : "this";
3129 } else if (node is FastaAccessor) { 3127 } else if (node is FastaAccessor) {
3130 return node.plainNameForRead; 3128 return node.plainNameForRead;
3131 } else { 3129 } else {
3132 return internalError("Unhandled: ${node.runtimeType}"); 3130 return internalError("Unhandled: ${node.runtimeType}");
3133 } 3131 }
3134 } 3132 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698