Refactor handling of compounds.

BUG=
R=asgerf@google.com, karlklose@google.com

Review URL: https://codereview.chromium.org//1126173002
This commit is contained in:
Johnni Winther
2015-05-20 10:38:16 +02:00
parent 7d4a8df496
commit e248820e56
10 changed files with 6666 additions and 1907 deletions
File diff suppressed because it is too large Load Diff
@@ -1007,8 +1007,8 @@ class SimpleTypeInferrerVisitor<T>
@override
T visitSuperCompoundIndexSet(
ast.SendSet node,
FunctionElement getter,
FunctionElement setter,
MethodElement getter,
MethodElement setter,
ast.Node index,
op.AssignmentOperator operator,
ast.Node rhs,
@@ -1020,6 +1020,7 @@ class SimpleTypeInferrerVisitor<T>
T visitUnresolvedSuperGetterCompoundIndexSet(
ast.SendSet node,
Element element,
MethodElement setter,
ast.Node index,
op.AssignmentOperator operator,
ast.Node rhs,
@@ -1030,7 +1031,7 @@ class SimpleTypeInferrerVisitor<T>
@override
T visitUnresolvedSuperSetterCompoundIndexSet(
ast.SendSet node,
FunctionElement getter,
MethodElement getter,
Element element,
ast.Node index,
op.AssignmentOperator operator,
@@ -1043,6 +1044,7 @@ class SimpleTypeInferrerVisitor<T>
T visitUnresolvedSuperGetterIndexPrefix(
ast.SendSet node,
Element element,
MethodElement setter,
ast.Node index,
op.IncDecOperator operator,
_) {
@@ -1053,7 +1055,7 @@ class SimpleTypeInferrerVisitor<T>
@override
T visitUnresolvedSuperSetterIndexPrefix(
ast.SendSet node,
FunctionElement getter,
MethodElement getter,
Element element,
ast.Node index,
op.IncDecOperator operator,
@@ -1066,6 +1068,7 @@ class SimpleTypeInferrerVisitor<T>
T visitUnresolvedSuperGetterIndexPostfix(
ast.SendSet node,
Element element,
MethodElement setter,
ast.Node index,
op.IncDecOperator operator,
_) {
@@ -1076,7 +1079,7 @@ class SimpleTypeInferrerVisitor<T>
@override
T visitUnresolvedSuperSetterIndexPostfix(
ast.SendSet node,
FunctionElement getter,
MethodElement getter,
Element element,
ast.Node index,
op.IncDecOperator operator,
@@ -27,18 +27,30 @@ enum AccessKind {
/// an enclosing function or method.
LOCAL_FUNCTION,
/// The destination of the access is a variable that is defined locally within
/// an enclosing function or method.
/// The destination of the access is a non-final variable that is defined
/// locally within an enclosing function or method.
LOCAL_VARIABLE,
/// The destination of the access is a variable that is defined as a parameter
/// to an enclosing function or method.
/// The destination of the access is a final variable that is defined locally
/// within an enclosing function or method.
FINAL_LOCAL_VARIABLE,
/// The destination of the access is a variable that is defined as a non-final
/// parameter to an enclosing function or method.
PARAMETER,
/// The destination of the access is a field that is defined statically within
/// a class.
/// The destination of the access is a variable that is defined as a final
/// parameter to an enclosing function or method.
FINAL_PARAMETER,
/// The destination of the access is a non-final field that is defined
/// statically within a class.
STATIC_FIELD,
/// The destination of the access is a final field that is defined statically
/// within a class.
FINAL_STATIC_FIELD,
/// The destination of the access is a method that is defined statically
/// within a class.
STATIC_METHOD,
@@ -51,10 +63,14 @@ enum AccessKind {
/// statically within a class.
STATIC_SETTER,
/// The destination of the access is a top level variable defined within a
/// library.
/// The destination of the access is a non-final top level variable defined
/// within a library.
TOPLEVEL_FIELD,
/// The destination of the access is a final top level variable defined within
/// a library.
FINAL_TOPLEVEL_FIELD,
/// The destination of the access is a top level method defined within a
/// library.
TOPLEVEL_METHOD,
@@ -91,10 +107,14 @@ enum AccessKind {
/// of the enclosing class.
THIS_PROPERTY,
/// The destination of the access is a field of the super class of the
/// enclosing class.
/// The destination of the access is a non-final field of the super class of
/// the enclosing class.
SUPER_FIELD,
/// The destination of the access is a final field of the super class of the
/// enclosing class.
SUPER_FINAL_FIELD,
/// The destination of the access is a method of the super class of the
/// enclosing class.
SUPER_METHOD,
@@ -122,16 +142,26 @@ enum AccessKind {
}
enum CompoundAccessKind {
/// Read from a static getter and write to static setter.
/// Read from a static getter and write to a static setter.
STATIC_GETTER_SETTER,
/// Read from a static method (closurize) and write to static setter.
/// Read from a static method (closurize) and write to a static setter.
STATIC_METHOD_SETTER,
/// Read from an unresolved static getter and write to a static setter.
UNRESOLVED_STATIC_GETTER,
/// Read from a static getter and write to an unresolved static setter.
UNRESOLVED_STATIC_SETTER,
/// Read from a top level getter and write to a top level setter.
TOPLEVEL_GETTER_SETTER,
/// Read from a top level method (closurize) and write to top level setter.
TOPLEVEL_METHOD_SETTER,
/// Read from an unresolved top level getter and write to a top level setter.
UNRESOLVED_TOPLEVEL_GETTER,
/// Read from a top level getter and write to an unresolved top level setter.
UNRESOLVED_TOPLEVEL_SETTER,
/// Read from one superclass field and write to another.
SUPER_FIELD_FIELD,
/// Read from a superclass field and write to a superclass setter.
@@ -258,6 +288,9 @@ class StaticAccess extends AccessSemantics {
StaticAccess.superField(FieldElement this.element)
: super._(AccessKind.SUPER_FIELD);
StaticAccess.superFinalField(FieldElement this.element)
: super._(AccessKind.SUPER_FINAL_FIELD);
StaticAccess.superMethod(MethodElement this.element)
: super._(AccessKind.SUPER_METHOD);
@@ -273,12 +306,21 @@ class StaticAccess extends AccessSemantics {
StaticAccess.localVariable(LocalVariableElement this.element)
: super._(AccessKind.LOCAL_VARIABLE);
StaticAccess.finalLocalVariable(LocalVariableElement this.element)
: super._(AccessKind.FINAL_LOCAL_VARIABLE);
StaticAccess.parameter(ParameterElement this.element)
: super._(AccessKind.PARAMETER);
StaticAccess.finalParameter(ParameterElement this.element)
: super._(AccessKind.FINAL_PARAMETER);
StaticAccess.staticField(FieldElement this.element)
: super._(AccessKind.STATIC_FIELD);
StaticAccess.finalStaticField(FieldElement this.element)
: super._(AccessKind.FINAL_STATIC_FIELD);
StaticAccess.staticMethod(MethodElement this.element)
: super._(AccessKind.STATIC_METHOD);
@@ -291,6 +333,9 @@ class StaticAccess extends AccessSemantics {
StaticAccess.topLevelField(FieldElement this.element)
: super._(AccessKind.TOPLEVEL_FIELD);
StaticAccess.finalTopLevelField(FieldElement this.element)
: super._(AccessKind.FINAL_TOPLEVEL_FIELD);
StaticAccess.topLevelMethod(MethodElement this.element)
: super._(AccessKind.TOPLEVEL_METHOD);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -28,10 +28,82 @@ abstract class SendResolverMixin {
internalError(Spannable spannable, String message);
AccessSemantics handleStaticallyResolvedAccess(Send node,
Element element,
Element getter) {
AccessSemantics handleCompoundErroneousSetterAccess(
Send node,
Element setter,
Element getter) {
assert(invariant(node, Elements.isUnresolved(setter),
message: "Unexpected erreneous compound setter: $setter."));
if (getter.isStatic) {
if (getter.isGetter) {
return new CompoundAccessSemantics(
CompoundAccessKind.UNRESOLVED_STATIC_SETTER, getter, setter);
} else if (getter.isField) {
// TODO(johnniwinther): Handle const field separately.
assert(invariant(node, getter.isFinal || getter.isConst,
message: "Field expected to be final or const."));
return new StaticAccess.finalStaticField(getter);
} else if (getter.isFunction) {
return new StaticAccess.staticMethod(getter);
} else {
return internalError(node,
"Unexpected erroneous static compound: getter=$getter");
}
} else if (getter.isTopLevel) {
if (getter.isGetter) {
return new CompoundAccessSemantics(
CompoundAccessKind.UNRESOLVED_TOPLEVEL_SETTER, getter, setter);
} else if (getter.isField) {
// TODO(johnniwinther): Handle const field separately.
assert(invariant(node, getter.isFinal || getter.isConst,
message: "Field expected to be final or const."));
return new StaticAccess.finalTopLevelField(getter);
} else if (getter.isFunction) {
return new StaticAccess.topLevelMethod(getter);
} else {
return internalError(node,
"Unexpected erroneous top level compound: getter=$getter");
}
} else if (getter.isParameter) {
assert(invariant(node, getter.isFinal,
message: "Parameter expected to be final."));
return new StaticAccess.finalParameter(getter);
} else if (getter.isLocal) {
if (getter.isVariable) {
// TODO(johnniwinther): Handle const variable separately.
assert(invariant(node, getter.isFinal || getter.isConst,
message: "Variable expected to be final or const."));
return new StaticAccess.finalLocalVariable(getter);
} else if (getter.isFunction) {
return new StaticAccess.localFunction(getter);
} else {
return internalError(node,
"Unexpected erroneous local compound: getter=$getter");
}
} else if (getter.isErroneous) {
return new StaticAccess.unresolved(getter);
} else {
return internalError(node,
"Unexpected erroneous compound: getter=$getter");
}
}
AccessSemantics handleStaticallyResolvedAccess(
Send node,
Element element,
Element getter,
{bool isCompound}) {
if (element == null) {
assert(invariant(node, isCompound, message:
"Non-compound static access without element."));
assert(invariant(node, getter != null, message:
"Compound static access without element."));
return handleCompoundErroneousSetterAccess(node, element, getter);
}
if (element.isErroneous) {
if (isCompound) {
return handleCompoundErroneousSetterAccess(node, element, getter);
}
return new StaticAccess.unresolved(element);
} else if (element.isParameter) {
return new StaticAccess.parameter(element);
@@ -43,13 +115,32 @@ abstract class SendResolverMixin {
}
} else if (element.isStatic) {
if (element.isField) {
if (element.isFinal || element.isConst) {
// TODO(johnniwinther): Handle const field separately.
return new StaticAccess.finalStaticField(element);
}
return new StaticAccess.staticField(element);
} else if (element.isGetter) {
if (isCompound) {
return new CompoundAccessSemantics(
CompoundAccessKind.UNRESOLVED_STATIC_SETTER, element, null);
}
return new StaticAccess.staticGetter(element);
} else if (element.isSetter) {
if (getter != null) {
CompoundAccessKind accessKind;
if (getter.isGetter) {
if (getter.isErroneous) {
accessKind = CompoundAccessKind.UNRESOLVED_STATIC_GETTER;
} else if (getter.isAbstractField) {
AbstractFieldElement abstractField = getter;
if (abstractField.getter == null) {
accessKind = CompoundAccessKind.UNRESOLVED_STATIC_GETTER;
} else {
// TODO(johnniwinther): This might be dead code.
getter = abstractField.getter;
accessKind = CompoundAccessKind.STATIC_GETTER_SETTER;
}
} else if (getter.isGetter) {
accessKind = CompoundAccessKind.STATIC_GETTER_SETTER;
} else {
accessKind = CompoundAccessKind.STATIC_METHOD_SETTER;
@@ -64,13 +155,28 @@ abstract class SendResolverMixin {
}
} else if (element.isTopLevel) {
if (element.isField) {
if (element.isFinal || element.isConst) {
// TODO(johnniwinther): Handle const field separately.
return new StaticAccess.finalTopLevelField(element);
}
return new StaticAccess.topLevelField(element);
} else if (element.isGetter) {
return new StaticAccess.topLevelGetter(element);
} else if (element.isSetter) {
if (getter != null) {
CompoundAccessKind accessKind;
if (getter.isGetter) {
if (getter.isErroneous) {
accessKind = CompoundAccessKind.UNRESOLVED_TOPLEVEL_GETTER;
} else if (getter.isAbstractField) {
AbstractFieldElement abstractField = getter;
if (abstractField.getter == null) {
accessKind = CompoundAccessKind.UNRESOLVED_TOPLEVEL_GETTER;
} else {
// TODO(johnniwinther): This might be dead code.
getter = abstractField.getter;
accessKind = CompoundAccessKind.TOPLEVEL_GETTER_SETTER;
}
} else if (getter.isGetter) {
accessKind = CompoundAccessKind.TOPLEVEL_GETTER_SETTER;
} else {
accessKind = CompoundAccessKind.TOPLEVEL_METHOD_SETTER;
@@ -344,8 +450,18 @@ abstract class SendResolverMixin {
if (Elements.isUnresolved(getter)) {
// TODO(johnniwinther): Ensure that [getter] is not null. This
// happens in the case of missing super getter.
return new CompoundAccessSemantics(
CompoundAccessKind.UNRESOLVED_SUPER_GETTER, getter, element);
return new StaticAccess.unresolvedSuper(element);
} else if (getter.isField) {
assert(invariant(node, getter.isFinal,
message: "Super field expected to be final."));
return new StaticAccess.superFinalField(getter);
} else if (getter.isFunction) {
if (node.isIndex) {
return new CompoundAccessSemantics(
CompoundAccessKind.UNRESOLVED_SUPER_SETTER, getter, element);
} else {
return new StaticAccess.superMethod(getter);
}
} else {
return new CompoundAccessSemantics(
CompoundAccessKind.UNRESOLVED_SUPER_SETTER, getter, element);
@@ -370,6 +486,8 @@ abstract class SendResolverMixin {
"Unsupported super call: $node : $element/$getter.");
}
return new CompoundAccessSemantics(accessKind, getter, element);
} else if (element.isFinal) {
return new StaticAccess.superFinalField(element);
}
return new StaticAccess.superField(element);
} else if (element.isGetter) {
@@ -405,25 +523,26 @@ abstract class SendResolverMixin {
} else if (Elements.isErroneous(element)) {
return new StaticAccess.unresolved(element);
} else {
return handleStaticallyResolvedAccess(node, element, getter);
return handleStaticallyResolvedAccess(
node, element, getter, isCompound: isCompound);
}
} else {
if (Elements.isErroneous(element)) {
return new StaticAccess.unresolved(element);
} else if (isCompound && Elements.isErroneous(getter)) {
return new StaticAccess.unresolved(getter);
} else if (element == null || element.isInstanceMember) {
bool isDynamicAccess(Element e) => e == null || e.isInstanceMember;
if (isDynamicAccess(element) &&
(!isCompound || isDynamicAccess(getter))) {
if (node.receiver == null || node.receiver.isThis()) {
return new AccessSemantics.thisProperty();
} else {
return new DynamicAccess.dynamicProperty(node.receiver);
}
} else if (element.impliesType) {
} else if (element != null && element.impliesType) {
// TODO(johnniwinther): Provide an [ErroneousElement].
// This happens for code like `C.this`.
return new StaticAccess.unresolved(null);
} else {
return handleStaticallyResolvedAccess(node, element, getter);
return handleStaticallyResolvedAccess(
node, element, getter, isCompound: isCompound);
}
}
}
@@ -177,6 +177,7 @@ class InvokeStructure<R, A> implements SendStructure<R, A> {
callStructure,
arg);
case AccessKind.LOCAL_VARIABLE:
case AccessKind.FINAL_LOCAL_VARIABLE:
return visitor.visitLocalVariableInvoke(
node,
semantics.element,
@@ -186,6 +187,7 @@ class InvokeStructure<R, A> implements SendStructure<R, A> {
callStructure,
arg);
case AccessKind.PARAMETER:
case AccessKind.FINAL_PARAMETER:
return visitor.visitParameterInvoke(
node,
semantics.element,
@@ -195,6 +197,7 @@ class InvokeStructure<R, A> implements SendStructure<R, A> {
callStructure,
arg);
case AccessKind.STATIC_FIELD:
case AccessKind.FINAL_STATIC_FIELD:
return visitor.visitStaticFieldInvoke(
node,
semantics.element,
@@ -223,6 +226,7 @@ class InvokeStructure<R, A> implements SendStructure<R, A> {
callStructure,
arg);
case AccessKind.TOPLEVEL_FIELD:
case AccessKind.FINAL_TOPLEVEL_FIELD:
return visitor.visitTopLevelFieldInvoke(
node,
semantics.element,
@@ -298,6 +302,7 @@ class InvokeStructure<R, A> implements SendStructure<R, A> {
selector,
arg);
case AccessKind.SUPER_FIELD:
case AccessKind.SUPER_FINAL_FIELD:
return visitor.visitSuperFieldInvoke(
node,
semantics.element,
@@ -430,16 +435,19 @@ class GetStructure<R, A> implements SendStructure<R, A> {
semantics.element,
arg);
case AccessKind.LOCAL_VARIABLE:
case AccessKind.FINAL_LOCAL_VARIABLE:
return visitor.visitLocalVariableGet(
node,
semantics.element,
arg);
case AccessKind.PARAMETER:
case AccessKind.FINAL_PARAMETER:
return visitor.visitParameterGet(
node,
semantics.element,
arg);
case AccessKind.STATIC_FIELD:
case AccessKind.FINAL_STATIC_FIELD:
return visitor.visitStaticFieldGet(
node,
semantics.element,
@@ -460,6 +468,7 @@ class GetStructure<R, A> implements SendStructure<R, A> {
semantics.element,
arg);
case AccessKind.TOPLEVEL_FIELD:
case AccessKind.FINAL_TOPLEVEL_FIELD:
return visitor.visitTopLevelFieldGet(
node,
semantics.element,
@@ -511,6 +520,7 @@ class GetStructure<R, A> implements SendStructure<R, A> {
selector,
arg);
case AccessKind.SUPER_FIELD:
case AccessKind.SUPER_FINAL_FIELD:
return visitor.visitSuperFieldGet(
node,
semantics.element,
@@ -586,18 +596,36 @@ class SetStructure<R, A> implements SendStructure<R, A> {
semantics.element,
node.arguments.single,
arg);
case AccessKind.FINAL_LOCAL_VARIABLE:
return visitor.errorFinalLocalVariableSet(
node,
semantics.element,
node.arguments.single,
arg);
case AccessKind.PARAMETER:
return visitor.visitParameterSet(
node,
semantics.element,
node.arguments.single,
arg);
case AccessKind.FINAL_PARAMETER:
return visitor.errorFinalParameterSet(
node,
semantics.element,
node.arguments.single,
arg);
case AccessKind.STATIC_FIELD:
return visitor.visitStaticFieldSet(
node,
semantics.element,
node.arguments.single,
arg);
case AccessKind.FINAL_STATIC_FIELD:
return visitor.errorFinalStaticFieldSet(
node,
semantics.element,
node.arguments.single,
arg);
case AccessKind.STATIC_METHOD:
return visitor.errorStaticFunctionSet(
node,
@@ -622,6 +650,12 @@ class SetStructure<R, A> implements SendStructure<R, A> {
semantics.element,
node.arguments.single,
arg);
case AccessKind.FINAL_TOPLEVEL_FIELD:
return visitor.errorFinalTopLevelFieldSet(
node,
semantics.element,
node.arguments.single,
arg);
case AccessKind.TOPLEVEL_METHOD:
return visitor.errorTopLevelFunctionSet(
node,
@@ -682,6 +716,12 @@ class SetStructure<R, A> implements SendStructure<R, A> {
semantics.element,
node.arguments.single,
arg);
case AccessKind.SUPER_FINAL_FIELD:
return visitor.errorFinalSuperFieldSet(
node,
semantics.element,
node.arguments.single,
arg);
case AccessKind.SUPER_METHOD:
return visitor.errorSuperMethodSet(
node,
@@ -1067,6 +1107,13 @@ class IndexPrefixStructure<R, A> implements SendStructure<R, A> {
node.arguments.single,
operator,
arg);
case AccessKind.UNRESOLVED_SUPER:
return visitor.visitUnresolvedSuperIndexPrefix(
node,
semantics.element,
node.arguments.single,
operator,
arg);
case AccessKind.COMPOUND:
CompoundAccessSemantics compoundSemantics = semantics;
switch (compoundSemantics.compoundAccessKind) {
@@ -1082,6 +1129,7 @@ class IndexPrefixStructure<R, A> implements SendStructure<R, A> {
return visitor.visitUnresolvedSuperGetterIndexPrefix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
node.arguments.single,
operator,
arg);
@@ -1138,6 +1186,13 @@ class IndexPostfixStructure<R, A> implements SendStructure<R, A> {
node.arguments.single,
operator,
arg);
case AccessKind.UNRESOLVED_SUPER:
return visitor.visitUnresolvedSuperIndexPostfix(
node,
semantics.element,
node.arguments.single,
operator,
arg);
case AccessKind.COMPOUND:
CompoundAccessSemantics compoundSemantics = semantics;
switch (compoundSemantics.compoundAccessKind) {
@@ -1153,6 +1208,7 @@ class IndexPostfixStructure<R, A> implements SendStructure<R, A> {
return visitor.visitUnresolvedSuperGetterIndexPostfix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
node.arguments.single,
operator,
arg);
@@ -1210,7 +1266,7 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
setterSelector,
arg);
case AccessKind.LOCAL_FUNCTION:
return visitor.errorLocalFunctionCompound(
return visitor.visitLocalFunctionCompound(
node,
semantics.element,
operator,
@@ -1223,6 +1279,13 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
operator,
node.arguments.single,
arg);
case AccessKind.FINAL_LOCAL_VARIABLE:
return visitor.visitFinalLocalVariableCompound(
node,
semantics.element,
operator,
node.arguments.single,
arg);
case AccessKind.PARAMETER:
return visitor.visitParameterCompound(
node,
@@ -1230,6 +1293,13 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
operator,
node.arguments.single,
arg);
case AccessKind.FINAL_PARAMETER:
return visitor.visitFinalParameterCompound(
node,
semantics.element,
operator,
node.arguments.single,
arg);
case AccessKind.STATIC_FIELD:
return visitor.visitStaticFieldCompound(
node,
@@ -1237,9 +1307,20 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
operator,
node.arguments.single,
arg);
case AccessKind.FINAL_STATIC_FIELD:
return visitor.visitFinalStaticFieldCompound(
node,
semantics.element,
operator,
node.arguments.single,
arg);
case AccessKind.STATIC_METHOD:
// TODO(johnniwinther): Handle this.
break;
return visitor.visitStaticMethodCompound(
node,
semantics.element,
operator,
node.arguments.single,
arg);
case AccessKind.STATIC_GETTER:
// This is not a valid case.
break;
@@ -1253,9 +1334,20 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
operator,
node.arguments.single,
arg);
case AccessKind.FINAL_TOPLEVEL_FIELD:
return visitor.visitFinalTopLevelFieldCompound(
node,
semantics.element,
operator,
node.arguments.single,
arg);
case AccessKind.TOPLEVEL_METHOD:
// TODO(johnniwinther): Handle this.
break;
return visitor.visitTopLevelMethodCompound(
node,
semantics.element,
operator,
node.arguments.single,
arg);
case AccessKind.TOPLEVEL_GETTER:
// This is not a valid case.
break;
@@ -1263,28 +1355,28 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
// This is not a valid case.
break;
case AccessKind.CLASS_TYPE_LITERAL:
return visitor.errorClassTypeLiteralCompound(
return visitor.visitClassTypeLiteralCompound(
node,
semantics.constant,
operator,
node.arguments.single,
arg);
case AccessKind.TYPEDEF_TYPE_LITERAL:
return visitor.errorTypedefTypeLiteralCompound(
return visitor.visitTypedefTypeLiteralCompound(
node,
semantics.constant,
operator,
node.arguments.single,
arg);
case AccessKind.DYNAMIC_TYPE_LITERAL:
return visitor.errorDynamicTypeLiteralCompound(
return visitor.visitDynamicTypeLiteralCompound(
node,
semantics.constant,
operator,
node.arguments.single,
arg);
case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
return visitor.errorTypeVariableTypeLiteralCompound(
return visitor.visitTypeVariableTypeLiteralCompound(
node,
semantics.element,
operator,
@@ -1311,9 +1403,20 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
operator,
node.arguments.single,
arg);
case AccessKind.SUPER_FINAL_FIELD:
return visitor.visitFinalSuperFieldCompound(
node,
semantics.element,
operator,
node.arguments.single,
arg);
case AccessKind.SUPER_METHOD:
// TODO(johnniwinther): Handle this.
break;
return visitor.visitSuperMethodCompound(
node,
semantics.element,
operator,
node.arguments.single,
arg);
case AccessKind.SUPER_GETTER:
// This is not a valid case.
break;
@@ -1324,9 +1427,14 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
// TODO(johnniwinther): Should this be a valid case?
break;
case AccessKind.UNRESOLVED_SUPER:
return visitor.visitUnresolvedSuperCompound(
node,
semantics.element,
operator,
node.arguments.single,
arg);
case AccessKind.UNRESOLVED:
// TODO(johnniwinther): Support these through [AccessKind.COMPOUND].
return visitor.errorUnresolvedCompound(
return visitor.visitUnresolvedCompound(
node,
semantics.element,
operator,
@@ -1351,6 +1459,22 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
operator,
node.arguments.single,
arg);
case CompoundAccessKind.UNRESOLVED_STATIC_GETTER:
return visitor.visitUnresolvedStaticGetterCompound(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
node.arguments.single,
arg);
case CompoundAccessKind.UNRESOLVED_STATIC_SETTER:
return visitor.visitUnresolvedStaticSetterCompound(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
node.arguments.single,
arg);
case CompoundAccessKind.TOPLEVEL_GETTER_SETTER:
return visitor.visitTopLevelGetterSetterCompound(
node,
@@ -1367,6 +1491,22 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
operator,
node.arguments.single,
arg);
case CompoundAccessKind.UNRESOLVED_TOPLEVEL_GETTER:
return visitor.visitUnresolvedTopLevelGetterCompound(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
node.arguments.single,
arg);
case CompoundAccessKind.UNRESOLVED_TOPLEVEL_SETTER:
return visitor.visitUnresolvedTopLevelSetterCompound(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
node.arguments.single,
arg);
case CompoundAccessKind.SUPER_FIELD_FIELD:
// TODO(johnniwinther): Handle this.
break;
@@ -1403,11 +1543,18 @@ class CompoundStructure<R, A> implements SendStructure<R, A> {
node.arguments.single,
arg);
case CompoundAccessKind.UNRESOLVED_SUPER_GETTER:
case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
// TODO(johnniwinther): Handle these separately.
return visitor.errorUnresolvedCompound(
return visitor.visitUnresolvedSuperGetterCompound(
node,
semantics.element,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
node.arguments.single,
arg);
case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
return visitor.visitUnresolvedSuperSetterCompound(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
node.arguments.single,
arg);
@@ -1450,6 +1597,14 @@ class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> {
operator,
node.arguments.tail.head,
arg);
case AccessKind.UNRESOLVED_SUPER:
return visitor.visitUnresolvedSuperCompoundIndexSet(
node,
semantics.element,
node.arguments.first,
operator,
node.arguments.tail.head,
arg);
case AccessKind.COMPOUND:
CompoundAccessSemantics compoundSemantics = semantics;
switch (compoundSemantics.compoundAccessKind) {
@@ -1466,6 +1621,7 @@ class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> {
return visitor.visitUnresolvedSuperGetterCompoundIndexSet(
node,
compoundSemantics.getter,
compoundSemantics.setter,
node.arguments.first,
operator,
node.arguments.tail.head,
@@ -1526,7 +1682,7 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
setterSelector,
arg);
case AccessKind.LOCAL_FUNCTION:
return visitor.errorLocalFunctionPrefix(
return visitor.visitLocalFunctionPrefix(
node,
semantics.element,
operator,
@@ -1537,21 +1693,42 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
semantics.element,
operator,
arg);
case AccessKind.FINAL_LOCAL_VARIABLE:
return visitor.visitFinalLocalVariablePrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.PARAMETER:
return visitor.visitParameterPrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.FINAL_PARAMETER:
return visitor.visitFinalParameterPrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.STATIC_FIELD:
return visitor.visitStaticFieldPrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.FINAL_STATIC_FIELD:
return visitor.visitFinalStaticFieldPrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.STATIC_METHOD:
// TODO(johnniwinther): Handle this.
break;
return visitor.visitStaticMethodPrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.STATIC_GETTER:
// This is not a valid case.
break;
@@ -1564,9 +1741,18 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
semantics.element,
operator,
arg);
case AccessKind.FINAL_TOPLEVEL_FIELD:
return visitor.visitFinalTopLevelFieldPrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.TOPLEVEL_METHOD:
// TODO(johnniwinther): Handle this.
break;
return visitor.visitTopLevelMethodPrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.TOPLEVEL_GETTER:
// This is not a valid case.
break;
@@ -1574,25 +1760,25 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
// This is not a valid case.
break;
case AccessKind.CLASS_TYPE_LITERAL:
return visitor.errorClassTypeLiteralPrefix(
return visitor.visitClassTypeLiteralPrefix(
node,
semantics.constant,
operator,
arg);
case AccessKind.TYPEDEF_TYPE_LITERAL:
return visitor.errorTypedefTypeLiteralPrefix(
return visitor.visitTypedefTypeLiteralPrefix(
node,
semantics.constant,
operator,
arg);
case AccessKind.DYNAMIC_TYPE_LITERAL:
return visitor.errorDynamicTypeLiteralPrefix(
return visitor.visitDynamicTypeLiteralPrefix(
node,
semantics.constant,
operator,
arg);
case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
return visitor.errorTypeVariableTypeLiteralPrefix(
return visitor.visitTypeVariableTypeLiteralPrefix(
node,
semantics.element,
operator,
@@ -1616,9 +1802,18 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
semantics.element,
operator,
arg);
case AccessKind.SUPER_FINAL_FIELD:
return visitor.visitFinalSuperFieldPrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.SUPER_METHOD:
// TODO(johnniwinther): Handle this.
break;
return visitor.visitSuperMethodPrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.SUPER_GETTER:
// This is not a valid case.
break;
@@ -1629,9 +1824,13 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
// TODO(johnniwinther): Should this be a valid case?
break;
case AccessKind.UNRESOLVED_SUPER:
return visitor.visitUnresolvedSuperPrefix(
node,
semantics.element,
operator,
arg);
case AccessKind.UNRESOLVED:
// TODO(johnniwinther): Support these through [AccessKind.COMPOUND].
return visitor.errorUnresolvedPrefix(
return visitor.visitUnresolvedPrefix(
node,
semantics.element,
operator,
@@ -1653,6 +1852,27 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.UNRESOLVED_STATIC_GETTER:
return visitor.visitUnresolvedStaticGetterPrefix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.UNRESOLVED_STATIC_SETTER:
return visitor.visitUnresolvedStaticSetterPrefix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.STATIC_METHOD_SETTER:
return visitor.visitStaticMethodSetterPrefix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.TOPLEVEL_GETTER_SETTER:
return visitor.visitTopLevelGetterSetterPrefix(
node,
@@ -1667,6 +1887,20 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.UNRESOLVED_TOPLEVEL_GETTER:
return visitor.visitUnresolvedTopLevelGetterPrefix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.UNRESOLVED_TOPLEVEL_SETTER:
return visitor.visitUnresolvedTopLevelSetterPrefix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.SUPER_FIELD_FIELD:
return visitor.visitSuperFieldFieldPrefix(
node,
@@ -1703,11 +1937,17 @@ class PrefixStructure<R, A> implements SendStructure<R, A> {
operator,
arg);
case CompoundAccessKind.UNRESOLVED_SUPER_GETTER:
case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
// TODO(johnniwinther): Handle these directly.
return visitor.errorUnresolvedPrefix(
return visitor.visitUnresolvedSuperGetterPrefix(
node,
semantics.element,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
return visitor.visitUnresolvedSuperSetterPrefix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
}
@@ -1750,7 +1990,7 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
setterSelector,
arg);
case AccessKind.LOCAL_FUNCTION:
return visitor.errorLocalFunctionPostfix(
return visitor.visitLocalFunctionPostfix(
node,
semantics.element,
operator,
@@ -1761,21 +2001,42 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
semantics.element,
operator,
arg);
case AccessKind.FINAL_LOCAL_VARIABLE:
return visitor.visitFinalLocalVariablePostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.PARAMETER:
return visitor.visitParameterPostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.FINAL_PARAMETER:
return visitor.visitFinalParameterPostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.STATIC_FIELD:
return visitor.visitStaticFieldPostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.FINAL_STATIC_FIELD:
return visitor.visitFinalStaticFieldPostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.STATIC_METHOD:
// TODO(johnniwinther): Handle this.
break;
return visitor.visitStaticMethodPostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.STATIC_GETTER:
// This is not a valid case.
break;
@@ -1788,9 +2049,18 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
semantics.element,
operator,
arg);
case AccessKind.FINAL_TOPLEVEL_FIELD:
return visitor.visitFinalTopLevelFieldPostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.TOPLEVEL_METHOD:
// TODO(johnniwinther): Handle this.
break;
return visitor.visitTopLevelMethodPostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.TOPLEVEL_GETTER:
// This is not a valid case.
break;
@@ -1798,25 +2068,25 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
// This is not a valid case.
break;
case AccessKind.CLASS_TYPE_LITERAL:
return visitor.errorClassTypeLiteralPostfix(
return visitor.visitClassTypeLiteralPostfix(
node,
semantics.constant,
operator,
arg);
case AccessKind.TYPEDEF_TYPE_LITERAL:
return visitor.errorTypedefTypeLiteralPostfix(
return visitor.visitTypedefTypeLiteralPostfix(
node,
semantics.constant,
operator,
arg);
case AccessKind.DYNAMIC_TYPE_LITERAL:
return visitor.errorDynamicTypeLiteralPostfix(
return visitor.visitDynamicTypeLiteralPostfix(
node,
semantics.constant,
operator,
arg);
case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
return visitor.errorTypeVariableTypeLiteralPostfix(
return visitor.visitTypeVariableTypeLiteralPostfix(
node,
semantics.element,
operator,
@@ -1840,9 +2110,18 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
semantics.element,
operator,
arg);
case AccessKind.SUPER_FINAL_FIELD:
return visitor.visitFinalSuperFieldPostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.SUPER_METHOD:
// TODO(johnniwinther): Handle this.
break;
return visitor.visitSuperMethodPostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.SUPER_GETTER:
// This is not a valid case.
break;
@@ -1853,9 +2132,13 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
// TODO(johnniwinther): Should this be a valid case?
break;
case AccessKind.UNRESOLVED_SUPER:
return visitor.visitUnresolvedSuperPostfix(
node,
semantics.element,
operator,
arg);
case AccessKind.UNRESOLVED:
// TODO(johnniwinther): Support these through [AccessKind.COMPOUND].
return visitor.errorUnresolvedPostfix(
return visitor.visitUnresolvedPostfix(
node,
semantics.element,
operator,
@@ -1870,6 +2153,20 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.UNRESOLVED_STATIC_GETTER:
return visitor.visitUnresolvedStaticGetterPostfix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.UNRESOLVED_STATIC_SETTER:
return visitor.visitUnresolvedStaticSetterPostfix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.STATIC_METHOD_SETTER:
return visitor.visitStaticMethodSetterPostfix(
node,
@@ -1891,6 +2188,20 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.UNRESOLVED_TOPLEVEL_GETTER:
return visitor.visitUnresolvedTopLevelGetterPostfix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.UNRESOLVED_TOPLEVEL_SETTER:
return visitor.visitUnresolvedTopLevelSetterPostfix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.SUPER_FIELD_FIELD:
return visitor.visitSuperFieldFieldPostfix(
node,
@@ -1927,11 +2238,17 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
operator,
arg);
case CompoundAccessKind.UNRESOLVED_SUPER_GETTER:
case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
// TODO(johnniwinther): Handle these directly.
return visitor.errorUnresolvedPostfix(
return visitor.visitUnresolvedSuperGetterPostfix(
node,
semantics.element,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
return visitor.visitUnresolvedSuperSetterPostfix(
node,
compoundSemantics.getter,
compoundSemantics.setter,
operator,
arg);
}
+4 -4
View File
@@ -394,7 +394,7 @@ class ResolvedSemanticDispatcher<R> extends Object
}
@override
R errorLocalFunctionPostfix(
R visitLocalFunctionPostfix(
Send node,
LocalFunctionElement function,
op.IncDecOperator operator,
@@ -403,7 +403,7 @@ class ResolvedSemanticDispatcher<R> extends Object
}
@override
R errorLocalFunctionPrefix(
R visitLocalFunctionPrefix(
Send node,
LocalFunctionElement function,
op.IncDecOperator operator,
@@ -503,7 +503,7 @@ class ResolvedSemanticDispatcher<R> extends Object
}
@override
R errorUnresolvedPostfix(
R visitUnresolvedPostfix(
Send node,
Element element,
op.IncDecOperator operator,
@@ -512,7 +512,7 @@ class ResolvedSemanticDispatcher<R> extends Object
}
@override
R errorUnresolvedPrefix(
R visitUnresolvedPrefix(
Send node,
Element element,
op.IncDecOperator operator,
@@ -24,13 +24,11 @@ const Map<String, List<String>> WHITE_LIST = const {
// Some things in dart_printer are not yet used
"lib/src/dart_backend/backend_ast_nodes.dart": const [" is never "],
// Uncalled error methods in SemanticSendVisitor and subclasses.
// Uncalled methods in SemanticSendVisitor and subclasses.
"lib/src/resolution/semantic_visitor.dart": const [
"The method 'error"],
"The method 'error", "The method 'visit"],
"lib/src/resolution/semantic_visitor_mixins.dart": const [
"The method 'error"],
"lib/src/cps_ir/cps_ir_builder_task.dart": const [
"The method 'error"],
"The class 'Base", "The method 'error", "The method 'visit"],
// Uncalled type predicate. Keep while related predicates are used.
"lib/src/ssa/nodes.dart": const [
File diff suppressed because it is too large Load Diff