| 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 d507dda98383057fd48f8468e2033630502daad8..838e97bfaa5c8a34d36e556ec806d36ca2bc52ef 100644
|
| --- a/pkg/compiler/lib/src/resolution/send_structure.dart
|
| +++ b/pkg/compiler/lib/src/resolution/send_structure.dart
|
| @@ -1874,3 +1874,189 @@ class ConstInvokeStructure<R, A> extends NewStructure<R, A> {
|
| }
|
| }
|
|
|
| +/// The structure of a parameter declaration.
|
| +abstract class ParameterStructure<R, A> {
|
| + /// Calls the matching visit method on [visitor] with [definitions] and [arg].
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor,
|
| + VariableDefinitions definitions,
|
| + A arg);
|
| +}
|
| +
|
| +/// The structure of a required parameter declaration.
|
| +class RequiredParameterStructure<R, A> extends ParameterStructure<R, A> {
|
| + final ParameterElement parameter;
|
| + final Node node;
|
| + final int index;
|
| +
|
| + RequiredParameterStructure(this.node, this.parameter, this.index);
|
| +
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor,
|
| + VariableDefinitions definitions,
|
| + A arg) {
|
| + if (parameter.isInitializingFormal) {
|
| + return visitor.visitInitializingFormalDecl(
|
| + definitions, node, parameter, index, arg);
|
| + } else {
|
| + return visitor.visitParameterDecl(
|
| + definitions, node, parameter, index, arg);
|
| + }
|
| + }
|
| +}
|
| +
|
| +/// The structure of a optional positional parameter declaration.
|
| +class OptionalParameterStructure<R, A> extends ParameterStructure<R, A> {
|
| + final ParameterElement parameter;
|
| + final Node node;
|
| + final ConstantExpression defaultValue;
|
| + final int index;
|
| +
|
| + OptionalParameterStructure(
|
| + this.node, this.parameter, this.defaultValue, this.index);
|
| +
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor,
|
| + VariableDefinitions definitions,
|
| + A arg) {
|
| + if (parameter.isInitializingFormal) {
|
| + return visitor.visitOptionalInitializingFormalDecl(
|
| + definitions, node, parameter, defaultValue, index, arg);
|
| + } else {
|
| + return visitor.visitOptionalParameterDecl(
|
| + definitions, node, parameter, defaultValue, index, arg);
|
| + }
|
| + }
|
| +}
|
| +
|
| +/// The structure of a optional named parameter declaration.
|
| +class NamedParameterStructure<R, A> extends ParameterStructure<R, A> {
|
| + final ParameterElement parameter;
|
| + final Node node;
|
| + final ConstantExpression defaultValue;
|
| +
|
| + NamedParameterStructure(this.node, this.parameter, this.defaultValue);
|
| +
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor,
|
| + VariableDefinitions definitions,
|
| + A arg) {
|
| + if (parameter.isInitializingFormal) {
|
| + return visitor.visitNamedInitializingFormalDecl(
|
| + definitions, node, parameter, defaultValue, arg);
|
| + } else {
|
| + return visitor.visitNamedParameterDecl(
|
| + definitions, node, parameter, defaultValue, arg);
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| +enum VariableKind {
|
| + TOP_LEVEL_FIELD,
|
| + STATIC_FIELD,
|
| + INSTANCE_FIELD,
|
| + LOCAL_VARIABLE,
|
| +}
|
| +
|
| +abstract class VariableStructure<R, A> {
|
| + final VariableKind kind;
|
| + final Node node;
|
| + final VariableElement variable;
|
| +
|
| + VariableStructure(this.kind, this.node, this.variable);
|
| +
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor,
|
| + VariableDefinitions definitions,
|
| + A arg);
|
| +}
|
| +
|
| +class NonConstantVariableStructure<R, A>
|
| + extends VariableStructure<R, A> {
|
| + NonConstantVariableStructure(
|
| + VariableKind kind, Node node, VariableElement variable)
|
| + : super(kind, node, variable);
|
| +
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor,
|
| + VariableDefinitions definitions,
|
| + A arg) {
|
| + switch (kind) {
|
| + case VariableKind.TOP_LEVEL_FIELD:
|
| + return visitor.visitTopLevelFieldDecl(
|
| + definitions, node, variable, variable.initializer, arg);
|
| + case VariableKind.STATIC_FIELD:
|
| + return visitor.visitStaticFieldDecl(
|
| + definitions, node, variable, variable.initializer, arg);
|
| + case VariableKind.INSTANCE_FIELD:
|
| + return visitor.visitInstanceFieldDecl(
|
| + definitions, node, variable, variable.initializer, arg);
|
| + case VariableKind.LOCAL_VARIABLE:
|
| + return visitor.visitLocalVariableDecl(
|
| + definitions, node, variable, variable.initializer, arg);
|
| + }
|
| + }
|
| +}
|
| +
|
| +class ConstantVariableStructure<R, A>
|
| + extends VariableStructure<R, A> {
|
| + final ConstantExpression constant;
|
| +
|
| + ConstantVariableStructure(
|
| + VariableKind kind, Node node, VariableElement variable, this.constant)
|
| + : super(kind, node, variable);
|
| +
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor,
|
| + VariableDefinitions definitions,
|
| + A arg) {
|
| + switch (kind) {
|
| + case VariableKind.TOP_LEVEL_FIELD:
|
| + return visitor.visitTopLevelConstantDecl(
|
| + definitions, node, variable, constant, arg);
|
| + case VariableKind.STATIC_FIELD:
|
| + return visitor.visitStaticConstantDecl(
|
| + definitions, node, variable, constant, arg);
|
| + case VariableKind.LOCAL_VARIABLE:
|
| + return visitor.visitLocalConstantDecl(
|
| + definitions, node, variable, constant, arg);
|
| + default:
|
| + }
|
| + throw new SpannableAssertionFailure(
|
| + node, "Invalid constant variable: $variable");
|
| + }
|
| +}
|
| +
|
| +abstract class InitializerStructure<R, A> {
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor, Send node, A arg);
|
| +}
|
| +
|
| +class FieldInitializerStructure<R, A> extends InitializerStructure<R, A> {
|
| + final FieldElement field;
|
| +
|
| + FieldInitializerStructure(this.field);
|
| +
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor, Send node, A arg) {
|
| + return visitor.visitFieldInitializer(
|
| + node, field, node.arguments.single, arg);
|
| + }
|
| +}
|
| +
|
| +class SuperConstructorInvokeStructure<R, A> extends InitializerStructure<R, A> {
|
| + final ConstructorElement constructor;
|
| + final InterfaceType type;
|
| + final Selector selector;
|
| +
|
| + SuperConstructorInvokeStructure(this.constructor, this.type, this.selector);
|
| +
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor, Send node, A arg) {
|
| + return visitor.visitSuperConstructorInvoke(
|
| + node, constructor, type, node.argumentsNode, selector, arg);
|
| + }
|
| +}
|
| +
|
| +class ThisConstructorInvokeStructure<R, A> extends InitializerStructure<R, A> {
|
| + final ConstructorElement constructor;
|
| + final Selector selector;
|
| +
|
| + ThisConstructorInvokeStructure(this.constructor, this.selector);
|
| +
|
| + R dispatch(SemanticDeclVisitor<R, A> visitor, Send node, A arg) {
|
| + return visitor.visitThisConstructorInvoke(
|
| + node, constructor, node.argumentsNode, selector, arg);
|
| + }
|
| +}
|
|
|