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

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

Issue 1004683002: Refactor IrBuilder to use SemanticVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Handle local/static constants and index prefix/postfix. Created 5 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
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 715d599d0160e857c97290d51742360ce13407b6..c233b357ef93db21825b22d9a74afd5d47279c6e 100644
--- a/pkg/compiler/lib/src/resolution/send_structure.dart
+++ b/pkg/compiler/lib/src/resolution/send_structure.dart
@@ -732,6 +732,12 @@ class IndexStructure<R, A> implements SendStructure<R, A> {
semantics.element,
node.arguments.single,
arg);
+ case AccessKind.UNRESOLVED:
+ return visitor.errorUnresolvedSuperIndex(
+ node,
+ semantics.element,
+ node.arguments.single,
+ arg);
default:
// This is not a valid case.
break;
@@ -915,6 +921,132 @@ class IndexSetStructure<R, A> implements SendStructure<R, A> {
}
}
+/// The structure for a [Send] that is an prefix operation on an index
+/// expression, i.e. of the form `--a[b]`.
+class IndexPrefixStructure<R, A> implements SendStructure<R, A> {
+ /// The target of the left operand.
+ final AccessSemantics semantics;
+
+ /// The `++` or `--` operator used in the operation.
+ final IncDecOperator operator;
+
+ // TODO(johnniwinther): Should we store this?
+ /// The [Selector] for the `[]` invocation.
+ final Selector getterSelector;
+
+ // TODO(johnniwinther): Should we store this?
+ /// The [Selector] for the `[]=` invocation.
+ final Selector setterSelector;
+
+ IndexPrefixStructure(this.semantics,
+ this.operator,
+ this.getterSelector,
+ this.setterSelector);
+
+ R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
+ switch (semantics.kind) {
+ case AccessKind.DYNAMIC_PROPERTY:
+ return visitor.visitIndexPrefix(
+ node,
+ node.receiver,
+ node.arguments.single,
+ operator,
+ arg);
+ case AccessKind.UNRESOLVED:
+ return visitor.errorUnresolvedSuperIndexPrefix(
+ node,
+ semantics.element,
+ node.arguments.single,
+ operator,
+ arg);
+ case AccessKind.COMPOUND:
+ CompoundAccessSemantics compoundSemantics = semantics;
+ switch (compoundSemantics.compoundAccessKind) {
+ case CompoundAccessKind.SUPER_GETTER_SETTER:
+ return visitor.visitSuperIndexPrefix(
+ node,
+ compoundSemantics.getter,
+ compoundSemantics.setter,
+ node.arguments.single,
+ operator,
+ arg);
+ default:
+ // This is not a valid case.
+ break;
+ }
+ break;
+ default:
+ // This is not a valid case.
+ break;
+ }
+ throw new SpannableAssertionFailure(
+ node, "Invalid index prefix: ${semantics}");
+ }
+}
+
+/// The structure for a [Send] that is an postfix operation on an index
+/// expression, i.e. of the form `a[b]++`.
+class IndexPostfixStructure<R, A> implements SendStructure<R, A> {
+ /// The target of the left operand.
+ final AccessSemantics semantics;
+
+ /// The `++` or `--` operator used in the operation.
+ final IncDecOperator operator;
+
+ // TODO(johnniwinther): Should we store this?
+ /// The [Selector] for the `[]` invocation.
+ final Selector getterSelector;
+
+ // TODO(johnniwinther): Should we store this?
+ /// The [Selector] for the `[]=` invocation.
+ final Selector setterSelector;
+
+ IndexPostfixStructure(this.semantics,
+ this.operator,
+ this.getterSelector,
+ this.setterSelector);
+
+ R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
+ switch (semantics.kind) {
+ case AccessKind.DYNAMIC_PROPERTY:
+ return visitor.visitIndexPostfix(
+ node,
+ node.receiver,
+ node.arguments.single,
+ operator,
+ arg);
+ case AccessKind.UNRESOLVED:
+ return visitor.errorUnresolvedSuperIndexPostfix(
+ node,
+ semantics.element,
+ node.arguments.single,
+ operator,
+ arg);
+ case AccessKind.COMPOUND:
+ CompoundAccessSemantics compoundSemantics = semantics;
+ switch (compoundSemantics.compoundAccessKind) {
+ case CompoundAccessKind.SUPER_GETTER_SETTER:
+ return visitor.visitSuperIndexPostfix(
+ node,
+ compoundSemantics.getter,
+ compoundSemantics.setter,
+ node.arguments.single,
+ operator,
+ arg);
+ default:
+ // This is not a valid case.
+ break;
+ }
+ break;
+ default:
+ // This is not a valid case.
+ break;
+ }
+ throw new SpannableAssertionFailure(
+ node, "Invalid index postfix: ${semantics}");
+ }
+}
+
/// The structure for a [Send] that is a compound assignment. For instance
/// `a += b`.
class CompoundStructure<R, A> implements SendStructure<R, A> {
« no previous file with comments | « pkg/compiler/lib/src/resolution/send_resolver.dart ('k') | tests/compiler/dart2js/backend_dart/sexpr_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698