ast shape shifting pseudo note variables

This commit is contained in:
Felix Roos 2022-02-09 20:11:16 +01:00
parent ce579e48a6
commit 9ed198db28
29 changed files with 11174 additions and 12 deletions

View file

@ -0,0 +1,418 @@
// Generated by generate-adapt.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.
*/
import * as Shift from 'shift-ast';
export default (fn, reducer) => ({
__proto__: reducer,
reduceArrayAssignmentTarget(node, data) {
return fn(super.reduceArrayAssignmentTarget(node, data), node);
},
reduceArrayBinding(node, data) {
return fn(super.reduceArrayBinding(node, data), node);
},
reduceArrayExpression(node, data) {
return fn(super.reduceArrayExpression(node, data), node);
},
reduceArrowExpression(node, data) {
return fn(super.reduceArrowExpression(node, data), node);
},
reduceAssignmentExpression(node, data) {
return fn(super.reduceAssignmentExpression(node, data), node);
},
reduceAssignmentTargetIdentifier(node, data) {
return fn(super.reduceAssignmentTargetIdentifier(node, data), node);
},
reduceAssignmentTargetPropertyIdentifier(node, data) {
return fn(super.reduceAssignmentTargetPropertyIdentifier(node, data), node);
},
reduceAssignmentTargetPropertyProperty(node, data) {
return fn(super.reduceAssignmentTargetPropertyProperty(node, data), node);
},
reduceAssignmentTargetWithDefault(node, data) {
return fn(super.reduceAssignmentTargetWithDefault(node, data), node);
},
reduceAwaitExpression(node, data) {
return fn(super.reduceAwaitExpression(node, data), node);
},
reduceBinaryExpression(node, data) {
return fn(super.reduceBinaryExpression(node, data), node);
},
reduceBindingIdentifier(node, data) {
return fn(super.reduceBindingIdentifier(node, data), node);
},
reduceBindingPropertyIdentifier(node, data) {
return fn(super.reduceBindingPropertyIdentifier(node, data), node);
},
reduceBindingPropertyProperty(node, data) {
return fn(super.reduceBindingPropertyProperty(node, data), node);
},
reduceBindingWithDefault(node, data) {
return fn(super.reduceBindingWithDefault(node, data), node);
},
reduceBlock(node, data) {
return fn(super.reduceBlock(node, data), node);
},
reduceBlockStatement(node, data) {
return fn(super.reduceBlockStatement(node, data), node);
},
reduceBreakStatement(node, data) {
return fn(super.reduceBreakStatement(node, data), node);
},
reduceCallExpression(node, data) {
return fn(super.reduceCallExpression(node, data), node);
},
reduceCatchClause(node, data) {
return fn(super.reduceCatchClause(node, data), node);
},
reduceClassDeclaration(node, data) {
return fn(super.reduceClassDeclaration(node, data), node);
},
reduceClassElement(node, data) {
return fn(super.reduceClassElement(node, data), node);
},
reduceClassExpression(node, data) {
return fn(super.reduceClassExpression(node, data), node);
},
reduceCompoundAssignmentExpression(node, data) {
return fn(super.reduceCompoundAssignmentExpression(node, data), node);
},
reduceComputedMemberAssignmentTarget(node, data) {
return fn(super.reduceComputedMemberAssignmentTarget(node, data), node);
},
reduceComputedMemberExpression(node, data) {
return fn(super.reduceComputedMemberExpression(node, data), node);
},
reduceComputedPropertyName(node, data) {
return fn(super.reduceComputedPropertyName(node, data), node);
},
reduceConditionalExpression(node, data) {
return fn(super.reduceConditionalExpression(node, data), node);
},
reduceContinueStatement(node, data) {
return fn(super.reduceContinueStatement(node, data), node);
},
reduceDataProperty(node, data) {
return fn(super.reduceDataProperty(node, data), node);
},
reduceDebuggerStatement(node, data) {
return fn(super.reduceDebuggerStatement(node, data), node);
},
reduceDirective(node, data) {
return fn(super.reduceDirective(node, data), node);
},
reduceDoWhileStatement(node, data) {
return fn(super.reduceDoWhileStatement(node, data), node);
},
reduceEmptyStatement(node, data) {
return fn(super.reduceEmptyStatement(node, data), node);
},
reduceExport(node, data) {
return fn(super.reduceExport(node, data), node);
},
reduceExportAllFrom(node, data) {
return fn(super.reduceExportAllFrom(node, data), node);
},
reduceExportDefault(node, data) {
return fn(super.reduceExportDefault(node, data), node);
},
reduceExportFrom(node, data) {
return fn(super.reduceExportFrom(node, data), node);
},
reduceExportFromSpecifier(node, data) {
return fn(super.reduceExportFromSpecifier(node, data), node);
},
reduceExportLocalSpecifier(node, data) {
return fn(super.reduceExportLocalSpecifier(node, data), node);
},
reduceExportLocals(node, data) {
return fn(super.reduceExportLocals(node, data), node);
},
reduceExpressionStatement(node, data) {
return fn(super.reduceExpressionStatement(node, data), node);
},
reduceForAwaitStatement(node, data) {
return fn(super.reduceForAwaitStatement(node, data), node);
},
reduceForInStatement(node, data) {
return fn(super.reduceForInStatement(node, data), node);
},
reduceForOfStatement(node, data) {
return fn(super.reduceForOfStatement(node, data), node);
},
reduceForStatement(node, data) {
return fn(super.reduceForStatement(node, data), node);
},
reduceFormalParameters(node, data) {
return fn(super.reduceFormalParameters(node, data), node);
},
reduceFunctionBody(node, data) {
return fn(super.reduceFunctionBody(node, data), node);
},
reduceFunctionDeclaration(node, data) {
return fn(super.reduceFunctionDeclaration(node, data), node);
},
reduceFunctionExpression(node, data) {
return fn(super.reduceFunctionExpression(node, data), node);
},
reduceGetter(node, data) {
return fn(super.reduceGetter(node, data), node);
},
reduceIdentifierExpression(node, data) {
return fn(super.reduceIdentifierExpression(node, data), node);
},
reduceIfStatement(node, data) {
return fn(super.reduceIfStatement(node, data), node);
},
reduceImport(node, data) {
return fn(super.reduceImport(node, data), node);
},
reduceImportNamespace(node, data) {
return fn(super.reduceImportNamespace(node, data), node);
},
reduceImportSpecifier(node, data) {
return fn(super.reduceImportSpecifier(node, data), node);
},
reduceLabeledStatement(node, data) {
return fn(super.reduceLabeledStatement(node, data), node);
},
reduceLiteralBooleanExpression(node, data) {
return fn(super.reduceLiteralBooleanExpression(node, data), node);
},
reduceLiteralInfinityExpression(node, data) {
return fn(super.reduceLiteralInfinityExpression(node, data), node);
},
reduceLiteralNullExpression(node, data) {
return fn(super.reduceLiteralNullExpression(node, data), node);
},
reduceLiteralNumericExpression(node, data) {
return fn(super.reduceLiteralNumericExpression(node, data), node);
},
reduceLiteralRegExpExpression(node, data) {
return fn(super.reduceLiteralRegExpExpression(node, data), node);
},
reduceLiteralStringExpression(node, data) {
return fn(super.reduceLiteralStringExpression(node, data), node);
},
reduceMethod(node, data) {
return fn(super.reduceMethod(node, data), node);
},
reduceModule(node, data) {
return fn(super.reduceModule(node, data), node);
},
reduceNewExpression(node, data) {
return fn(super.reduceNewExpression(node, data), node);
},
reduceNewTargetExpression(node, data) {
return fn(super.reduceNewTargetExpression(node, data), node);
},
reduceObjectAssignmentTarget(node, data) {
return fn(super.reduceObjectAssignmentTarget(node, data), node);
},
reduceObjectBinding(node, data) {
return fn(super.reduceObjectBinding(node, data), node);
},
reduceObjectExpression(node, data) {
return fn(super.reduceObjectExpression(node, data), node);
},
reduceReturnStatement(node, data) {
return fn(super.reduceReturnStatement(node, data), node);
},
reduceScript(node, data) {
return fn(super.reduceScript(node, data), node);
},
reduceSetter(node, data) {
return fn(super.reduceSetter(node, data), node);
},
reduceShorthandProperty(node, data) {
return fn(super.reduceShorthandProperty(node, data), node);
},
reduceSpreadElement(node, data) {
return fn(super.reduceSpreadElement(node, data), node);
},
reduceSpreadProperty(node, data) {
return fn(super.reduceSpreadProperty(node, data), node);
},
reduceStaticMemberAssignmentTarget(node, data) {
return fn(super.reduceStaticMemberAssignmentTarget(node, data), node);
},
reduceStaticMemberExpression(node, data) {
return fn(super.reduceStaticMemberExpression(node, data), node);
},
reduceStaticPropertyName(node, data) {
return fn(super.reduceStaticPropertyName(node, data), node);
},
reduceSuper(node, data) {
return fn(super.reduceSuper(node, data), node);
},
reduceSwitchCase(node, data) {
return fn(super.reduceSwitchCase(node, data), node);
},
reduceSwitchDefault(node, data) {
return fn(super.reduceSwitchDefault(node, data), node);
},
reduceSwitchStatement(node, data) {
return fn(super.reduceSwitchStatement(node, data), node);
},
reduceSwitchStatementWithDefault(node, data) {
return fn(super.reduceSwitchStatementWithDefault(node, data), node);
},
reduceTemplateElement(node, data) {
return fn(super.reduceTemplateElement(node, data), node);
},
reduceTemplateExpression(node, data) {
return fn(super.reduceTemplateExpression(node, data), node);
},
reduceThisExpression(node, data) {
return fn(super.reduceThisExpression(node, data), node);
},
reduceThrowStatement(node, data) {
return fn(super.reduceThrowStatement(node, data), node);
},
reduceTryCatchStatement(node, data) {
return fn(super.reduceTryCatchStatement(node, data), node);
},
reduceTryFinallyStatement(node, data) {
return fn(super.reduceTryFinallyStatement(node, data), node);
},
reduceUnaryExpression(node, data) {
return fn(super.reduceUnaryExpression(node, data), node);
},
reduceUpdateExpression(node, data) {
return fn(super.reduceUpdateExpression(node, data), node);
},
reduceVariableDeclaration(node, data) {
return fn(super.reduceVariableDeclaration(node, data), node);
},
reduceVariableDeclarationStatement(node, data) {
return fn(super.reduceVariableDeclarationStatement(node, data), node);
},
reduceVariableDeclarator(node, data) {
return fn(super.reduceVariableDeclarator(node, data), node);
},
reduceWhileStatement(node, data) {
return fn(super.reduceWhileStatement(node, data), node);
},
reduceWithStatement(node, data) {
return fn(super.reduceWithStatement(node, data), node);
},
reduceYieldExpression(node, data) {
return fn(super.reduceYieldExpression(node, data), node);
},
reduceYieldGeneratorExpression(node, data) {
return fn(super.reduceYieldGeneratorExpression(node, data), node);
},
});

View file

@ -0,0 +1,416 @@
// Generated by generate-clone-reducer.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.
*/
import * as Shift from 'shift-ast';
export default class CloneReducer {
reduceArrayAssignmentTarget(node, { elements, rest }) {
return new Shift.ArrayAssignmentTarget({ elements, rest });
}
reduceArrayBinding(node, { elements, rest }) {
return new Shift.ArrayBinding({ elements, rest });
}
reduceArrayExpression(node, { elements }) {
return new Shift.ArrayExpression({ elements });
}
reduceArrowExpression(node, { params, body }) {
return new Shift.ArrowExpression({ isAsync: node.isAsync, params, body });
}
reduceAssignmentExpression(node, { binding, expression }) {
return new Shift.AssignmentExpression({ binding, expression });
}
reduceAssignmentTargetIdentifier(node) {
return new Shift.AssignmentTargetIdentifier({ name: node.name });
}
reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) {
return new Shift.AssignmentTargetPropertyIdentifier({ binding, init });
}
reduceAssignmentTargetPropertyProperty(node, { name, binding }) {
return new Shift.AssignmentTargetPropertyProperty({ name, binding });
}
reduceAssignmentTargetWithDefault(node, { binding, init }) {
return new Shift.AssignmentTargetWithDefault({ binding, init });
}
reduceAwaitExpression(node, { expression }) {
return new Shift.AwaitExpression({ expression });
}
reduceBinaryExpression(node, { left, right }) {
return new Shift.BinaryExpression({ left, operator: node.operator, right });
}
reduceBindingIdentifier(node) {
return new Shift.BindingIdentifier({ name: node.name });
}
reduceBindingPropertyIdentifier(node, { binding, init }) {
return new Shift.BindingPropertyIdentifier({ binding, init });
}
reduceBindingPropertyProperty(node, { name, binding }) {
return new Shift.BindingPropertyProperty({ name, binding });
}
reduceBindingWithDefault(node, { binding, init }) {
return new Shift.BindingWithDefault({ binding, init });
}
reduceBlock(node, { statements }) {
return new Shift.Block({ statements });
}
reduceBlockStatement(node, { block }) {
return new Shift.BlockStatement({ block });
}
reduceBreakStatement(node) {
return new Shift.BreakStatement({ label: node.label });
}
reduceCallExpression(node, { callee, arguments: _arguments }) {
return new Shift.CallExpression({ callee, arguments: _arguments });
}
reduceCatchClause(node, { binding, body }) {
return new Shift.CatchClause({ binding, body });
}
reduceClassDeclaration(node, { name, super: _super, elements }) {
return new Shift.ClassDeclaration({ name, super: _super, elements });
}
reduceClassElement(node, { method }) {
return new Shift.ClassElement({ isStatic: node.isStatic, method });
}
reduceClassExpression(node, { name, super: _super, elements }) {
return new Shift.ClassExpression({ name, super: _super, elements });
}
reduceCompoundAssignmentExpression(node, { binding, expression }) {
return new Shift.CompoundAssignmentExpression({ binding, operator: node.operator, expression });
}
reduceComputedMemberAssignmentTarget(node, { object, expression }) {
return new Shift.ComputedMemberAssignmentTarget({ object, expression });
}
reduceComputedMemberExpression(node, { object, expression }) {
return new Shift.ComputedMemberExpression({ object, expression });
}
reduceComputedPropertyName(node, { expression }) {
return new Shift.ComputedPropertyName({ expression });
}
reduceConditionalExpression(node, { test, consequent, alternate }) {
return new Shift.ConditionalExpression({ test, consequent, alternate });
}
reduceContinueStatement(node) {
return new Shift.ContinueStatement({ label: node.label });
}
reduceDataProperty(node, { name, expression }) {
return new Shift.DataProperty({ name, expression });
}
reduceDebuggerStatement(node) {
return new Shift.DebuggerStatement;
}
reduceDirective(node) {
return new Shift.Directive({ rawValue: node.rawValue });
}
reduceDoWhileStatement(node, { body, test }) {
return new Shift.DoWhileStatement({ body, test });
}
reduceEmptyStatement(node) {
return new Shift.EmptyStatement;
}
reduceExport(node, { declaration }) {
return new Shift.Export({ declaration });
}
reduceExportAllFrom(node) {
return new Shift.ExportAllFrom({ moduleSpecifier: node.moduleSpecifier });
}
reduceExportDefault(node, { body }) {
return new Shift.ExportDefault({ body });
}
reduceExportFrom(node, { namedExports }) {
return new Shift.ExportFrom({ namedExports, moduleSpecifier: node.moduleSpecifier });
}
reduceExportFromSpecifier(node) {
return new Shift.ExportFromSpecifier({ name: node.name, exportedName: node.exportedName });
}
reduceExportLocalSpecifier(node, { name }) {
return new Shift.ExportLocalSpecifier({ name, exportedName: node.exportedName });
}
reduceExportLocals(node, { namedExports }) {
return new Shift.ExportLocals({ namedExports });
}
reduceExpressionStatement(node, { expression }) {
return new Shift.ExpressionStatement({ expression });
}
reduceForAwaitStatement(node, { left, right, body }) {
return new Shift.ForAwaitStatement({ left, right, body });
}
reduceForInStatement(node, { left, right, body }) {
return new Shift.ForInStatement({ left, right, body });
}
reduceForOfStatement(node, { left, right, body }) {
return new Shift.ForOfStatement({ left, right, body });
}
reduceForStatement(node, { init, test, update, body }) {
return new Shift.ForStatement({ init, test, update, body });
}
reduceFormalParameters(node, { items, rest }) {
return new Shift.FormalParameters({ items, rest });
}
reduceFunctionBody(node, { directives, statements }) {
return new Shift.FunctionBody({ directives, statements });
}
reduceFunctionDeclaration(node, { name, params, body }) {
return new Shift.FunctionDeclaration({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body });
}
reduceFunctionExpression(node, { name, params, body }) {
return new Shift.FunctionExpression({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body });
}
reduceGetter(node, { name, body }) {
return new Shift.Getter({ name, body });
}
reduceIdentifierExpression(node) {
return new Shift.IdentifierExpression({ name: node.name });
}
reduceIfStatement(node, { test, consequent, alternate }) {
return new Shift.IfStatement({ test, consequent, alternate });
}
reduceImport(node, { defaultBinding, namedImports }) {
return new Shift.Import({ defaultBinding, namedImports, moduleSpecifier: node.moduleSpecifier });
}
reduceImportNamespace(node, { defaultBinding, namespaceBinding }) {
return new Shift.ImportNamespace({ defaultBinding, namespaceBinding, moduleSpecifier: node.moduleSpecifier });
}
reduceImportSpecifier(node, { binding }) {
return new Shift.ImportSpecifier({ name: node.name, binding });
}
reduceLabeledStatement(node, { body }) {
return new Shift.LabeledStatement({ label: node.label, body });
}
reduceLiteralBooleanExpression(node) {
return new Shift.LiteralBooleanExpression({ value: node.value });
}
reduceLiteralInfinityExpression(node) {
return new Shift.LiteralInfinityExpression;
}
reduceLiteralNullExpression(node) {
return new Shift.LiteralNullExpression;
}
reduceLiteralNumericExpression(node) {
return new Shift.LiteralNumericExpression({ value: node.value });
}
reduceLiteralRegExpExpression(node) {
return new Shift.LiteralRegExpExpression({ pattern: node.pattern, global: node.global, ignoreCase: node.ignoreCase, multiLine: node.multiLine, dotAll: node.dotAll, unicode: node.unicode, sticky: node.sticky });
}
reduceLiteralStringExpression(node) {
return new Shift.LiteralStringExpression({ value: node.value });
}
reduceMethod(node, { name, params, body }) {
return new Shift.Method({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body });
}
reduceModule(node, { directives, items }) {
return new Shift.Module({ directives, items });
}
reduceNewExpression(node, { callee, arguments: _arguments }) {
return new Shift.NewExpression({ callee, arguments: _arguments });
}
reduceNewTargetExpression(node) {
return new Shift.NewTargetExpression;
}
reduceObjectAssignmentTarget(node, { properties, rest }) {
return new Shift.ObjectAssignmentTarget({ properties, rest });
}
reduceObjectBinding(node, { properties, rest }) {
return new Shift.ObjectBinding({ properties, rest });
}
reduceObjectExpression(node, { properties }) {
return new Shift.ObjectExpression({ properties });
}
reduceReturnStatement(node, { expression }) {
return new Shift.ReturnStatement({ expression });
}
reduceScript(node, { directives, statements }) {
return new Shift.Script({ directives, statements });
}
reduceSetter(node, { name, param, body }) {
return new Shift.Setter({ name, param, body });
}
reduceShorthandProperty(node, { name }) {
return new Shift.ShorthandProperty({ name });
}
reduceSpreadElement(node, { expression }) {
return new Shift.SpreadElement({ expression });
}
reduceSpreadProperty(node, { expression }) {
return new Shift.SpreadProperty({ expression });
}
reduceStaticMemberAssignmentTarget(node, { object }) {
return new Shift.StaticMemberAssignmentTarget({ object, property: node.property });
}
reduceStaticMemberExpression(node, { object }) {
return new Shift.StaticMemberExpression({ object, property: node.property });
}
reduceStaticPropertyName(node) {
return new Shift.StaticPropertyName({ value: node.value });
}
reduceSuper(node) {
return new Shift.Super;
}
reduceSwitchCase(node, { test, consequent }) {
return new Shift.SwitchCase({ test, consequent });
}
reduceSwitchDefault(node, { consequent }) {
return new Shift.SwitchDefault({ consequent });
}
reduceSwitchStatement(node, { discriminant, cases }) {
return new Shift.SwitchStatement({ discriminant, cases });
}
reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) {
return new Shift.SwitchStatementWithDefault({ discriminant, preDefaultCases, defaultCase, postDefaultCases });
}
reduceTemplateElement(node) {
return new Shift.TemplateElement({ rawValue: node.rawValue });
}
reduceTemplateExpression(node, { tag, elements }) {
return new Shift.TemplateExpression({ tag, elements });
}
reduceThisExpression(node) {
return new Shift.ThisExpression;
}
reduceThrowStatement(node, { expression }) {
return new Shift.ThrowStatement({ expression });
}
reduceTryCatchStatement(node, { body, catchClause }) {
return new Shift.TryCatchStatement({ body, catchClause });
}
reduceTryFinallyStatement(node, { body, catchClause, finalizer }) {
return new Shift.TryFinallyStatement({ body, catchClause, finalizer });
}
reduceUnaryExpression(node, { operand }) {
return new Shift.UnaryExpression({ operator: node.operator, operand });
}
reduceUpdateExpression(node, { operand }) {
return new Shift.UpdateExpression({ isPrefix: node.isPrefix, operator: node.operator, operand });
}
reduceVariableDeclaration(node, { declarators }) {
return new Shift.VariableDeclaration({ kind: node.kind, declarators });
}
reduceVariableDeclarationStatement(node, { declaration }) {
return new Shift.VariableDeclarationStatement({ declaration });
}
reduceVariableDeclarator(node, { binding, init }) {
return new Shift.VariableDeclarator({ binding, init });
}
reduceWhileStatement(node, { test, body }) {
return new Shift.WhileStatement({ test, body });
}
reduceWithStatement(node, { object, body }) {
return new Shift.WithStatement({ object, body });
}
reduceYieldExpression(node, { expression }) {
return new Shift.YieldExpression({ expression });
}
reduceYieldGeneratorExpression(node, { expression }) {
return new Shift.YieldGeneratorExpression({ expression });
}
}

