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

Unified Diff: pkg/compiler/lib/src/resolution/send_structure.dart

Issue 1842033004: Add *IndexSetIfNull methods to SemanticSendVisitor. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/send_structure.dart
diff --git a/pkg/compiler/lib/src/resolution/send_structure.dart b/pkg/compiler/lib/src/resolution/send_structure.dart
index 5ff76effa0b996fe8a516ee26f86c3f4a76fb6ff..647e80e693b3090770da279179e6bd6e4f0af213 100644
--- a/pkg/compiler/lib/src/resolution/send_structure.dart
+++ b/pkg/compiler/lib/src/resolution/send_structure.dart
@@ -1990,6 +1990,80 @@ class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> {
String toString() => 'compound []=($operator,$semantics)';
}
+/// The structure for a [Send] that is a if-null assignment on the index
+/// operator. For instance `a[b] ??= c`.
+class IndexSetIfNullStructure<R, A> implements SendStructure<R, A> {
+ /// The target of the index operations.
+ final AccessSemantics semantics;
+
+ IndexSetIfNullStructure(this.semantics);
+
+ R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
+ switch (semantics.kind) {
+ case AccessKind.EXPRESSION:
+ return visitor.visitIndexSetIfNull(
+ node,
+ node.receiver,
+ node.arguments.first,
+ node.arguments.tail.head,
+ arg);
+ case AccessKind.UNRESOLVED_SUPER:
+ return visitor.visitUnresolvedSuperIndexSetIfNull(
+ node,
+ semantics.element,
+ node.arguments.first,
+ node.arguments.tail.head,
+ arg);
+ case AccessKind.INVALID:
+ return visitor.errorInvalidIndexSetIfNull(
+ node,
+ semantics.element,
+ node.arguments.first,
+ node.arguments.tail.head,
+ arg);
+ case AccessKind.COMPOUND:
+ CompoundAccessSemantics compoundSemantics = semantics;
+ switch (compoundSemantics.compoundAccessKind) {
+ case CompoundAccessKind.SUPER_GETTER_SETTER:
+ return visitor.visitSuperIndexSetIfNull(
+ node,
+ compoundSemantics.getter,
+ compoundSemantics.setter,
+ node.arguments.first,
+ node.arguments.tail.head,
+ arg);
+ case CompoundAccessKind.UNRESOLVED_SUPER_GETTER:
+ return visitor.visitUnresolvedSuperGetterIndexSetIfNull(
+ node,
+ compoundSemantics.getter,
+ compoundSemantics.setter,
+ node.arguments.first,
+ node.arguments.tail.head,
+ arg);
+ case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
+ return visitor.visitUnresolvedSuperSetterIndexSetIfNull(
+ node,
+ compoundSemantics.getter,
+ compoundSemantics.setter,
+ node.arguments.first,
+ node.arguments.tail.head,
+ arg);
+ default:
+ // This is not a valid case.
+ break;
+ }
+ break;
+ default:
+ // This is not a valid case.
+ break;
+ }
+ throw new SpannableAssertionFailure(
+ node, "Invalid index set if-null: ${semantics}");
+ }
+
+ String toString() => 'index set if-null []??=($semantics)';
+}
+
/// The structure for a [Send] that is a prefix operations. For instance
/// `++a`.
class PrefixStructure<R, A> implements SendStructure<R, A> {
« no previous file with comments | « pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698