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

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

Issue 1867333002: Add kinds for serialization. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 4 years, 8 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/operators.dart ('k') | no next file » | 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 bdf8762cb77ce4ae6931b1632f0b71811e871559..53c0356fe00de98b12ca8ca6b80500d093651550 100644
--- a/pkg/compiler/lib/src/resolution/send_structure.dart
+++ b/pkg/compiler/lib/src/resolution/send_structure.dart
@@ -24,6 +24,37 @@ abstract class SemanticSendStructure<R, A> {
R dispatch(SemanticSendVisitor<R, A> visitor, Node node, A arg);
}
+enum SendStructureKind {
+ IF_NULL,
+ LOGICAL_AND,
+ LOGICAL_OR,
+ IS,
+ IS_NOT,
+ AS,
+ INVOKE,
+ INCOMPATIBLE_INVOKE,
+ GET,
+ SET,
+ NOT,
+ UNARY,
+ INVALID_UNARY,
+ INDEX,
+ EQUALS,
+ NOT_EQUALS,
+ BINARY,
+ INVALID_BINARY,
+ INDEX_SET,
+ INDEX_PREFIX,
+ INDEX_POSTFIX,
+ COMPOUND,
+ SET_IF_NULL,
+ COMPOUND_INDEX_SET,
+ INDEX_SET_IF_NULL,
+ PREFIX,
+ POSTFIX,
+ DEFERRED_PREFIX,
+}
+
/// Interface for the structure of the semantics of a [Send] node.
///
/// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`,
@@ -31,6 +62,8 @@ abstract class SemanticSendStructure<R, A> {
abstract class SendStructure<R, A> extends SemanticSendStructure<R, A> {
/// Calls the matching visit method on [visitor] with [send] and [arg].
R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg);
+
+ SendStructureKind get kind;
}
/// The structure for a [Send] of the form `a ?? b`.
@@ -41,6 +74,9 @@ class IfNullStructure<R, A> implements SendStructure<R, A> {
return visitor.visitIfNull(node, node.receiver, node.arguments.single, arg);
}
+ @override
+ SendStructureKind get kind => SendStructureKind.IF_NULL;
+
String toString() => '??';
}
@@ -53,6 +89,9 @@ class LogicalAndStructure<R, A> implements SendStructure<R, A> {
node, node.receiver, node.arguments.single, arg);
}
+ @override
+ SendStructureKind get kind => SendStructureKind.LOGICAL_AND;
+
String toString() => '&&';
}
@@ -65,6 +104,9 @@ class LogicalOrStructure<R, A> implements SendStructure<R, A> {
node, node.receiver, node.arguments.single, arg);
}
+ @override
+ SendStructureKind get kind => SendStructureKind.LOGICAL_OR;
+
String toString() => '||';
}
@@ -79,6 +121,9 @@ class IsStructure<R, A> implements SendStructure<R, A> {
return visitor.visitIs(node, node.receiver, type, arg);
}
+ @override
+ SendStructureKind get kind => SendStructureKind.IS;
+
String toString() => 'is $type';
}
@@ -93,6 +138,9 @@ class IsNotStructure<R, A> implements SendStructure<R, A> {
return visitor.visitIsNot(node, node.receiver, type, arg);
}
+ @override
+ SendStructureKind get kind => SendStructureKind.IS_NOT;
+
String toString() => 'is! $type';
}
@@ -107,6 +155,9 @@ class AsStructure<R, A> implements SendStructure<R, A> {
return visitor.visitAs(node, node.receiver, type, arg);
}
+ @override
+ SendStructureKind get kind => SendStructureKind.AS;
+
String toString() => 'as $type';
}
@@ -125,6 +176,9 @@ class InvokeStructure<R, A> implements SendStructure<R, A> {
InvokeStructure(this.semantics, this.selector);
+ @override
+ SendStructureKind get kind => SendStructureKind.INVOKE;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
@@ -260,6 +314,9 @@ class IncompatibleInvokeStructure<R, A> implements SendStructure<R, A> {
IncompatibleInvokeStructure(this.semantics, this.selector);
+ @override
+ SendStructureKind get kind => SendStructureKind.INCOMPATIBLE_INVOKE;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.STATIC_METHOD:
@@ -292,6 +349,9 @@ class GetStructure<R, A> implements SendStructure<R, A> {
GetStructure(this.semantics);
+ @override
+ SendStructureKind get kind => SendStructureKind.GET;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
@@ -379,6 +439,9 @@ class SetStructure<R, A> implements SendStructure<R, A> {
SetStructure(this.semantics);
+ @override
+ SendStructureKind get kind => SendStructureKind.SET;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
@@ -498,6 +561,9 @@ class NotStructure<R, A> implements SendStructure<R, A> {
return visitor.visitNot(node, node.receiver, arg);
}
+ @override
+ SendStructureKind get kind => SendStructureKind.NOT;
+
String toString() => 'not()';
}
@@ -512,6 +578,9 @@ class UnaryStructure<R, A> implements SendStructure<R, A> {
UnaryStructure(this.semantics, this.operator);
+ @override
+ SendStructureKind get kind => SendStructureKind.UNARY;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.EXPRESSION:
@@ -545,6 +614,9 @@ class InvalidUnaryStructure<R, A> implements SendStructure<R, A> {
node, node.selector, node.receiver, arg);
}
+ @override
+ SendStructureKind get kind => SendStructureKind.INVALID_UNARY;
+
String toString() => 'invalid unary';
}
@@ -556,6 +628,9 @@ class IndexStructure<R, A> implements SendStructure<R, A> {
IndexStructure(this.semantics);
+ @override
+ SendStructureKind get kind => SendStructureKind.INDEX;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.EXPRESSION:
@@ -586,6 +661,9 @@ class EqualsStructure<R, A> implements SendStructure<R, A> {
EqualsStructure(this.semantics);
+ @override
+ SendStructureKind get kind => SendStructureKind.EQUALS;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.EXPRESSION:
@@ -615,6 +693,9 @@ class NotEqualsStructure<R, A> implements SendStructure<R, A> {
NotEqualsStructure(this.semantics);
+ @override
+ SendStructureKind get kind => SendStructureKind.NOT_EQUALS;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.EXPRESSION:
@@ -648,6 +729,9 @@ class BinaryStructure<R, A> implements SendStructure<R, A> {
BinaryStructure(this.semantics, this.operator);
+ @override
+ SendStructureKind get kind => SendStructureKind.BINARY;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.EXPRESSION:
@@ -683,6 +767,9 @@ class InvalidBinaryStructure<R, A> implements SendStructure<R, A> {
node, node.receiver, node.selector, node.arguments.single, arg);
}
+ @override
+ SendStructureKind get kind => SendStructureKind.INVALID_BINARY;
+
String toString() => 'invalid binary';
}
@@ -693,6 +780,9 @@ class IndexSetStructure<R, A> implements SendStructure<R, A> {
IndexSetStructure(this.semantics);
+ @override
+ SendStructureKind get kind => SendStructureKind.INDEX_SET;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.EXPRESSION:
@@ -730,6 +820,9 @@ class IndexPrefixStructure<R, A> implements SendStructure<R, A> {
IndexPrefixStructure(this.semantics, this.operator);
+ @override
+ SendStructureKind get kind => SendStructureKind.INDEX_PREFIX;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.EXPRESSION:
@@ -788,6 +881,9 @@ class IndexPostfixStructure<R, A> implements SendStructure<R, A> {
IndexPostfixStructure(this.semantics, this.operator);
+ @override
+ SendStructureKind get kind => SendStructureKind.INDEX_POSTFIX;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.EXPRESSION:
@@ -851,6 +947,9 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
CompoundStructure(this.semantics, this.operator);
+ @override
+ SendStructureKind get kind => SendStructureKind.COMPOUND;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
@@ -1098,6 +1197,9 @@ class SetIfNullStructure<R, A> implements SendStructure<R, A> {
SetIfNullStructure(this.semantics);
+ @override
+ SendStructureKind get kind => SendStructureKind.SET_IF_NULL;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
@@ -1328,6 +1430,9 @@ class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> {
CompoundIndexSetStructure(this.semantics, this.operator);
+ @override
+ SendStructureKind get kind => SendStructureKind.COMPOUND_INDEX_SET;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.EXPRESSION:
@@ -1398,6 +1503,9 @@ class IndexSetIfNullStructure<R, A> implements SendStructure<R, A> {
IndexSetIfNullStructure(this.semantics);
+ @override
+ SendStructureKind get kind => SendStructureKind.INDEX_SET;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.EXPRESSION:
@@ -1467,6 +1575,9 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
PrefixStructure(this.semantics, this.operator);
+ @override
+ SendStructureKind get kind => SendStructureKind.PREFIX;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
@@ -1703,6 +1814,9 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
PostfixStructure(this.semantics, this.operator);
+ @override
+ SendStructureKind get kind => SendStructureKind.POSTFIX;
+
R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
switch (semantics.kind) {
case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
@@ -1937,16 +2051,23 @@ class DeferredPrefixStructure<R, A> implements SendStructure<R, A> {
}
@override
+ SendStructureKind get kind => SendStructureKind.DEFERRED_PREFIX;
+
+ @override
R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg) {
visitor.previsitDeferredAccess(send, prefix, arg);
return sendStructure.dispatch(visitor, send, arg);
}
}
+enum NewStructureKind { NEW_INVOKE, CONST_INVOKE, LATE_CONST, }
+
/// The structure for a [NewExpression] of a new invocation.
abstract class NewStructure<R, A> implements SemanticSendStructure<R, A> {
/// Calls the matching visit method on [visitor] with [node] and [arg].
R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg);
+
+ NewStructureKind get kind;
}
/// The structure for a [NewExpression] of a new invocation. For instance
@@ -1957,6 +2078,9 @@ class NewInvokeStructure<R, A> extends NewStructure<R, A> {
NewInvokeStructure(this.semantics, this.selector);
+ @override
+ NewStructureKind get kind => NewStructureKind.NEW_INVOKE;
+
CallStructure get callStructure => selector.callStructure;
R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
@@ -2069,13 +2193,16 @@ enum ConstantInvokeKind {
/// The structure for a [NewExpression] of a constant invocation. For instance
/// `const C()`.
class ConstInvokeStructure<R, A> extends NewStructure<R, A> {
- final ConstantInvokeKind kind;
+ final ConstantInvokeKind constantInvokeKind;
final ConstantExpression constant;
- ConstInvokeStructure(this.kind, this.constant);
+ ConstInvokeStructure(this.constantInvokeKind, this.constant);
+
+ @override
+ NewStructureKind get kind => NewStructureKind.CONST_INVOKE;
R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
- switch (kind) {
+ switch (constantInvokeKind) {
case ConstantInvokeKind.CONSTRUCTED:
return visitor.visitConstConstructorInvoke(node, constant, arg);
case ConstantInvokeKind.BOOL_FROM_ENVIRONMENT:
@@ -2100,6 +2227,9 @@ class LateConstInvokeStructure<R, A> extends NewStructure<R, A> {
LateConstInvokeStructure(this.elements);
+ @override
+ NewStructureKind get kind => NewStructureKind.LATE_CONST;
+
/// Convert this new structure into a regular new structure using the data
/// available in [elements].
NewStructure resolve(NewExpression node) {
« no previous file with comments | « pkg/compiler/lib/src/resolution/operators.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698