View file

@ -0,0 +1,418 @@
// Generated by generate-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.
*/
const director = {
ArrayAssignmentTarget(reducer, node) {
return reducer.reduceArrayAssignmentTarget(node, { elements: node.elements.map(v => v && this[v.type](reducer, v)), rest: node.rest && this[node.rest.type](reducer, node.rest) });
},
ArrayBinding(reducer, node) {
return reducer.reduceArrayBinding(node, { elements: node.elements.map(v => v && this[v.type](reducer, v)), rest: node.rest && this[node.rest.type](reducer, node.rest) });
},
ArrayExpression(reducer, node) {
return reducer.reduceArrayExpression(node, { elements: node.elements.map(v => v && this[v.type](reducer, v)) });
},
ArrowExpression(reducer, node) {
return reducer.reduceArrowExpression(node, { params: this.FormalParameters(reducer, node.params), body: this[node.body.type](reducer, node.body) });
},
AssignmentExpression(reducer, node) {
return reducer.reduceAssignmentExpression(node, { binding: this[node.binding.type](reducer, node.binding), expression: this[node.expression.type](reducer, node.expression) });
},
AssignmentTargetIdentifier(reducer, node) {
return reducer.reduceAssignmentTargetIdentifier(node);
},
AssignmentTargetPropertyIdentifier(reducer, node) {
return reducer.reduceAssignmentTargetPropertyIdentifier(node, { binding: this.AssignmentTargetIdentifier(reducer, node.binding), init: node.init && this[node.init.type](reducer, node.init) });
},
AssignmentTargetPropertyProperty(reducer, node) {
return reducer.reduceAssignmentTargetPropertyProperty(node, { name: this[node.name.type](reducer, node.name), binding: this[node.binding.type](reducer, node.binding) });
},
AssignmentTargetWithDefault(reducer, node) {
return reducer.reduceAssignmentTargetWithDefault(node, { binding: this[node.binding.type](reducer, node.binding), init: this[node.init.type](reducer, node.init) });
},
AwaitExpression(reducer, node) {
return reducer.reduceAwaitExpression(node, { expression: this[node.expression.type](reducer, node.expression) });
},
BinaryExpression(reducer, node) {
return reducer.reduceBinaryExpression(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right) });
},
BindingIdentifier(reducer, node) {
return reducer.reduceBindingIdentifier(node);
},
BindingPropertyIdentifier(reducer, node) {
return reducer.reduceBindingPropertyIdentifier(node, { binding: this.BindingIdentifier(reducer, node.binding), init: node.init && this[node.init.type](reducer, node.init) });
},
BindingPropertyProperty(reducer, node) {
return reducer.reduceBindingPropertyProperty(node, { name: this[node.name.type](reducer, node.name), binding: this[node.binding.type](reducer, node.binding) });
},
BindingWithDefault(reducer, node) {
return reducer.reduceBindingWithDefault(node, { binding: this[node.binding.type](reducer, node.binding), init: this[node.init.type](reducer, node.init) });
},
Block(reducer, node) {
return reducer.reduceBlock(node, { statements: node.statements.map(v => this[v.type](reducer, v)) });
},
BlockStatement(reducer, node) {
return reducer.reduceBlockStatement(node, { block: this.Block(reducer, node.block) });
},
BreakStatement(reducer, node) {
return reducer.reduceBreakStatement(node);
},
CallExpression(reducer, node) {
return reducer.reduceCallExpression(node, { callee: this[node.callee.type](reducer, node.callee), arguments: node.arguments.map(v => this[v.type](reducer, v)) });
},
CatchClause(reducer, node) {
return reducer.reduceCatchClause(node, { binding: this[node.binding.type](reducer, node.binding), body: this.Block(reducer, node.body) });
},
ClassDeclaration(reducer, node) {
return reducer.reduceClassDeclaration(node, { name: this.BindingIdentifier(reducer, node.name), super: node.super && this[node.super.type](reducer, node.super), elements: node.elements.map(v => this.ClassElement(reducer, v)) });
},
ClassElement(reducer, node) {
return reducer.reduceClassElement(node, { method: this[node.method.type](reducer, node.method) });
},
ClassExpression(reducer, node) {
return reducer.reduceClassExpression(node, { name: node.name && this.BindingIdentifier(reducer, node.name), super: node.super && this[node.super.type](reducer, node.super), elements: node.elements.map(v => this.ClassElement(reducer, v)) });
},
CompoundAssignmentExpression(reducer, node) {
return reducer.reduceCompoundAssignmentExpression(node, { binding: this[node.binding.type](reducer, node.binding), expression: this[node.expression.type](reducer, node.expression) });
},
ComputedMemberAssignmentTarget(reducer, node) {
return reducer.reduceComputedMemberAssignmentTarget(node, { object: this[node.object.type](reducer, node.object), expression: this[node.expression.type](reducer, node.expression) });
},
ComputedMemberExpression(reducer, node) {
return reducer.reduceComputedMemberExpression(node, { object: this[node.object.type](reducer, node.object), expression: this[node.expression.type](reducer, node.expression) });
},
ComputedPropertyName(reducer, node) {
return reducer.reduceComputedPropertyName(node, { expression: this[node.expression.type](reducer, node.expression) });
},
ConditionalExpression(reducer, node) {
return reducer.reduceConditionalExpression(node, { test: this[node.test.type](reducer, node.test), consequent: this[node.consequent.type](reducer, node.consequent), alternate: this[node.alternate.type](reducer, node.alternate) });
},
ContinueStatement(reducer, node) {
return reducer.reduceContinueStatement(node);
},
DataProperty(reducer, node) {
return reducer.reduceDataProperty(node, { name: this[node.name.type](reducer, node.name), expression: this[node.expression.type](reducer, node.expression) });
},
DebuggerStatement(reducer, node) {
return reducer.reduceDebuggerStatement(node);
},
Directive(reducer, node) {
return reducer.reduceDirective(node);
},
DoWhileStatement(reducer, node) {
return reducer.reduceDoWhileStatement(node, { body: this[node.body.type](reducer, node.body), test: this[node.test.type](reducer, node.test) });
},
EmptyStatement(reducer, node) {
return reducer.reduceEmptyStatement(node);
},
Export(reducer, node) {
return reducer.reduceExport(node, { declaration: this[node.declaration.type](reducer, node.declaration) });
},
ExportAllFrom(reducer, node) {
return reducer.reduceExportAllFrom(node);
},
ExportDefault(reducer, node) {
return reducer.reduceExportDefault(node, { body: this[node.body.type](reducer, node.body) });
},
ExportFrom(reducer, node) {
return reducer.reduceExportFrom(node, { namedExports: node.namedExports.map(v => this.ExportFromSpecifier(reducer, v)) });
},
ExportFromSpecifier(reducer, node) {
return reducer.reduceExportFromSpecifier(node);
},
ExportLocalSpecifier(reducer, node) {
return reducer.reduceExportLocalSpecifier(node, { name: this.IdentifierExpression(reducer, node.name) });
},
ExportLocals(reducer, node) {
return reducer.reduceExportLocals(node, { namedExports: node.namedExports.map(v => this.ExportLocalSpecifier(reducer, v)) });
},
ExpressionStatement(reducer, node) {
return reducer.reduceExpressionStatement(node, { expression: this[node.expression.type](reducer, node.expression) });
},
ForAwaitStatement(reducer, node) {
return reducer.reduceForAwaitStatement(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right), body: this[node.body.type](reducer, node.body) });
},
ForInStatement(reducer, node) {
return reducer.reduceForInStatement(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right), body: this[node.body.type](reducer, node.body) });
},
ForOfStatement(reducer, node) {
return reducer.reduceForOfStatement(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right), body: this[node.body.type](reducer, node.body) });
},
ForStatement(reducer, node) {
return reducer.reduceForStatement(node, { init: node.init && this[node.init.type](reducer, node.init), test: node.test && this[node.test.type](reducer, node.test), update: node.update && this[node.update.type](reducer, node.update), body: this[node.body.type](reducer, node.body) });
},
FormalParameters(reducer, node) {
return reducer.reduceFormalParameters(node, { items: node.items.map(v => this[v.type](reducer, v)), rest: node.rest && this[node.rest.type](reducer, node.rest) });
},
FunctionBody(reducer, node) {
return reducer.reduceFunctionBody(node, { directives: node.directives.map(v => this.Directive(reducer, v)), statements: node.statements.map(v => this[v.type](reducer, v)) });
},
FunctionDeclaration(reducer, node) {
return reducer.reduceFunctionDeclaration(node, { name: this.BindingIdentifier(reducer, node.name), params: this.FormalParameters(reducer, node.params), body: this.FunctionBody(reducer, node.body) });
},
FunctionExpression(reducer, node) {
return reducer.reduceFunctionExpression(node, { name: node.name && this.BindingIdentifier(reducer, node.name), params: this.FormalParameters(reducer, node.params), body: this.FunctionBody(reducer, node.body) });
},
Getter(reducer, node) {
return reducer.reduceGetter(node, { name: this[node.name.type](reducer, node.name), body: this.FunctionBody(reducer, node.body) });
},
IdentifierExpression(reducer, node) {
return reducer.reduceIdentifierExpression(node);
},
IfStatement(reducer, node) {
return reducer.reduceIfStatement(node, { test: this[node.test.type](reducer, node.test), consequent: this[node.consequent.type](reducer, node.consequent), alternate: node.alternate && this[node.alternate.type](reducer, node.alternate) });
},
Import(reducer, node) {
return reducer.reduceImport(node, { defaultBinding: node.defaultBinding && this.BindingIdentifier(reducer, node.defaultBinding), namedImports: node.namedImports.map(v => this.ImportSpecifier(reducer, v)) });
},
ImportNamespace(reducer, node) {
return reducer.reduceImportNamespace(node, { defaultBinding: node.defaultBinding && this.BindingIdentifier(reducer, node.defaultBinding), namespaceBinding: this.BindingIdentifier(reducer, node.namespaceBinding) });
},
ImportSpecifier(reducer, node) {
return reducer.reduceImportSpecifier(node, { binding: this.BindingIdentifier(reducer, node.binding) });
},
LabeledStatement(reducer, node) {
return reducer.reduceLabeledStatement(node, { body: this[node.body.type](reducer, node.body) });
},
LiteralBooleanExpression(reducer, node) {
return reducer.reduceLiteralBooleanExpression(node);
},
LiteralInfinityExpression(reducer, node) {
return reducer.reduceLiteralInfinityExpression(node);
},
LiteralNullExpression(reducer, node) {
return reducer.reduceLiteralNullExpression(node);
},
LiteralNumericExpression(reducer, node) {
return reducer.reduceLiteralNumericExpression(node);
},
LiteralRegExpExpression(reducer, node) {
return reducer.reduceLiteralRegExpExpression(node);
},
LiteralStringExpression(reducer, node) {
return reducer.reduceLiteralStringExpression(node);
},
Method(reducer, node) {
return reducer.reduceMethod(node, { name: this[node.name.type](reducer, node.name), params: this.FormalParameters(reducer, node.params), body: this.FunctionBody(reducer, node.body) });
},
Module(reducer, node) {
return reducer.reduceModule(node, { directives: node.directives.map(v => this.Directive(reducer, v)), items: node.items.map(v => this[v.type](reducer, v)) });
},
NewExpression(reducer, node) {
return reducer.reduceNewExpression(node, { callee: this[node.callee.type](reducer, node.callee), arguments: node.arguments.map(v => this[v.type](reducer, v)) });
},
NewTargetExpression(reducer, node) {
return reducer.reduceNewTargetExpression(node);
},
ObjectAssignmentTarget(reducer, node) {
return reducer.reduceObjectAssignmentTarget(node, { properties: node.properties.map(v => this[v.type](reducer, v)), rest: node.rest && this[node.rest.type](reducer, node.rest) });
},
ObjectBinding(reducer, node) {
return reducer.reduceObjectBinding(node, { properties: node.properties.map(v => this[v.type](reducer, v)), rest: node.rest && this[node.rest.type](reducer, node.rest) });
},
ObjectExpression(reducer, node) {
return reducer.reduceObjectExpression(node, { properties: node.properties.map(v => this[v.type](reducer, v)) });
},
ReturnStatement(reducer, node) {
return reducer.reduceReturnStatement(node, { expression: node.expression && this[node.expression.type](reducer, node.expression) });
},
Script(reducer, node) {
return reducer.reduceScript(node, { directives: node.directives.map(v => this.Directive(reducer, v)), statements: node.statements.map(v => this[v.type](reducer, v)) });
},
Setter(reducer, node) {
return reducer.reduceSetter(node, { name: this[node.name.type](reducer, node.name), param: this[node.param.type](reducer, node.param), body: this.FunctionBody(reducer, node.body) });
},
ShorthandProperty(reducer, node) {
return reducer.reduceShorthandProperty(node, { name: this.IdentifierExpression(reducer, node.name) });
},
SpreadElement(reducer, node) {
return reducer.reduceSpreadElement(node, { expression: this[node.expression.type](reducer, node.expression) });
},
SpreadProperty(reducer, node) {
return reducer.reduceSpreadProperty(node, { expression: this[node.expression.type](reducer, node.expression) });
},
StaticMemberAssignmentTarget(reducer, node) {
return reducer.reduceStaticMemberAssignmentTarget(node, { object: this[node.object.type](reducer, node.object) });
},
StaticMemberExpression(reducer, node) {
return reducer.reduceStaticMemberExpression(node, { object: this[node.object.type](reducer, node.object) });
},
StaticPropertyName(reducer, node) {
return reducer.reduceStaticPropertyName(node);
},
Super(reducer, node) {
return reducer.reduceSuper(node);
},
SwitchCase(reducer, node) {
return reducer.reduceSwitchCase(node, { test: this[node.test.type](reducer, node.test), consequent: node.consequent.map(v => this[v.type](reducer, v)) });
},
SwitchDefault(reducer, node) {
return reducer.reduceSwitchDefault(node, { consequent: node.consequent.map(v => this[v.type](reducer, v)) });
},
SwitchStatement(reducer, node) {
return reducer.reduceSwitchStatement(node, { discriminant: this[node.discriminant.type](reducer, node.discriminant), cases: node.cases.map(v => this.SwitchCase(reducer, v)) });
},
SwitchStatementWithDefault(reducer, node) {
return reducer.reduceSwitchStatementWithDefault(node, { discriminant: this[node.discriminant.type](reducer, node.discriminant), preDefaultCases: node.preDefaultCases.map(v => this.SwitchCase(reducer, v)), defaultCase: this.SwitchDefault(reducer, node.defaultCase), postDefaultCases: node.postDefaultCases.map(v => this.SwitchCase(reducer, v)) });
},
TemplateElement(reducer, node) {
return reducer.reduceTemplateElement(node);
},
TemplateExpression(reducer, node) {
return reducer.reduceTemplateExpression(node, { tag: node.tag && this[node.tag.type](reducer, node.tag), elements: node.elements.map(v => this[v.type](reducer, v)) });
},
ThisExpression(reducer, node) {
return reducer.reduceThisExpression(node);
},
ThrowStatement(reducer, node) {
return reducer.reduceThrowStatement(node, { expression: this[node.expression.type](reducer, node.expression) });
},
TryCatchStatement(reducer, node) {
return reducer.reduceTryCatchStatement(node, { body: this.Block(reducer, node.body), catchClause: this.CatchClause(reducer, node.catchClause) });
},
TryFinallyStatement(reducer, node) {
return reducer.reduceTryFinallyStatement(node, { body: this.Block(reducer, node.body), catchClause: node.catchClause && this.CatchClause(reducer, node.catchClause), finalizer: this.Block(reducer, node.finalizer) });
},
UnaryExpression(reducer, node) {
return reducer.reduceUnaryExpression(node, { operand: this[node.operand.type](reducer, node.operand) });
},
UpdateExpression(reducer, node) {
return reducer.reduceUpdateExpression(node, { operand: this[node.operand.type](reducer, node.operand) });
},
VariableDeclaration(reducer, node) {
return reducer.reduceVariableDeclaration(node, { declarators: node.declarators.map(v => this.VariableDeclarator(reducer, v)) });
},
VariableDeclarationStatement(reducer, node) {
return reducer.reduceVariableDeclarationStatement(node, { declaration: this.VariableDeclaration(reducer, node.declaration) });
},
VariableDeclarator(reducer, node) {
return reducer.reduceVariableDeclarator(node, { binding: this[node.binding.type](reducer, node.binding), init: node.init && this[node.init.type](reducer, node.init) });
},
WhileStatement(reducer, node) {
return reducer.reduceWhileStatement(node, { test: this[node.test.type](reducer, node.test), body: this[node.body.type](reducer, node.body) });
},
WithStatement(reducer, node) {
return reducer.reduceWithStatement(node, { object: this[node.object.type](reducer, node.object), body: this[node.body.type](reducer, node.body) });
},
YieldExpression(reducer, node) {
return reducer.reduceYieldExpression(node, { expression: node.expression && this[node.expression.type](reducer, node.expression) });
},
YieldGeneratorExpression(reducer, node) {
return reducer.reduceYieldGeneratorExpression(node, { expression: this[node.expression.type](reducer, node.expression) });
},
};
export function reduce(reducer, node) {
return director[node.type](reducer, node);
}

