Chromium Code Reviews| Index: lib/kernel_visitor.dart |
| diff --git a/lib/kernel_visitor.dart b/lib/kernel_visitor.dart |
| index cf0532062ad5f583b22327a554842204844969c1..4b9049f20c8cbe5b3601c02ad62f5303d8ff4811 100644 |
| --- a/lib/kernel_visitor.dart |
| +++ b/lib/kernel_visitor.dart |
| @@ -363,9 +363,7 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw handleError(Node node) { |
| - return buildUnsupported(node, "handleError"); |
| - } |
| + ir.Expression handleError(Node node) => new ir.InvalidExpression(); |
| @override |
| void apply(Node node, _) { |
| @@ -707,8 +705,9 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitCaseMatch(CaseMatch node) { |
| - return buildUnsupported(node, "CaseMatch"); |
| + visitCaseMatch(CaseMatch node) { |
| + // Shouldn't normally be called. Handled by [visitSwitchCase]. |
|
kasperl
2016/06/20 20:10:18
What does normally mean in this context? That it m
ahe
2016/06/21 10:51:05
Done.
|
| + return internalError(node, "CaseMatch"); |
| } |
| @override |
| @@ -826,8 +825,10 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitLabel(Label node) { |
| - return buildUnsupported(node, "Label"); |
| + visitLabel(Label node) { |
| + // Shouldn't normally be called. Handled by visitLabeledStatement and |
| + // visitSwitchCase. |
| + return internalError(node, "Label"); |
| } |
| @override |
| @@ -908,8 +909,9 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitLiteralMapEntry(LiteralMapEntry node) { |
| - return buildUnsupported(node, "LiteralMapEntry"); |
| + visitLiteralMapEntry(LiteralMapEntry node) { |
| + // Shouldn't normally be called. Handled by [visitLiteralMap]. |
| + return internalError(node, "LiteralMapEntry"); |
| } |
| @override |
| @@ -929,8 +931,10 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitMetadata(Metadata node) { |
| - return buildUnsupported(node, "Metadata"); |
| + visitMetadata(Metadata node) { |
| + // Shouldn't normally be called. Metadata should already have been analyzed |
| + // and converted to a constant expression in the resolver. |
| + return internalError(node, "Metadata not handled as constant."); |
| } |
| @override |
| @@ -940,8 +944,10 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitOperator(Operator node) { |
| - return buildUnsupported(node, "Operator"); |
| + visitOperator(Operator node) { |
| + // This is a special subclass of [Identifier], and we should never see that |
| + // in the semantic visitor. |
| + return internalError(node, "Operator"); |
| } |
| @override |
| @@ -950,8 +956,9 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitRedirectingFactoryBody(RedirectingFactoryBody node) { |
| - return buildUnsupported(node, "RedirectingFactoryBody"); |
| + visitRedirectingFactoryBody(RedirectingFactoryBody node) { |
| + // Not implemented yet. |
| + return internalError(node, "RedirectingFactoryBody"); |
| } |
| @override |
| @@ -1069,13 +1076,17 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitTypeAnnotation(TypeAnnotation node) { |
| - return buildUnsupported(node, "TypeAnnotation"); |
| + visitTypeAnnotation(TypeAnnotation node) { |
| + // Shouldn't be called, as the resolver have already resolved types and |
| + // created [DartType] objects. |
| + return internalError(node, "TypeAnnotation"); |
| } |
| @override |
| - ir.Throw visitTypeVariable(TypeVariable node) { |
| - return buildUnsupported(node, "TypeVariable"); |
| + visitTypeVariable(TypeVariable node) { |
| + // Shouldn't be called, as the resolver have already resolved types and |
| + // created [DartType] objects. |
| + return internalError(node, "TypeVariable"); |
| } |
| @override |
| @@ -1609,7 +1620,7 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitIfNotNullDynamicPropertySetIfNull( |
| + ir.Expression visitIfNotNullDynamicPropertySetIfNull( |
| Send node, |
| Node receiver, |
| Name name, |
| @@ -1718,13 +1729,14 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitInstanceFieldDeclaration( |
| + visitInstanceFieldDeclaration( |
| VariableDefinitions node, |
| Node definition, |
| FieldElement field, |
| Node initializer, |
| _) { |
| - return buildUnsupported(node, "InstanceFieldDeclaration"); |
| + // Should not normally be called, handled by fieldToIr. |
| + return internalError(node, "InstanceFieldDeclaration"); |
| } |
| @override |
| @@ -1893,13 +1905,15 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitNamedParameterDeclaration( |
| + visitNamedParameterDeclaration( |
| VariableDefinitions node, |
| Node definition, |
| ParameterElement parameter, |
| ConstantExpression defaultValue, |
| _) { |
| - return buildUnsupported(node, "NamedParameterDeclaration"); |
| + // Shouldn't be called normally, we handle parameters via |
| + // [FunctionSignture]. |
| + return internalError(node, "NamedParameterDeclaration"); |
| } |
| @override |
| @@ -1924,24 +1938,28 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitOptionalParameterDeclaration( |
| + visitOptionalParameterDeclaration( |
| VariableDefinitions node, |
| Node definition, |
| ParameterElement parameter, |
| ConstantExpression defaultValue, |
| int index, |
| _) { |
| - return buildUnsupported(node, "OptionalParameterDeclaration"); |
| + // Shouldn't be called normally, we handle parameters via |
| + // [FunctionSignture]. |
| + return internalError(node, "OptionalParameterDeclaration"); |
| } |
| @override |
| - ir.Throw visitParameterDeclaration( |
| + visitParameterDeclaration( |
| VariableDefinitions node, |
| Node definition, |
| ParameterElement parameter, |
| int index, |
| _) { |
| - return buildUnsupported(node, "ParameterDeclaration"); |
| + // Shouldn't be called normally, we handle parameters via |
| + // [FunctionSignture]. |
| + return internalError(node, "ParameterDeclaration"); |
| } |
| @override |
| @@ -1989,8 +2007,7 @@ class KernelVisitor extends Object |
| // we support reflection. At the call-site, we bypass this factory and |
| // call its effective target directly. So this factory is only necessary |
| // for reflection. |
| - body = new ir.ExpressionStatement( |
| - buildUnsupported(node, "redirecting factory constructor body.")); |
| + body = new ir.InvalidStatement(); |
| } |
| IrFunction function = |
| buildIrFunction(ir.ProcedureKind.Factory, constructor, null); |
| @@ -2040,7 +2057,7 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitStaticConstantDeclaration( |
| + visitStaticConstantDeclaration( |
| VariableDefinitions node, |
| Node definition, |
| FieldElement field, |
| @@ -2051,7 +2068,7 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitStaticFieldDeclaration( |
| + visitStaticFieldDeclaration( |
| VariableDefinitions node, |
| Node definition, |
| FieldElement field, |
| @@ -2283,7 +2300,8 @@ class KernelVisitor extends Object |
| FunctionElement getter, |
| _) { |
| if (getter.isDeferredLoaderGetter) { |
| - return buildUnsupported(node, "deferred access"); |
| + // TODO(ahe): Support deferred load. |
| + return new ir.InvalidExpression(); |
| } |
| return buildStaticGet(getter); |
| } |
| @@ -2296,7 +2314,8 @@ class KernelVisitor extends Object |
| CallStructure callStructure, |
| _) { |
| if (getter.isDeferredLoaderGetter) { |
| - return buildUnsupported(node, "deferred access"); |
| + // TODO(ahe): Support deferred load. |
| + return new ir.InvalidExpression(); |
| } |
| return buildCall(buildStaticGet(getter), callStructure, arguments); |
| } |
| @@ -2740,23 +2759,25 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitTopLevelConstantDeclaration( |
| + ir.Expression visitTopLevelConstantDeclaration( |
| VariableDefinitions node, |
| Node definition, |
| FieldElement field, |
| ConstantExpression constant, |
| _) { |
| - return buildUnsupported(node, "TopLevelConstantDeclaration"); |
| + // Should not normally be called, handled by fieldToIr. |
| + return internalError(node, "TopLevelFieldDeclaration"); |
| } |
| @override |
| - ir.Throw visitTopLevelFieldDeclaration( |
| + ir.Expression visitTopLevelFieldDeclaration( |
| VariableDefinitions node, |
| Node definition, |
| FieldElement field, |
| Node initializer, |
| _) { |
| - return buildUnsupported(node, "TopLevelFieldDeclaration"); |
| + // Should not normally be called, handled by fieldToIr. |
| + return internalError(node, "TopLevelFieldDeclaration"); |
| } |
| @override |
| @@ -2891,19 +2912,22 @@ class KernelVisitor extends Object |
| } |
| @override |
| - ir.Throw visitConditionalUri(ConditionalUri node) { |
| - return buildUnsupported(node, "ConditionalUri"); |
| + visitConditionalUri(ConditionalUri node) { |
| + // Shouldn't be called normally, handled by library loader. |
| + return internalError(node, "ConditionalUri"); |
| } |
| @override |
| - ir.Throw visitDottedName(DottedName node) { |
| - return buildUnsupported(node, "DottedName"); |
| + visitDottedName(DottedName node) { |
| + // Shouldn't be called normally, handled by library loader. |
| + return internalError(node, "DottedName"); |
| } |
| @override |
| - ir.Throw visitForIn(ForIn node) { |
| - return internalError( |
| - node, "Should have been caught by visitAsyncForIn or visitSyncForIn"); |
| + visitForIn(ForIn node) { |
| + // Shouldn't be called normally, handled by [visitAsyncForIn] or |
| + // [visitSyncForIn]. |
| + return internalError(node, "ForIn"); |
| } |
| @override |