shift-ast
Version:
constructors for the Shift AST format
864 lines (817 loc) • 116 kB
JavaScript
// Generated by scripts/generate-checked.js.
/**
* Copyright 2016 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.
*/
function isNotExpression(node) {
return typeof node === 'undefined' || (node.type !== 'ArrayExpression') && (node.type !== 'ArrowExpression') && (node.type !== 'AssignmentExpression') && (node.type !== 'AwaitExpression') && (node.type !== 'BinaryExpression') && (node.type !== 'CallExpression') && (node.type !== 'ClassExpression') && (node.type !== 'CompoundAssignmentExpression') && (node.type !== 'ConditionalExpression') && (node.type !== 'FunctionExpression') && (node.type !== 'IdentifierExpression') && (node.type !== 'LiteralBooleanExpression') && (node.type !== 'LiteralInfinityExpression') && (node.type !== 'LiteralNullExpression') && (node.type !== 'LiteralNumericExpression') && (node.type !== 'LiteralRegExpExpression') && (node.type !== 'LiteralStringExpression') && ((node.type !== 'ComputedMemberExpression') && (node.type !== 'StaticMemberExpression')) && (node.type !== 'NewExpression') && (node.type !== 'NewTargetExpression') && (node.type !== 'ObjectExpression') && (node.type !== 'TemplateExpression') && (node.type !== 'ThisExpression') && (node.type !== 'UnaryExpression') && (node.type !== 'UpdateExpression') && (node.type !== 'YieldExpression') && (node.type !== 'YieldGeneratorExpression');
}
function isNotStatement(node) {
return typeof node === 'undefined' || (node.type !== 'BlockStatement') && (node.type !== 'BreakStatement') && (node.type !== 'ClassDeclaration') && (node.type !== 'ContinueStatement') && (node.type !== 'DebuggerStatement') && (node.type !== 'EmptyStatement') && (node.type !== 'ExpressionStatement') && (node.type !== 'FunctionDeclaration') && (node.type !== 'IfStatement') && ((node.type !== 'DoWhileStatement') && (node.type !== 'ForAwaitStatement') && (node.type !== 'ForInStatement') && (node.type !== 'ForOfStatement') && (node.type !== 'ForStatement') && (node.type !== 'WhileStatement')) && (node.type !== 'LabeledStatement') && (node.type !== 'ReturnStatement') && (node.type !== 'SwitchStatement') && (node.type !== 'SwitchStatementWithDefault') && (node.type !== 'ThrowStatement') && (node.type !== 'TryCatchStatement') && (node.type !== 'TryFinallyStatement') && (node.type !== 'VariableDeclarationStatement') && (node.type !== 'WithStatement');
}
function printActualType(arg) {
if (typeof arg !== 'object') {
return typeof arg;
}
if (Array.isArray(arg)) {
return `[${arg.map(printActualType).join(', ')}]`;
}
if (arg === null) {
return null;
}
if (!arg.type) {
return JSON.stringify(arg);
}
return arg.type;
}
function arrayEquals(a, b) {
return a.length === b.length && a.every((v, i) => v === b[i]);
}
exports.ArrayAssignmentTarget = class {
constructor(arg, ...extraArgs) {
const { elements, rest } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ArrayAssignmentTarget constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['elements', 'rest'])) {
throw new TypeError('Argument to ArrayAssignmentTarget constructor has wrong keys: expected {elements, rest}, got {' + Object.keys(arg).join(', ') + '}');
}
if (!Array.isArray(elements) || elements.some(f => typeof f === 'undefined' || f !== null && ((f.type !== 'AssignmentTargetWithDefault') && (((f.type !== 'ArrayAssignmentTarget') && (f.type !== 'ObjectAssignmentTarget')) && ((f.type !== 'AssignmentTargetIdentifier') && ((f.type !== 'ComputedMemberAssignmentTarget') && (f.type !== 'StaticMemberAssignmentTarget'))))))) {
throw new TypeError('Field "elements" of ArrayAssignmentTarget constructor argument is of incorrect type (expected [null or one of {AssignmentTargetWithDefault, ArrayAssignmentTarget, ObjectAssignmentTarget, AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget}], got ' + printActualType(elements) + ')');
}
if (typeof rest === 'undefined' || rest !== null && (((rest.type !== 'ArrayAssignmentTarget') && (rest.type !== 'ObjectAssignmentTarget')) && ((rest.type !== 'AssignmentTargetIdentifier') && ((rest.type !== 'ComputedMemberAssignmentTarget') && (rest.type !== 'StaticMemberAssignmentTarget'))))) {
throw new TypeError('Field "rest" of ArrayAssignmentTarget constructor argument is of incorrect type (expected null or one of {ArrayAssignmentTarget, ObjectAssignmentTarget, AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget}, got ' + printActualType(rest) + ')');
}
this.type = 'ArrayAssignmentTarget';
this.elements = elements;
this.rest = rest;
}
};
exports.ArrayBinding = class {
constructor(arg, ...extraArgs) {
const { elements, rest } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ArrayBinding constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['elements', 'rest'])) {
throw new TypeError('Argument to ArrayBinding constructor has wrong keys: expected {elements, rest}, got {' + Object.keys(arg).join(', ') + '}');
}
if (!Array.isArray(elements) || elements.some(f => typeof f === 'undefined' || f !== null && ((f.type !== 'BindingWithDefault') && ((f.type !== 'BindingIdentifier') && ((f.type !== 'ArrayBinding') && (f.type !== 'ObjectBinding')))))) {
throw new TypeError('Field "elements" of ArrayBinding constructor argument is of incorrect type (expected [null or one of {BindingWithDefault, BindingIdentifier, ArrayBinding, ObjectBinding}], got ' + printActualType(elements) + ')');
}
if (typeof rest === 'undefined' || rest !== null && ((rest.type !== 'BindingIdentifier') && ((rest.type !== 'ArrayBinding') && (rest.type !== 'ObjectBinding')))) {
throw new TypeError('Field "rest" of ArrayBinding constructor argument is of incorrect type (expected null or one of {BindingIdentifier, ArrayBinding, ObjectBinding}, got ' + printActualType(rest) + ')');
}
this.type = 'ArrayBinding';
this.elements = elements;
this.rest = rest;
}
};
exports.ArrayExpression = class {
constructor(arg, ...extraArgs) {
const { elements } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ArrayExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['elements'])) {
throw new TypeError('Argument to ArrayExpression constructor has wrong keys: expected {elements}, got {' + Object.keys(arg).join(', ') + '}');
}
if (!Array.isArray(elements) || elements.some(f => typeof f === 'undefined' || f !== null && ((isNotExpression(f)) && (f.type !== 'SpreadElement')))) {
throw new TypeError('Field "elements" of ArrayExpression constructor argument is of incorrect type (expected [null or one of {Expression, SpreadElement}], got ' + printActualType(elements) + ')');
}
this.type = 'ArrayExpression';
this.elements = elements;
}
};
exports.ArrowExpression = class {
constructor(arg, ...extraArgs) {
const { isAsync, params, body } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ArrowExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['body', 'isAsync', 'params'])) {
throw new TypeError('Argument to ArrowExpression constructor has wrong keys: expected {isAsync, params, body}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof isAsync !== 'boolean') {
throw new TypeError('Field "isAsync" of ArrowExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(isAsync) + ')');
}
if (typeof params === 'undefined' || params.type !== 'FormalParameters') {
throw new TypeError('Field "params" of ArrowExpression constructor argument is of incorrect type (expected FormalParameters, got ' + printActualType(params) + ')');
}
if (typeof body === 'undefined' || (isNotExpression(body)) && (body.type !== 'FunctionBody')) {
throw new TypeError('Field "body" of ArrowExpression constructor argument is of incorrect type (expected one of {Expression, FunctionBody}, got ' + printActualType(body) + ')');
}
this.type = 'ArrowExpression';
this.isAsync = isAsync;
this.params = params;
this.body = body;
}
};
exports.AssignmentExpression = class {
constructor(arg, ...extraArgs) {
const { binding, expression } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('AssignmentExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'expression'])) {
throw new TypeError('Argument to AssignmentExpression constructor has wrong keys: expected {binding, expression}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof binding === 'undefined' || ((binding.type !== 'ArrayAssignmentTarget') && (binding.type !== 'ObjectAssignmentTarget')) && ((binding.type !== 'AssignmentTargetIdentifier') && ((binding.type !== 'ComputedMemberAssignmentTarget') && (binding.type !== 'StaticMemberAssignmentTarget')))) {
throw new TypeError('Field "binding" of AssignmentExpression constructor argument is of incorrect type (expected one of {ArrayAssignmentTarget, ObjectAssignmentTarget, AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget}, got ' + printActualType(binding) + ')');
}
if (isNotExpression(expression)) {
throw new TypeError('Field "expression" of AssignmentExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')');
}
this.type = 'AssignmentExpression';
this.binding = binding;
this.expression = expression;
}
};
exports.AssignmentTargetIdentifier = class {
constructor(arg, ...extraArgs) {
const { name } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('AssignmentTargetIdentifier constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['name'])) {
throw new TypeError('Argument to AssignmentTargetIdentifier constructor has wrong keys: expected {name}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof name !== 'string') {
throw new TypeError('Field "name" of AssignmentTargetIdentifier constructor argument is of incorrect type (expected string, got ' + printActualType(name) + ')');
}
this.type = 'AssignmentTargetIdentifier';
this.name = name;
}
};
exports.AssignmentTargetPropertyIdentifier = class {
constructor(arg, ...extraArgs) {
const { binding, init } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('AssignmentTargetPropertyIdentifier constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'init'])) {
throw new TypeError('Argument to AssignmentTargetPropertyIdentifier constructor has wrong keys: expected {binding, init}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof binding === 'undefined' || binding.type !== 'AssignmentTargetIdentifier') {
throw new TypeError('Field "binding" of AssignmentTargetPropertyIdentifier constructor argument is of incorrect type (expected AssignmentTargetIdentifier, got ' + printActualType(binding) + ')');
}
if (typeof init === 'undefined' || init !== null && (isNotExpression(init))) {
throw new TypeError('Field "init" of AssignmentTargetPropertyIdentifier constructor argument is of incorrect type (expected null or Expression, got ' + printActualType(init) + ')');
}
this.type = 'AssignmentTargetPropertyIdentifier';
this.binding = binding;
this.init = init;
}
};
exports.AssignmentTargetPropertyProperty = class {
constructor(arg, ...extraArgs) {
const { name, binding } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('AssignmentTargetPropertyProperty constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'name'])) {
throw new TypeError('Argument to AssignmentTargetPropertyProperty constructor has wrong keys: expected {name, binding}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof name === 'undefined' || (name.type !== 'ComputedPropertyName') && (name.type !== 'StaticPropertyName')) {
throw new TypeError('Field "name" of AssignmentTargetPropertyProperty constructor argument is of incorrect type (expected one of {ComputedPropertyName, StaticPropertyName}, got ' + printActualType(name) + ')');
}
if (typeof binding === 'undefined' || (binding.type !== 'AssignmentTargetWithDefault') && (((binding.type !== 'ArrayAssignmentTarget') && (binding.type !== 'ObjectAssignmentTarget')) && ((binding.type !== 'AssignmentTargetIdentifier') && ((binding.type !== 'ComputedMemberAssignmentTarget') && (binding.type !== 'StaticMemberAssignmentTarget'))))) {
throw new TypeError('Field "binding" of AssignmentTargetPropertyProperty constructor argument is of incorrect type (expected one of {AssignmentTargetWithDefault, ArrayAssignmentTarget, ObjectAssignmentTarget, AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget}, got ' + printActualType(binding) + ')');
}
this.type = 'AssignmentTargetPropertyProperty';
this.name = name;
this.binding = binding;
}
};
exports.AssignmentTargetWithDefault = class {
constructor(arg, ...extraArgs) {
const { binding, init } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('AssignmentTargetWithDefault constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'init'])) {
throw new TypeError('Argument to AssignmentTargetWithDefault constructor has wrong keys: expected {binding, init}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof binding === 'undefined' || ((binding.type !== 'ArrayAssignmentTarget') && (binding.type !== 'ObjectAssignmentTarget')) && ((binding.type !== 'AssignmentTargetIdentifier') && ((binding.type !== 'ComputedMemberAssignmentTarget') && (binding.type !== 'StaticMemberAssignmentTarget')))) {
throw new TypeError('Field "binding" of AssignmentTargetWithDefault constructor argument is of incorrect type (expected one of {ArrayAssignmentTarget, ObjectAssignmentTarget, AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget}, got ' + printActualType(binding) + ')');
}
if (isNotExpression(init)) {
throw new TypeError('Field "init" of AssignmentTargetWithDefault constructor argument is of incorrect type (expected Expression, got ' + printActualType(init) + ')');
}
this.type = 'AssignmentTargetWithDefault';
this.binding = binding;
this.init = init;
}
};
exports.AwaitExpression = class {
constructor(arg, ...extraArgs) {
const { expression } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('AwaitExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['expression'])) {
throw new TypeError('Argument to AwaitExpression constructor has wrong keys: expected {expression}, got {' + Object.keys(arg).join(', ') + '}');
}
if (isNotExpression(expression)) {
throw new TypeError('Field "expression" of AwaitExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')');
}
this.type = 'AwaitExpression';
this.expression = expression;
}
};
exports.BinaryExpression = class {
constructor(arg, ...extraArgs) {
const { left, operator, right } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('BinaryExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['left', 'operator', 'right'])) {
throw new TypeError('Argument to BinaryExpression constructor has wrong keys: expected {left, operator, right}, got {' + Object.keys(arg).join(', ') + '}');
}
if (isNotExpression(left)) {
throw new TypeError('Field "left" of BinaryExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(left) + ')');
}
if (typeof operator === 'undefined' || ['==', '!=', '===', '!==', '<', '<=', '>', '>=', 'in', 'instanceof', '<<', '>>', '>>>', '+', '-', '*', '/', '%', '**', ',', '||', '&&', '|', '^', '&'].indexOf(operator) === -1) {
throw new TypeError('Field "operator" of BinaryExpression constructor argument is of incorrect type (expected one of {"==", "!=", "===", "!==", "<", "<=", ">", ">=", "in", "instanceof", "<<", ">>", ">>>", "+", "-", "*", "/", "%", "**", ",", "||", "&&", "|", "^", "&"}, got ' + printActualType(operator) + ')');
}
if (isNotExpression(right)) {
throw new TypeError('Field "right" of BinaryExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(right) + ')');
}
this.type = 'BinaryExpression';
this.left = left;
this.operator = operator;
this.right = right;
}
};
exports.BindingIdentifier = class {
constructor(arg, ...extraArgs) {
const { name } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('BindingIdentifier constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['name'])) {
throw new TypeError('Argument to BindingIdentifier constructor has wrong keys: expected {name}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof name !== 'string') {
throw new TypeError('Field "name" of BindingIdentifier constructor argument is of incorrect type (expected string, got ' + printActualType(name) + ')');
}
this.type = 'BindingIdentifier';
this.name = name;
}
};
exports.BindingPropertyIdentifier = class {
constructor(arg, ...extraArgs) {
const { binding, init } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('BindingPropertyIdentifier constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'init'])) {
throw new TypeError('Argument to BindingPropertyIdentifier constructor has wrong keys: expected {binding, init}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof binding === 'undefined' || binding.type !== 'BindingIdentifier') {
throw new TypeError('Field "binding" of BindingPropertyIdentifier constructor argument is of incorrect type (expected BindingIdentifier, got ' + printActualType(binding) + ')');
}
if (typeof init === 'undefined' || init !== null && (isNotExpression(init))) {
throw new TypeError('Field "init" of BindingPropertyIdentifier constructor argument is of incorrect type (expected null or Expression, got ' + printActualType(init) + ')');
}
this.type = 'BindingPropertyIdentifier';
this.binding = binding;
this.init = init;
}
};
exports.BindingPropertyProperty = class {
constructor(arg, ...extraArgs) {
const { name, binding } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('BindingPropertyProperty constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'name'])) {
throw new TypeError('Argument to BindingPropertyProperty constructor has wrong keys: expected {name, binding}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof name === 'undefined' || (name.type !== 'ComputedPropertyName') && (name.type !== 'StaticPropertyName')) {
throw new TypeError('Field "name" of BindingPropertyProperty constructor argument is of incorrect type (expected one of {ComputedPropertyName, StaticPropertyName}, got ' + printActualType(name) + ')');
}
if (typeof binding === 'undefined' || (binding.type !== 'BindingWithDefault') && ((binding.type !== 'BindingIdentifier') && ((binding.type !== 'ArrayBinding') && (binding.type !== 'ObjectBinding')))) {
throw new TypeError('Field "binding" of BindingPropertyProperty constructor argument is of incorrect type (expected one of {BindingWithDefault, BindingIdentifier, ArrayBinding, ObjectBinding}, got ' + printActualType(binding) + ')');
}
this.type = 'BindingPropertyProperty';
this.name = name;
this.binding = binding;
}
};
exports.BindingWithDefault = class {
constructor(arg, ...extraArgs) {
const { binding, init } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('BindingWithDefault constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'init'])) {
throw new TypeError('Argument to BindingWithDefault constructor has wrong keys: expected {binding, init}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof binding === 'undefined' || (binding.type !== 'BindingIdentifier') && ((binding.type !== 'ArrayBinding') && (binding.type !== 'ObjectBinding'))) {
throw new TypeError('Field "binding" of BindingWithDefault constructor argument is of incorrect type (expected one of {BindingIdentifier, ArrayBinding, ObjectBinding}, got ' + printActualType(binding) + ')');
}
if (isNotExpression(init)) {
throw new TypeError('Field "init" of BindingWithDefault constructor argument is of incorrect type (expected Expression, got ' + printActualType(init) + ')');
}
this.type = 'BindingWithDefault';
this.binding = binding;
this.init = init;
}
};
exports.Block = class {
constructor(arg, ...extraArgs) {
const { statements } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('Block constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['statements'])) {
throw new TypeError('Argument to Block constructor has wrong keys: expected {statements}, got {' + Object.keys(arg).join(', ') + '}');
}
if (!Array.isArray(statements) || statements.some(f => isNotStatement(f))) {
throw new TypeError('Field "statements" of Block constructor argument is of incorrect type (expected [Statement], got ' + printActualType(statements) + ')');
}
this.type = 'Block';
this.statements = statements;
}
};
exports.BlockStatement = class {
constructor(arg, ...extraArgs) {
const { block } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('BlockStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['block'])) {
throw new TypeError('Argument to BlockStatement constructor has wrong keys: expected {block}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof block === 'undefined' || block.type !== 'Block') {
throw new TypeError('Field "block" of BlockStatement constructor argument is of incorrect type (expected Block, got ' + printActualType(block) + ')');
}
this.type = 'BlockStatement';
this.block = block;
}
};
exports.BreakStatement = class {
constructor(arg, ...extraArgs) {
const { label } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('BreakStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['label'])) {
throw new TypeError('Argument to BreakStatement constructor has wrong keys: expected {label}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof label === 'undefined' || label !== null && (typeof label !== 'string')) {
throw new TypeError('Field "label" of BreakStatement constructor argument is of incorrect type (expected null or string, got ' + printActualType(label) + ')');
}
this.type = 'BreakStatement';
this.label = label;
}
};
exports.CallExpression = class {
constructor(arg, ...extraArgs) {
const { callee, arguments: _arguments } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('CallExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['arguments', 'callee'])) {
throw new TypeError('Argument to CallExpression constructor has wrong keys: expected {callee, arguments}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof callee === 'undefined' || (isNotExpression(callee)) && (callee.type !== 'Super')) {
throw new TypeError('Field "callee" of CallExpression constructor argument is of incorrect type (expected one of {Expression, Super}, got ' + printActualType(callee) + ')');
}
if (!Array.isArray(_arguments) || _arguments.some(f => typeof f === 'undefined' || (isNotExpression(f)) && (f.type !== 'SpreadElement'))) {
throw new TypeError('Field "arguments" of CallExpression constructor argument is of incorrect type (expected [one of {Expression, SpreadElement}], got ' + printActualType(_arguments) + ')');
}
this.type = 'CallExpression';
this.callee = callee;
this.arguments = _arguments;
}
};
exports.CatchClause = class {
constructor(arg, ...extraArgs) {
const { binding, body } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('CatchClause constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'body'])) {
throw new TypeError('Argument to CatchClause constructor has wrong keys: expected {binding, body}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof binding === 'undefined' || binding !== null && ((binding.type !== 'BindingIdentifier') && ((binding.type !== 'ArrayBinding') && (binding.type !== 'ObjectBinding')))) {
throw new TypeError('Field "binding" of CatchClause constructor argument is of incorrect type (expected null or one of {BindingIdentifier, ArrayBinding, ObjectBinding}, got ' + printActualType(binding) + ')');
}
if (typeof body === 'undefined' || body.type !== 'Block') {
throw new TypeError('Field "body" of CatchClause constructor argument is of incorrect type (expected Block, got ' + printActualType(body) + ')');
}
this.type = 'CatchClause';
this.binding = binding;
this.body = body;
}
};
exports.ClassDeclaration = class {
constructor(arg, ...extraArgs) {
const { name, super: _super, elements } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ClassDeclaration constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['elements', 'name', 'super'])) {
throw new TypeError('Argument to ClassDeclaration constructor has wrong keys: expected {name, super, elements}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof name === 'undefined' || name.type !== 'BindingIdentifier') {
throw new TypeError('Field "name" of ClassDeclaration constructor argument is of incorrect type (expected BindingIdentifier, got ' + printActualType(name) + ')');
}
if (typeof _super === 'undefined' || _super !== null && (isNotExpression(_super))) {
throw new TypeError('Field "super" of ClassDeclaration constructor argument is of incorrect type (expected null or Expression, got ' + printActualType(_super) + ')');
}
if (!Array.isArray(elements) || elements.some(f => typeof f === 'undefined' || f.type !== 'ClassElement')) {
throw new TypeError('Field "elements" of ClassDeclaration constructor argument is of incorrect type (expected [ClassElement], got ' + printActualType(elements) + ')');
}
this.type = 'ClassDeclaration';
this.name = name;
this.super = _super;
this.elements = elements;
}
};
exports.ClassElement = class {
constructor(arg, ...extraArgs) {
const { isStatic, method } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ClassElement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['isStatic', 'method'])) {
throw new TypeError('Argument to ClassElement constructor has wrong keys: expected {isStatic, method}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof isStatic !== 'boolean') {
throw new TypeError('Field "isStatic" of ClassElement constructor argument is of incorrect type (expected boolean, got ' + printActualType(isStatic) + ')');
}
if (typeof method === 'undefined' || (method.type !== 'Getter') && (method.type !== 'Method') && (method.type !== 'Setter')) {
throw new TypeError('Field "method" of ClassElement constructor argument is of incorrect type (expected one of {Getter, Method, Setter}, got ' + printActualType(method) + ')');
}
this.type = 'ClassElement';
this.isStatic = isStatic;
this.method = method;
}
};
exports.ClassExpression = class {
constructor(arg, ...extraArgs) {
const { name, super: _super, elements } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ClassExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['elements', 'name', 'super'])) {
throw new TypeError('Argument to ClassExpression constructor has wrong keys: expected {name, super, elements}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof name === 'undefined' || name !== null && (name.type !== 'BindingIdentifier')) {
throw new TypeError('Field "name" of ClassExpression constructor argument is of incorrect type (expected null or BindingIdentifier, got ' + printActualType(name) + ')');
}
if (typeof _super === 'undefined' || _super !== null && (isNotExpression(_super))) {
throw new TypeError('Field "super" of ClassExpression constructor argument is of incorrect type (expected null or Expression, got ' + printActualType(_super) + ')');
}
if (!Array.isArray(elements) || elements.some(f => typeof f === 'undefined' || f.type !== 'ClassElement')) {
throw new TypeError('Field "elements" of ClassExpression constructor argument is of incorrect type (expected [ClassElement], got ' + printActualType(elements) + ')');
}
this.type = 'ClassExpression';
this.name = name;
this.super = _super;
this.elements = elements;
}
};
exports.CompoundAssignmentExpression = class {
constructor(arg, ...extraArgs) {
const { binding, operator, expression } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('CompoundAssignmentExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'expression', 'operator'])) {
throw new TypeError('Argument to CompoundAssignmentExpression constructor has wrong keys: expected {binding, operator, expression}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof binding === 'undefined' || (binding.type !== 'AssignmentTargetIdentifier') && ((binding.type !== 'ComputedMemberAssignmentTarget') && (binding.type !== 'StaticMemberAssignmentTarget'))) {
throw new TypeError('Field "binding" of CompoundAssignmentExpression constructor argument is of incorrect type (expected one of {AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget}, got ' + printActualType(binding) + ')');
}
if (typeof operator === 'undefined' || ['+=', '-=', '*=', '/=', '%=', '**=', '<<=', '>>=', '>>>=', '|=', '^=', '&='].indexOf(operator) === -1) {
throw new TypeError('Field "operator" of CompoundAssignmentExpression constructor argument is of incorrect type (expected one of {"+=", "-=", "*=", "/=", "%=", "**=", "<<=", ">>=", ">>>=", "|=", "^=", "&="}, got ' + printActualType(operator) + ')');
}
if (isNotExpression(expression)) {
throw new TypeError('Field "expression" of CompoundAssignmentExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')');
}
this.type = 'CompoundAssignmentExpression';
this.binding = binding;
this.operator = operator;
this.expression = expression;
}
};
exports.ComputedMemberAssignmentTarget = class {
constructor(arg, ...extraArgs) {
const { object, expression } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ComputedMemberAssignmentTarget constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['expression', 'object'])) {
throw new TypeError('Argument to ComputedMemberAssignmentTarget constructor has wrong keys: expected {object, expression}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof object === 'undefined' || (isNotExpression(object)) && (object.type !== 'Super')) {
throw new TypeError('Field "object" of ComputedMemberAssignmentTarget constructor argument is of incorrect type (expected one of {Expression, Super}, got ' + printActualType(object) + ')');
}
if (isNotExpression(expression)) {
throw new TypeError('Field "expression" of ComputedMemberAssignmentTarget constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')');
}
this.type = 'ComputedMemberAssignmentTarget';
this.object = object;
this.expression = expression;
}
};
exports.ComputedMemberExpression = class {
constructor(arg, ...extraArgs) {
const { object, expression } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ComputedMemberExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['expression', 'object'])) {
throw new TypeError('Argument to ComputedMemberExpression constructor has wrong keys: expected {object, expression}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof object === 'undefined' || (isNotExpression(object)) && (object.type !== 'Super')) {
throw new TypeError('Field "object" of ComputedMemberExpression constructor argument is of incorrect type (expected one of {Expression, Super}, got ' + printActualType(object) + ')');
}
if (isNotExpression(expression)) {
throw new TypeError('Field "expression" of ComputedMemberExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')');
}
this.type = 'ComputedMemberExpression';
this.object = object;
this.expression = expression;
}
};
exports.ComputedPropertyName = class {
constructor(arg, ...extraArgs) {
const { expression } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ComputedPropertyName constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['expression'])) {
throw new TypeError('Argument to ComputedPropertyName constructor has wrong keys: expected {expression}, got {' + Object.keys(arg).join(', ') + '}');
}
if (isNotExpression(expression)) {
throw new TypeError('Field "expression" of ComputedPropertyName constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')');
}
this.type = 'ComputedPropertyName';
this.expression = expression;
}
};
exports.ConditionalExpression = class {
constructor(arg, ...extraArgs) {
const { test, consequent, alternate } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ConditionalExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['alternate', 'consequent', 'test'])) {
throw new TypeError('Argument to ConditionalExpression constructor has wrong keys: expected {test, consequent, alternate}, got {' + Object.keys(arg).join(', ') + '}');
}
if (isNotExpression(test)) {
throw new TypeError('Field "test" of ConditionalExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(test) + ')');
}
if (isNotExpression(consequent)) {
throw new TypeError('Field "consequent" of ConditionalExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(consequent) + ')');
}
if (isNotExpression(alternate)) {
throw new TypeError('Field "alternate" of ConditionalExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(alternate) + ')');
}
this.type = 'ConditionalExpression';
this.test = test;
this.consequent = consequent;
this.alternate = alternate;
}
};
exports.ContinueStatement = class {
constructor(arg, ...extraArgs) {
const { label } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ContinueStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['label'])) {
throw new TypeError('Argument to ContinueStatement constructor has wrong keys: expected {label}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof label === 'undefined' || label !== null && (typeof label !== 'string')) {
throw new TypeError('Field "label" of ContinueStatement constructor argument is of incorrect type (expected null or string, got ' + printActualType(label) + ')');
}
this.type = 'ContinueStatement';
this.label = label;
}
};
exports.DataProperty = class {
constructor(arg, ...extraArgs) {
const { name, expression } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('DataProperty constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['expression', 'name'])) {
throw new TypeError('Argument to DataProperty constructor has wrong keys: expected {name, expression}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof name === 'undefined' || (name.type !== 'ComputedPropertyName') && (name.type !== 'StaticPropertyName')) {
throw new TypeError('Field "name" of DataProperty constructor argument is of incorrect type (expected one of {ComputedPropertyName, StaticPropertyName}, got ' + printActualType(name) + ')');
}
if (isNotExpression(expression)) {
throw new TypeError('Field "expression" of DataProperty constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')');
}
this.type = 'DataProperty';
this.name = name;
this.expression = expression;
}
};
exports.DebuggerStatement = class {
constructor(...extraArgs) {
if (extraArgs.length > 1 || extraArgs.length === 1 && (typeof extraArgs[0] !== 'object' || extraArgs[0] === null || Object.keys(extraArgs[0]).length !== 0)) {
throw new TypeError('DebuggerStatement constructor takes no arguments');
}
this.type = 'DebuggerStatement';
}
};
exports.Directive = class {
constructor(arg, ...extraArgs) {
const { rawValue } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('Directive constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['rawValue'])) {
throw new TypeError('Argument to Directive constructor has wrong keys: expected {rawValue}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof rawValue !== 'string') {
throw new TypeError('Field "rawValue" of Directive constructor argument is of incorrect type (expected string, got ' + printActualType(rawValue) + ')');
}
this.type = 'Directive';
this.rawValue = rawValue;
}
};
exports.DoWhileStatement = class {
constructor(arg, ...extraArgs) {
const { body, test } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('DoWhileStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['body', 'test'])) {
throw new TypeError('Argument to DoWhileStatement constructor has wrong keys: expected {body, test}, got {' + Object.keys(arg).join(', ') + '}');
}
if (isNotStatement(body)) {
throw new TypeError('Field "body" of DoWhileStatement constructor argument is of incorrect type (expected Statement, got ' + printActualType(body) + ')');
}
if (isNotExpression(test)) {
throw new TypeError('Field "test" of DoWhileStatement constructor argument is of incorrect type (expected Expression, got ' + printActualType(test) + ')');
}
this.type = 'DoWhileStatement';
this.body = body;
this.test = test;
}
};
exports.EmptyStatement = class {
constructor(...extraArgs) {
if (extraArgs.length > 1 || extraArgs.length === 1 && (typeof extraArgs[0] !== 'object' || extraArgs[0] === null || Object.keys(extraArgs[0]).length !== 0)) {
throw new TypeError('EmptyStatement constructor takes no arguments');
}
this.type = 'EmptyStatement';
}
};
exports.Export = class {
constructor(arg, ...extraArgs) {
const { declaration } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('Export constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['declaration'])) {
throw new TypeError('Argument to Export constructor has wrong keys: expected {declaration}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof declaration === 'undefined' || (declaration.type !== 'ClassDeclaration') && (declaration.type !== 'FunctionDeclaration') && (declaration.type !== 'VariableDeclaration')) {
throw new TypeError('Field "declaration" of Export constructor argument is of incorrect type (expected one of {ClassDeclaration, FunctionDeclaration, VariableDeclaration}, got ' + printActualType(declaration) + ')');
}
this.type = 'Export';
this.declaration = declaration;
}
};
exports.ExportAllFrom = class {
constructor(arg, ...extraArgs) {
const { moduleSpecifier } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ExportAllFrom constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['moduleSpecifier'])) {
throw new TypeError('Argument to ExportAllFrom constructor has wrong keys: expected {moduleSpecifier}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof moduleSpecifier !== 'string') {
throw new TypeError('Field "moduleSpecifier" of ExportAllFrom constructor argument is of incorrect type (expected string, got ' + printActualType(moduleSpecifier) + ')');
}
this.type = 'ExportAllFrom';
this.moduleSpecifier = moduleSpecifier;
}
};
exports.ExportDefault = class {
constructor(arg, ...extraArgs) {
const { body } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ExportDefault constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['body'])) {
throw new TypeError('Argument to ExportDefault constructor has wrong keys: expected {body}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof body === 'undefined' || (body.type !== 'ClassDeclaration') && (isNotExpression(body)) && (body.type !== 'FunctionDeclaration')) {
throw new TypeError('Field "body" of ExportDefault constructor argument is of incorrect type (expected one of {ClassDeclaration, Expression, FunctionDeclaration}, got ' + printActualType(body) + ')');
}
this.type = 'ExportDefault';
this.body = body;
}
};
exports.ExportFrom = class {
constructor(arg, ...extraArgs) {
const { namedExports, moduleSpecifier } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ExportFrom constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['moduleSpecifier', 'namedExports'])) {
throw new TypeError('Argument to ExportFrom constructor has wrong keys: expected {namedExports, moduleSpecifier}, got {' + Object.keys(arg).join(', ') + '}');
}
if (!Array.isArray(namedExports) || namedExports.some(f => typeof f === 'undefined' || f.type !== 'ExportFromSpecifier')) {
throw new TypeError('Field "namedExports" of ExportFrom constructor argument is of incorrect type (expected [ExportFromSpecifier], got ' + printActualType(namedExports) + ')');
}
if (typeof moduleSpecifier !== 'string') {
throw new TypeError('Field "moduleSpecifier" of ExportFrom constructor argument is of incorrect type (expected string, got ' + printActualType(moduleSpecifier) + ')');
}
this.type = 'ExportFrom';
this.namedExports = namedExports;
this.moduleSpecifier = moduleSpecifier;
}
};
exports.ExportFromSpecifier = class {
constructor(arg, ...extraArgs) {
const { name, exportedName } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ExportFromSpecifier constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['exportedName', 'name'])) {
throw new TypeError('Argument to ExportFromSpecifier constructor has wrong keys: expected {name, exportedName}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof name !== 'string') {
throw new TypeError('Field "name" of ExportFromSpecifier constructor argument is of incorrect type (expected string, got ' + printActualType(name) + ')');
}
if (typeof exportedName === 'undefined' || exportedName !== null && (typeof exportedName !== 'string')) {
throw new TypeError('Field "exportedName" of ExportFromSpecifier constructor argument is of incorrect type (expected null or string, got ' + printActualType(exportedName) + ')');
}
this.type = 'ExportFromSpecifier';
this.name = name;
this.exportedName = exportedName;
}
};
exports.ExportLocalSpecifier = class {
constructor(arg, ...extraArgs) {
const { name, exportedName } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ExportLocalSpecifier constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['exportedName', 'name'])) {
throw new TypeError('Argument to ExportLocalSpecifier constructor has wrong keys: expected {name, exportedName}, got {' + Object.keys(arg).join(', ') + '}');
}
if (typeof name === 'undefined' || name.type !== 'IdentifierExpression') {
throw new TypeError('Field "name" of ExportLocalSpecifier constructor argument is of incorrect type (expected IdentifierExpression, got ' + printActualType(name) + ')');
}
if (typeof exportedName === 'undefined' || exportedName !== null && (typeof exportedName !== 'string')) {
throw new TypeError('Field "exportedName" of ExportLocalSpecifier constructor argument is of incorrect type (expected null or string, got ' + printActualType(exportedName) + ')');
}
this.type = 'ExportLocalSpecifier';
this.name = name;
this.exportedName = exportedName;
}
};
exports.ExportLocals = class {
constructor(arg, ...extraArgs) {
const { namedExports } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ExportLocals constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['namedExports'])) {
throw new TypeError('Argument to ExportLocals constructor has wrong keys: expected {namedExports}, got {' + Object.keys(arg).join(', ') + '}');
}
if (!Array.isArray(namedExports) || namedExports.some(f => typeof f === 'undefined' || f.type !== 'ExportLocalSpecifier')) {
throw new TypeError('Field "namedExports" of ExportLocals constructor argument is of incorrect type (expected [ExportLocalSpecifier], got ' + printActualType(namedExports) + ')');
}
this.type = 'ExportLocals';
this.namedExports = namedExports;
}
};
exports.ExpressionStatement = class {
constructor(arg, ...extraArgs) {
const { expression } = arg;
if (extraArgs.length !== 0) {
throw new TypeError('ExpressionStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)');
}
if (!arrayEquals(Object.keys(arg).sort(), ['expression'])) {
throw new TypeError('Argument to ExpressionStatement constructor has wrong keys: expected {expression}, got {' + Object.keys(arg).join(', ') + '}');
}
if (isNotExpression(expression)) {
throw new TypeError('Field "expression" of ExpressionStatement constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')');
}
this.