View file

@ -0,0 +1,27 @@
/*
* 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.
*/
export { reduce, reduce as default } from './director.js';
export { thunkedReduce } from './thunked-director.js';
export { default as thunkify } from './thunkify.js';
export { default as thunkifyClass } from './thunkify-class.js';
export { default as memoize } from './memoize.js';
export { default as CloneReducer } from './clone-reducer.js';
export { default as LazyCloneReducer } from './lazy-clone-reducer.js';
export { default as MonoidalReducer } from './monoidal-reducer.js';
export { default as ThunkedMonoidalReducer } from './thunked-monoidal-reducer.js';
export { default as adapt } from './adapt.js';
export { PlusReducer, ThunkedPlusReducer, ConcatReducer, ThunkedConcatReducer, AndReducer, ThunkedAndReducer, OrReducer, ThunkedOrReducer } from './reducers.js';

View file

@ -0,0 +1,650 @@
// Generated by generate-lazy-clone-reducer.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.
*/
import * as Shift from 'shift-ast';
export default class LazyCloneReducer {
reduceArrayAssignmentTarget(node, { elements, rest }) {
if ((node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i])) && node.rest === rest) {
return node;
}
return new Shift.ArrayAssignmentTarget({ elements, rest });
}
reduceArrayBinding(node, { elements, rest }) {
if ((node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i])) && node.rest === rest) {
return node;
}
return new Shift.ArrayBinding({ elements, rest });
}
reduceArrayExpression(node, { elements }) {
if ((node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i]))) {
return node;
}
return new Shift.ArrayExpression({ elements });
}
reduceArrowExpression(node, { params, body }) {
if (node.params === params && node.body === body) {
return node;
}
return new Shift.ArrowExpression({ isAsync: node.isAsync, params, body });
}
reduceAssignmentExpression(node, { binding, expression }) {
if (node.binding === binding && node.expression === expression) {
return node;
}
return new Shift.AssignmentExpression({ binding, expression });
}
reduceAssignmentTargetIdentifier(node) {
return node;
}
reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) {
if (node.binding === binding && node.init === init) {
return node;
}
return new Shift.AssignmentTargetPropertyIdentifier({ binding, init });
}
reduceAssignmentTargetPropertyProperty(node, { name, binding }) {
if (node.name === name && node.binding === binding) {
return node;
}
return new Shift.AssignmentTargetPropertyProperty({ name, binding });
}
reduceAssignmentTargetWithDefault(node, { binding, init }) {
if (node.binding === binding && node.init === init) {
return node;
}
return new Shift.AssignmentTargetWithDefault({ binding, init });
}
reduceAwaitExpression(node, { expression }) {
if (node.expression === expression) {
return node;
}
return new Shift.AwaitExpression({ expression });
}
reduceBinaryExpression(node, { left, right }) {
if (node.left === left && node.right === right) {
return node;
}
return new Shift.BinaryExpression({ left, operator: node.operator, right });
}
reduceBindingIdentifier(node) {
return node;
}
reduceBindingPropertyIdentifier(node, { binding, init }) {
if (node.binding === binding && node.init === init) {
return node;
}
return new Shift.BindingPropertyIdentifier({ binding, init });
}
reduceBindingPropertyProperty(node, { name, binding }) {
if (node.name === name && node.binding === binding) {
return node;
}
return new Shift.BindingPropertyProperty({ name, binding });
}
reduceBindingWithDefault(node, { binding, init }) {
if (node.binding === binding && node.init === init) {
return node;
}
return new Shift.BindingWithDefault({ binding, init });
}
reduceBlock(node, { statements }) {
if ((node.statements.length === statements.length && node.statements.every((v, i) => v === statements[i]))) {
return node;
}
return new Shift.Block({ statements });
}
reduceBlockStatement(node, { block }) {
if (node.block === block) {
return node;
}
return new Shift.BlockStatement({ block });
}
reduceBreakStatement(node) {
return node;
}
reduceCallExpression(node, { callee, arguments: _arguments }) {
if (node.callee === callee && (node.arguments.length === _arguments.length && node.arguments.every((v, i) => v === _arguments[i]))) {
return node;
}
return new Shift.CallExpression({ callee, arguments: _arguments });
}
reduceCatchClause(node, { binding, body }) {
if (node.binding === binding && node.body === body) {
return node;
}
return new Shift.CatchClause({ binding, body });
}
reduceClassDeclaration(node, { name, super: _super, elements }) {
if (node.name === name && node.super === _super && (node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i]))) {
return node;
}
return new Shift.ClassDeclaration({ name, super: _super, elements });
}
reduceClassElement(node, { method }) {
if (node.method === method) {
return node;
}
return new Shift.ClassElement({ isStatic: node.isStatic, method });
}
reduceClassExpression(node, { name, super: _super, elements }) {
if (node.name === name && node.super === _super && (node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i]))) {
return node;
}
return new Shift.ClassExpression({ name, super: _super, elements });
}
reduceCompoundAssignmentExpression(node, { binding, expression }) {
if (node.binding === binding && node.expression === expression) {
return node;
}
return new Shift.CompoundAssignmentExpression({ binding, operator: node.operator, expression });
}
reduceComputedMemberAssignmentTarget(node, { object, expression }) {
if (node.object === object && node.expression === expression) {
return node;
}
return new Shift.ComputedMemberAssignmentTarget({ object, expression });
}
reduceComputedMemberExpression(node, { object, expression }) {
if (node.object === object && node.expression === expression) {
return node;
}
return new Shift.ComputedMemberExpression({ object, expression });
}
reduceComputedPropertyName(node, { expression }) {
if (node.expression === expression) {
return node;
}
return new Shift.ComputedPropertyName({ expression });
}
reduceConditionalExpression(node, { test, consequent, alternate }) {
if (node.test === test && node.consequent === consequent && node.alternate === alternate) {
return node;
}
return new Shift.ConditionalExpression({ test, consequent, alternate });
}
reduceContinueStatement(node) {
return node;
}
reduceDataProperty(node, { name, expression }) {
if (node.name === name && node.expression === expression) {
return node;
}
return new Shift.DataProperty({ name, expression });
}
reduceDebuggerStatement(node) {
return node;
}
reduceDirective(node) {
return node;
}
reduceDoWhileStatement(node, { body, test }) {
if (node.body === body && node.test === test) {
return node;
}
return new Shift.DoWhileStatement({ body, test });
}
reduceEmptyStatement(node) {
return node;
}
reduceExport(node, { declaration }) {
if (node.declaration === declaration) {
return node;
}
return new Shift.Export({ declaration });
}
reduceExportAllFrom(node) {
return node;
}
reduceExportDefault(node, { body }) {
if (node.body === body) {
return node;
}
return new Shift.ExportDefault({ body });
}
reduceExportFrom(node, { namedExports }) {
if ((node.namedExports.length === namedExports.length && node.namedExports.every((v, i) => v === namedExports[i]))) {
return node;
}
return new Shift.ExportFrom({ namedExports, moduleSpecifier: node.moduleSpecifier });
}
reduceExportFromSpecifier(node) {
return node;
}
reduceExportLocalSpecifier(node, { name }) {
if (node.name === name) {
return node;
}
return new Shift.ExportLocalSpecifier({ name, exportedName: node.exportedName });
}
reduceExportLocals(node, { namedExports }) {
if ((node.namedExports.length === namedExports.length && node.namedExports.every((v, i) => v === namedExports[i]))) {
return node;
}
return new Shift.ExportLocals({ namedExports });
}
reduceExpressionStatement(node, { expression }) {
if (node.expression === expression) {
return node;
}
return new Shift.ExpressionStatement({ expression });
}
reduceForAwaitStatement(node, { left, right, body }) {
if (node.left === left && node.right === right && node.body === body) {
return node;
}
return new Shift.ForAwaitStatement({ left, right, body });
}
reduceForInStatement(node, { left, right, body }) {
if (node.left === left && node.right === right && node.body === body) {
return node;
}
return new Shift.ForInStatement({ left, right, body });
}
reduceForOfStatement(node, { left, right, body }) {
if (node.left === left && node.right === right && node.body === body) {
return node;
}
return new Shift.ForOfStatement({ left, right, body });
}
reduceForStatement(node, { init, test, update, body }) {
if (node.init === init && node.test === test && node.update === update && node.body === body) {
return node;
}
return new Shift.ForStatement({ init, test, update, body });
}
reduceFormalParameters(node, { items, rest }) {
if ((node.items.length === items.length && node.items.every((v, i) => v === items[i])) && node.rest === rest) {
return node;
}
return new Shift.FormalParameters({ items, rest });
}
reduceFunctionBody(node, { directives, statements }) {
if ((node.directives.length === directives.length && node.directives.every((v, i) => v === directives[i])) && (node.statements.length === statements.length && node.statements.every((v, i) => v === statements[i]))) {
return node;
}
return new Shift.FunctionBody({ directives, statements });
}
reduceFunctionDeclaration(node, { name, params, body }) {
if (node.name === name && node.params === params && node.body === body) {
return node;
}
return new Shift.FunctionDeclaration({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body });
}
reduceFunctionExpression(node, { name, params, body }) {
if (node.name === name && node.params === params && node.body === body) {
return node;
}
return new Shift.FunctionExpression({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body });
}
reduceGetter(node, { name, body }) {
if (node.name === name && node.body === body) {
return node;
}
return new Shift.Getter({ name, body });
}
reduceIdentifierExpression(node) {
return node;
}
reduceIfStatement(node, { test, consequent, alternate }) {
if (node.test === test && node.consequent === consequent && node.alternate === alternate) {
return node;
}
return new Shift.IfStatement({ test, consequent, alternate });
}
reduceImport(node, { defaultBinding, namedImports }) {
if (node.defaultBinding === defaultBinding && (node.namedImports.length === namedImports.length && node.namedImports.every((v, i) => v === namedImports[i]))) {
return node;
}
return new Shift.Import({ defaultBinding, namedImports, moduleSpecifier: node.moduleSpecifier });
}
reduceImportNamespace(node, { defaultBinding, namespaceBinding }) {
if (node.defaultBinding === defaultBinding && node.namespaceBinding === namespaceBinding) {
return node;
}
return new Shift.ImportNamespace({ defaultBinding, namespaceBinding, moduleSpecifier: node.moduleSpecifier });
}
reduceImportSpecifier(node, { binding }) {
if (node.binding === binding) {
return node;
}
return new Shift.ImportSpecifier({ name: node.name, binding });
}
reduceLabeledStatement(node, { body }) {
if (node.body === body) {
return node;
}
return new Shift.LabeledStatement({ label: node.label, body });
}
reduceLiteralBooleanExpression(node) {
return node;
}
reduceLiteralInfinityExpression(node) {
return node;
}
reduceLiteralNullExpression(node) {
return node;
}
reduceLiteralNumericExpression(node) {
return node;
}
reduceLiteralRegExpExpression(node) {
return node;
}
reduceLiteralStringExpression(node) {
return node;
}
reduceMethod(node, { name, params, body }) {
if (node.name === name && node.params === params && node.body === body) {
return node;
}
return new Shift.Method({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body });
}
reduceModule(node, { directives, items }) {
if ((node.directives.length === directives.length && node.directives.every((v, i) => v === directives[i])) && (node.items.length === items.length && node.items.every((v, i) => v === items[i]))) {
return node;
}
return new Shift.Module({ directives, items });
}
reduceNewExpression(node, { callee, arguments: _arguments }) {
if (node.callee === callee && (node.arguments.length === _arguments.length && node.arguments.every((v, i) => v === _arguments[i]))) {
return node;
}
return new Shift.NewExpression({ callee, arguments: _arguments });
}
reduceNewTargetExpression(node) {
return node;
}
reduceObjectAssignmentTarget(node, { properties, rest }) {
if ((node.properties.length === properties.length && node.properties.every((v, i) => v === properties[i])) && node.rest === rest) {
return node;
}
return new Shift.ObjectAssignmentTarget({ properties, rest });
}
reduceObjectBinding(node, { properties, rest }) {
if ((node.properties.length === properties.length && node.properties.every((v, i) => v === properties[i])) && node.rest === rest) {
return node;
}
return new Shift.ObjectBinding({ properties, rest });
}
reduceObjectExpression(node, { properties }) {
if ((node.properties.length === properties.length && node.properties.every((v, i) => v === properties[i]))) {
return node;
}
return new Shift.ObjectExpression({ properties });
}
reduceReturnStatement(node, { expression }) {
if (node.expression === expression) {
return node;
}
return new Shift.ReturnStatement({ expression });
}
reduceScript(node, { directives, statements }) {
if ((node.directives.length === directives.length && node.directives.every((v, i) => v === directives[i])) && (node.statements.length === statements.length && node.statements.every((v, i) => v === statements[i]))) {
return node;
}
return new Shift.Script({ directives, statements });
}
reduceSetter(node, { name, param, body }) {
if (node.name === name && node.param === param && node.body === body) {
return node;
}
return new Shift.Setter({ name, param, body });
}
reduceShorthandProperty(node, { name }) {
if (node.name === name) {
return node;
}
return new Shift.ShorthandProperty({ name });
}
reduceSpreadElement(node, { expression }) {
if (node.expression === expression) {
return node;
}
return new Shift.SpreadElement({ expression });
}
reduceSpreadProperty(node, { expression }) {
if (node.expression === expression) {
return node;
}
return new Shift.SpreadProperty({ expression });
}
reduceStaticMemberAssignmentTarget(node, { object }) {
if (node.object === object) {
return node;
}
return new Shift.StaticMemberAssignmentTarget({ object, property: node.property });
}
reduceStaticMemberExpression(node, { object }) {
if (node.object === object) {
return node;
}
return new Shift.StaticMemberExpression({ object, property: node.property });
}
reduceStaticPropertyName(node) {
return node;
}
reduceSuper(node) {
return node;
}
reduceSwitchCase(node, { test, consequent }) {
if (node.test === test && (node.consequent.length === consequent.length && node.consequent.every((v, i) => v === consequent[i]))) {
return node;
}
return new Shift.SwitchCase({ test, consequent });
}
reduceSwitchDefault(node, { consequent }) {
if ((node.consequent.length === consequent.length && node.consequent.every((v, i) => v === consequent[i]))) {
return node;
}
return new Shift.SwitchDefault({ consequent });
}
reduceSwitchStatement(node, { discriminant, cases }) {
if (node.discriminant === discriminant && (node.cases.length === cases.length && node.cases.every((v, i) => v === cases[i]))) {
return node;
}
return new Shift.SwitchStatement({ discriminant, cases });
}
reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) {
if (node.discriminant === discriminant && (node.preDefaultCases.length === preDefaultCases.length && node.preDefaultCases.every((v, i) => v === preDefaultCases[i])) && node.defaultCase === defaultCase && (node.postDefaultCases.length === postDefaultCases.length && node.postDefaultCases.every((v, i) => v === postDefaultCases[i]))) {
return node;
}
return new Shift.SwitchStatementWithDefault({ discriminant, preDefaultCases, defaultCase, postDefaultCases });
}
reduceTemplateElement(node) {
return node;
}
reduceTemplateExpression(node, { tag, elements }) {
if (node.tag === tag && (node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i]))) {
return node;
}
return new Shift.TemplateExpression({ tag, elements });
}
reduceThisExpression(node) {
return node;
}
reduceThrowStatement(node, { expression }) {
if (node.expression === expression) {
return node;
}
return new Shift.ThrowStatement({ expression });
}
reduceTryCatchStatement(node, { body, catchClause }) {
if (node.body === body && node.catchClause === catchClause) {
return node;
}
return new Shift.TryCatchStatement({ body, catchClause });
}
reduceTryFinallyStatement(node, { body, catchClause, finalizer }) {
if (node.body === body && node.catchClause === catchClause && node.finalizer === finalizer) {
return node;
}
return new Shift.TryFinallyStatement({ body, catchClause, finalizer });
}
reduceUnaryExpression(node, { operand }) {
if (node.operand === operand) {
return node;
}
return new Shift.UnaryExpression({ operator: node.operator, operand });
}
reduceUpdateExpression(node, { operand }) {
if (node.operand === operand) {
return node;
}
return new Shift.UpdateExpression({ isPrefix: node.isPrefix, operator: node.operator, operand });
}
reduceVariableDeclaration(node, { declarators }) {
if ((node.declarators.length === declarators.length && node.declarators.every((v, i) => v === declarators[i]))) {
return node;
}
return new Shift.VariableDeclaration({ kind: node.kind, declarators });
}
reduceVariableDeclarationStatement(node, { declaration }) {
if (node.declaration === declaration) {
return node;
}
return new Shift.VariableDeclarationStatement({ declaration });
}
reduceVariableDeclarator(node, { binding, init }) {
if (node.binding === binding && node.init === init) {
return node;
}
return new Shift.VariableDeclarator({ binding, init });
}
reduceWhileStatement(node, { test, body }) {
if (node.test === test && node.body === body) {
return node;
}
return new Shift.WhileStatement({ test, body });
}
reduceWithStatement(node, { object, body }) {
if (node.object === object && node.body === body) {
return node;
}
return new Shift.WithStatement({ object, body });
}
reduceYieldExpression(node, { expression }) {
if (node.expression === expression) {
return node;
}
return new Shift.YieldExpression({ expression });
}
reduceYieldGeneratorExpression(node, { expression }) {
if (node.expression === expression) {
return node;
}
return new Shift.YieldGeneratorExpression({ expression });
}
}

