com.shapesecurity.shift.es2017.reducer.ThunkedDirector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of es2017 Show documentation
Show all versions of es2017 Show documentation
Shift format ECMAScript 2017 AST tooling
// Generated by director.js
/**
* Copyright 2018 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.shapesecurity.shift.es2017.reducer;
import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.shift.es2017.ast.*;
import javax.annotation.Nonnull;
import java.util.function.Supplier;
public final class ThunkedDirector {
@Nonnull
public static State reduceArrayAssignmentTarget(
@Nonnull ThunkedReducer reducer,
@Nonnull ArrayAssignmentTarget node) {
return reducer.reduceArrayAssignmentTarget(node, reduceListMaybeAssignmentTargetAssignmentTargetWithDefault(reducer, node.elements), reduceMaybeAssignmentTarget(reducer, node.rest));
}
@Nonnull
public static State reduceArrayBinding(
@Nonnull ThunkedReducer reducer,
@Nonnull ArrayBinding node) {
return reducer.reduceArrayBinding(node, reduceListMaybeBindingBindingWithDefault(reducer, node.elements), reduceMaybeBinding(reducer, node.rest));
}
@Nonnull
public static State reduceArrayExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull ArrayExpression node) {
return reducer.reduceArrayExpression(node, reduceListMaybeSpreadElementExpression(reducer, node.elements));
}
@Nonnull
public static State reduceArrowExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull ArrowExpression node) {
return reducer.reduceArrowExpression(node, () -> reduceFormalParameters(reducer, node.params), () -> reduceFunctionBodyExpression(reducer, node.body));
}
@Nonnull
public static State reduceAssignmentExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull AssignmentExpression node) {
return reducer.reduceAssignmentExpression(node, () -> reduceAssignmentTarget(reducer, node.binding), () -> reduceExpression(reducer, node.expression));
}
@Nonnull
public static State reduceAssignmentTarget(
@Nonnull ThunkedReducer reducer,
@Nonnull AssignmentTarget node) {
if (node instanceof AssignmentTargetPattern) {
return reduceAssignmentTargetPattern(reducer, (AssignmentTargetPattern) node);
} else if (node instanceof SimpleAssignmentTarget) {
return reduceSimpleAssignmentTarget(reducer, (SimpleAssignmentTarget) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceAssignmentTargetAssignmentTargetWithDefault(
@Nonnull ThunkedReducer reducer,
@Nonnull AssignmentTargetAssignmentTargetWithDefault node) {
if (node instanceof AssignmentTarget) {
return reduceAssignmentTarget(reducer, (AssignmentTarget) node);
} else if (node instanceof AssignmentTargetWithDefault) {
return reduceAssignmentTargetWithDefault(reducer, (AssignmentTargetWithDefault) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceAssignmentTargetIdentifier(
@Nonnull ThunkedReducer reducer,
@Nonnull AssignmentTargetIdentifier node) {
return reducer.reduceAssignmentTargetIdentifier(node);
}
@Nonnull
public static State reduceAssignmentTargetPattern(
@Nonnull ThunkedReducer reducer,
@Nonnull AssignmentTargetPattern node) {
if (node instanceof ObjectAssignmentTarget) {
return reduceObjectAssignmentTarget(reducer, (ObjectAssignmentTarget) node);
} else if (node instanceof ArrayAssignmentTarget) {
return reduceArrayAssignmentTarget(reducer, (ArrayAssignmentTarget) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceAssignmentTargetProperty(
@Nonnull ThunkedReducer reducer,
@Nonnull AssignmentTargetProperty node) {
if (node instanceof AssignmentTargetPropertyIdentifier) {
return reduceAssignmentTargetPropertyIdentifier(reducer, (AssignmentTargetPropertyIdentifier) node);
} else if (node instanceof AssignmentTargetPropertyProperty) {
return reduceAssignmentTargetPropertyProperty(reducer, (AssignmentTargetPropertyProperty) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceAssignmentTargetPropertyIdentifier(
@Nonnull ThunkedReducer reducer,
@Nonnull AssignmentTargetPropertyIdentifier node) {
return reducer.reduceAssignmentTargetPropertyIdentifier(node, () -> reduceAssignmentTargetIdentifier(reducer, node.binding), reduceMaybeExpression(reducer, node.init));
}
@Nonnull
public static State reduceAssignmentTargetPropertyProperty(
@Nonnull ThunkedReducer reducer,
@Nonnull AssignmentTargetPropertyProperty node) {
return reducer.reduceAssignmentTargetPropertyProperty(node, () -> reducePropertyName(reducer, node.name), () -> reduceAssignmentTargetAssignmentTargetWithDefault(reducer, node.binding));
}
@Nonnull
public static State reduceAssignmentTargetWithDefault(
@Nonnull ThunkedReducer reducer,
@Nonnull AssignmentTargetWithDefault node) {
return reducer.reduceAssignmentTargetWithDefault(node, () -> reduceAssignmentTarget(reducer, node.binding), () -> reduceExpression(reducer, node.init));
}
@Nonnull
public static State reduceAwaitExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull AwaitExpression node) {
return reducer.reduceAwaitExpression(node, () -> reduceExpression(reducer, node.expression));
}
@Nonnull
public static State reduceBinaryExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull BinaryExpression node) {
return reducer.reduceBinaryExpression(node, () -> reduceExpression(reducer, node.left), () -> reduceExpression(reducer, node.right));
}
@Nonnull
public static State reduceBinding(
@Nonnull ThunkedReducer reducer,
@Nonnull Binding node) {
if (node instanceof BindingPattern) {
return reduceBindingPattern(reducer, (BindingPattern) node);
} else if (node instanceof BindingIdentifier) {
return reduceBindingIdentifier(reducer, (BindingIdentifier) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceBindingBindingWithDefault(
@Nonnull ThunkedReducer reducer,
@Nonnull BindingBindingWithDefault node) {
if (node instanceof Binding) {
return reduceBinding(reducer, (Binding) node);
} else if (node instanceof BindingWithDefault) {
return reduceBindingWithDefault(reducer, (BindingWithDefault) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceBindingIdentifier(
@Nonnull ThunkedReducer reducer,
@Nonnull BindingIdentifier node) {
return reducer.reduceBindingIdentifier(node);
}
@Nonnull
public static State reduceBindingPattern(
@Nonnull ThunkedReducer reducer,
@Nonnull BindingPattern node) {
if (node instanceof ObjectBinding) {
return reduceObjectBinding(reducer, (ObjectBinding) node);
} else if (node instanceof ArrayBinding) {
return reduceArrayBinding(reducer, (ArrayBinding) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceBindingProperty(
@Nonnull ThunkedReducer reducer,
@Nonnull BindingProperty node) {
if (node instanceof BindingPropertyIdentifier) {
return reduceBindingPropertyIdentifier(reducer, (BindingPropertyIdentifier) node);
} else if (node instanceof BindingPropertyProperty) {
return reduceBindingPropertyProperty(reducer, (BindingPropertyProperty) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceBindingPropertyIdentifier(
@Nonnull ThunkedReducer reducer,
@Nonnull BindingPropertyIdentifier node) {
return reducer.reduceBindingPropertyIdentifier(node, () -> reduceBindingIdentifier(reducer, node.binding), reduceMaybeExpression(reducer, node.init));
}
@Nonnull
public static State reduceBindingPropertyProperty(
@Nonnull ThunkedReducer reducer,
@Nonnull BindingPropertyProperty node) {
return reducer.reduceBindingPropertyProperty(node, () -> reducePropertyName(reducer, node.name), () -> reduceBindingBindingWithDefault(reducer, node.binding));
}
@Nonnull
public static State reduceBindingWithDefault(
@Nonnull ThunkedReducer reducer,
@Nonnull BindingWithDefault node) {
return reducer.reduceBindingWithDefault(node, () -> reduceBinding(reducer, node.binding), () -> reduceExpression(reducer, node.init));
}
@Nonnull
public static State reduceBlock(
@Nonnull ThunkedReducer reducer,
@Nonnull Block node) {
return reducer.reduceBlock(node, reduceListStatement(reducer, node.statements));
}
@Nonnull
public static State reduceBlockStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull BlockStatement node) {
return reducer.reduceBlockStatement(node, () -> reduceBlock(reducer, node.block));
}
@Nonnull
public static State reduceBreakStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull BreakStatement node) {
return reducer.reduceBreakStatement(node);
}
@Nonnull
public static State reduceCallExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull CallExpression node) {
return reducer.reduceCallExpression(node, () -> reduceExpressionSuper(reducer, node.callee), reduceListSpreadElementExpression(reducer, node.arguments));
}
@Nonnull
public static State reduceCatchClause(
@Nonnull ThunkedReducer reducer,
@Nonnull CatchClause node) {
return reducer.reduceCatchClause(node, () -> reduceBinding(reducer, node.binding), () -> reduceBlock(reducer, node.body));
}
@Nonnull
public static State reduceClassDeclaration(
@Nonnull ThunkedReducer reducer,
@Nonnull ClassDeclaration node) {
return reducer.reduceClassDeclaration(node, () -> reduceBindingIdentifier(reducer, node.name), reduceMaybeExpression(reducer, node._super), reduceListClassElement(reducer, node.elements));
}
@Nonnull
public static State reduceClassElement(
@Nonnull ThunkedReducer reducer,
@Nonnull ClassElement node) {
return reducer.reduceClassElement(node, () -> reduceMethodDefinition(reducer, node.method));
}
@Nonnull
public static State reduceClassExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull ClassExpression node) {
return reducer.reduceClassExpression(node, reduceMaybeBindingIdentifier(reducer, node.name), reduceMaybeExpression(reducer, node._super), reduceListClassElement(reducer, node.elements));
}
@Nonnull
public static State reduceCompoundAssignmentExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull CompoundAssignmentExpression node) {
return reducer.reduceCompoundAssignmentExpression(node, () -> reduceSimpleAssignmentTarget(reducer, node.binding), () -> reduceExpression(reducer, node.expression));
}
@Nonnull
public static State reduceComputedMemberAssignmentTarget(
@Nonnull ThunkedReducer reducer,
@Nonnull ComputedMemberAssignmentTarget node) {
return reducer.reduceComputedMemberAssignmentTarget(node, () -> reduceExpressionSuper(reducer, node.object), () -> reduceExpression(reducer, node.expression));
}
@Nonnull
public static State reduceComputedMemberExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull ComputedMemberExpression node) {
return reducer.reduceComputedMemberExpression(node, () -> reduceExpressionSuper(reducer, node.object), () -> reduceExpression(reducer, node.expression));
}
@Nonnull
public static State reduceComputedPropertyName(
@Nonnull ThunkedReducer reducer,
@Nonnull ComputedPropertyName node) {
return reducer.reduceComputedPropertyName(node, () -> reduceExpression(reducer, node.expression));
}
@Nonnull
public static State reduceConditionalExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull ConditionalExpression node) {
return reducer.reduceConditionalExpression(node, () -> reduceExpression(reducer, node.test), () -> reduceExpression(reducer, node.consequent), () -> reduceExpression(reducer, node.alternate));
}
@Nonnull
public static State reduceContinueStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull ContinueStatement node) {
return reducer.reduceContinueStatement(node);
}
@Nonnull
public static State reduceDataProperty(
@Nonnull ThunkedReducer reducer,
@Nonnull DataProperty node) {
return reducer.reduceDataProperty(node, () -> reducePropertyName(reducer, node.name), () -> reduceExpression(reducer, node.expression));
}
@Nonnull
public static State reduceDebuggerStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull DebuggerStatement node) {
return reducer.reduceDebuggerStatement(node);
}
@Nonnull
public static State reduceDirective(
@Nonnull ThunkedReducer reducer,
@Nonnull Directive node) {
return reducer.reduceDirective(node);
}
@Nonnull
public static State reduceDoWhileStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull DoWhileStatement node) {
return reducer.reduceDoWhileStatement(node, () -> reduceStatement(reducer, node.body), () -> reduceExpression(reducer, node.test));
}
@Nonnull
public static State reduceEmptyStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull EmptyStatement node) {
return reducer.reduceEmptyStatement(node);
}
@Nonnull
public static State reduceExport(
@Nonnull ThunkedReducer reducer,
@Nonnull Export node) {
return reducer.reduceExport(node, () -> reduceFunctionDeclarationClassDeclarationVariableDeclaration(reducer, node.declaration));
}
@Nonnull
public static State reduceExportAllFrom(
@Nonnull ThunkedReducer reducer,
@Nonnull ExportAllFrom node) {
return reducer.reduceExportAllFrom(node);
}
@Nonnull
public static State reduceExportDeclaration(
@Nonnull ThunkedReducer reducer,
@Nonnull ExportDeclaration node) {
if (node instanceof ExportAllFrom) {
return reduceExportAllFrom(reducer, (ExportAllFrom) node);
} else if (node instanceof ExportFrom) {
return reduceExportFrom(reducer, (ExportFrom) node);
} else if (node instanceof ExportLocals) {
return reduceExportLocals(reducer, (ExportLocals) node);
} else if (node instanceof Export) {
return reduceExport(reducer, (Export) node);
} else if (node instanceof ExportDefault) {
return reduceExportDefault(reducer, (ExportDefault) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceExportDefault(
@Nonnull ThunkedReducer reducer,
@Nonnull ExportDefault node) {
return reducer.reduceExportDefault(node, () -> reduceFunctionDeclarationClassDeclarationExpression(reducer, node.body));
}
@Nonnull
public static State reduceExportFrom(
@Nonnull ThunkedReducer reducer,
@Nonnull ExportFrom node) {
return reducer.reduceExportFrom(node, reduceListExportFromSpecifier(reducer, node.namedExports));
}
@Nonnull
public static State reduceExportFromSpecifier(
@Nonnull ThunkedReducer reducer,
@Nonnull ExportFromSpecifier node) {
return reducer.reduceExportFromSpecifier(node);
}
@Nonnull
public static State reduceExportLocalSpecifier(
@Nonnull ThunkedReducer reducer,
@Nonnull ExportLocalSpecifier node) {
return reducer.reduceExportLocalSpecifier(node, () -> reduceIdentifierExpression(reducer, node.name));
}
@Nonnull
public static State reduceExportLocals(
@Nonnull ThunkedReducer reducer,
@Nonnull ExportLocals node) {
return reducer.reduceExportLocals(node, reduceListExportLocalSpecifier(reducer, node.namedExports));
}
@Nonnull
public static State reduceExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull Expression node) {
if (node instanceof MemberExpression) {
return reduceMemberExpression(reducer, (MemberExpression) node);
} else if (node instanceof ClassExpression) {
return reduceClassExpression(reducer, (ClassExpression) node);
} else if (node instanceof LiteralBooleanExpression) {
return reduceLiteralBooleanExpression(reducer, (LiteralBooleanExpression) node);
} else if (node instanceof LiteralInfinityExpression) {
return reduceLiteralInfinityExpression(reducer, (LiteralInfinityExpression) node);
} else if (node instanceof LiteralNullExpression) {
return reduceLiteralNullExpression(reducer, (LiteralNullExpression) node);
} else if (node instanceof LiteralNumericExpression) {
return reduceLiteralNumericExpression(reducer, (LiteralNumericExpression) node);
} else if (node instanceof LiteralRegExpExpression) {
return reduceLiteralRegExpExpression(reducer, (LiteralRegExpExpression) node);
} else if (node instanceof LiteralStringExpression) {
return reduceLiteralStringExpression(reducer, (LiteralStringExpression) node);
} else if (node instanceof ArrayExpression) {
return reduceArrayExpression(reducer, (ArrayExpression) node);
} else if (node instanceof ArrowExpression) {
return reduceArrowExpression(reducer, (ArrowExpression) node);
} else if (node instanceof AssignmentExpression) {
return reduceAssignmentExpression(reducer, (AssignmentExpression) node);
} else if (node instanceof BinaryExpression) {
return reduceBinaryExpression(reducer, (BinaryExpression) node);
} else if (node instanceof CallExpression) {
return reduceCallExpression(reducer, (CallExpression) node);
} else if (node instanceof CompoundAssignmentExpression) {
return reduceCompoundAssignmentExpression(reducer, (CompoundAssignmentExpression) node);
} else if (node instanceof ConditionalExpression) {
return reduceConditionalExpression(reducer, (ConditionalExpression) node);
} else if (node instanceof FunctionExpression) {
return reduceFunctionExpression(reducer, (FunctionExpression) node);
} else if (node instanceof IdentifierExpression) {
return reduceIdentifierExpression(reducer, (IdentifierExpression) node);
} else if (node instanceof NewExpression) {
return reduceNewExpression(reducer, (NewExpression) node);
} else if (node instanceof NewTargetExpression) {
return reduceNewTargetExpression(reducer, (NewTargetExpression) node);
} else if (node instanceof ObjectExpression) {
return reduceObjectExpression(reducer, (ObjectExpression) node);
} else if (node instanceof UnaryExpression) {
return reduceUnaryExpression(reducer, (UnaryExpression) node);
} else if (node instanceof TemplateExpression) {
return reduceTemplateExpression(reducer, (TemplateExpression) node);
} else if (node instanceof ThisExpression) {
return reduceThisExpression(reducer, (ThisExpression) node);
} else if (node instanceof UpdateExpression) {
return reduceUpdateExpression(reducer, (UpdateExpression) node);
} else if (node instanceof YieldExpression) {
return reduceYieldExpression(reducer, (YieldExpression) node);
} else if (node instanceof YieldGeneratorExpression) {
return reduceYieldGeneratorExpression(reducer, (YieldGeneratorExpression) node);
} else if (node instanceof AwaitExpression) {
return reduceAwaitExpression(reducer, (AwaitExpression) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceExpressionStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull ExpressionStatement node) {
return reducer.reduceExpressionStatement(node, () -> reduceExpression(reducer, node.expression));
}
@Nonnull
public static State reduceExpressionSuper(
@Nonnull ThunkedReducer reducer,
@Nonnull ExpressionSuper node) {
if (node instanceof Expression) {
return reduceExpression(reducer, (Expression) node);
} else if (node instanceof Super) {
return reduceSuper(reducer, (Super) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceExpressionTemplateElement(
@Nonnull ThunkedReducer reducer,
@Nonnull ExpressionTemplateElement node) {
if (node instanceof Expression) {
return reduceExpression(reducer, (Expression) node);
} else if (node instanceof TemplateElement) {
return reduceTemplateElement(reducer, (TemplateElement) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceForInStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull ForInStatement node) {
return reducer.reduceForInStatement(node, () -> reduceVariableDeclarationAssignmentTarget(reducer, node.left), () -> reduceExpression(reducer, node.right), () -> reduceStatement(reducer, node.body));
}
@Nonnull
public static State reduceForOfStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull ForOfStatement node) {
return reducer.reduceForOfStatement(node, () -> reduceVariableDeclarationAssignmentTarget(reducer, node.left), () -> reduceExpression(reducer, node.right), () -> reduceStatement(reducer, node.body));
}
@Nonnull
public static State reduceForStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull ForStatement node) {
return reducer.reduceForStatement(node, reduceMaybeVariableDeclarationExpression(reducer, node.init), reduceMaybeExpression(reducer, node.test), reduceMaybeExpression(reducer, node.update), () -> reduceStatement(reducer, node.body));
}
@Nonnull
public static State reduceFormalParameters(
@Nonnull ThunkedReducer reducer,
@Nonnull FormalParameters node) {
return reducer.reduceFormalParameters(node, reduceListParameter(reducer, node.items), reduceMaybeBinding(reducer, node.rest));
}
@Nonnull
public static State reduceFunctionBody(
@Nonnull ThunkedReducer reducer,
@Nonnull FunctionBody node) {
return reducer.reduceFunctionBody(node, reduceListDirective(reducer, node.directives), reduceListStatement(reducer, node.statements));
}
@Nonnull
public static State reduceFunctionBodyExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull FunctionBodyExpression node) {
if (node instanceof FunctionBody) {
return reduceFunctionBody(reducer, (FunctionBody) node);
} else if (node instanceof Expression) {
return reduceExpression(reducer, (Expression) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceFunctionDeclaration(
@Nonnull ThunkedReducer reducer,
@Nonnull FunctionDeclaration node) {
return reducer.reduceFunctionDeclaration(node, () -> reduceBindingIdentifier(reducer, node.name), () -> reduceFormalParameters(reducer, node.params), () -> reduceFunctionBody(reducer, node.body));
}
@Nonnull
public static State reduceFunctionDeclarationClassDeclarationExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull FunctionDeclarationClassDeclarationExpression node) {
if (node instanceof FunctionDeclaration) {
return reduceFunctionDeclaration(reducer, (FunctionDeclaration) node);
} else if (node instanceof ClassDeclaration) {
return reduceClassDeclaration(reducer, (ClassDeclaration) node);
} else if (node instanceof Expression) {
return reduceExpression(reducer, (Expression) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceFunctionDeclarationClassDeclarationVariableDeclaration(
@Nonnull ThunkedReducer reducer,
@Nonnull FunctionDeclarationClassDeclarationVariableDeclaration node) {
if (node instanceof FunctionDeclaration) {
return reduceFunctionDeclaration(reducer, (FunctionDeclaration) node);
} else if (node instanceof ClassDeclaration) {
return reduceClassDeclaration(reducer, (ClassDeclaration) node);
} else if (node instanceof VariableDeclaration) {
return reduceVariableDeclaration(reducer, (VariableDeclaration) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceFunctionExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull FunctionExpression node) {
return reducer.reduceFunctionExpression(node, reduceMaybeBindingIdentifier(reducer, node.name), () -> reduceFormalParameters(reducer, node.params), () -> reduceFunctionBody(reducer, node.body));
}
@Nonnull
public static State reduceGetter(
@Nonnull ThunkedReducer reducer,
@Nonnull Getter node) {
return reducer.reduceGetter(node, () -> reducePropertyName(reducer, node.name), () -> reduceFunctionBody(reducer, node.body));
}
@Nonnull
public static State reduceIdentifierExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull IdentifierExpression node) {
return reducer.reduceIdentifierExpression(node);
}
@Nonnull
public static State reduceIfStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull IfStatement node) {
return reducer.reduceIfStatement(node, () -> reduceExpression(reducer, node.test), () -> reduceStatement(reducer, node.consequent), reduceMaybeStatement(reducer, node.alternate));
}
@Nonnull
public static State reduceImport(
@Nonnull ThunkedReducer reducer,
@Nonnull Import node) {
return reducer.reduceImport(node, reduceMaybeBindingIdentifier(reducer, node.defaultBinding), reduceListImportSpecifier(reducer, node.namedImports));
}
@Nonnull
public static State reduceImportDeclaration(
@Nonnull ThunkedReducer reducer,
@Nonnull ImportDeclaration node) {
if (node instanceof Import) {
return reduceImport(reducer, (Import) node);
} else if (node instanceof ImportNamespace) {
return reduceImportNamespace(reducer, (ImportNamespace) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceImportDeclarationExportDeclarationStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull ImportDeclarationExportDeclarationStatement node) {
if (node instanceof ImportDeclaration) {
return reduceImportDeclaration(reducer, (ImportDeclaration) node);
} else if (node instanceof ExportDeclaration) {
return reduceExportDeclaration(reducer, (ExportDeclaration) node);
} else if (node instanceof Statement) {
return reduceStatement(reducer, (Statement) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceImportNamespace(
@Nonnull ThunkedReducer reducer,
@Nonnull ImportNamespace node) {
return reducer.reduceImportNamespace(node, reduceMaybeBindingIdentifier(reducer, node.defaultBinding), () -> reduceBindingIdentifier(reducer, node.namespaceBinding));
}
@Nonnull
public static State reduceImportSpecifier(
@Nonnull ThunkedReducer reducer,
@Nonnull ImportSpecifier node) {
return reducer.reduceImportSpecifier(node, () -> reduceBindingIdentifier(reducer, node.binding));
}
@Nonnull
public static State reduceIterationStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull IterationStatement node) {
if (node instanceof DoWhileStatement) {
return reduceDoWhileStatement(reducer, (DoWhileStatement) node);
} else if (node instanceof ForInStatement) {
return reduceForInStatement(reducer, (ForInStatement) node);
} else if (node instanceof ForOfStatement) {
return reduceForOfStatement(reducer, (ForOfStatement) node);
} else if (node instanceof ForStatement) {
return reduceForStatement(reducer, (ForStatement) node);
} else if (node instanceof WhileStatement) {
return reduceWhileStatement(reducer, (WhileStatement) node);
} else {
throw new RuntimeException("Not reached");
}
}
@Nonnull
public static State reduceLabeledStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull LabeledStatement node) {
return reducer.reduceLabeledStatement(node, () -> reduceStatement(reducer, node.body));
}
@Nonnull
public static ImmutableList> reduceListAssignmentTargetProperty(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceAssignmentTargetProperty(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListBindingProperty(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceBindingProperty(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListClassElement(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceClassElement(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListDirective(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceDirective(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListExportFromSpecifier(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceExportFromSpecifier(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListExportLocalSpecifier(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceExportLocalSpecifier(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListExpressionTemplateElement(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceExpressionTemplateElement(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListImportDeclarationExportDeclarationStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceImportDeclarationExportDeclarationStatement(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListImportSpecifier(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceImportSpecifier(reducer, x));
}
@Nonnull
public static ImmutableList>> reduceListMaybeAssignmentTargetAssignmentTargetWithDefault(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList> list) {
return list.map(x -> reduceMaybeAssignmentTargetAssignmentTargetWithDefault(reducer, x));
}
@Nonnull
public static ImmutableList>> reduceListMaybeBindingBindingWithDefault(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList> list) {
return list.map(x -> reduceMaybeBindingBindingWithDefault(reducer, x));
}
@Nonnull
public static ImmutableList>> reduceListMaybeSpreadElementExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList> list) {
return list.map(x -> reduceMaybeSpreadElementExpression(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListObjectProperty(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceObjectProperty(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListParameter(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceParameter(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListSpreadElementExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceSpreadElementExpression(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListStatement(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceStatement(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListSwitchCase(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceSwitchCase(reducer, x));
}
@Nonnull
public static ImmutableList> reduceListVariableDeclarator(
@Nonnull ThunkedReducer reducer,
@Nonnull ImmutableList list) {
return list.map(x -> () -> reduceVariableDeclarator(reducer, x));
}
@Nonnull
public static State reduceLiteralBooleanExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull LiteralBooleanExpression node) {
return reducer.reduceLiteralBooleanExpression(node);
}
@Nonnull
public static State reduceLiteralInfinityExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull LiteralInfinityExpression node) {
return reducer.reduceLiteralInfinityExpression(node);
}
@Nonnull
public static State reduceLiteralNullExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull LiteralNullExpression node) {
return reducer.reduceLiteralNullExpression(node);
}
@Nonnull
public static State reduceLiteralNumericExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull LiteralNumericExpression node) {
return reducer.reduceLiteralNumericExpression(node);
}
@Nonnull
public static State reduceLiteralRegExpExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull LiteralRegExpExpression node) {
return reducer.reduceLiteralRegExpExpression(node);
}
@Nonnull
public static State reduceLiteralStringExpression(
@Nonnull ThunkedReducer reducer,
@Nonnull LiteralStringExpression node) {
return reducer.reduceLiteralStringExpression(node);
}
@Nonnull
public static Maybe> reduceMaybeAssignmentTarget(
@Nonnull ThunkedReducer reducer,
@Nonnull Maybe maybe) {
return maybe.map(x -> () -> reduceAssignmentTarget(reducer, x));
}
@Nonnull
public static Maybe> reduceMaybeAssignmentTargetAssignmentTargetWithDefault(
@Nonnull ThunkedReducer reducer,
@Nonnull Maybe maybe) {
return maybe.map(x -> () -> reduceAssignmentTargetAssignmentTargetWithDefault(reducer, x));
}
@Nonnull
public static Maybe> reduceMaybeBinding(
@Nonnull ThunkedReducer reducer,
@Nonnull Maybe maybe) {
return maybe.map(x -> () -> reduceBinding(reducer, x));
}
@Nonnull
public static Maybe> reduceMaybeBindingBindingWithDefault(
@Nonnull ThunkedReducer reducer,
@Nonnull Maybe maybe) {
return maybe.map(x -> () -> reduceBindingBindingWithDefault(reducer, x));
}
@Nonnull
public static Maybe> reduceMaybeBindingIdentifier(
@Nonnull ThunkedReducer reducer,
@Nonnull Maybe