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

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

Issue 2704143003: Implement super operators. (Closed)
Patch Set: 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
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 'package:front_end/src/fasta/parser/parser.dart' show 7 import 'package:front_end/src/fasta/parser/parser.dart' show
8 FormalParameterType, 8 FormalParameterType,
9 optional; 9 optional;
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 final Name leftShiftName = new Name("<<"); 96 final Name leftShiftName = new Name("<<");
97 97
98 final Name rightShiftName = new Name(">>"); 98 final Name rightShiftName = new Name(">>");
99 99
100 final Name caretName = new Name("^"); 100 final Name caretName = new Name("^");
101 101
102 final Name barName = new Name("|"); 102 final Name barName = new Name("|");
103 103
104 final Name mustacheName = new Name("~/"); 104 final Name mustacheName = new Name("~/");
105 105
106 final Name indexGetName = new Name("[]");
107
108 final Name indexSetName = new Name("[]=");
109
106 class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { 110 class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
107 final KernelLibraryBuilder library; 111 final KernelLibraryBuilder library;
108 112
109 final MemberBuilder member; 113 final MemberBuilder member;
110 114
111 final KernelClassBuilder classBuilder; 115 final KernelClassBuilder classBuilder;
112 116
113 final ClassHierarchy hierarchy; 117 final ClassHierarchy hierarchy;
114 118
115 @override 119 @override
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 void handleNoExpression(Token token) { 1441 void handleNoExpression(Token token) {
1438 debugEvent("NoExpression"); 1442 debugEvent("NoExpression");
1439 push(NullValue.Expression); 1443 push(NullValue.Expression);
1440 } 1444 }
1441 1445
1442 @override 1446 @override
1443 void handleIndexedExpression( 1447 void handleIndexedExpression(
1444 Token openCurlyBracket, Token closeCurlyBracket) { 1448 Token openCurlyBracket, Token closeCurlyBracket) {
1445 debugEvent("IndexedExpression"); 1449 debugEvent("IndexedExpression");
1446 Expression index = popForValue(); 1450 Expression index = popForValue();
1447 Expression receiver = popForValue(); 1451 var receiver = pop();
karlklose 2017/02/20 13:10:41 Keep the type annotation?
ahe 2017/02/20 13:18:42 The annotation doesn't work anymore because Access
1448 push(IndexAccessor.make(this, openCurlyBracket.charOffset, receiver, index, 1452 if (receiver is ThisAccessor && receiver.isSuper) {
1449 null, null)); 1453 push(new SuperIndexAccessor(
1454 this, receiver.charOffset, index,
1455 lookupSuperMember(indexGetName),
1456 lookupSuperMember(indexSetName)));
1457 } else {
1458 push(IndexAccessor.make(this, openCurlyBracket.charOffset,
1459 toValue(receiver), index, null, null));
1460 }
1450 } 1461 }
1451 1462
1452 @override 1463 @override
1453 void handleUnaryPrefixExpression(Token token) { 1464 void handleUnaryPrefixExpression(Token token) {
1454 debugEvent("UnaryPrefixExpression"); 1465 debugEvent("UnaryPrefixExpression");
1455 Expression expression = popForValue(); 1466 var receiver = pop();
1456 if (optional("!", token)) { 1467 if (optional("!", token)) {
1457 push(new Not(expression)); 1468 push(new Not(toValue(receiver)));
1458 } else { 1469 } else {
1459 String operator = token.stringValue; 1470 String operator = token.stringValue;
1460 if (optional("-", token)) { 1471 if (optional("-", token)) {
1461 operator = "unary-"; 1472 operator = "unary-";
1462 } 1473 }
1463 push(buildMethodInvocation(expression, new Name(operator), 1474 if (receiver is ThisAccessor && receiver.isSuper) {
1464 new Arguments.empty(), token.charOffset)); 1475 push(toSuperMethodInvocation(buildMethodInvocation(
1476 new ThisExpression()..fileOffset = receiver.charOffset,
1477 new Name(operator), new Arguments.empty(), token.charOffset)));
1478 } else {
1479 push(buildMethodInvocation(toValue(receiver), new Name(operator),
1480 new Arguments.empty(), token.charOffset));
1481 }
1465 } 1482 }
1466 } 1483 }
1467 1484
1468 Name incrementOperator(Token token) { 1485 Name incrementOperator(Token token) {
1469 if (optional("++", token)) return plusName; 1486 if (optional("++", token)) return plusName;
1470 if (optional("--", token)) return minusName; 1487 if (optional("--", token)) return minusName;
1471 return internalError("Unknown increment operator: ${token.value}"); 1488 return internalError("Unknown increment operator: ${token.value}");
1472 } 1489 }
1473 1490
1474 @override 1491 @override
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 } else if (node is TypeDeclarationBuilder) { 2696 } else if (node is TypeDeclarationBuilder) {
2680 return node.name; 2697 return node.name;
2681 } else if (node is PrefixBuilder) { 2698 } else if (node is PrefixBuilder) {
2682 return node.name; 2699 return node.name;
2683 } else if (node is ThisPropertyAccessor) { 2700 } else if (node is ThisPropertyAccessor) {
2684 return node.name.name; 2701 return node.name.name;
2685 } else { 2702 } else {
2686 return internalError("Unhandled: ${node.runtimeType}"); 2703 return internalError("Unhandled: ${node.runtimeType}");
2687 } 2704 }
2688 } 2705 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698