View file

@ -0,0 +1,914 @@
// Generated by generate-memoize.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.
*/
import * as Shift from 'shift-ast';
export default function memoize(reducer) {
const cache = new WeakMap;
return {
reduceArrayAssignmentTarget(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceArrayAssignmentTarget(node, arg);
cache.set(node, res);
return res;
},
reduceArrayBinding(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceArrayBinding(node, arg);
cache.set(node, res);
return res;
},
reduceArrayExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceArrayExpression(node, arg);
cache.set(node, res);
return res;
},
reduceArrowExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceArrowExpression(node, arg);
cache.set(node, res);
return res;
},
reduceAssignmentExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceAssignmentExpression(node, arg);
cache.set(node, res);
return res;
},
reduceAssignmentTargetIdentifier(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceAssignmentTargetIdentifier(node);
cache.set(node, res);
return res;
},
reduceAssignmentTargetPropertyIdentifier(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceAssignmentTargetPropertyIdentifier(node, arg);
cache.set(node, res);
return res;
},
reduceAssignmentTargetPropertyProperty(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceAssignmentTargetPropertyProperty(node, arg);
cache.set(node, res);
return res;
},
reduceAssignmentTargetWithDefault(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceAssignmentTargetWithDefault(node, arg);
cache.set(node, res);
return res;
},
reduceAwaitExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceAwaitExpression(node, arg);
cache.set(node, res);
return res;
},
reduceBinaryExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceBinaryExpression(node, arg);
cache.set(node, res);
return res;
},
reduceBindingIdentifier(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceBindingIdentifier(node);
cache.set(node, res);
return res;
},
reduceBindingPropertyIdentifier(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceBindingPropertyIdentifier(node, arg);
cache.set(node, res);
return res;
},
reduceBindingPropertyProperty(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceBindingPropertyProperty(node, arg);
cache.set(node, res);
return res;
},
reduceBindingWithDefault(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceBindingWithDefault(node, arg);
cache.set(node, res);
return res;
},
reduceBlock(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceBlock(node, arg);
cache.set(node, res);
return res;
},
reduceBlockStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceBlockStatement(node, arg);
cache.set(node, res);
return res;
},
reduceBreakStatement(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceBreakStatement(node);
cache.set(node, res);
return res;
},
reduceCallExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceCallExpression(node, arg);
cache.set(node, res);
return res;
},
reduceCatchClause(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceCatchClause(node, arg);
cache.set(node, res);
return res;
},
reduceClassDeclaration(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceClassDeclaration(node, arg);
cache.set(node, res);
return res;
},
reduceClassElement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceClassElement(node, arg);
cache.set(node, res);
return res;
},
reduceClassExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceClassExpression(node, arg);
cache.set(node, res);
return res;
},
reduceCompoundAssignmentExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceCompoundAssignmentExpression(node, arg);
cache.set(node, res);
return res;
},
reduceComputedMemberAssignmentTarget(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceComputedMemberAssignmentTarget(node, arg);
cache.set(node, res);
return res;
},
reduceComputedMemberExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceComputedMemberExpression(node, arg);
cache.set(node, res);
return res;
},
reduceComputedPropertyName(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceComputedPropertyName(node, arg);
cache.set(node, res);
return res;
},
reduceConditionalExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceConditionalExpression(node, arg);
cache.set(node, res);
return res;
},
reduceContinueStatement(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceContinueStatement(node);
cache.set(node, res);
return res;
},
reduceDataProperty(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceDataProperty(node, arg);
cache.set(node, res);
return res;
},
reduceDebuggerStatement(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceDebuggerStatement(node);
cache.set(node, res);
return res;
},
reduceDirective(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceDirective(node);
cache.set(node, res);
return res;
},
reduceDoWhileStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceDoWhileStatement(node, arg);
cache.set(node, res);
return res;
},
reduceEmptyStatement(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceEmptyStatement(node);
cache.set(node, res);
return res;
},
reduceExport(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceExport(node, arg);
cache.set(node, res);
return res;
},
reduceExportAllFrom(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceExportAllFrom(node);
cache.set(node, res);
return res;
},
reduceExportDefault(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceExportDefault(node, arg);
cache.set(node, res);
return res;
},
reduceExportFrom(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceExportFrom(node, arg);
cache.set(node, res);
return res;
},
reduceExportFromSpecifier(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceExportFromSpecifier(node);
cache.set(node, res);
return res;
},
reduceExportLocalSpecifier(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceExportLocalSpecifier(node, arg);
cache.set(node, res);
return res;
},
reduceExportLocals(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceExportLocals(node, arg);
cache.set(node, res);
return res;
},
reduceExpressionStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceExpressionStatement(node, arg);
cache.set(node, res);
return res;
},
reduceForAwaitStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceForAwaitStatement(node, arg);
cache.set(node, res);
return res;
},
reduceForInStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceForInStatement(node, arg);
cache.set(node, res);
return res;
},
reduceForOfStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceForOfStatement(node, arg);
cache.set(node, res);
return res;
},
reduceForStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceForStatement(node, arg);
cache.set(node, res);
return res;
},
reduceFormalParameters(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceFormalParameters(node, arg);
cache.set(node, res);
return res;
},
reduceFunctionBody(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceFunctionBody(node, arg);
cache.set(node, res);
return res;
},
reduceFunctionDeclaration(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceFunctionDeclaration(node, arg);
cache.set(node, res);
return res;
},
reduceFunctionExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceFunctionExpression(node, arg);
cache.set(node, res);
return res;
},
reduceGetter(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceGetter(node, arg);
cache.set(node, res);
return res;
},
reduceIdentifierExpression(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceIdentifierExpression(node);
cache.set(node, res);
return res;
},
reduceIfStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceIfStatement(node, arg);
cache.set(node, res);
return res;
},
reduceImport(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceImport(node, arg);
cache.set(node, res);
return res;
},
reduceImportNamespace(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceImportNamespace(node, arg);
cache.set(node, res);
return res;
},
reduceImportSpecifier(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceImportSpecifier(node, arg);
cache.set(node, res);
return res;
},
reduceLabeledStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceLabeledStatement(node, arg);
cache.set(node, res);
return res;
},
reduceLiteralBooleanExpression(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceLiteralBooleanExpression(node);
cache.set(node, res);
return res;
},
reduceLiteralInfinityExpression(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceLiteralInfinityExpression(node);
cache.set(node, res);
return res;
},
reduceLiteralNullExpression(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceLiteralNullExpression(node);
cache.set(node, res);
return res;
},
reduceLiteralNumericExpression(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceLiteralNumericExpression(node);
cache.set(node, res);
return res;
},
reduceLiteralRegExpExpression(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceLiteralRegExpExpression(node);
cache.set(node, res);
return res;
},
reduceLiteralStringExpression(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceLiteralStringExpression(node);
cache.set(node, res);
return res;
},
reduceMethod(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceMethod(node, arg);
cache.set(node, res);
return res;
},
reduceModule(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceModule(node, arg);
cache.set(node, res);
return res;
},
reduceNewExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceNewExpression(node, arg);
cache.set(node, res);
return res;
},
reduceNewTargetExpression(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceNewTargetExpression(node);
cache.set(node, res);
return res;
},
reduceObjectAssignmentTarget(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceObjectAssignmentTarget(node, arg);
cache.set(node, res);
return res;
},
reduceObjectBinding(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceObjectBinding(node, arg);
cache.set(node, res);
return res;
},
reduceObjectExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceObjectExpression(node, arg);
cache.set(node, res);
return res;
},
reduceReturnStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceReturnStatement(node, arg);
cache.set(node, res);
return res;
},
reduceScript(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceScript(node, arg);
cache.set(node, res);
return res;
},
reduceSetter(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceSetter(node, arg);
cache.set(node, res);
return res;
},
reduceShorthandProperty(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceShorthandProperty(node, arg);
cache.set(node, res);
return res;
},
reduceSpreadElement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceSpreadElement(node, arg);
cache.set(node, res);
return res;
},
reduceSpreadProperty(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceSpreadProperty(node, arg);
cache.set(node, res);
return res;
},
reduceStaticMemberAssignmentTarget(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceStaticMemberAssignmentTarget(node, arg);
cache.set(node, res);
return res;
},
reduceStaticMemberExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceStaticMemberExpression(node, arg);
cache.set(node, res);
return res;
},
reduceStaticPropertyName(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceStaticPropertyName(node);
cache.set(node, res);
return res;
},
reduceSuper(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceSuper(node);
cache.set(node, res);
return res;
},
reduceSwitchCase(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceSwitchCase(node, arg);
cache.set(node, res);
return res;
},
reduceSwitchDefault(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceSwitchDefault(node, arg);
cache.set(node, res);
return res;
},
reduceSwitchStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceSwitchStatement(node, arg);
cache.set(node, res);
return res;
},
reduceSwitchStatementWithDefault(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceSwitchStatementWithDefault(node, arg);
cache.set(node, res);
return res;
},
reduceTemplateElement(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceTemplateElement(node);
cache.set(node, res);
return res;
},
reduceTemplateExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceTemplateExpression(node, arg);
cache.set(node, res);
return res;
},
reduceThisExpression(node) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceThisExpression(node);
cache.set(node, res);
return res;
},
reduceThrowStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceThrowStatement(node, arg);
cache.set(node, res);
return res;
},
reduceTryCatchStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceTryCatchStatement(node, arg);
cache.set(node, res);
return res;
},
reduceTryFinallyStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceTryFinallyStatement(node, arg);
cache.set(node, res);
return res;
},
reduceUnaryExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceUnaryExpression(node, arg);
cache.set(node, res);
return res;
},
reduceUpdateExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceUpdateExpression(node, arg);
cache.set(node, res);
return res;
},
reduceVariableDeclaration(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceVariableDeclaration(node, arg);
cache.set(node, res);
return res;
},
reduceVariableDeclarationStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceVariableDeclarationStatement(node, arg);
cache.set(node, res);
return res;
},
reduceVariableDeclarator(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceVariableDeclarator(node, arg);
cache.set(node, res);
return res;
},
reduceWhileStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceWhileStatement(node, arg);
cache.set(node, res);
return res;
},
reduceWithStatement(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceWithStatement(node, arg);
cache.set(node, res);
return res;
},
reduceYieldExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceYieldExpression(node, arg);
cache.set(node, res);
return res;
},
reduceYieldGeneratorExpression(node, arg) {
if (cache.has(node)) {
return cache.get(node);
}
const res = reducer.reduceYieldGeneratorExpression(node, arg);
cache.set(node, res);
return res;
},
};
}

