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

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

Issue 1001863003: Update SemanticVisitor with visitIndex, visitSuperIndex (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update analyze_unused_dart2js_test. 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 05f886a441542b6af8a518193e7a86cd54be0699..715d599d0160e857c97290d51742360ce13407b6 100644
--- a/pkg/compiler/lib/src/resolution/send_structure.dart
+++ b/pkg/compiler/lib/src/resolution/send_structure.dart
@@ -706,6 +706,40 @@ class InvalidUnaryStructure<R, A> implements SendStructure<R, A> {
}
}
+/// The structure for a [Send] that is an index expression, i.e. of the form
+/// `a[b]`.
+class IndexStructure<R, A> implements SendStructure<R, A> {
+ /// The target of the left operand.
+ final AccessSemantics semantics;
+
+ // TODO(johnniwinther): Should we store this?
+ /// The [Selector] for the `[]` invocation.
+ final Selector selector;
+
+ IndexStructure(this.semantics, this.selector);
+
+ R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
+ switch (semantics.kind) {
+ case AccessKind.DYNAMIC_PROPERTY:
+ return visitor.visitIndex(
+ node,
+ node.receiver,
+ node.arguments.single,
+ arg);
+ case AccessKind.SUPER_METHOD:
+ return visitor.visitSuperIndex(
+ node,
+ semantics.element,
+ node.arguments.single,
+ arg);
+ default:
+ // This is not a valid case.
+ break;
+ }
+ throw new SpannableAssertionFailure(node, "Invalid index: ${semantics}");
+ }
+}
+
/// The structure for a [Send] that is an equals test, i.e. of the form
/// `a == b`.
class EqualsStructure<R, A> implements SendStructure<R, A> {
@@ -966,28 +1000,28 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
// This is not a valid case.
break;
case AccessKind.CLASS_TYPE_LITERAL:
- return visitor.visitClassTypeLiteralCompound(
+ return visitor.errorClassTypeLiteralCompound(
node,
semantics.constant,
operator,
node.arguments.single,
arg);
case AccessKind.TYPEDEF_TYPE_LITERAL:
- return visitor.visitTypedefTypeLiteralCompound(
+ return visitor.errorTypedefTypeLiteralCompound(
node,
semantics.constant,
operator,
node.arguments.single,
arg);
case AccessKind.DYNAMIC_TYPE_LITERAL:
- return visitor.visitDynamicTypeLiteralCompound(
+ return visitor.errorDynamicTypeLiteralCompound(
node,
semantics.constant,
operator,
node.arguments.single,
arg);
case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
- return visitor.visitTypeVariableTypeLiteralCompound(
+ return visitor.errorTypeVariableTypeLiteralCompound(
node,
semantics.element,
operator,
@@ -1253,25 +1287,25 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
// This is not a valid case.
break;
case AccessKind.CLASS_TYPE_LITERAL:
- return visitor.visitClassTypeLiteralPrefix(
+ return visitor.errorClassTypeLiteralPrefix(
node,
semantics.constant,
operator,
arg);
case AccessKind.TYPEDEF_TYPE_LITERAL:
- return visitor.visitTypedefTypeLiteralPrefix(
+ return visitor.errorTypedefTypeLiteralPrefix(
node,
semantics.constant,
operator,
arg);
case AccessKind.DYNAMIC_TYPE_LITERAL:
- return visitor.visitDynamicTypeLiteralPrefix(
+ return visitor.errorDynamicTypeLiteralPrefix(
node,
semantics.constant,
operator,
arg);
case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
- return visitor.visitTypeVariableTypeLiteralPrefix(
+ return visitor.errorTypeVariableTypeLiteralPrefix(
node,
semantics.element,
operator,
@@ -1465,25 +1499,25 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
// This is not a valid case.
break;
case AccessKind.CLASS_TYPE_LITERAL:
- return visitor.visitClassTypeLiteralPostfix(
+ return visitor.errorClassTypeLiteralPostfix(
node,
semantics.constant,
operator,
arg);
case AccessKind.TYPEDEF_TYPE_LITERAL:
- return visitor.visitTypedefTypeLiteralPostfix(
+ return visitor.errorTypedefTypeLiteralPostfix(
node,
semantics.constant,
operator,
arg);
case AccessKind.DYNAMIC_TYPE_LITERAL:
- return visitor.visitDynamicTypeLiteralPostfix(
+ return visitor.errorDynamicTypeLiteralPostfix(
node,
semantics.constant,
operator,
arg);
case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
- return visitor.visitTypeVariableTypeLiteralPostfix(
+ return visitor.errorTypeVariableTypeLiteralPostfix(
node,
semantics.element,
operator,
« no previous file with comments | « pkg/compiler/lib/src/resolution/send_resolver.dart ('k') | tests/compiler/dart2js/analyze_unused_dart2js_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698