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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index b450b3572c7d485b5419ad99407d7812f03a0465..901b4cb6a2bb94bd505a37e7f6f6fc95fcce5c59 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -103,6 +103,10 @@ final Name barName = new Name("|");
final Name mustacheName = new Name("~/");
+final Name indexGetName = new Name("[]");
+
+final Name indexSetName = new Name("[]=");
+
class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
final KernelLibraryBuilder library;
@@ -1444,24 +1448,37 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
Token openCurlyBracket, Token closeCurlyBracket) {
debugEvent("IndexedExpression");
Expression index = popForValue();
- Expression receiver = popForValue();
- push(IndexAccessor.make(this, openCurlyBracket.charOffset, receiver, index,
- null, null));
+ 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
+ if (receiver is ThisAccessor && receiver.isSuper) {
+ push(new SuperIndexAccessor(
+ this, receiver.charOffset, index,
+ lookupSuperMember(indexGetName),
+ lookupSuperMember(indexSetName)));
+ } else {
+ push(IndexAccessor.make(this, openCurlyBracket.charOffset,
+ toValue(receiver), index, null, null));
+ }
}
@override
void handleUnaryPrefixExpression(Token token) {
debugEvent("UnaryPrefixExpression");
- Expression expression = popForValue();
+ var receiver = pop();
if (optional("!", token)) {
- push(new Not(expression));
+ push(new Not(toValue(receiver)));
} else {
String operator = token.stringValue;
if (optional("-", token)) {
operator = "unary-";
}
- push(buildMethodInvocation(expression, new Name(operator),
- new Arguments.empty(), token.charOffset));
+ if (receiver is ThisAccessor && receiver.isSuper) {
+ push(toSuperMethodInvocation(buildMethodInvocation(
+ new ThisExpression()..fileOffset = receiver.charOffset,
+ new Name(operator), new Arguments.empty(), token.charOffset)));
+ } else {
+ push(buildMethodInvocation(toValue(receiver), new Name(operator),
+ new Arguments.empty(), token.charOffset));
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698