View file

@ -0,0 +1,430 @@
// Generated by generate-monoidal-reducer.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.
*/
import Shift from 'shift-ast';
export default class MonoidalReducer {
constructor(monoid) {
let identity = monoid.empty();
this.identity = identity;
let concat;
if (monoid.prototype && typeof monoid.prototype.concat === 'function') {
concat = Function.prototype.call.bind(monoid.prototype.concat);
} else if (typeof monoid.concat === 'function') {
concat = monoid.concat;
} else {
throw new TypeError('Monoid must provide a `concat` method');
}
this.append = (...args) => args.reduce(concat, identity);
}
reduceArrayAssignmentTarget(node, { elements, rest }) {
return this.append(...elements.filter(n => n != null), rest == null ? this.identity : rest);
}
reduceArrayBinding(node, { elements, rest }) {
return this.append(...elements.filter(n => n != null), rest == null ? this.identity : rest);
}
reduceArrayExpression(node, { elements }) {
return this.append(...elements.filter(n => n != null));
}
reduceArrowExpression(node, { params, body }) {
return this.append(params, body);
}
reduceAssignmentExpression(node, { binding, expression }) {
return this.append(binding, expression);
}
reduceAssignmentTargetIdentifier(node) {
return this.identity;
}
reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) {
return this.append(binding, init == null ? this.identity : init);
}
reduceAssignmentTargetPropertyProperty(node, { name, binding }) {
return this.append(name, binding);
}
reduceAssignmentTargetWithDefault(node, { binding, init }) {
return this.append(binding, init);
}
reduceAwaitExpression(node, { expression }) {
return expression;
}
reduceBinaryExpression(node, { left, right }) {
return this.append(left, right);
}
reduceBindingIdentifier(node) {
return this.identity;
}
reduceBindingPropertyIdentifier(node, { binding, init }) {
return this.append(binding, init == null ? this.identity : init);
}
reduceBindingPropertyProperty(node, { name, binding }) {
return this.append(name, binding);
}
reduceBindingWithDefault(node, { binding, init }) {
return this.append(binding, init);
}
reduceBlock(node, { statements }) {
return this.append(...statements);
}
reduceBlockStatement(node, { block }) {
return block;
}
reduceBreakStatement(node) {
return this.identity;
}
reduceCallExpression(node, { callee, arguments: _arguments }) {
return this.append(callee, ..._arguments);
}
reduceCatchClause(node, { binding, body }) {
return this.append(binding, body);
}
reduceClassDeclaration(node, { name, super: _super, elements }) {
return this.append(name, _super == null ? this.identity : _super, ...elements);
}
reduceClassElement(node, { method }) {
return method;
}
reduceClassExpression(node, { name, super: _super, elements }) {
return this.append(name == null ? this.identity : name, _super == null ? this.identity : _super, ...elements);
}
reduceCompoundAssignmentExpression(node, { binding, expression }) {
return this.append(binding, expression);
}
reduceComputedMemberAssignmentTarget(node, { object, expression }) {
return this.append(object, expression);
}
reduceComputedMemberExpression(node, { object, expression }) {
return this.append(object, expression);
}
reduceComputedPropertyName(node, { expression }) {
return expression;
}
reduceConditionalExpression(node, { test, consequent, alternate }) {
return this.append(test, consequent, alternate);
}
reduceContinueStatement(node) {
return this.identity;
}
reduceDataProperty(node, { name, expression }) {
return this.append(name, expression);
}
reduceDebuggerStatement(node) {
return this.identity;
}
reduceDirective(node) {
return this.identity;
}
reduceDoWhileStatement(node, { body, test }) {
return this.append(body, test);
}
reduceEmptyStatement(node) {
return this.identity;
}
reduceExport(node, { declaration }) {
return declaration;
}
reduceExportAllFrom(node) {
return this.identity;
}
reduceExportDefault(node, { body }) {
return body;
}
reduceExportFrom(node, { namedExports }) {
return this.append(...namedExports);
}
reduceExportFromSpecifier(node) {
return this.identity;
}
reduceExportLocalSpecifier(node, { name }) {
return name;
}
reduceExportLocals(node, { namedExports }) {
return this.append(...namedExports);
}
reduceExpressionStatement(node, { expression }) {
return expression;
}
reduceForAwaitStatement(node, { left, right, body }) {
return this.append(left, right, body);
}
reduceForInStatement(node, { left, right, body }) {
return this.append(left, right, body);
}
reduceForOfStatement(node, { left, right, body }) {
return this.append(left, right, body);
}
reduceForStatement(node, { init, test, update, body }) {
return this.append(init == null ? this.identity : init, test == null ? this.identity : test, update == null ? this.identity : update, body);
}
reduceFormalParameters(node, { items, rest }) {
return this.append(...items, rest == null ? this.identity : rest);
}
reduceFunctionBody(node, { directives, statements }) {
return this.append(...directives, ...statements);
}
reduceFunctionDeclaration(node, { name, params, body }) {
return this.append(name, params, body);
}
reduceFunctionExpression(node, { name, params, body }) {
return this.append(name == null ? this.identity : name, params, body);
}
reduceGetter(node, { name, body }) {
return this.append(name, body);
}
reduceIdentifierExpression(node) {
return this.identity;
}
reduceIfStatement(node, { test, consequent, alternate }) {
return this.append(test, consequent, alternate == null ? this.identity : alternate);
}
reduceImport(node, { defaultBinding, namedImports }) {
return this.append(defaultBinding == null ? this.identity : defaultBinding, ...namedImports);
}
reduceImportNamespace(node, { defaultBinding, namespaceBinding }) {
return this.append(defaultBinding == null ? this.identity : defaultBinding, namespaceBinding);
}
reduceImportSpecifier(node, { binding }) {
return binding;
}
reduceLabeledStatement(node, { body }) {
return body;
}
reduceLiteralBooleanExpression(node) {
return this.identity;
}
reduceLiteralInfinityExpression(node) {
return this.identity;
}
reduceLiteralNullExpression(node) {
return this.identity;
}
reduceLiteralNumericExpression(node) {
return this.identity;
}
reduceLiteralRegExpExpression(node) {
return this.identity;
}
reduceLiteralStringExpression(node) {
return this.identity;
}
reduceMethod(node, { name, params, body }) {
return this.append(name, params, body);
}
reduceModule(node, { directives, items }) {
return this.append(...directives, ...items);
}
reduceNewExpression(node, { callee, arguments: _arguments }) {
return this.append(callee, ..._arguments);
}
reduceNewTargetExpression(node) {
return this.identity;
}
reduceObjectAssignmentTarget(node, { properties, rest }) {
return this.append(...properties, rest == null ? this.identity : rest);
}
reduceObjectBinding(node, { properties, rest }) {
return this.append(...properties, rest == null ? this.identity : rest);
}
reduceObjectExpression(node, { properties }) {
return this.append(...properties);
}
reduceReturnStatement(node, { expression }) {
return expression == null ? this.identity : expression;
}
reduceScript(node, { directives, statements }) {
return this.append(...directives, ...statements);
}
reduceSetter(node, { name, param, body }) {
return this.append(name, param, body);
}
reduceShorthandProperty(node, { name }) {
return name;
}
reduceSpreadElement(node, { expression }) {
return expression;
}
reduceSpreadProperty(node, { expression }) {
return expression;
}
reduceStaticMemberAssignmentTarget(node, { object }) {
return object;
}
reduceStaticMemberExpression(node, { object }) {
return object;
}
reduceStaticPropertyName(node) {
return this.identity;
}
reduceSuper(node) {
return this.identity;
}
reduceSwitchCase(node, { test, consequent }) {
return this.append(test, ...consequent);
}
reduceSwitchDefault(node, { consequent }) {
return this.append(...consequent);
}
reduceSwitchStatement(node, { discriminant, cases }) {
return this.append(discriminant, ...cases);
}
reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) {
return this.append(discriminant, ...preDefaultCases, defaultCase, ...postDefaultCases);
}
reduceTemplateElement(node) {
return this.identity;
}
reduceTemplateExpression(node, { tag, elements }) {
return this.append(tag == null ? this.identity : tag, ...elements);
}
reduceThisExpression(node) {
return this.identity;
}
reduceThrowStatement(node, { expression }) {
return expression;
}
reduceTryCatchStatement(node, { body, catchClause }) {
return this.append(body, catchClause);
}
reduceTryFinallyStatement(node, { body, catchClause, finalizer }) {
return this.append(body, catchClause == null ? this.identity : catchClause, finalizer);
}
reduceUnaryExpression(node, { operand }) {
return operand;
}
reduceUpdateExpression(node, { operand }) {
return operand;
}
reduceVariableDeclaration(node, { declarators }) {
return this.append(...declarators);
}
reduceVariableDeclarationStatement(node, { declaration }) {
return declaration;
}
reduceVariableDeclarator(node, { binding, init }) {
return this.append(binding, init == null ? this.identity : init);
}
reduceWhileStatement(node, { test, body }) {
return this.append(test, body);
}
reduceWithStatement(node, { object, body }) {
return this.append(object, body);
}
reduceYieldExpression(node, { expression }) {
return expression == null ? this.identity : expression;
}
reduceYieldGeneratorExpression(node, { expression }) {
return expression;
}
}

View file

@ -0,0 +1,91 @@
/*
* 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.
*/
'use strict';
import MonoidalReducer from './monoidal-reducer.js';
import ThunkedMonoidalReducer from './thunked-monoidal-reducer.js';
const PlusMonoid = {
empty: () => 0,
concat: (a, b) => a + b,
};
const ConcatMonoid = {
empty: () => [],
concat: (a, b) => a.concat(b),
};
const AndMonoid = {
empty: () => true,
concat: (a, b) => a && b,
concatThunk: (a, b) => a && b(),
};
const OrMonoid = {
empty: () => false,
concat: (a, b) => a || b,
concatThunk: (a, b) => a || b(),
};
export class PlusReducer extends MonoidalReducer {
constructor() {
super(PlusMonoid);
}
}
export class ThunkedPlusReducer extends ThunkedMonoidalReducer {
constructor() {
super(PlusMonoid);
}
}
export class ConcatReducer extends MonoidalReducer {
constructor() {
super(ConcatMonoid);
}
}
export class ThunkedConcatReducer extends ThunkedMonoidalReducer {
constructor() {
super(ConcatMonoid);
}
}
export class AndReducer extends MonoidalReducer {
constructor() {
super(AndMonoid);
}
}
export class ThunkedAndReducer extends ThunkedMonoidalReducer {
constructor() {
super(AndMonoid);
}
}
export class OrReducer extends MonoidalReducer {
constructor() {
super(OrMonoid);
}
}
export class ThunkedOrReducer extends ThunkedMonoidalReducer {
constructor() {
super(OrMonoid);
}
}

View file

@ -0,0 +1,418 @@
// Generated by generate-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.
*/
const director = {
ArrayAssignmentTarget(reducer, node) {
return reducer.reduceArrayAssignmentTarget(node, { elements: node.elements.map(v => v && (() => this[v.type](reducer, v))), rest: node.rest && (() => this[node.rest.type](reducer, node.rest)) });
},
ArrayBinding(reducer, node) {
return reducer.reduceArrayBinding(node, { elements: node.elements.map(v => v && (() => this[v.type](reducer, v))), rest: node.rest && (() => this[node.rest.type](reducer, node.rest)) });
},
ArrayExpression(reducer, node) {
return reducer.reduceArrayExpression(node, { elements: node.elements.map(v => v && (() => this[v.type](reducer, v))) });
},
ArrowExpression(reducer, node) {
return reducer.reduceArrowExpression(node, { params: (() => this.FormalParameters(reducer, node.params)), body: (() => this[node.body.type](reducer, node.body)) });
},
AssignmentExpression(reducer, node) {
return reducer.reduceAssignmentExpression(node, { binding: (() => this[node.binding.type](reducer, node.binding)), expression: (() => this[node.expression.type](reducer, node.expression)) });
},
AssignmentTargetIdentifier(reducer, node) {
return reducer.reduceAssignmentTargetIdentifier(node);
},
AssignmentTargetPropertyIdentifier(reducer, node) {
return reducer.reduceAssignmentTargetPropertyIdentifier(node, { binding: (() => this.AssignmentTargetIdentifier(reducer, node.binding)), init: node.init && (() => this[node.init.type](reducer, node.init)) });
},
AssignmentTargetPropertyProperty(reducer, node) {
return reducer.reduceAssignmentTargetPropertyProperty(node, { name: (() => this[node.name.type](reducer, node.name)), binding: (() => this[node.binding.type](reducer, node.binding)) });
},
AssignmentTargetWithDefault(reducer, node) {
return reducer.reduceAssignmentTargetWithDefault(node, { binding: (() => this[node.binding.type](reducer, node.binding)), init: (() => this[node.init.type](reducer, node.init)) });
},
AwaitExpression(reducer, node) {
return reducer.reduceAwaitExpression(node, { expression: (() => this[node.expression.type](reducer, node.expression)) });
},
BinaryExpression(reducer, node) {
return reducer.reduceBinaryExpression(node, { left: (() => this[node.left.type](reducer, node.left)), right: (() => this[node.right.type](reducer, node.right)) });
},
BindingIdentifier(reducer, node) {
return reducer.reduceBindingIdentifier(node);
},
BindingPropertyIdentifier(reducer, node) {
return reducer.reduceBindingPropertyIdentifier(node, { binding: (() => this.BindingIdentifier(reducer, node.binding)), init: node.init && (() => this[node.init.type](reducer, node.init)) });
},
BindingPropertyProperty(reducer, node) {
return reducer.reduceBindingPropertyProperty(node, { name: (() => this[node.name.type](reducer, node.name)), binding: (() => this[node.binding.type](reducer, node.binding)) });
},
BindingWithDefault(reducer, node) {
return reducer.reduceBindingWithDefault(node, { binding: (() => this[node.binding.type](reducer, node.binding)), init: (() => this[node.init.type](reducer, node.init)) });
},
Block(reducer, node) {
return reducer.reduceBlock(node, { statements: node.statements.map(v => (() => this[v.type](reducer, v))) });
},
BlockStatement(reducer, node) {
return reducer.reduceBlockStatement(node, { block: (() => this.Block(reducer, node.block)) });
},
BreakStatement(reducer, node) {
return reducer.reduceBreakStatement(node);
},
CallExpression(reducer, node) {
return reducer.reduceCallExpression(node, { callee: (() => this[node.callee.type](reducer, node.callee)), arguments: node.arguments.map(v => (() => this[v.type](reducer, v))) });
},
CatchClause(reducer, node) {
return reducer.reduceCatchClause(node, { binding: (() => this[node.binding.type](reducer, node.binding)), body: (() => this.Block(reducer, node.body)) });
},
ClassDeclaration(reducer, node) {
return reducer.reduceClassDeclaration(node, { name: (() => this.BindingIdentifier(reducer, node.name)), super: node.super && (() => this[node.super.type](reducer, node.super)), elements: node.elements.map(v => (() => this.ClassElement(reducer, v))) });
},
ClassElement(reducer, node) {
return reducer.reduceClassElement(node, { method: (() => this[node.method.type](reducer, node.method)) });
},
ClassExpression(reducer, node) {
return reducer.reduceClassExpression(node, { name: node.name && (() => this.BindingIdentifier(reducer, node.name)), super: node.super && (() => this[node.super.type](reducer, node.super)), elements: node.elements.map(v => (() => this.ClassElement(reducer, v))) });
},
CompoundAssignmentExpression(reducer, node) {
return reducer.reduceCompoundAssignmentExpression(node, { binding: (() => this[node.binding.type](reducer, node.binding)), expression: (() => this[node.expression.type](reducer, node.expression)) });
},
ComputedMemberAssignmentTarget(reducer, node) {
return reducer.reduceComputedMemberAssignmentTarget(node, { object: (() => this[node.object.type](reducer, node.object)), expression: (() => this[node.expression.type](reducer, node.expression)) });
},
ComputedMemberExpression(reducer, node) {
return reducer.reduceComputedMemberExpression(node, { object: (() => this[node.object.type](reducer, node.object)), expression: (() => this[node.expression.type](reducer, node.expression)) });
},
ComputedPropertyName(reducer, node) {
return reducer.reduceComputedPropertyName(node, { expression: (() => this[node.expression.type](reducer, node.expression)) });
},
ConditionalExpression(reducer, node) {
return reducer.reduceConditionalExpression(node, { test: (() => this[node.test.type](reducer, node.test)), consequent: (() => this[node.consequent.type](reducer, node.consequent)), alternate: (() => this[node.alternate.type](reducer, node.alternate)) });
},
ContinueStatement(reducer, node) {
return reducer.reduceContinueStatement(node);
},
DataProperty(reducer, node) {
return reducer.reduceDataProperty(node, { name: (() => this[node.name.type](reducer, node.name)), expression: (() => this[node.expression.type](reducer, node.expression)) });
},
DebuggerStatement(reducer, node) {
return reducer.reduceDebuggerStatement(node);
},
Directive(reducer, node) {
return reducer.reduceDirective(node);
},
DoWhileStatement(reducer, node) {
return reducer.reduceDoWhileStatement(node, { body: (() => this[node.body.type](reducer, node.body)), test: (() => this[node.test.type](reducer, node.test)) });
},
EmptyStatement(reducer, node) {
return reducer.reduceEmptyStatement(node);
},
Export(reducer, node) {
return reducer.reduceExport(node, { declaration: (() => this[node.declaration.type](reducer, node.declaration)) });
},
ExportAllFrom(reducer, node) {
return reducer.reduceExportAllFrom(node);
},
ExportDefault(reducer, node) {
return reducer.reduceExportDefault(node, { body: (() => this[node.body.type](reducer, node.body)) });
},
ExportFrom(reducer, node) {
return reducer.reduceExportFrom(node, { namedExports: node.namedExports.map(v => (() => this.ExportFromSpecifier(reducer, v))) });
},
ExportFromSpecifier(reducer, node) {
return reducer.reduceExportFromSpecifier(node);
},
ExportLocalSpecifier(reducer, node) {
return reducer.reduceExportLocalSpecifier(node, { name: (() => this.IdentifierExpression(reducer, node.name)) });
},
ExportLocals(reducer, node) {
return reducer.reduceExportLocals(node, { namedExports: node.namedExports.map(v => (() => this.ExportLocalSpecifier(reducer, v))) });
},
ExpressionStatement(reducer, node) {
return reducer.reduceExpressionStatement(node, { expression: (() => this[node.expression.type](reducer, node.expression)) });
},
ForAwaitStatement(reducer, node) {
return reducer.reduceForAwaitStatement(node, { left: (() => this[node.left.type](reducer, node.left)), right: (() => this[node.right.type](reducer, node.right)), body: (() => this[node.body.type](reducer, node.body)) });
},
ForInStatement(reducer, node) {
return reducer.reduceForInStatement(node, { left: (() => this[node.left.type](reducer, node.left)), right: (() => this[node.right.type](reducer, node.right)), body: (() => this[node.body.type](reducer, node.body)) });
},
ForOfStatement(reducer, node) {
return reducer.reduceForOfStatement(node, { left: (() => this[node.left.type](reducer, node.left)), right: (() => this[node.right.type](reducer, node.right)), body: (() => this[node.body.type](reducer, node.body)) });
},
ForStatement(reducer, node) {
return reducer.reduceForStatement(node, { init: node.init && (() => this[node.init.type](reducer, node.init)), test: node.test && (() => this[node.test.type](reducer, node.test)), update: node.update && (() => this[node.update.type](reducer, node.update)), body: (() => this[node.body.type](reducer, node.body)) });
},
FormalParameters(reducer, node) {
return reducer.reduceFormalParameters(node, { items: node.items.map(v => (() => this[v.type](reducer, v))), rest: node.rest && (() => this[node.rest.type](reducer, node.rest)) });
},
FunctionBody(reducer, node) {
return reducer.reduceFunctionBody(node, { directives: node.directives.map(v => (() => this.Directive(reducer, v))), statements: node.statements.map(v => (() => this[v.type](reducer, v))) });
},
FunctionDeclaration(reducer, node) {
return reducer.reduceFunctionDeclaration(node, { name: (() => this.BindingIdentifier(reducer, node.name)), params: (() => this.FormalParameters(reducer, node.params)), body: (() => this.FunctionBody(reducer, node.body)) });
},
FunctionExpression(reducer, node) {
return reducer.reduceFunctionExpression(node, { name: node.name && (() => this.BindingIdentifier(reducer, node.name)), params: (() => this.FormalParameters(reducer, node.params)), body: (() => this.FunctionBody(reducer, node.body)) });
},
Getter(reducer, node) {
return reducer.reduceGetter(node, { name: (() => this[node.name.type](reducer, node.name)), body: (() => this.FunctionBody(reducer, node.body)) });
},
IdentifierExpression(reducer, node) {
return reducer.reduceIdentifierExpression(node);
},
IfStatement(reducer, node) {
return reducer.reduceIfStatement(node, { test: (() => this[node.test.type](reducer, node.test)), consequent: (() => this[node.consequent.type](reducer, node.consequent)), alternate: node.alternate && (() => this[node.alternate.type](reducer, node.alternate)) });
},
Import(reducer, node) {
return reducer.reduceImport(node, { defaultBinding: node.defaultBinding && (() => this.BindingIdentifier(reducer, node.defaultBinding)), namedImports: node.namedImports.map(v => (() => this.ImportSpecifier(reducer, v))) });
},
ImportNamespace(reducer, node) {
return reducer.reduceImportNamespace(node, { defaultBinding: node.defaultBinding && (() => this.BindingIdentifier(reducer, node.defaultBinding)), namespaceBinding: (() => this.BindingIdentifier(reducer, node.namespaceBinding)) });
},
ImportSpecifier(reducer, node) {
return reducer.reduceImportSpecifier(node, { binding: (() => this.BindingIdentifier(reducer, node.binding)) });
},
LabeledStatement(reducer, node) {
return reducer.reduceLabeledStatement(node, { body: (() => this[node.body.type](reducer, node.body)) });
},
LiteralBooleanExpression(reducer, node) {
return reducer.reduceLiteralBooleanExpression(node);
},
LiteralInfinityExpression(reducer, node) {
return reducer.reduceLiteralInfinityExpression(node);
},
LiteralNullExpression(reducer, node) {
return reducer.reduceLiteralNullExpression(node);
},
LiteralNumericExpression(reducer, node) {
return reducer.reduceLiteralNumericExpression(node);
},
LiteralRegExpExpression(reducer, node) {
return reducer.reduceLiteralRegExpExpression(node);
},
LiteralStringExpression(reducer, node) {
return reducer.reduceLiteralStringExpression(node);
},
Method(reducer, node) {
return reducer.reduceMethod(node, { name: (() => this[node.name.type](reducer, node.name)), params: (() => this.FormalParameters(reducer, node.params)), body: (() => this.FunctionBody(reducer, node.body)) });
},
Module(reducer, node) {
return reducer.reduceModule(node, { directives: node.directives.map(v => (() => this.Directive(reducer, v))), items: node.items.map(v => (() => this[v.type](reducer, v))) });
},
NewExpression(reducer, node) {
return reducer.reduceNewExpression(node, { callee: (() => this[node.callee.type](reducer, node.callee)), arguments: node.arguments.map(v => (() => this[v.type](reducer, v))) });
},
NewTargetExpression(reducer, node) {
return reducer.reduceNewTargetExpression(node);
},
ObjectAssignmentTarget(reducer, node) {
return reducer.reduceObjectAssignmentTarget(node, { properties: node.properties.map(v => (() => this[v.type](reducer, v))), rest: node.rest && (() => this[node.rest.type](reducer, node.rest)) });
},
ObjectBinding(reducer, node) {
return reducer.reduceObjectBinding(node, { properties: node.properties.map(v => (() => this[v.type](reducer, v))), rest: node.rest && (() => this[node.rest.type](reducer, node.rest)) });
},
ObjectExpression(reducer, node) {
return reducer.reduceObjectExpression(node, { properties: node.properties.map(v => (() => this[v.type](reducer, v))) });
},
ReturnStatement(reducer, node) {
return reducer.reduceReturnStatement(node, { expression: node.expression && (() => this[node.expression.type](reducer, node.expression)) });
},
Script(reducer, node) {
return reducer.reduceScript(node, { directives: node.directives.map(v => (() => this.Directive(reducer, v))), statements: node.statements.map(v => (() => this[v.type](reducer, v))) });
},
Setter(reducer, node) {
return reducer.reduceSetter(node, { name: (() => this[node.name.type](reducer, node.name)), param: (() => this[node.param.type](reducer, node.param)), body: (() => this.FunctionBody(reducer, node.body)) });
},
ShorthandProperty(reducer, node) {
return reducer.reduceShorthandProperty(node, { name: (() => this.IdentifierExpression(reducer, node.name)) });
},
SpreadElement(reducer, node) {
return reducer.reduceSpreadElement(node, { expression: (() => this[node.expression.type](reducer, node.expression)) });
},
SpreadProperty(reducer, node) {
return reducer.reduceSpreadProperty(node, { expression: (() => this[node.expression.type](reducer, node.expression)) });
},
StaticMemberAssignmentTarget(reducer, node) {
return reducer.reduceStaticMemberAssignmentTarget(node, { object: (() => this[node.object.type](reducer, node.object)) });
},
StaticMemberExpression(reducer, node) {
return reducer.reduceStaticMemberExpression(node, { object: (() => this[node.object.type](reducer, node.object)) });
},
StaticPropertyName(reducer, node) {
return reducer.reduceStaticPropertyName(node);
},
Super(reducer, node) {
return reducer.reduceSuper(node);
},
SwitchCase(reducer, node) {
return reducer.reduceSwitchCase(node, { test: (() => this[node.test.type](reducer, node.test)), consequent: node.consequent.map(v => (() => this[v.type](reducer, v))) });
},
SwitchDefault(reducer, node) {
return reducer.reduceSwitchDefault(node, { consequent: node.consequent.map(v => (() => this[v.type](reducer, v))) });
},
SwitchStatement(reducer, node) {
return reducer.reduceSwitchStatement(node, { discriminant: (() => this[node.discriminant.type](reducer, node.discriminant)), cases: node.cases.map(v => (() => this.SwitchCase(reducer, v))) });
},
SwitchStatementWithDefault(reducer, node) {
return reducer.reduceSwitchStatementWithDefault(node, { discriminant: (() => this[node.discriminant.type](reducer, node.discriminant)), preDefaultCases: node.preDefaultCases.map(v => (() => this.SwitchCase(reducer, v))), defaultCase: (() => this.SwitchDefault(reducer, node.defaultCase)), postDefaultCases: node.postDefaultCases.map(v => (() => this.SwitchCase(reducer, v))) });
},
TemplateElement(reducer, node) {
return reducer.reduceTemplateElement(node);
},
TemplateExpression(reducer, node) {
return reducer.reduceTemplateExpression(node, { tag: node.tag && (() => this[node.tag.type](reducer, node.tag)), elements: node.elements.map(v => (() => this[v.type](reducer, v))) });
},
ThisExpression(reducer, node) {
return reducer.reduceThisExpression(node);
},
ThrowStatement(reducer, node) {
return reducer.reduceThrowStatement(node, { expression: (() => this[node.expression.type](reducer, node.expression)) });
},
TryCatchStatement(reducer, node) {
return reducer.reduceTryCatchStatement(node, { body: (() => this.Block(reducer, node.body)), catchClause: (() => this.CatchClause(reducer, node.catchClause)) });
},
TryFinallyStatement(reducer, node) {
return reducer.reduceTryFinallyStatement(node, { body: (() => this.Block(reducer, node.body)), catchClause: node.catchClause && (() => this.CatchClause(reducer, node.catchClause)), finalizer: (() => this.Block(reducer, node.finalizer)) });
},
UnaryExpression(reducer, node) {
return reducer.reduceUnaryExpression(node, { operand: (() => this[node.operand.type](reducer, node.operand)) });
},
UpdateExpression(reducer, node) {
return reducer.reduceUpdateExpression(node, { operand: (() => this[node.operand.type](reducer, node.operand)) });
},
VariableDeclaration(reducer, node) {
return reducer.reduceVariableDeclaration(node, { declarators: node.declarators.map(v => (() => this.VariableDeclarator(reducer, v))) });
},
VariableDeclarationStatement(reducer, node) {
return reducer.reduceVariableDeclarationStatement(node, { declaration: (() => this.VariableDeclaration(reducer, node.declaration)) });
},
VariableDeclarator(reducer, node) {
return reducer.reduceVariableDeclarator(node, { binding: (() => this[node.binding.type](reducer, node.binding)), init: node.init && (() => this[node.init.type](reducer, node.init)) });
},
WhileStatement(reducer, node) {
return reducer.reduceWhileStatement(node, { test: (() => this[node.test.type](reducer, node.test)), body: (() => this[node.body.type](reducer, node.body)) });
},
WithStatement(reducer, node) {
return reducer.reduceWithStatement(node, { object: (() => this[node.object.type](reducer, node.object)), body: (() => this[node.body.type](reducer, node.body)) });
},
YieldExpression(reducer, node) {
return reducer.reduceYieldExpression(node, { expression: node.expression && (() => this[node.expression.type](reducer, node.expression)) });
},
YieldGeneratorExpression(reducer, node) {
return reducer.reduceYieldGeneratorExpression(node, { expression: (() => this[node.expression.type](reducer, node.expression)) });
},
};
export function thunkedReduce(reducer, node) {
return director[node.type](reducer, node);
}

View file

@ -0,0 +1,444 @@
// Generated by generate-monoidal-reducer.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.
*/
import Shift from 'shift-ast';
export default class MonoidalReducer {
constructor(monoid) {
let identity = monoid.empty();
this.identity = identity;
let concatThunk;
if (monoid.prototype && typeof monoid.prototype.concatThunk === 'function') {
concatThunk = Function.prototype.call.bind(monoid.prototype.concatThunk);
} else if (typeof monoid.concatThunk === 'function') {
concatThunk = monoid.concatThunk;
} else {
let concat;
if (monoid.prototype && typeof monoid.prototype.concat === 'function') {
concat = Function.prototype.call.bind(monoid.prototype.concat);
} else if (typeof monoid.concat === 'function') {
concat = monoid.concat;
} else {
throw new TypeError('Monoid must provide a `concatThunk` or `concat` method');
}
if (typeof monoid.isAbsorbing === 'function') {
let isAbsorbing = monoid.isAbsorbing;
concatThunk = (a, b) => isAbsorbing(a) ? a : concat(a, b());
} else {
concatThunk = (a, b) => concat(a, b());
}
}
this.append = (...args) => args.reduce(concatThunk, identity);
}
reduceArrayAssignmentTarget(node, { elements, rest }) {
return this.append(...elements.filter(n => n != null), rest == null ? () => this.identity : rest);
}
reduceArrayBinding(node, { elements, rest }) {
return this.append(...elements.filter(n => n != null), rest == null ? () => this.identity : rest);
}
reduceArrayExpression(node, { elements }) {
return this.append(...elements.filter(n => n != null));
}
reduceArrowExpression(node, { params, body }) {
return this.append(params, body);
}
reduceAssignmentExpression(node, { binding, expression }) {
return this.append(binding, expression);
}
reduceAssignmentTargetIdentifier(node) {
return this.identity;
}
reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) {
return this.append(binding, init == null ? () => this.identity : init);
}
reduceAssignmentTargetPropertyProperty(node, { name, binding }) {
return this.append(name, binding);
}
reduceAssignmentTargetWithDefault(node, { binding, init }) {
return this.append(binding, init);
}
reduceAwaitExpression(node, { expression }) {
return expression();
}
reduceBinaryExpression(node, { left, right }) {
return this.append(left, right);
}
reduceBindingIdentifier(node) {
return this.identity;
}
reduceBindingPropertyIdentifier(node, { binding, init }) {
return this.append(binding, init == null ? () => this.identity : init);
}
reduceBindingPropertyProperty(node, { name, binding }) {
return this.append(name, binding);
}
reduceBindingWithDefault(node, { binding, init }) {
return this.append(binding, init);
}
reduceBlock(node, { statements }) {
return this.append(...statements);
}
reduceBlockStatement(node, { block }) {
return block();
}
reduceBreakStatement(node) {
return this.identity;
}
reduceCallExpression(node, { callee, arguments: _arguments }) {
return this.append(callee, ..._arguments);
}
reduceCatchClause(node, { binding, body }) {
return this.append(binding, body);
}
reduceClassDeclaration(node, { name, super: _super, elements }) {
return this.append(name, _super == null ? () => this.identity : _super, ...elements);
}
reduceClassElement(node, { method }) {
return method();
}
reduceClassExpression(node, { name, super: _super, elements }) {
return this.append(name == null ? () => this.identity : name, _super == null ? () => this.identity : _super, ...elements);
}
reduceCompoundAssignmentExpression(node, { binding, expression }) {
return this.append(binding, expression);
}
reduceComputedMemberAssignmentTarget(node, { object, expression }) {
return this.append(object, expression);
}
reduceComputedMemberExpression(node, { object, expression }) {
return this.append(object, expression);
}
reduceComputedPropertyName(node, { expression }) {
return expression();
}
reduceConditionalExpression(node, { test, consequent, alternate }) {
return this.append(test, consequent, alternate);
}
reduceContinueStatement(node) {
return this.identity;
}
reduceDataProperty(node, { name, expression }) {
return this.append(name, expression);
}
reduceDebuggerStatement(node) {
return this.identity;
}
reduceDirective(node) {
return this.identity;
}
reduceDoWhileStatement(node, { body, test }) {
return this.append(body, test);
}
reduceEmptyStatement(node) {
return this.identity;
}
reduceExport(node, { declaration }) {
return declaration();
}
reduceExportAllFrom(node) {
return this.identity;
}
reduceExportDefault(node, { body }) {
return body();
}
reduceExportFrom(node, { namedExports }) {
return this.append(...namedExports);
}
reduceExportFromSpecifier(node) {
return this.identity;
}
reduceExportLocalSpecifier(node, { name }) {
return name();
}
reduceExportLocals(node, { namedExports }) {
return this.append(...namedExports);
}
reduceExpressionStatement(node, { expression }) {
return expression();
}
reduceForAwaitStatement(node, { left, right, body }) {
return this.append(left, right, body);
}
reduceForInStatement(node, { left, right, body }) {
return this.append(left, right, body);
}
reduceForOfStatement(node, { left, right, body }) {
return this.append(left, right, body);
}
reduceForStatement(node, { init, test, update, body }) {
return this.append(init == null ? () => this.identity : init, test == null ? () => this.identity : test, update == null ? () => this.identity : update, body);
}
reduceFormalParameters(node, { items, rest }) {
return this.append(...items, rest == null ? () => this.identity : rest);
}
reduceFunctionBody(node, { directives, statements }) {
return this.append(...directives, ...statements);
}
reduceFunctionDeclaration(node, { name, params, body }) {
return this.append(name, params, body);
}
reduceFunctionExpression(node, { name, params, body }) {
return this.append(name == null ? () => this.identity : name, params, body);
}
reduceGetter(node, { name, body }) {
return this.append(name, body);
}
reduceIdentifierExpression(node) {
return this.identity;
}
reduceIfStatement(node, { test, consequent, alternate }) {
return this.append(test, consequent, alternate == null ? () => this.identity : alternate);
}
reduceImport(node, { defaultBinding, namedImports }) {
return this.append(defaultBinding == null ? () => this.identity : defaultBinding, ...namedImports);
}
reduceImportNamespace(node, { defaultBinding, namespaceBinding }) {
return this.append(defaultBinding == null ? () => this.identity : defaultBinding, namespaceBinding);
}
reduceImportSpecifier(node, { binding }) {
return binding();
}
reduceLabeledStatement(node, { body }) {
return body();
}
reduceLiteralBooleanExpression(node) {
return this.identity;
}
reduceLiteralInfinityExpression(node) {
return this.identity;
}
reduceLiteralNullExpression(node) {
return this.identity;
}
reduceLiteralNumericExpression(node) {
return this.identity;
}
reduceLiteralRegExpExpression(node) {
return this.identity;
}
reduceLiteralStringExpression(node) {
return this.identity;
}
reduceMethod(node, { name, params, body }) {
return this.append(name, params, body);
}
reduceModule(node, { directives, items }) {
return this.append(...directives, ...items);
}
reduceNewExpression(node, { callee, arguments: _arguments }) {
return this.append(callee, ..._arguments);
}
reduceNewTargetExpression(node) {
return this.identity;
}
reduceObjectAssignmentTarget(node, { properties, rest }) {
return this.append(...properties, rest == null ? () => this.identity : rest);
}
reduceObjectBinding(node, { properties, rest }) {
return this.append(...properties, rest == null ? () => this.identity : rest);
}
reduceObjectExpression(node, { properties }) {
return this.append(...properties);
}
reduceReturnStatement(node, { expression }) {
return expression == null ? this.identity : expression();
}
reduceScript(node, { directives, statements }) {
return this.append(...directives, ...statements);
}
reduceSetter(node, { name, param, body }) {
return this.append(name, param, body);
}
reduceShorthandProperty(node, { name }) {
return name();
}
reduceSpreadElement(node, { expression }) {
return expression();
}
reduceSpreadProperty(node, { expression }) {
return expression();
}
reduceStaticMemberAssignmentTarget(node, { object }) {
return object();
}
reduceStaticMemberExpression(node, { object }) {
return object();
}
reduceStaticPropertyName(node) {
return this.identity;
}
reduceSuper(node) {
return this.identity;
}
reduceSwitchCase(node, { test, consequent }) {
return this.append(test, ...consequent);
}
reduceSwitchDefault(node, { consequent }) {
return this.append(...consequent);
}
reduceSwitchStatement(node, { discriminant, cases }) {
return this.append(discriminant, ...cases);
}
reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) {
return this.append(discriminant, ...preDefaultCases, defaultCase, ...postDefaultCases);
}
reduceTemplateElement(node) {
return this.identity;
}
reduceTemplateExpression(node, { tag, elements }) {
return this.append(tag == null ? () => this.identity : tag, ...elements);
}
reduceThisExpression(node) {
return this.identity;
}
reduceThrowStatement(node, { expression }) {
return expression();
}
reduceTryCatchStatement(node, { body, catchClause }) {
return this.append(body, catchClause);
}
reduceTryFinallyStatement(node, { body, catchClause, finalizer }) {
return this.append(body, catchClause == null ? () => this.identity : catchClause, finalizer);
}
reduceUnaryExpression(node, { operand }) {
return operand();
}
reduceUpdateExpression(node, { operand }) {
return operand();
}
reduceVariableDeclaration(node, { declarators }) {
return this.append(...declarators);
}
reduceVariableDeclarationStatement(node, { declaration }) {
return declaration();
}
reduceVariableDeclarator(node, { binding, init }) {
return this.append(binding, init == null ? () => this.identity : init);
}
reduceWhileStatement(node, { test, body }) {
return this.append(test, body);
}
reduceWithStatement(node, { object, body }) {
return this.append(object, body);
}
reduceYieldExpression(node, { expression }) {
return expression == null ? this.identity : expression();
}
reduceYieldGeneratorExpression(node, { expression }) {
return expression();
}
}

View file

@ -0,0 +1,416 @@
// Generated by generate-thunkify.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.
*/
export default function thunkifyClass(reducerClass) {
return class extends reducerClass {
reduceArrayAssignmentTarget(node, { elements, rest }) {
return super.reduceArrayAssignmentTarget(node, { elements: elements.map(n => n == null ? null : n()), rest: rest == null ? null : rest() });
}
reduceArrayBinding(node, { elements, rest }) {
return super.reduceArrayBinding(node, { elements: elements.map(n => n == null ? null : n()), rest: rest == null ? null : rest() });
}
reduceArrayExpression(node, { elements }) {
return super.reduceArrayExpression(node, { elements: elements.map(n => n == null ? null : n()) });
}
reduceArrowExpression(node, { params, body }) {
return super.reduceArrowExpression(node, { params: params(), body: body() });
}
reduceAssignmentExpression(node, { binding, expression }) {
return super.reduceAssignmentExpression(node, { binding: binding(), expression: expression() });
}
reduceAssignmentTargetIdentifier(node) {
return super.reduceAssignmentTargetIdentifier(node);
}
reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) {
return super.reduceAssignmentTargetPropertyIdentifier(node, { binding: binding(), init: init == null ? null : init() });
}
reduceAssignmentTargetPropertyProperty(node, { name, binding }) {
return super.reduceAssignmentTargetPropertyProperty(node, { name: name(), binding: binding() });
}
reduceAssignmentTargetWithDefault(node, { binding, init }) {
return super.reduceAssignmentTargetWithDefault(node, { binding: binding(), init: init() });
}
reduceAwaitExpression(node, { expression }) {
return super.reduceAwaitExpression(node, { expression: expression() });
}
reduceBinaryExpression(node, { left, right }) {
return super.reduceBinaryExpression(node, { left: left(), right: right() });
}
reduceBindingIdentifier(node) {
return super.reduceBindingIdentifier(node);
}
reduceBindingPropertyIdentifier(node, { binding, init }) {
return super.reduceBindingPropertyIdentifier(node, { binding: binding(), init: init == null ? null : init() });
}
reduceBindingPropertyProperty(node, { name, binding }) {
return super.reduceBindingPropertyProperty(node, { name: name(), binding: binding() });
}
reduceBindingWithDefault(node, { binding, init }) {
return super.reduceBindingWithDefault(node, { binding: binding(), init: init() });
}
reduceBlock(node, { statements }) {
return super.reduceBlock(node, { statements: statements.map(n => n()) });
}
reduceBlockStatement(node, { block }) {
return super.reduceBlockStatement(node, { block: block() });
}
reduceBreakStatement(node) {
return super.reduceBreakStatement(node);
}
reduceCallExpression(node, { callee, arguments: _arguments }) {
return super.reduceCallExpression(node, { callee: callee(), arguments: _arguments.map(n => n()) });
}
reduceCatchClause(node, { binding, body }) {
return super.reduceCatchClause(node, { binding: binding(), body: body() });
}
reduceClassDeclaration(node, { name, super: _super, elements }) {
return super.reduceClassDeclaration(node, { name: name(), super: _super == null ? null : _super(), elements: elements.map(n => n()) });
}
reduceClassElement(node, { method }) {
return super.reduceClassElement(node, { method: method() });
}
reduceClassExpression(node, { name, super: _super, elements }) {
return super.reduceClassExpression(node, { name: name == null ? null : name(), super: _super == null ? null : _super(), elements: elements.map(n => n()) });
}
reduceCompoundAssignmentExpression(node, { binding, expression }) {
return super.reduceCompoundAssignmentExpression(node, { binding: binding(), expression: expression() });
}
reduceComputedMemberAssignmentTarget(node, { object, expression }) {
return super.reduceComputedMemberAssignmentTarget(node, { object: object(), expression: expression() });
}
reduceComputedMemberExpression(node, { object, expression }) {
return super.reduceComputedMemberExpression(node, { object: object(), expression: expression() });
}
reduceComputedPropertyName(node, { expression }) {
return super.reduceComputedPropertyName(node, { expression: expression() });
}
reduceConditionalExpression(node, { test, consequent, alternate }) {
return super.reduceConditionalExpression(node, { test: test(), consequent: consequent(), alternate: alternate() });
}
reduceContinueStatement(node) {
return super.reduceContinueStatement(node);
}
reduceDataProperty(node, { name, expression }) {
return super.reduceDataProperty(node, { name: name(), expression: expression() });
}
reduceDebuggerStatement(node) {
return super.reduceDebuggerStatement(node);
}
reduceDirective(node) {
return super.reduceDirective(node);
}
reduceDoWhileStatement(node, { body, test }) {
return super.reduceDoWhileStatement(node, { body: body(), test: test() });
}
reduceEmptyStatement(node) {
return super.reduceEmptyStatement(node);
}
reduceExport(node, { declaration }) {
return super.reduceExport(node, { declaration: declaration() });
}
reduceExportAllFrom(node) {
return super.reduceExportAllFrom(node);
}
reduceExportDefault(node, { body }) {
return super.reduceExportDefault(node, { body: body() });
}
reduceExportFrom(node, { namedExports }) {
return super.reduceExportFrom(node, { namedExports: namedExports.map(n => n()) });
}
reduceExportFromSpecifier(node) {
return super.reduceExportFromSpecifier(node);
}
reduceExportLocalSpecifier(node, { name }) {
return super.reduceExportLocalSpecifier(node, { name: name() });
}
reduceExportLocals(node, { namedExports }) {
return super.reduceExportLocals(node, { namedExports: namedExports.map(n => n()) });
}
reduceExpressionStatement(node, { expression }) {
return super.reduceExpressionStatement(node, { expression: expression() });
}
reduceForAwaitStatement(node, { left, right, body }) {
return super.reduceForAwaitStatement(node, { left: left(), right: right(), body: body() });
}
reduceForInStatement(node, { left, right, body }) {
return super.reduceForInStatement(node, { left: left(), right: right(), body: body() });
}
reduceForOfStatement(node, { left, right, body }) {
return super.reduceForOfStatement(node, { left: left(), right: right(), body: body() });
}
reduceForStatement(node, { init, test, update, body }) {
return super.reduceForStatement(node, { init: init == null ? null : init(), test: test == null ? null : test(), update: update == null ? null : update(), body: body() });
}
reduceFormalParameters(node, { items, rest }) {
return super.reduceFormalParameters(node, { items: items.map(n => n()), rest: rest == null ? null : rest() });
}
reduceFunctionBody(node, { directives, statements }) {
return super.reduceFunctionBody(node, { directives: directives.map(n => n()), statements: statements.map(n => n()) });
}
reduceFunctionDeclaration(node, { name, params, body }) {
return super.reduceFunctionDeclaration(node, { name: name(), params: params(), body: body() });
}
reduceFunctionExpression(node, { name, params, body }) {
return super.reduceFunctionExpression(node, { name: name == null ? null : name(), params: params(), body: body() });
}
reduceGetter(node, { name, body }) {
return super.reduceGetter(node, { name: name(), body: body() });
}
reduceIdentifierExpression(node) {
return super.reduceIdentifierExpression(node);
}
reduceIfStatement(node, { test, consequent, alternate }) {
return super.reduceIfStatement(node, { test: test(), consequent: consequent(), alternate: alternate == null ? null : alternate() });
}
reduceImport(node, { defaultBinding, namedImports }) {
return super.reduceImport(node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namedImports: namedImports.map(n => n()) });
}
reduceImportNamespace(node, { defaultBinding, namespaceBinding }) {
return super.reduceImportNamespace(node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namespaceBinding: namespaceBinding() });
}
reduceImportSpecifier(node, { binding }) {
return super.reduceImportSpecifier(node, { binding: binding() });
}
reduceLabeledStatement(node, { body }) {
return super.reduceLabeledStatement(node, { body: body() });
}
reduceLiteralBooleanExpression(node) {
return super.reduceLiteralBooleanExpression(node);
}
reduceLiteralInfinityExpression(node) {
return super.reduceLiteralInfinityExpression(node);
}
reduceLiteralNullExpression(node) {
return super.reduceLiteralNullExpression(node);
}
reduceLiteralNumericExpression(node) {
return super.reduceLiteralNumericExpression(node);
}
reduceLiteralRegExpExpression(node) {
return super.reduceLiteralRegExpExpression(node);
}
reduceLiteralStringExpression(node) {
return super.reduceLiteralStringExpression(node);
}
reduceMethod(node, { name, params, body }) {
return super.reduceMethod(node, { name: name(), params: params(), body: body() });
}
reduceModule(node, { directives, items }) {
return super.reduceModule(node, { directives: directives.map(n => n()), items: items.map(n => n()) });
}
reduceNewExpression(node, { callee, arguments: _arguments }) {
return super.reduceNewExpression(node, { callee: callee(), arguments: _arguments.map(n => n()) });
}
reduceNewTargetExpression(node) {
return super.reduceNewTargetExpression(node);
}
reduceObjectAssignmentTarget(node, { properties, rest }) {
return super.reduceObjectAssignmentTarget(node, { properties: properties.map(n => n()), rest: rest == null ? null : rest() });
}
reduceObjectBinding(node, { properties, rest }) {
return super.reduceObjectBinding(node, { properties: properties.map(n => n()), rest: rest == null ? null : rest() });
}
reduceObjectExpression(node, { properties }) {
return super.reduceObjectExpression(node, { properties: properties.map(n => n()) });
}
reduceReturnStatement(node, { expression }) {
return super.reduceReturnStatement(node, { expression: expression == null ? null : expression() });
}
reduceScript(node, { directives, statements }) {
return super.reduceScript(node, { directives: directives.map(n => n()), statements: statements.map(n => n()) });
}
reduceSetter(node, { name, param, body }) {
return super.reduceSetter(node, { name: name(), param: param(), body: body() });
}
reduceShorthandProperty(node, { name }) {
return super.reduceShorthandProperty(node, { name: name() });
}
reduceSpreadElement(node, { expression }) {
return super.reduceSpreadElement(node, { expression: expression() });
}
reduceSpreadProperty(node, { expression }) {
return super.reduceSpreadProperty(node, { expression: expression() });
}
reduceStaticMemberAssignmentTarget(node, { object }) {
return super.reduceStaticMemberAssignmentTarget(node, { object: object() });
}
reduceStaticMemberExpression(node, { object }) {
return super.reduceStaticMemberExpression(node, { object: object() });
}
reduceStaticPropertyName(node) {
return super.reduceStaticPropertyName(node);
}
reduceSuper(node) {
return super.reduceSuper(node);
}
reduceSwitchCase(node, { test, consequent }) {
return super.reduceSwitchCase(node, { test: test(), consequent: consequent.map(n => n()) });
}
reduceSwitchDefault(node, { consequent }) {
return super.reduceSwitchDefault(node, { consequent: consequent.map(n => n()) });
}
reduceSwitchStatement(node, { discriminant, cases }) {
return super.reduceSwitchStatement(node, { discriminant: discriminant(), cases: cases.map(n => n()) });
}
reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) {
return super.reduceSwitchStatementWithDefault(node, { discriminant: discriminant(), preDefaultCases: preDefaultCases.map(n => n()), defaultCase: defaultCase(), postDefaultCases: postDefaultCases.map(n => n()) });
}
reduceTemplateElement(node) {
return super.reduceTemplateElement(node);
}
reduceTemplateExpression(node, { tag, elements }) {
return super.reduceTemplateExpression(node, { tag: tag == null ? null : tag(), elements: elements.map(n => n()) });
}
reduceThisExpression(node) {
return super.reduceThisExpression(node);
}
reduceThrowStatement(node, { expression }) {
return super.reduceThrowStatement(node, { expression: expression() });
}
reduceTryCatchStatement(node, { body, catchClause }) {
return super.reduceTryCatchStatement(node, { body: body(), catchClause: catchClause() });
}
reduceTryFinallyStatement(node, { body, catchClause, finalizer }) {
return super.reduceTryFinallyStatement(node, { body: body(), catchClause: catchClause == null ? null : catchClause(), finalizer: finalizer() });
}
reduceUnaryExpression(node, { operand }) {
return super.reduceUnaryExpression(node, { operand: operand() });
}
reduceUpdateExpression(node, { operand }) {
return super.reduceUpdateExpression(node, { operand: operand() });
}
reduceVariableDeclaration(node, { declarators }) {
return super.reduceVariableDeclaration(node, { declarators: declarators.map(n => n()) });
}
reduceVariableDeclarationStatement(node, { declaration }) {
return super.reduceVariableDeclarationStatement(node, { declaration: declaration() });
}
reduceVariableDeclarator(node, { binding, init }) {
return super.reduceVariableDeclarator(node, { binding: binding(), init: init == null ? null : init() });
}
reduceWhileStatement(node, { test, body }) {
return super.reduceWhileStatement(node, { test: test(), body: body() });
}
reduceWithStatement(node, { object, body }) {
return super.reduceWithStatement(node, { object: object(), body: body() });
}
reduceYieldExpression(node, { expression }) {
return super.reduceYieldExpression(node, { expression: expression == null ? null : expression() });
}
reduceYieldGeneratorExpression(node, { expression }) {
return super.reduceYieldGeneratorExpression(node, { expression: expression() });
}
};
}

View file

@ -0,0 +1,416 @@
// Generated by generate-thunkify.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.
*/
export default function thunkify(reducer) {
return {
reduceArrayAssignmentTarget(node, { elements, rest }) {
return reducer.reduceArrayAssignmentTarget(node, { elements: elements.map(n => n == null ? null : n()), rest: rest == null ? null : rest() });
},
reduceArrayBinding(node, { elements, rest }) {
return reducer.reduceArrayBinding(node, { elements: elements.map(n => n == null ? null : n()), rest: rest == null ? null : rest() });
},
reduceArrayExpression(node, { elements }) {
return reducer.reduceArrayExpression(node, { elements: elements.map(n => n == null ? null : n()) });
},
reduceArrowExpression(node, { params, body }) {
return reducer.reduceArrowExpression(node, { params: params(), body: body() });
},
reduceAssignmentExpression(node, { binding, expression }) {
return reducer.reduceAssignmentExpression(node, { binding: binding(), expression: expression() });
},
reduceAssignmentTargetIdentifier(node) {
return reducer.reduceAssignmentTargetIdentifier(node);
},
reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) {
return reducer.reduceAssignmentTargetPropertyIdentifier(node, { binding: binding(), init: init == null ? null : init() });
},
reduceAssignmentTargetPropertyProperty(node, { name, binding }) {
return reducer.reduceAssignmentTargetPropertyProperty(node, { name: name(), binding: binding() });
},
reduceAssignmentTargetWithDefault(node, { binding, init }) {
return reducer.reduceAssignmentTargetWithDefault(node, { binding: binding(), init: init() });
},
reduceAwaitExpression(node, { expression }) {
return reducer.reduceAwaitExpression(node, { expression: expression() });
},
reduceBinaryExpression(node, { left, right }) {
return reducer.reduceBinaryExpression(node, { left: left(), right: right() });
},
reduceBindingIdentifier(node) {
return reducer.reduceBindingIdentifier(node);
},
reduceBindingPropertyIdentifier(node, { binding, init }) {
return reducer.reduceBindingPropertyIdentifier(node, { binding: binding(), init: init == null ? null : init() });
},
reduceBindingPropertyProperty(node, { name, binding }) {
return reducer.reduceBindingPropertyProperty(node, { name: name(), binding: binding() });
},
reduceBindingWithDefault(node, { binding, init }) {
return reducer.reduceBindingWithDefault(node, { binding: binding(), init: init() });
},
reduceBlock(node, { statements }) {
return reducer.reduceBlock(node, { statements: statements.map(n => n()) });
},
reduceBlockStatement(node, { block }) {
return reducer.reduceBlockStatement(node, { block: block() });
},
reduceBreakStatement(node) {
return reducer.reduceBreakStatement(node);
},
reduceCallExpression(node, { callee, arguments: _arguments }) {
return reducer.reduceCallExpression(node, { callee: callee(), arguments: _arguments.map(n => n()) });
},
reduceCatchClause(node, { binding, body }) {
return reducer.reduceCatchClause(node, { binding: binding(), body: body() });
},
reduceClassDeclaration(node, { name, super: _super, elements }) {
return reducer.reduceClassDeclaration(node, { name: name(), super: _super == null ? null : _super(), elements: elements.map(n => n()) });
},
reduceClassElement(node, { method }) {
return reducer.reduceClassElement(node, { method: method() });
},
reduceClassExpression(node, { name, super: _super, elements }) {
return reducer.reduceClassExpression(node, { name: name == null ? null : name(), super: _super == null ? null : _super(), elements: elements.map(n => n()) });
},
reduceCompoundAssignmentExpression(node, { binding, expression }) {
return reducer.reduceCompoundAssignmentExpression(node, { binding: binding(), expression: expression() });
},
reduceComputedMemberAssignmentTarget(node, { object, expression }) {
return reducer.reduceComputedMemberAssignmentTarget(node, { object: object(), expression: expression() });
},
reduceComputedMemberExpression(node, { object, expression }) {
return reducer.reduceComputedMemberExpression(node, { object: object(), expression: expression() });
},
reduceComputedPropertyName(node, { expression }) {
return reducer.reduceComputedPropertyName(node, { expression: expression() });
},
reduceConditionalExpression(node, { test, consequent, alternate }) {
return reducer.reduceConditionalExpression(node, { test: test(), consequent: consequent(), alternate: alternate() });
},
reduceContinueStatement(node) {
return reducer.reduceContinueStatement(node);
},
reduceDataProperty(node, { name, expression }) {
return reducer.reduceDataProperty(node, { name: name(), expression: expression() });
},
reduceDebuggerStatement(node) {
return reducer.reduceDebuggerStatement(node);
},
reduceDirective(node) {
return reducer.reduceDirective(node);
},
reduceDoWhileStatement(node, { body, test }) {
return reducer.reduceDoWhileStatement(node, { body: body(), test: test() });
},
reduceEmptyStatement(node) {
return reducer.reduceEmptyStatement(node);
},
reduceExport(node, { declaration }) {
return reducer.reduceExport(node, { declaration: declaration() });
},
reduceExportAllFrom(node) {
return reducer.reduceExportAllFrom(node);
},
reduceExportDefault(node, { body }) {
return reducer.reduceExportDefault(node, { body: body() });
},
reduceExportFrom(node, { namedExports }) {
return reducer.reduceExportFrom(node, { namedExports: namedExports.map(n => n()) });
},
reduceExportFromSpecifier(node) {
return reducer.reduceExportFromSpecifier(node);
},
reduceExportLocalSpecifier(node, { name }) {
return reducer.reduceExportLocalSpecifier(node, { name: name() });
},
reduceExportLocals(node, { namedExports }) {
return reducer.reduceExportLocals(node, { namedExports: namedExports.map(n => n()) });
},
reduceExpressionStatement(node, { expression }) {
return reducer.reduceExpressionStatement(node, { expression: expression() });
},
reduceForAwaitStatement(node, { left, right, body }) {
return reducer.reduceForAwaitStatement(node, { left: left(), right: right(), body: body() });
},
reduceForInStatement(node, { left, right, body }) {
return reducer.reduceForInStatement(node, { left: left(), right: right(), body: body() });
},
reduceForOfStatement(node, { left, right, body }) {
return reducer.reduceForOfStatement(node, { left: left(), right: right(), body: body() });
},
reduceForStatement(node, { init, test, update, body }) {
return reducer.reduceForStatement(node, { init: init == null ? null : init(), test: test == null ? null : test(), update: update == null ? null : update(), body: body() });
},
reduceFormalParameters(node, { items, rest }) {
return reducer.reduceFormalParameters(node, { items: items.map(n => n()), rest: rest == null ? null : rest() });
},
reduceFunctionBody(node, { directives, statements }) {
return reducer.reduceFunctionBody(node, { directives: directives.map(n => n()), statements: statements.map(n => n()) });
},
reduceFunctionDeclaration(node, { name, params, body }) {
return reducer.reduceFunctionDeclaration(node, { name: name(), params: params(), body: body() });
},
reduceFunctionExpression(node, { name, params, body }) {
return reducer.reduceFunctionExpression(node, { name: name == null ? null : name(), params: params(), body: body() });
},
reduceGetter(node, { name, body }) {
return reducer.reduceGetter(node, { name: name(), body: body() });
},
reduceIdentifierExpression(node) {
return reducer.reduceIdentifierExpression(node);
},
reduceIfStatement(node, { test, consequent, alternate }) {
return reducer.reduceIfStatement(node, { test: test(), consequent: consequent(), alternate: alternate == null ? null : alternate() });
},
reduceImport(node, { defaultBinding, namedImports }) {
return reducer.reduceImport(node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namedImports: namedImports.map(n => n()) });
},
reduceImportNamespace(node, { defaultBinding, namespaceBinding }) {
return reducer.reduceImportNamespace(node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namespaceBinding: namespaceBinding() });
},
reduceImportSpecifier(node, { binding }) {
return reducer.reduceImportSpecifier(node, { binding: binding() });
},
reduceLabeledStatement(node, { body }) {
return reducer.reduceLabeledStatement(node, { body: body() });
},
reduceLiteralBooleanExpression(node) {
return reducer.reduceLiteralBooleanExpression(node);
},
reduceLiteralInfinityExpression(node) {
return reducer.reduceLiteralInfinityExpression(node);
},
reduceLiteralNullExpression(node) {
return reducer.reduceLiteralNullExpression(node);
},
reduceLiteralNumericExpression(node) {
return reducer.reduceLiteralNumericExpression(node);
},
reduceLiteralRegExpExpression(node) {
return reducer.reduceLiteralRegExpExpression(node);
},
reduceLiteralStringExpression(node) {
return reducer.reduceLiteralStringExpression(node);
},
reduceMethod(node, { name, params, body }) {
return reducer.reduceMethod(node, { name: name(), params: params(), body: body() });
},
reduceModule(node, { directives, items }) {
return reducer.reduceModule(node, { directives: directives.map(n => n()), items: items.map(n => n()) });
},
reduceNewExpression(node, { callee, arguments: _arguments }) {
return reducer.reduceNewExpression(node, { callee: callee(), arguments: _arguments.map(n => n()) });
},
reduceNewTargetExpression(node) {
return reducer.reduceNewTargetExpression(node);
},
reduceObjectAssignmentTarget(node, { properties, rest }) {
return reducer.reduceObjectAssignmentTarget(node, { properties: properties.map(n => n()), rest: rest == null ? null : rest() });
},
reduceObjectBinding(node, { properties, rest }) {
return reducer.reduceObjectBinding(node, { properties: properties.map(n => n()), rest: rest == null ? null : rest() });
},
reduceObjectExpression(node, { properties }) {
return reducer.reduceObjectExpression(node, { properties: properties.map(n => n()) });
},
reduceReturnStatement(node, { expression }) {
return reducer.reduceReturnStatement(node, { expression: expression == null ? null : expression() });
},
reduceScript(node, { directives, statements }) {
return reducer.reduceScript(node, { directives: directives.map(n => n()), statements: statements.map(n => n()) });
},
reduceSetter(node, { name, param, body }) {
return reducer.reduceSetter(node, { name: name(), param: param(), body: body() });
},
reduceShorthandProperty(node, { name }) {
return reducer.reduceShorthandProperty(node, { name: name() });
},
reduceSpreadElement(node, { expression }) {
return reducer.reduceSpreadElement(node, { expression: expression() });
},
reduceSpreadProperty(node, { expression }) {
return reducer.reduceSpreadProperty(node, { expression: expression() });
},
reduceStaticMemberAssignmentTarget(node, { object }) {
return reducer.reduceStaticMemberAssignmentTarget(node, { object: object() });
},
reduceStaticMemberExpression(node, { object }) {
return reducer.reduceStaticMemberExpression(node, { object: object() });
},
reduceStaticPropertyName(node) {
return reducer.reduceStaticPropertyName(node);
},
reduceSuper(node) {
return reducer.reduceSuper(node);
},
reduceSwitchCase(node, { test, consequent }) {
return reducer.reduceSwitchCase(node, { test: test(), consequent: consequent.map(n => n()) });
},
reduceSwitchDefault(node, { consequent }) {
return reducer.reduceSwitchDefault(node, { consequent: consequent.map(n => n()) });
},
reduceSwitchStatement(node, { discriminant, cases }) {
return reducer.reduceSwitchStatement(node, { discriminant: discriminant(), cases: cases.map(n => n()) });
},
reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) {
return reducer.reduceSwitchStatementWithDefault(node, { discriminant: discriminant(), preDefaultCases: preDefaultCases.map(n => n()), defaultCase: defaultCase(), postDefaultCases: postDefaultCases.map(n => n()) });
},
reduceTemplateElement(node) {
return reducer.reduceTemplateElement(node);
},
reduceTemplateExpression(node, { tag, elements }) {
return reducer.reduceTemplateExpression(node, { tag: tag == null ? null : tag(), elements: elements.map(n => n()) });
},
reduceThisExpression(node) {
return reducer.reduceThisExpression(node);
},
reduceThrowStatement(node, { expression }) {
return reducer.reduceThrowStatement(node, { expression: expression() });
},
reduceTryCatchStatement(node, { body, catchClause }) {
return reducer.reduceTryCatchStatement(node, { body: body(), catchClause: catchClause() });
},
reduceTryFinallyStatement(node, { body, catchClause, finalizer }) {
return reducer.reduceTryFinallyStatement(node, { body: body(), catchClause: catchClause == null ? null : catchClause(), finalizer: finalizer() });
},
reduceUnaryExpression(node, { operand }) {
return reducer.reduceUnaryExpression(node, { operand: operand() });
},
reduceUpdateExpression(node, { operand }) {
return reducer.reduceUpdateExpression(node, { operand: operand() });
},
reduceVariableDeclaration(node, { declarators }) {
return reducer.reduceVariableDeclaration(node, { declarators: declarators.map(n => n()) });
},
reduceVariableDeclarationStatement(node, { declaration }) {
return reducer.reduceVariableDeclarationStatement(node, { declaration: declaration() });
},
reduceVariableDeclarator(node, { binding, init }) {
return reducer.reduceVariableDeclarator(node, { binding: binding(), init: init == null ? null : init() });
},
reduceWhileStatement(node, { test, body }) {
return reducer.reduceWhileStatement(node, { test: test(), body: body() });
},
reduceWithStatement(node, { object, body }) {
return reducer.reduceWithStatement(node, { object: object(), body: body() });
},
reduceYieldExpression(node, { expression }) {
return reducer.reduceYieldExpression(node, { expression: expression == null ? null : expression() });
},
reduceYieldGeneratorExpression(node, { expression }) {
return reducer.reduceYieldGeneratorExpression(node, { expression: expression() });
},
};
}