commit 83ccc6370c4ed76d63d4df8ceb45112228b779f0 Author: Graham Kelly Date: Tue Apr 11 16:38:39 2023 -0400 Initial commit diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..1c49918 --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +node ./lcakec.js > lcake.js \ No newline at end of file diff --git a/lcake.js b/lcake.js new file mode 100644 index 0000000..ea9472d --- /dev/null +++ b/lcake.js @@ -0,0 +1,87 @@ + +// Credit to http://m1el.github.io/smallest-lambda-eval/ +function Eval(prog, env) { + if (typeof prog === 'string') { + // lookup a variable + return env[prog]; + } else if (prog[0] === '$') { + // constructing a new lambda + return (arg) => Eval(prog[2], { ...env, [prog[1]]: arg }); + } else { + // function application + return Eval(prog[0], env)(Eval(prog[1], env)); + } +} +function FromChurch(f) { + var i = 0; + f(function (x) { + i++; + return x; + })(function (x) { + return x; + })(undefined); +} +function ToChurch(i) { + return function (a) { + return function (b) { + var c = b; + for (let j = 0; j < i; j++)c = a(c); + return c + } + } +} +function FromArray(x) { + return x([])((a) => (v) => [...a, v]) +} +function ToArray(x) { + return function (n) { + return function (s) { + var o = n; + for (var i of x) { + o = s(o)(i); + } + return o + } + } +} +function FromString(x) { + return String.fromCodePoint(...FromArray(x).map(FromChurch)) +} +function ToString(s){ + return toArray([...s].map(x => x.codePointAt(0)).map(FromChurch)) +} +var opcodes = { + 0: 'io_ref_new', + 1: 'io_ref_read', + 2: 'io_ref_write', +} +function RunIO(prog) { + return prog(function(x){ + return x; + })(function (ty) { + return function (pay) { + return function (cont) { + var then = function(x){ + return RunIO(cont(x)) + } + switch (opcodes[FromChurch(ty)]) { + case 'io_ref_new': + var x = Math.random().toString(); + RunIO["io_ref/" + x] = pay; + return then(ToString(x)); + case 'io_ref_read': + return then(RunIO["io_ref/" + FromString(pay)]) + case 'io_ref_write': + return pay(function(a){ + return function(b){ + RunIO["io_ref/" + FromString(a)] = b; + return then(b); + } + }) + } + } + } + }) +} +RunIO(Eval([["$","val",["$","p",["$","i",["p","val"]]]],["$","+",["$","0","0"]]],{})) + diff --git a/lcakec.js b/lcakec.js new file mode 100644 index 0000000..24461d4 --- /dev/null +++ b/lcakec.js @@ -0,0 +1,286 @@ +let {reduceUsing} = require('shift-reducer') + +const cyrb53 = (str, seed = 0) => { + let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed; + for(let i = 0, ch; i < str.length; i++) { + ch = str.charCodeAt(i); + h1 = Math.imul(h1 ^ ch, 2654435761); + h2 = Math.imul(h2 ^ ch, 1597334677); + } + h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507); + h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909); + h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507); + h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909); + + return 4294967296 * (2097151 & h2) + (h1 >>> 0); +}; + +let srcBase = ` +// Credit to http://m1el.github.io/smallest-lambda-eval/ +function Eval(prog, env) { + if (typeof prog === 'string') { + // lookup a variable + return env[prog]; + } else if (prog[0] === '$') { + // constructing a new lambda + return (arg) => Eval(prog[2], { ...env, [prog[1]]: arg }); + } else { + // function application + return Eval(prog[0], env)(Eval(prog[1], env)); + } +} +function FromChurch(f) { + var i = 0; + f(function (x) { + i++; + return x; + })(function (x) { + return x; + })(undefined); +} +function ToChurch(i) { + return function (a) { + return function (b) { + var c = b; + for (let j = 0; j < i; j++)c = a(c); + return c + } + } +} +function FromArray(x) { + return x([])((a) => (v) => [...a, v]) +} +function ToArray(x) { + return function (n) { + return function (s) { + var o = n; + for (var i of x) { + o = s(o)(i); + } + return o + } + } +} +function FromString(x) { + return String.fromCodePoint(...FromArray(x).map(FromChurch)) +} +function ToString(s){ + return toArray([...s].map(x => x.codePointAt(0)).map(FromChurch)) +} +var opcodes = { + 0: 'io_ref_new', + 1: 'io_ref_read', + 2: 'io_ref_write', +} +function RunIO(prog) { + return prog(function(x){ + return x; + })(function (ty) { + return function (pay) { + return function (cont) { + var then = function(x){ + return RunIO(cont(x)) + } + switch (opcodes[FromChurch(ty)]) { + case 'io_ref_new': + var x = Math.random().toString(); + RunIO["io_ref/" + x] = pay; + return then(ToString(x)); + case 'io_ref_read': + return then(RunIO["io_ref/" + FromString(pay)]) + case 'io_ref_write': + return pay(function(a){ + return function(b){ + RunIO["io_ref/" + FromString(a)] = b; + return then(b); + } + }) + } + } + } + }) +}` + +function vari(x){ + return x; +} + +function abs(a,b){ + return ['$',a,b] +} + +function app(a,b){ + return [a,b] +} + +function appx(...a){ + var b = a[0]; + for(var i in a){ + if(i != 0){ + b = app(b,a[i]) + } + } + return b +} + +function subst(x,b,c){ + if(typeof x == 'string'){ + if(x === b)return c; + return x; + }else if (x[0] == '$'){ + if(x[1] == b){ + return x; + } + return abs(x[1],subst(x[2],b,c)); + } + return app(subst(x[0],b,c),subst(x[1],b,c)) +} + +Function.prototype.fuse = function(){ + var a = abs('$$0',this('$$0')) + var h = cyrb53(JSON.stringify(a)) + return abs(`h${h}`,subst(a[2],'$$0',`h${h}`)) +} + +function createChurch(n){ + var v = '0'; + for(let i = 0; i < n; i++){ + v = ['+',v]; + } + return ['$','+',['$','0',v]] +} +function createList(n){ + var v = 'null'; + for(var i of n){ + v = app('push')(v)(i); + } + return abs('null',abs('push',v)) +} +function createString(s){ + return createList([...s].map(x => x.codePointAt(0)).map(createChurch)) +} +function createBool(b){ + return abs('x',app('y',b ? 'x' : 'y')) +} +var yb = abs('f',abs('x',app('x',abs('z',app(app(app('f','f'),'x'),'z'))))) +var y = app(yb,yb) +var IO = { + pure: abs('val',abs('p',abs('i',app('p','val')))), + bind: app(y,abs('bind',abs('m',abs('f',app(app('m','f'),abs('ty',abs('pay',abs('cont',abs('h',app(app(app('h','ty'),'pay'),abs('x',app(app('bind',app('cont','x')),'f')))))))))))), + name: 'io' +} +var createIO = abs('t',abs('p',abs('pu',abs('i',appx('i','t','p',IO.pure))))) +var newIORef = appx(createIO,createChurch(0)) +var readIORef = appx(createIO,createChurch(1)) +var writeIORef = abs('r',abs('v',appx(createIO,createChurch(2),abs('f',appx('f','r','v'))))) + +function warp(x,{pure,bind,name} = IO){ + if(typeof x == 'string'){ + return app(pure,name + '$' + x); + }else if (x[0] == '$'){ + return app(pure,abs(name + '$' + x[1],warpIO(x[2]))) + }else if(x[0] == 'splice_' + name){ + return x[1]; + } + return appx(bind,warp(x[0],{pure,bind,name}),abs('f',appx(bind,warp(x[1],{pure,bind,name}),abs('x',app('f','x'))))) +} + + +var pred = abs('n',abs('f',abs('x',app(app(app('n',abs('g',abs('h',app('h',app('g','f'))))),abs('u','x')),abs('u','u'))))) +var isZero = abs('n',app(app('n',abs('x',createBool(false)),createBool(true)))) +var l_and = abs('p',abs('q',app(app('p','q'),'p'))) +var minus = abs('a',abs('b',app(app('b',pred),'a'))) +var leq = abs('m',abs('n',app(isZero,app(app(minus,'m'),'n')))) +var eq = abs('m',abs('n',app(app(l_and,app(app(leq,'m'),'n')),app(app(leq,'n'),'m')))) + +var tru = abs('t',abs('f','t')) +var fals = abs('t',abs('f','f')) + +var jsFun = abs('x',abs('fn',abs('truthy',abs('falsy',app('fn','x'))))) +var jsTruthy = abs('t',abs('v',abs('fn',abs('truthy',abs('falsy',app(app('truthy','t'),'v')))))) +var jsFalsy = abs('t',app('fn',abs('truthy',abs('falsy',app('falsy','t'))))) + +var sempty = abs('e',abs('c','e')) +var scons = abs('h',abs('t',abs('e',abs('c',appx('c','h','t'))))) + +var stoc = appx(y,function(a){ + return abs('l',abs('n',abs('c',appx('l','n',abs('a',abs('b',appx('c','a',appx(a,'b','n','c')))))))) +}.fuse) + +var ctos = abs('a',appx('a',sempty,scons)) + +var strEq = appx(y,abs('strEq',abs('a',abs('b',appx('a',appx('b',tru,abs('_a',abs('_b',fals))),abs('c',abs('d',appx('b',fals,abs('e',abs('f',appx(eq,'c','e',appx('strEq','d','f'),fals))))))))))) + +var churchSucc = abs('x',abs('o',abs('s',app('s',appx('x','o','s'))))) + +var TY_NULL = 0; + +var jsNull = app(jsFalsy,createChurch(TY_NULL)) + +var getVarS = getGetVarSlot => abs('v',abs('p',abs('b',abs('l',appx(stoc,'l',abs('_',appx(free.pure,jsNull)),abs('f',abs('p',appx(getGetVarSlot('f'),'p'))),'v'))))) + +var free = { + name: 'free', + pure: abs('x',abs('p',abs('b',abs('l',app('p','x'))))), + bind: abs('m',abs('f',abs('p',abs('b',abs('l',appx('b',appx('m','p','b','l'),abs('v',appx('f','v','p','b','l')))))))) +} + +var addVarS = push => abs('f',abs('v',abs('p',abs('b',abs('l',appx('f', + abs('v',abs('x',app('p','v'))), // pure + abs('m',abs('f',abs('x',appx('b',app('m','x'),abs('v',appx('f','v','x')))))), // bind + appx(scons,push( + abs('m',abs('x','m')), //lift + abs('r',abs('v',abs('x',appx(isZero,'v',app(free.pure,'x'),abs('_', appx('r',appx(pred,'v'))))))), //getVar + ),'l'), + 'v' +)))))) + +var liftIOS = getLift => abs('i',abs('p',abs('b',app('l',appx(stoc,'l','i',abs('d',abs('m',app(getLift('d'),'m')))))))) + + +var readerT = old => ({ + base: old, + lift: abs('x',abs('v','x')), + pure: abs('x',abs('v',app(old.pure,'x'))), + bind: abs('m',abs('f',abs('v',appx(old.bind,app('m','v'),abs('w',appx('f','w','v')))))), + name: `readerT(${old.name})` +}) + +var contT = old => ({ + base: old, + lift: abs('x',abs('cc',appx(old.bind,'x','cc'))), + pure: abs('x',abs('cc',app('cc','x'))), + bind: abs('m',abs('f',abs('cc',app('m',abs('x',appx('f','x','cc')))))), + name: `contT(${old.name})` +}) + +var js = contT(readerT(free)) + +var getVarB = getGetVarSlot => abs('j',app(js.lift,abs('vs',appx(getVarS(getGetVarSlot),appx('vs','j'))))) + +var liftIOB = getLift => abs('i',app(js.lift,abs('v',appx(liftIOS(getLift),'i')))) + +var pushBase = (a,b) => abs('f',appx('f',a,b)) + +var addVarB = push => abs('m',abs('v',abs('f',appx(js.base.lift,addVarS(push),appx('f',abs('n',appx(strEq,'m','n',createChurch(0),app(churchSucc,app('f','n'))))),'v')))); + +var addVar = addVarB(pushBase) + +js.addVar = addVar + +var getGetVarSlotBase = x => app(x,abs('a',abs('b','b'))) + +var getLiftBase = x => app(x,abs('a',abs('b','a'))) + +var getVar = getVarB(getGetVarSlotBase) + +js.getVar = getVar + +var liftIOJ = liftIOB(getLiftBase) + +js.liftIO = liftIOJ + + +console.log(srcBase + ` +RunIO(Eval(${JSON.stringify(app(IO.pure,createChurch(0)))},{})) +`) \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 0000000..cdefd72 --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,83 @@ +{ + "name": "lambdaworld", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/multimap": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/multimap/-/multimap-1.1.0.tgz", + "integrity": "sha512-0ZIR9PasPxGXmRsEF8jsDzndzHDj7tIav+JUmvIFB/WHswliFnquxECT/De7GR4yg99ky/NlRKJT82G1y271bw==" + }, + "node_modules/shift-ast": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/shift-ast/-/shift-ast-7.0.0.tgz", + "integrity": "sha512-O0INwsZa1XH/lMSf52udGnjNOxKBLxFiZHt0Ys3i6bqtwuGEA3eDR4+e0qJELIsCy8+BiTtlTgQzP76K1ehipQ==" + }, + "node_modules/shift-parser": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/shift-parser/-/shift-parser-8.0.0.tgz", + "integrity": "sha512-IShW1wGhvA5e+SPNVQ+Dwi/Be6651F2jZc6wwYHbYW7PiswAYfvR/v3Q+CjjxsVCna5L6J5OtR6y+tkkCzvCfw==", + "dependencies": { + "multimap": "^1.0.2", + "shift-ast": "7.0.0", + "shift-reducer": "7.0.0", + "shift-regexp-acceptor": "3.0.0" + } + }, + "node_modules/shift-reducer": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/shift-reducer/-/shift-reducer-7.0.0.tgz", + "integrity": "sha512-9igIDMHzp1+CkQZITGHM1sAd9jqMPV0vhqHuh8jlYumHSMIwsYcrDeo1tlpzNRUnfbEq1nLyh8Bf1YU8HGUE7g==", + "dependencies": { + "shift-ast": "7.0.0" + } + }, + "node_modules/shift-regexp-acceptor": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shift-regexp-acceptor/-/shift-regexp-acceptor-3.0.0.tgz", + "integrity": "sha512-98UKizBjHY6SjjLUr51YYw4rtR+vxjGFm8znqNsoahesAI8Y9+WVAyiBCxxkov1KSDhW0Wz8FwwUqHnlFnjdUg==", + "dependencies": { + "unicode-match-property-ecmascript": "1.0.4", + "unicode-match-property-value-ecmascript": "1.0.2", + "unicode-property-aliases-ecmascript": "1.0.4" + } + }, + "node_modules/unicode-canonical-property-names-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", + "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==", + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", + "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", + "dependencies": { + "unicode-canonical-property-names-ecmascript": "^1.0.4", + "unicode-property-aliases-ecmascript": "^1.0.4" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-value-ecmascript": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.0.2.tgz", + "integrity": "sha512-Rx7yODZC1L/T8XKo/2kNzVAQaRE88AaMvI1EF/Xnj3GW2wzN6fop9DDWuFAKUVFH7vozkz26DzP0qyWLKLIVPQ==", + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-property-aliases-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.4.tgz", + "integrity": "sha512-2WSLa6OdYd2ng8oqiGIWnJqyFArvhn+5vgx5GTxMbUYjCYKUcuKS62YLFF0R/BDGlB1yzXjQOLtPAfHsgirEpg==", + "engines": { + "node": ">=4" + } + } + } +} diff --git a/node_modules/multimap/.jshintrc b/node_modules/multimap/.jshintrc new file mode 100644 index 0000000..93da3d4 --- /dev/null +++ b/node_modules/multimap/.jshintrc @@ -0,0 +1,41 @@ +{ + "passfail" : false, + "maxerr" : 20, + "browser" : false, + "node" : true, + "debug" : false, + "devel" : true, + "es5" : false, + "strict" : false, + "globalstrict" : false, + "asi" : false, + "laxbreak" : false, + "bitwise" : false, + "boss" : true, + "curly" : false, + "eqeqeq" : false, + "eqnull" : false, + "evil" : true, + "expr" : true, + "forin" : false, + "immed" : true, + "latedef" : false, + "loopfunc" : true, + "noarg" : true, + "regexp" : true, + "regexdash" : false, + "scripturl" : true, + "shadow" : true, + "supernew" : false, + "undef" : false, + "newcap" : false, + "proto" : true, + "noempty" : true, + "nonew" : false, + "nomen" : false, + "onevar" : false, + "plusplus" : false, + "sub" : false, + "trailing" : false, + "white" : false +} \ No newline at end of file diff --git a/node_modules/multimap/.travis.yml b/node_modules/multimap/.travis.yml new file mode 100644 index 0000000..ee21a4a --- /dev/null +++ b/node_modules/multimap/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.10" + - "0.11" + +script: npm run test \ No newline at end of file diff --git a/node_modules/multimap/README.md b/node_modules/multimap/README.md new file mode 100644 index 0000000..cb5c667 --- /dev/null +++ b/node_modules/multimap/README.md @@ -0,0 +1,136 @@ +# Multimap - Map which Allow Multiple Values for the same Key + +[![NPM version](https://badge.fury.io/js/multimap.svg)](http://badge.fury.io/js/multimap) +[![Build Status](https://travis-ci.org/villadora/multi-map.png?branch=master)](https://travis-ci.org/villadora/multi-map) + +## Install + +```bash +npm install multimap --save +``` + +## Usage + + +If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing `Map` on global scope, do: + +```javascript +var Multimap = require('multimap'); +var m = new Multimap(); +``` + +If the global es6 `Map` exists or `Multimap.Map` is set, `Multimap` will use the `Map` as inner store, that means Object can be used as key. + +```javascript +var Multimap = require('multimap'); + +// if harmony is on +/* nothing need to do */ +// or if you are using es6-shim +Multimap.Map = ShimMap; + +var m = new Multimap(); +var key = {}; +m.set(key, 'one'); + +``` + +Otherwise, an object will be used, all the keys will be transformed into string. + + +### In Modern Browser + +Just download the `index.js` as `Multimap.js`. + +``` + + +``` + +Or use as an AMD loader: + +``` +require(['./Multimap.js'], function (Multimap) { + var map = new Multimap([['a', 1], ['b', 2], ['c', 3]]); + map = map.set('b', 20); + map.get('b'); // [2, 20] +}); +``` + +* Browsers should support `Object.defineProperty` and `Array.prototype.forEach`. + + +## API + +Following shows how to use `Multimap`: + +```javascript +var Multimap = require('multimap'); + +var map = new Multimap([['a', 'one'], ['b', 1], ['a', 'two'], ['b', 2]]); + +map.size; // 4 +map.count; // 2 + +map.get('a'); // ['one', 'two'] +map.get('b'); // [1, 2] + +map.has('a'); // true +map.has('foo'); // false + +map.has('a', 'one'); // true +map.has('b', 3); // false + +map.set('a', 'three'); +map.size; // 5 +map.count; // 2 +map.get('a'); // ['one', 'two', 'three'] + +map.set('b', 3, 4); +map.size; // 7 +map.count; // 2 + +map.delete('a', 'three'); // true +map.delete('x'); // false +map.delete('a', 'four'); // false +map.delete('b'); // true + +map.size; // 2 +map.count; // 1 + +map.set('b', 1, 2); +map.size; // 4 +map.count; // 2 + + +map.forEach(function (value, key) { + // iterates { 'one', 'a' }, { 'two', 'a' }, { 1, b }, { 2, 'b' } +}); + +map.forEachEntry(function (entry, key) { + // iterates {['one', 'two'], 'a' }, {[1, 2], 'b' } +}); + + +var keys = map.keys(); // iterator with ['a', 'b'] +keys.next().value; // 'a' +var values = map.values(); // iterator ['one', 'two', 1, 2] + +map.clear(); // undefined +map.size; // 0 +map.count; // 0 +``` + + + + +## License + +(The MIT License) + +Copyright (c) 2013, Villa.Gao ; +All rights reserved. diff --git a/node_modules/multimap/index.js b/node_modules/multimap/index.js new file mode 100644 index 0000000..818cf07 --- /dev/null +++ b/node_modules/multimap/index.js @@ -0,0 +1,226 @@ +"use strict"; + +/* global module, define */ + +function mapEach(map, operation){ + var keys = map.keys(); + var next; + while(!(next = keys.next()).done) { + operation(map.get(next.value), next.value, map); + } +} + +var Multimap = (function() { + var mapCtor; + if (typeof Map !== 'undefined') { + mapCtor = Map; + + if (!Map.prototype.keys) { + Map.prototype.keys = function() { + var keys = []; + this.forEach(function(item, key) { + keys.push(key); + }); + return keys; + }; + } + } + + function Multimap(iterable) { + var self = this; + + self._map = mapCtor; + + if (Multimap.Map) { + self._map = Multimap.Map; + } + + self._ = self._map ? new self._map() : {}; + + if (iterable) { + iterable.forEach(function(i) { + self.set(i[0], i[1]); + }); + } + } + + /** + * @param {Object} key + * @return {Array} An array of values, undefined if no such a key; + */ + Multimap.prototype.get = function(key) { + return this._map ? this._.get(key) : this._[key]; + }; + + /** + * @param {Object} key + * @param {Object} val... + */ + Multimap.prototype.set = function(key, val) { + var args = Array.prototype.slice.call(arguments); + + key = args.shift(); + + var entry = this.get(key); + if (!entry) { + entry = []; + if (this._map) + this._.set(key, entry); + else + this._[key] = entry; + } + + Array.prototype.push.apply(entry, args); + return this; + }; + + /** + * @param {Object} key + * @param {Object=} val + * @return {boolean} true if any thing changed + */ + Multimap.prototype.delete = function(key, val) { + if (!this.has(key)) + return false; + + if (arguments.length == 1) { + this._map ? (this._.delete(key)) : (delete this._[key]); + return true; + } else { + var entry = this.get(key); + var idx = entry.indexOf(val); + if (idx != -1) { + entry.splice(idx, 1); + return true; + } + } + + return false; + }; + + /** + * @param {Object} key + * @param {Object=} val + * @return {boolean} whether the map contains 'key' or 'key=>val' pair + */ + Multimap.prototype.has = function(key, val) { + var hasKey = this._map ? this._.has(key) : this._.hasOwnProperty(key); + + if (arguments.length == 1 || !hasKey) + return hasKey; + + var entry = this.get(key) || []; + return entry.indexOf(val) != -1; + }; + + + /** + * @return {Array} all the keys in the map + */ + Multimap.prototype.keys = function() { + if (this._map) + return makeIterator(this._.keys()); + + return makeIterator(Object.keys(this._)); + }; + + /** + * @return {Array} all the values in the map + */ + Multimap.prototype.values = function() { + var vals = []; + this.forEachEntry(function(entry) { + Array.prototype.push.apply(vals, entry); + }); + + return makeIterator(vals); + }; + + /** + * + */ + Multimap.prototype.forEachEntry = function(iter) { + mapEach(this, iter); + }; + + Multimap.prototype.forEach = function(iter) { + var self = this; + self.forEachEntry(function(entry, key) { + entry.forEach(function(item) { + iter(item, key, self); + }); + }); + }; + + + Multimap.prototype.clear = function() { + if (this._map) { + this._.clear(); + } else { + this._ = {}; + } + }; + + Object.defineProperty( + Multimap.prototype, + "size", { + configurable: false, + enumerable: true, + get: function() { + var total = 0; + + mapEach(this, function(value){ + total += value.length; + }); + + return total; + } + }); + + Object.defineProperty( + Multimap.prototype, + "count", { + configurable: false, + enumerable: true, + get: function() { + return this._.size; + } + }); + + var safariNext; + + try{ + safariNext = new Function('iterator', 'makeIterator', 'var keysArray = []; for(var key of iterator){keysArray.push(key);} return makeIterator(keysArray).next;'); + }catch(error){ + // for of not implemented; + } + + function makeIterator(iterator){ + if(Array.isArray(iterator)){ + var nextIndex = 0; + + return { + next: function(){ + return nextIndex < iterator.length ? + {value: iterator[nextIndex++], done: false} : + {done: true}; + } + }; + } + + // Only an issue in safari + if(!iterator.next && safariNext){ + iterator.next = safariNext(iterator, makeIterator); + } + + return iterator; + } + + return Multimap; +})(); + + +if(typeof exports === 'object' && module && module.exports) + module.exports = Multimap; +else if(typeof define === 'function' && define.amd) + define(function() { return Multimap; }); diff --git a/node_modules/multimap/package.json b/node_modules/multimap/package.json new file mode 100644 index 0000000..8eb58e4 --- /dev/null +++ b/node_modules/multimap/package.json @@ -0,0 +1,34 @@ +{ + "name": "multimap", + "version": "1.1.0", + "description": "multi-map which allow multiple values for the same key", + "main": "index.js", + "scripts": { + "lint": "./node_modules/.bin/jshint *.js test/*.js", + "test": "npm run lint; node test/index.js;node test/es6map.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/villadora/multi-map.git" + }, + "bugs": { + "url": "https://github.com/villadora/multi-map/issues" + }, + "keywords": [ + "keys", + "map", + "multiple" + ], + "dependencies": {}, + "devDependencies": { + "chai": "~1.7.2", + "es6-shim": "^0.13.0", + "jshint": "~2.1.9" + }, + "readmeFilename": "README.md", + "author": { + "name": "villa.gao", + "email": "jky239@gmail.com" + }, + "license": "MIT" +} diff --git a/node_modules/multimap/test/es6map.js b/node_modules/multimap/test/es6map.js new file mode 100644 index 0000000..c7c0c23 --- /dev/null +++ b/node_modules/multimap/test/es6map.js @@ -0,0 +1,86 @@ +"use strict"; + +var assert = require('chai').assert; +require('es6-shim'); + +var Multimap = require('..'); + +var map = new Multimap([ + ['a', 'one'], + ['b', 1], + ['a', 'two'], + ['b', 2] +]); + +assert.equal(map.size, 4); + +assert.equal(map.get('a').length, 2); +assert.equal(map.get('a')[0], 'one'); // ['one', 'two'] +assert.equal(map.get('a')[1], 'two'); // ['one', 'two'] + +assert.equal(map.get('b').length, 2); +assert.equal(map.get('b')[0], 1); // [1, 2] +assert.equal(map.get('b')[1], 2); // [1, 2] + + +assert(map.has('a'), "map contains key 'a'"); +assert(!map.has('foo'), "map does not contain key 'foo'"); + +assert(map.has('a', 'one'), "map contains entry 'a'=>'one'"); +assert(!map.has('b', 3), "map does not contain entry 'b'=>3"); + +map.set('a', 'three'); + +assert.equal(map.size, 5); +assert.equal(map.get('a').length, 3); // ['one', 'two', 'three'] + +map.set('b', 3, 4); +assert.equal(map.size, 7); + +assert(map.delete('a', 'three'), "delete 'a'=>'three'"); +assert.equal(map.size, 6); +assert(!map.delete('x'), "empty 'x' for delete"); +assert(!map.delete('a', 'four'), "no such entry 'a'=>'four'"); +assert(map.delete('b'), "delete all 'b'"); + +assert.equal(map.size, 2); + +map.set('b', 1, 2); +assert.equal(map.size, 4); // 4 + +var cnt = 0; +map.forEach(function(value, key) { + // iterates { 'a', 'one' }, { 'a', 'two' }, { 'b', 1 }, { 'b', 2 } + cnt++; + assert(key == 'a' || key == 'b', "key must be either 'a' or 'b'"); +}); + +assert.equal(cnt, 4); + +cnt = 0; +map.forEachEntry(function(entry, key) { + // iterates { 'a', ['one', 'two'] }, { 'b', [1, 2] } + cnt++; + assert(key == 'a' || key == 'b', "key must be either 'a' or 'b'"); + assert.equal(entry.length, 2); +}); + +assert.equal(cnt, 2); + + + +var keys = map.keys(); // ['a', 'b'] +assert.equal(keys.next().value, 'a'); +assert.equal(keys.next().value, 'b'); +assert(keys.next().done); + +var values = map.values(); // ['one', 'two', 1, 2] +assert.equal(values.next().value, 'one'); +assert.equal(values.next().value, 'two'); +assert.equal(values.next().value, 1); +assert.equal(values.next().value, 2); +assert(values.next().done); + +map.clear(); + +assert.equal(map.size, 0); diff --git a/node_modules/multimap/test/index.js b/node_modules/multimap/test/index.js new file mode 100644 index 0000000..b4fd35c --- /dev/null +++ b/node_modules/multimap/test/index.js @@ -0,0 +1,91 @@ +"use strict"; + +var assert = require('chai').assert; +var Multimap = require('..'); + +var map = new Multimap([ + ['a', 'one'], + ['b', 1], + ['a', 'two'], + ['b', 2] +]); + +assert.equal(map.size, 4); +assert.equal(map.count, 2); + +assert.equal(map.get('a').length, 2); +assert.equal(map.get('a')[0], 'one'); // ['one', 'two'] +assert.equal(map.get('a')[1], 'two'); // ['one', 'two'] + +assert.equal(map.get('b').length, 2); +assert.equal(map.get('b')[0], 1); // [1, 2] +assert.equal(map.get('b')[1], 2); // [1, 2] + + +assert(map.has('a'), "map contains key 'a'"); +assert(!map.has('foo'), "map does not contain key 'foo'"); + +assert(map.has('a', 'one'), "map contains entry 'a'=>'one'"); +assert(!map.has('b', 3), "map does not contain entry 'b'=>3"); + +map.set('a', 'three'); + +assert.equal(map.size, 5); +assert.equal(map.count, 2); +assert.equal(map.get('a').length, 3); // ['one', 'two', 'three'] + +map.set('b', 3, 4); +assert.equal(map.size, 7); +assert.equal(map.count, 2); + +assert(map.delete('a', 'three'), "delete 'a'=>'three'"); +assert.equal(map.size, 6); +assert.equal(map.count, 2); +assert(!map.delete('x'), "empty 'x' for delete"); +assert(!map.delete('a', 'four'), "no such entry 'a'=>'four'"); +assert(map.delete('b'), "delete all 'b'"); + +assert.equal(map.size, 2); +assert.equal(map.count, 1); + +map.set('b', 1, 2); +assert.equal(map.size, 4); // 4 +assert.equal(map.count, 2); + +var cnt = 0; +map.forEach(function(value, key) { + // iterates { 'a', 'one' }, { 'a', 'two' }, { 'b', 1 }, { 'b', 2 } + cnt++; + assert(key == 'a' || key == 'b', "key must be either 'a' or 'b'"); +}); + +assert.equal(cnt, 4); + +cnt = 0; +map.forEachEntry(function(entry, key) { + // iterates { 'a', ['one', 'two'] }, { 'b', [1, 2] } + cnt++; + assert(key == 'a' || key == 'b', "key must be either 'a' or 'b'"); + assert.equal(entry.length, 2); +}); + +assert.equal(cnt, 2); + + +var keys = map.keys(); // ['a', 'b'] +assert.equal(keys.next().value, 'a'); +assert.equal(keys.next().value, 'b'); +assert(keys.next().done); + +var values = map.values(); // ['one', 'two', 1, 2] +assert.equal(values.next().value, 'one'); +assert.equal(values.next().value, 'two'); +assert.equal(values.next().value, 1); +assert.equal(values.next().value, 2); +assert(values.next().done); + + +map.clear(); + +assert.equal(map.size, 0); +assert.equal(map.count, 0); diff --git a/node_modules/multimap/test/test.html b/node_modules/multimap/test/test.html new file mode 100644 index 0000000..899d9de --- /dev/null +++ b/node_modules/multimap/test/test.html @@ -0,0 +1,92 @@ + + + MultiMap Tests + + + + + + + diff --git a/node_modules/shift-ast/LICENSE b/node_modules/shift-ast/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/node_modules/shift-ast/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/node_modules/shift-ast/README.md b/node_modules/shift-ast/README.md new file mode 100644 index 0000000..aa831a4 --- /dev/null +++ b/node_modules/shift-ast/README.md @@ -0,0 +1,63 @@ +Shift AST Constructors +====================== + + +## About + +This project provides constructors for +[Shift format](https://github.com/shapesecurity/shift-spec) AST nodes. + +The resulting objects are suitable for use with the rest of the [Shift suite](http://shift-ast.org/). + +There is a version with typechecking available as `shift-ast/checked` for use during development. + +## Status + +[Stable](http://nodejs.org/api/documentation.html#documentation_stability_index). + + +## Installation + +```sh +npm install shift-ast +``` + + +## Usage + +```js +var AST = require("shift-ast"); // or "shift-ast/checked" +var myAstFragment = new AST.LabeledStatement({ + label: "label", + body: new AST.EmptyStatement +}); +``` + + +## Contributing + +* Open a Github issue with a description of your desired change. If one exists already, leave a message stating that you are working on it with the date you expect it to be complete. +* Fork this repo, and clone the forked repo. +* Install dependencies with `npm install`. +* Build and test in your environment with `npm run build && npm test`. +* Create a feature branch. Make your changes. Add tests. +* Build and test in your environment with `npm run build && npm test`. +* Make a commit that includes the text "fixes #*XX*" where *XX* is the Github issue. +* Open a Pull Request on Github. + + +## License + + Copyright 2014 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. diff --git a/node_modules/shift-ast/checked.js b/node_modules/shift-ast/checked.js new file mode 100644 index 0000000..45938ea --- /dev/null +++ b/node_modules/shift-ast/checked.js @@ -0,0 +1,17 @@ +/** + * 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. + */ + +module.exports = require('./gen/checked'); diff --git a/node_modules/shift-ast/gen/checked.d.ts b/node_modules/shift-ast/gen/checked.d.ts new file mode 100644 index 0000000..1177c46 --- /dev/null +++ b/node_modules/shift-ast/gen/checked.d.ts @@ -0,0 +1,19 @@ +// Generated by scripts/generate-dts.js. + +/** + * Copyright 2019 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 * from './index'; diff --git a/node_modules/shift-ast/gen/checked.js b/node_modules/shift-ast/gen/checked.js new file mode 100644 index 0000000..734a263 --- /dev/null +++ b/node_modules/shift-ast/gen/checked.js @@ -0,0 +1,2048 @@ +// 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.type = 'ExpressionStatement'; + this.expression = expression; + } +}; + +exports.ForAwaitStatement = class { + constructor(arg, ...extraArgs) { + const { left, right, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ForAwaitStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'left', 'right'])) { + throw new TypeError('Argument to ForAwaitStatement constructor has wrong keys: expected {left, right, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof left === 'undefined' || (((left.type !== 'ArrayAssignmentTarget') && (left.type !== 'ObjectAssignmentTarget')) && ((left.type !== 'AssignmentTargetIdentifier') && ((left.type !== 'ComputedMemberAssignmentTarget') && (left.type !== 'StaticMemberAssignmentTarget')))) && (left.type !== 'VariableDeclaration')) { + throw new TypeError('Field "left" of ForAwaitStatement constructor argument is of incorrect type (expected one of {ArrayAssignmentTarget, ObjectAssignmentTarget, AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget, VariableDeclaration}, got ' + printActualType(left) + ')'); + } + if (isNotExpression(right)) { + throw new TypeError('Field "right" of ForAwaitStatement constructor argument is of incorrect type (expected Expression, got ' + printActualType(right) + ')'); + } + if (isNotStatement(body)) { + throw new TypeError('Field "body" of ForAwaitStatement constructor argument is of incorrect type (expected Statement, got ' + printActualType(body) + ')'); + } + this.type = 'ForAwaitStatement'; + this.left = left; + this.right = right; + this.body = body; + } +}; + +exports.ForInStatement = class { + constructor(arg, ...extraArgs) { + const { left, right, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ForInStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'left', 'right'])) { + throw new TypeError('Argument to ForInStatement constructor has wrong keys: expected {left, right, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof left === 'undefined' || (((left.type !== 'ArrayAssignmentTarget') && (left.type !== 'ObjectAssignmentTarget')) && ((left.type !== 'AssignmentTargetIdentifier') && ((left.type !== 'ComputedMemberAssignmentTarget') && (left.type !== 'StaticMemberAssignmentTarget')))) && (left.type !== 'VariableDeclaration')) { + throw new TypeError('Field "left" of ForInStatement constructor argument is of incorrect type (expected one of {ArrayAssignmentTarget, ObjectAssignmentTarget, AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget, VariableDeclaration}, got ' + printActualType(left) + ')'); + } + if (isNotExpression(right)) { + throw new TypeError('Field "right" of ForInStatement constructor argument is of incorrect type (expected Expression, got ' + printActualType(right) + ')'); + } + if (isNotStatement(body)) { + throw new TypeError('Field "body" of ForInStatement constructor argument is of incorrect type (expected Statement, got ' + printActualType(body) + ')'); + } + this.type = 'ForInStatement'; + this.left = left; + this.right = right; + this.body = body; + } +}; + +exports.ForOfStatement = class { + constructor(arg, ...extraArgs) { + const { left, right, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ForOfStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'left', 'right'])) { + throw new TypeError('Argument to ForOfStatement constructor has wrong keys: expected {left, right, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof left === 'undefined' || (((left.type !== 'ArrayAssignmentTarget') && (left.type !== 'ObjectAssignmentTarget')) && ((left.type !== 'AssignmentTargetIdentifier') && ((left.type !== 'ComputedMemberAssignmentTarget') && (left.type !== 'StaticMemberAssignmentTarget')))) && (left.type !== 'VariableDeclaration')) { + throw new TypeError('Field "left" of ForOfStatement constructor argument is of incorrect type (expected one of {ArrayAssignmentTarget, ObjectAssignmentTarget, AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget, VariableDeclaration}, got ' + printActualType(left) + ')'); + } + if (isNotExpression(right)) { + throw new TypeError('Field "right" of ForOfStatement constructor argument is of incorrect type (expected Expression, got ' + printActualType(right) + ')'); + } + if (isNotStatement(body)) { + throw new TypeError('Field "body" of ForOfStatement constructor argument is of incorrect type (expected Statement, got ' + printActualType(body) + ')'); + } + this.type = 'ForOfStatement'; + this.left = left; + this.right = right; + this.body = body; + } +}; + +exports.ForStatement = class { + constructor(arg, ...extraArgs) { + const { init, test, update, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ForStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'init', 'test', 'update'])) { + throw new TypeError('Argument to ForStatement constructor has wrong keys: expected {init, test, update, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof init === 'undefined' || init !== null && ((isNotExpression(init)) && (init.type !== 'VariableDeclaration'))) { + throw new TypeError('Field "init" of ForStatement constructor argument is of incorrect type (expected null or one of {Expression, VariableDeclaration}, got ' + printActualType(init) + ')'); + } + if (typeof test === 'undefined' || test !== null && (isNotExpression(test))) { + throw new TypeError('Field "test" of ForStatement constructor argument is of incorrect type (expected null or Expression, got ' + printActualType(test) + ')'); + } + if (typeof update === 'undefined' || update !== null && (isNotExpression(update))) { + throw new TypeError('Field "update" of ForStatement constructor argument is of incorrect type (expected null or Expression, got ' + printActualType(update) + ')'); + } + if (isNotStatement(body)) { + throw new TypeError('Field "body" of ForStatement constructor argument is of incorrect type (expected Statement, got ' + printActualType(body) + ')'); + } + this.type = 'ForStatement'; + this.init = init; + this.test = test; + this.update = update; + this.body = body; + } +}; + +exports.FormalParameters = class { + constructor(arg, ...extraArgs) { + const { items, rest } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('FormalParameters constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['items', 'rest'])) { + throw new TypeError('Argument to FormalParameters constructor has wrong keys: expected {items, rest}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (!Array.isArray(items) || items.some(f => typeof f === 'undefined' || (f.type !== 'BindingWithDefault') && ((f.type !== 'BindingIdentifier') && ((f.type !== 'ArrayBinding') && (f.type !== 'ObjectBinding'))))) { + throw new TypeError('Field "items" of FormalParameters constructor argument is of incorrect type (expected [one of {BindingWithDefault, BindingIdentifier, ArrayBinding, ObjectBinding}], got ' + printActualType(items) + ')'); + } + if (typeof rest === 'undefined' || rest !== null && ((rest.type !== 'BindingIdentifier') && ((rest.type !== 'ArrayBinding') && (rest.type !== 'ObjectBinding')))) { + throw new TypeError('Field "rest" of FormalParameters constructor argument is of incorrect type (expected null or one of {BindingIdentifier, ArrayBinding, ObjectBinding}, got ' + printActualType(rest) + ')'); + } + this.type = 'FormalParameters'; + this.items = items; + this.rest = rest; + } +}; + +exports.FunctionBody = class { + constructor(arg, ...extraArgs) { + const { directives, statements } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('FunctionBody constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['directives', 'statements'])) { + throw new TypeError('Argument to FunctionBody constructor has wrong keys: expected {directives, statements}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (!Array.isArray(directives) || directives.some(f => typeof f === 'undefined' || f.type !== 'Directive')) { + throw new TypeError('Field "directives" of FunctionBody constructor argument is of incorrect type (expected [Directive], got ' + printActualType(directives) + ')'); + } + if (!Array.isArray(statements) || statements.some(f => isNotStatement(f))) { + throw new TypeError('Field "statements" of FunctionBody constructor argument is of incorrect type (expected [Statement], got ' + printActualType(statements) + ')'); + } + this.type = 'FunctionBody'; + this.directives = directives; + this.statements = statements; + } +}; + +exports.FunctionDeclaration = class { + constructor(arg, ...extraArgs) { + const { isAsync, isGenerator, name, params, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('FunctionDeclaration constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'isAsync', 'isGenerator', 'name', 'params'])) { + throw new TypeError('Argument to FunctionDeclaration constructor has wrong keys: expected {isAsync, isGenerator, name, params, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof isAsync !== 'boolean') { + throw new TypeError('Field "isAsync" of FunctionDeclaration constructor argument is of incorrect type (expected boolean, got ' + printActualType(isAsync) + ')'); + } + if (typeof isGenerator !== 'boolean') { + throw new TypeError('Field "isGenerator" of FunctionDeclaration constructor argument is of incorrect type (expected boolean, got ' + printActualType(isGenerator) + ')'); + } + if (typeof name === 'undefined' || name.type !== 'BindingIdentifier') { + throw new TypeError('Field "name" of FunctionDeclaration constructor argument is of incorrect type (expected BindingIdentifier, got ' + printActualType(name) + ')'); + } + if (typeof params === 'undefined' || params.type !== 'FormalParameters') { + throw new TypeError('Field "params" of FunctionDeclaration constructor argument is of incorrect type (expected FormalParameters, got ' + printActualType(params) + ')'); + } + if (typeof body === 'undefined' || body.type !== 'FunctionBody') { + throw new TypeError('Field "body" of FunctionDeclaration constructor argument is of incorrect type (expected FunctionBody, got ' + printActualType(body) + ')'); + } + this.type = 'FunctionDeclaration'; + this.isAsync = isAsync; + this.isGenerator = isGenerator; + this.name = name; + this.params = params; + this.body = body; + } +}; + +exports.FunctionExpression = class { + constructor(arg, ...extraArgs) { + const { isAsync, isGenerator, name, params, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('FunctionExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'isAsync', 'isGenerator', 'name', 'params'])) { + throw new TypeError('Argument to FunctionExpression constructor has wrong keys: expected {isAsync, isGenerator, name, params, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof isAsync !== 'boolean') { + throw new TypeError('Field "isAsync" of FunctionExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(isAsync) + ')'); + } + if (typeof isGenerator !== 'boolean') { + throw new TypeError('Field "isGenerator" of FunctionExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(isGenerator) + ')'); + } + if (typeof name === 'undefined' || name !== null && (name.type !== 'BindingIdentifier')) { + throw new TypeError('Field "name" of FunctionExpression constructor argument is of incorrect type (expected null or BindingIdentifier, got ' + printActualType(name) + ')'); + } + if (typeof params === 'undefined' || params.type !== 'FormalParameters') { + throw new TypeError('Field "params" of FunctionExpression constructor argument is of incorrect type (expected FormalParameters, got ' + printActualType(params) + ')'); + } + if (typeof body === 'undefined' || body.type !== 'FunctionBody') { + throw new TypeError('Field "body" of FunctionExpression constructor argument is of incorrect type (expected FunctionBody, got ' + printActualType(body) + ')'); + } + this.type = 'FunctionExpression'; + this.isAsync = isAsync; + this.isGenerator = isGenerator; + this.name = name; + this.params = params; + this.body = body; + } +}; + +exports.Getter = class { + constructor(arg, ...extraArgs) { + const { name, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('Getter constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'name'])) { + throw new TypeError('Argument to Getter constructor has wrong keys: expected {name, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof name === 'undefined' || (name.type !== 'ComputedPropertyName') && (name.type !== 'StaticPropertyName')) { + throw new TypeError('Field "name" of Getter constructor argument is of incorrect type (expected one of {ComputedPropertyName, StaticPropertyName}, got ' + printActualType(name) + ')'); + } + if (typeof body === 'undefined' || body.type !== 'FunctionBody') { + throw new TypeError('Field "body" of Getter constructor argument is of incorrect type (expected FunctionBody, got ' + printActualType(body) + ')'); + } + this.type = 'Getter'; + this.name = name; + this.body = body; + } +}; + +exports.IdentifierExpression = class { + constructor(arg, ...extraArgs) { + const { name } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('IdentifierExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['name'])) { + throw new TypeError('Argument to IdentifierExpression constructor has wrong keys: expected {name}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof name !== 'string') { + throw new TypeError('Field "name" of IdentifierExpression constructor argument is of incorrect type (expected string, got ' + printActualType(name) + ')'); + } + this.type = 'IdentifierExpression'; + this.name = name; + } +}; + +exports.IfStatement = class { + constructor(arg, ...extraArgs) { + const { test, consequent, alternate } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('IfStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['alternate', 'consequent', 'test'])) { + throw new TypeError('Argument to IfStatement constructor has wrong keys: expected {test, consequent, alternate}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(test)) { + throw new TypeError('Field "test" of IfStatement constructor argument is of incorrect type (expected Expression, got ' + printActualType(test) + ')'); + } + if (isNotStatement(consequent)) { + throw new TypeError('Field "consequent" of IfStatement constructor argument is of incorrect type (expected Statement, got ' + printActualType(consequent) + ')'); + } + if (typeof alternate === 'undefined' || alternate !== null && (isNotStatement(alternate))) { + throw new TypeError('Field "alternate" of IfStatement constructor argument is of incorrect type (expected null or Statement, got ' + printActualType(alternate) + ')'); + } + this.type = 'IfStatement'; + this.test = test; + this.consequent = consequent; + this.alternate = alternate; + } +}; + +exports.Import = class { + constructor(arg, ...extraArgs) { + const { defaultBinding, namedImports, moduleSpecifier } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('Import constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['defaultBinding', 'moduleSpecifier', 'namedImports'])) { + throw new TypeError('Argument to Import constructor has wrong keys: expected {defaultBinding, namedImports, moduleSpecifier}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof defaultBinding === 'undefined' || defaultBinding !== null && (defaultBinding.type !== 'BindingIdentifier')) { + throw new TypeError('Field "defaultBinding" of Import constructor argument is of incorrect type (expected null or BindingIdentifier, got ' + printActualType(defaultBinding) + ')'); + } + if (!Array.isArray(namedImports) || namedImports.some(f => typeof f === 'undefined' || f.type !== 'ImportSpecifier')) { + throw new TypeError('Field "namedImports" of Import constructor argument is of incorrect type (expected [ImportSpecifier], got ' + printActualType(namedImports) + ')'); + } + if (typeof moduleSpecifier !== 'string') { + throw new TypeError('Field "moduleSpecifier" of Import constructor argument is of incorrect type (expected string, got ' + printActualType(moduleSpecifier) + ')'); + } + this.type = 'Import'; + this.defaultBinding = defaultBinding; + this.namedImports = namedImports; + this.moduleSpecifier = moduleSpecifier; + } +}; + +exports.ImportNamespace = class { + constructor(arg, ...extraArgs) { + const { defaultBinding, namespaceBinding, moduleSpecifier } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ImportNamespace constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['defaultBinding', 'moduleSpecifier', 'namespaceBinding'])) { + throw new TypeError('Argument to ImportNamespace constructor has wrong keys: expected {defaultBinding, namespaceBinding, moduleSpecifier}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof defaultBinding === 'undefined' || defaultBinding !== null && (defaultBinding.type !== 'BindingIdentifier')) { + throw new TypeError('Field "defaultBinding" of ImportNamespace constructor argument is of incorrect type (expected null or BindingIdentifier, got ' + printActualType(defaultBinding) + ')'); + } + if (typeof namespaceBinding === 'undefined' || namespaceBinding.type !== 'BindingIdentifier') { + throw new TypeError('Field "namespaceBinding" of ImportNamespace constructor argument is of incorrect type (expected BindingIdentifier, got ' + printActualType(namespaceBinding) + ')'); + } + if (typeof moduleSpecifier !== 'string') { + throw new TypeError('Field "moduleSpecifier" of ImportNamespace constructor argument is of incorrect type (expected string, got ' + printActualType(moduleSpecifier) + ')'); + } + this.type = 'ImportNamespace'; + this.defaultBinding = defaultBinding; + this.namespaceBinding = namespaceBinding; + this.moduleSpecifier = moduleSpecifier; + } +}; + +exports.ImportSpecifier = class { + constructor(arg, ...extraArgs) { + const { name, binding } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ImportSpecifier constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'name'])) { + throw new TypeError('Argument to ImportSpecifier constructor has wrong keys: expected {name, binding}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof name === 'undefined' || name !== null && (typeof name !== 'string')) { + throw new TypeError('Field "name" of ImportSpecifier constructor argument is of incorrect type (expected null or string, got ' + printActualType(name) + ')'); + } + if (typeof binding === 'undefined' || binding.type !== 'BindingIdentifier') { + throw new TypeError('Field "binding" of ImportSpecifier constructor argument is of incorrect type (expected BindingIdentifier, got ' + printActualType(binding) + ')'); + } + this.type = 'ImportSpecifier'; + this.name = name; + this.binding = binding; + } +}; + +exports.LabeledStatement = class { + constructor(arg, ...extraArgs) { + const { label, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('LabeledStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'label'])) { + throw new TypeError('Argument to LabeledStatement constructor has wrong keys: expected {label, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof label !== 'string') { + throw new TypeError('Field "label" of LabeledStatement constructor argument is of incorrect type (expected string, got ' + printActualType(label) + ')'); + } + if (isNotStatement(body)) { + throw new TypeError('Field "body" of LabeledStatement constructor argument is of incorrect type (expected Statement, got ' + printActualType(body) + ')'); + } + this.type = 'LabeledStatement'; + this.label = label; + this.body = body; + } +}; + +exports.LiteralBooleanExpression = class { + constructor(arg, ...extraArgs) { + const { value } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('LiteralBooleanExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['value'])) { + throw new TypeError('Argument to LiteralBooleanExpression constructor has wrong keys: expected {value}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof value !== 'boolean') { + throw new TypeError('Field "value" of LiteralBooleanExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(value) + ')'); + } + this.type = 'LiteralBooleanExpression'; + this.value = value; + } +}; + +exports.LiteralInfinityExpression = 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('LiteralInfinityExpression constructor takes no arguments'); + } + this.type = 'LiteralInfinityExpression'; + } +}; + +exports.LiteralNullExpression = 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('LiteralNullExpression constructor takes no arguments'); + } + this.type = 'LiteralNullExpression'; + } +}; + +exports.LiteralNumericExpression = class { + constructor(arg, ...extraArgs) { + const { value } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('LiteralNumericExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['value'])) { + throw new TypeError('Argument to LiteralNumericExpression constructor has wrong keys: expected {value}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof value !== 'number') { + throw new TypeError('Field "value" of LiteralNumericExpression constructor argument is of incorrect type (expected number, got ' + printActualType(value) + ')'); + } + this.type = 'LiteralNumericExpression'; + this.value = value; + } +}; + +exports.LiteralRegExpExpression = class { + constructor(arg, ...extraArgs) { + const { pattern, global, ignoreCase, multiLine, dotAll, unicode, sticky } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('LiteralRegExpExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['dotAll', 'global', 'ignoreCase', 'multiLine', 'pattern', 'sticky', 'unicode'])) { + throw new TypeError('Argument to LiteralRegExpExpression constructor has wrong keys: expected {pattern, global, ignoreCase, multiLine, dotAll, unicode, sticky}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof pattern !== 'string') { + throw new TypeError('Field "pattern" of LiteralRegExpExpression constructor argument is of incorrect type (expected string, got ' + printActualType(pattern) + ')'); + } + if (typeof global !== 'boolean') { + throw new TypeError('Field "global" of LiteralRegExpExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(global) + ')'); + } + if (typeof ignoreCase !== 'boolean') { + throw new TypeError('Field "ignoreCase" of LiteralRegExpExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(ignoreCase) + ')'); + } + if (typeof multiLine !== 'boolean') { + throw new TypeError('Field "multiLine" of LiteralRegExpExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(multiLine) + ')'); + } + if (typeof dotAll !== 'boolean') { + throw new TypeError('Field "dotAll" of LiteralRegExpExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(dotAll) + ')'); + } + if (typeof unicode !== 'boolean') { + throw new TypeError('Field "unicode" of LiteralRegExpExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(unicode) + ')'); + } + if (typeof sticky !== 'boolean') { + throw new TypeError('Field "sticky" of LiteralRegExpExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(sticky) + ')'); + } + this.type = 'LiteralRegExpExpression'; + this.pattern = pattern; + this.global = global; + this.ignoreCase = ignoreCase; + this.multiLine = multiLine; + this.dotAll = dotAll; + this.unicode = unicode; + this.sticky = sticky; + } +}; + +exports.LiteralStringExpression = class { + constructor(arg, ...extraArgs) { + const { value } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('LiteralStringExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['value'])) { + throw new TypeError('Argument to LiteralStringExpression constructor has wrong keys: expected {value}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof value !== 'string') { + throw new TypeError('Field "value" of LiteralStringExpression constructor argument is of incorrect type (expected string, got ' + printActualType(value) + ')'); + } + this.type = 'LiteralStringExpression'; + this.value = value; + } +}; + +exports.Method = class { + constructor(arg, ...extraArgs) { + const { isAsync, isGenerator, name, params, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('Method constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'isAsync', 'isGenerator', 'name', 'params'])) { + throw new TypeError('Argument to Method constructor has wrong keys: expected {isAsync, isGenerator, name, params, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof isAsync !== 'boolean') { + throw new TypeError('Field "isAsync" of Method constructor argument is of incorrect type (expected boolean, got ' + printActualType(isAsync) + ')'); + } + if (typeof isGenerator !== 'boolean') { + throw new TypeError('Field "isGenerator" of Method constructor argument is of incorrect type (expected boolean, got ' + printActualType(isGenerator) + ')'); + } + if (typeof name === 'undefined' || (name.type !== 'ComputedPropertyName') && (name.type !== 'StaticPropertyName')) { + throw new TypeError('Field "name" of Method constructor argument is of incorrect type (expected one of {ComputedPropertyName, StaticPropertyName}, got ' + printActualType(name) + ')'); + } + if (typeof params === 'undefined' || params.type !== 'FormalParameters') { + throw new TypeError('Field "params" of Method constructor argument is of incorrect type (expected FormalParameters, got ' + printActualType(params) + ')'); + } + if (typeof body === 'undefined' || body.type !== 'FunctionBody') { + throw new TypeError('Field "body" of Method constructor argument is of incorrect type (expected FunctionBody, got ' + printActualType(body) + ')'); + } + this.type = 'Method'; + this.isAsync = isAsync; + this.isGenerator = isGenerator; + this.name = name; + this.params = params; + this.body = body; + } +}; + +exports.Module = class { + constructor(arg, ...extraArgs) { + const { directives, items } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('Module constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['directives', 'items'])) { + throw new TypeError('Argument to Module constructor has wrong keys: expected {directives, items}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (!Array.isArray(directives) || directives.some(f => typeof f === 'undefined' || f.type !== 'Directive')) { + throw new TypeError('Field "directives" of Module constructor argument is of incorrect type (expected [Directive], got ' + printActualType(directives) + ')'); + } + if (!Array.isArray(items) || items.some(f => typeof f === 'undefined' || ((f.type !== 'Export') && (f.type !== 'ExportAllFrom') && (f.type !== 'ExportDefault') && (f.type !== 'ExportFrom') && (f.type !== 'ExportLocals')) && ((f.type !== 'Import') && (f.type !== 'ImportNamespace')) && (isNotStatement(f)))) { + throw new TypeError('Field "items" of Module constructor argument is of incorrect type (expected [one of {Export, ExportAllFrom, ExportDefault, ExportFrom, ExportLocals, Import, ImportNamespace, Statement}], got ' + printActualType(items) + ')'); + } + this.type = 'Module'; + this.directives = directives; + this.items = items; + } +}; + +exports.NewExpression = class { + constructor(arg, ...extraArgs) { + const { callee, arguments: _arguments } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('NewExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['arguments', 'callee'])) { + throw new TypeError('Argument to NewExpression constructor has wrong keys: expected {callee, arguments}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(callee)) { + throw new TypeError('Field "callee" of NewExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(callee) + ')'); + } + if (!Array.isArray(_arguments) || _arguments.some(f => typeof f === 'undefined' || (isNotExpression(f)) && (f.type !== 'SpreadElement'))) { + throw new TypeError('Field "arguments" of NewExpression constructor argument is of incorrect type (expected [one of {Expression, SpreadElement}], got ' + printActualType(_arguments) + ')'); + } + this.type = 'NewExpression'; + this.callee = callee; + this.arguments = _arguments; + } +}; + +exports.NewTargetExpression = 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('NewTargetExpression constructor takes no arguments'); + } + this.type = 'NewTargetExpression'; + } +}; + +exports.ObjectAssignmentTarget = class { + constructor(arg, ...extraArgs) { + const { properties, rest } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ObjectAssignmentTarget constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['properties', 'rest'])) { + throw new TypeError('Argument to ObjectAssignmentTarget constructor has wrong keys: expected {properties, rest}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (!Array.isArray(properties) || properties.some(f => typeof f === 'undefined' || (f.type !== 'AssignmentTargetPropertyIdentifier') && (f.type !== 'AssignmentTargetPropertyProperty'))) { + throw new TypeError('Field "properties" of ObjectAssignmentTarget constructor argument is of incorrect type (expected [one of {AssignmentTargetPropertyIdentifier, AssignmentTargetPropertyProperty}], got ' + printActualType(properties) + ')'); + } + if (typeof rest === 'undefined' || rest !== null && ((rest.type !== 'AssignmentTargetIdentifier') && ((rest.type !== 'ComputedMemberAssignmentTarget') && (rest.type !== 'StaticMemberAssignmentTarget')))) { + throw new TypeError('Field "rest" of ObjectAssignmentTarget constructor argument is of incorrect type (expected null or one of {AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget}, got ' + printActualType(rest) + ')'); + } + this.type = 'ObjectAssignmentTarget'; + this.properties = properties; + this.rest = rest; + } +}; + +exports.ObjectBinding = class { + constructor(arg, ...extraArgs) { + const { properties, rest } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ObjectBinding constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['properties', 'rest'])) { + throw new TypeError('Argument to ObjectBinding constructor has wrong keys: expected {properties, rest}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (!Array.isArray(properties) || properties.some(f => typeof f === 'undefined' || (f.type !== 'BindingPropertyIdentifier') && (f.type !== 'BindingPropertyProperty'))) { + throw new TypeError('Field "properties" of ObjectBinding constructor argument is of incorrect type (expected [one of {BindingPropertyIdentifier, BindingPropertyProperty}], got ' + printActualType(properties) + ')'); + } + if (typeof rest === 'undefined' || rest !== null && (rest.type !== 'BindingIdentifier')) { + throw new TypeError('Field "rest" of ObjectBinding constructor argument is of incorrect type (expected null or BindingIdentifier, got ' + printActualType(rest) + ')'); + } + this.type = 'ObjectBinding'; + this.properties = properties; + this.rest = rest; + } +}; + +exports.ObjectExpression = class { + constructor(arg, ...extraArgs) { + const { properties } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ObjectExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['properties'])) { + throw new TypeError('Argument to ObjectExpression constructor has wrong keys: expected {properties}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (!Array.isArray(properties) || properties.some(f => typeof f === 'undefined' || ((f.type !== 'DataProperty') && ((f.type !== 'Getter') && (f.type !== 'Method') && (f.type !== 'Setter'))) && (f.type !== 'ShorthandProperty') && (f.type !== 'SpreadProperty'))) { + throw new TypeError('Field "properties" of ObjectExpression constructor argument is of incorrect type (expected [one of {DataProperty, Getter, Method, Setter, ShorthandProperty, SpreadProperty}], got ' + printActualType(properties) + ')'); + } + this.type = 'ObjectExpression'; + this.properties = properties; + } +}; + +exports.ReturnStatement = class { + constructor(arg, ...extraArgs) { + const { expression } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ReturnStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['expression'])) { + throw new TypeError('Argument to ReturnStatement constructor has wrong keys: expected {expression}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof expression === 'undefined' || expression !== null && (isNotExpression(expression))) { + throw new TypeError('Field "expression" of ReturnStatement constructor argument is of incorrect type (expected null or Expression, got ' + printActualType(expression) + ')'); + } + this.type = 'ReturnStatement'; + this.expression = expression; + } +}; + +exports.Script = class { + constructor(arg, ...extraArgs) { + const { directives, statements } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('Script constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['directives', 'statements'])) { + throw new TypeError('Argument to Script constructor has wrong keys: expected {directives, statements}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (!Array.isArray(directives) || directives.some(f => typeof f === 'undefined' || f.type !== 'Directive')) { + throw new TypeError('Field "directives" of Script constructor argument is of incorrect type (expected [Directive], got ' + printActualType(directives) + ')'); + } + if (!Array.isArray(statements) || statements.some(f => isNotStatement(f))) { + throw new TypeError('Field "statements" of Script constructor argument is of incorrect type (expected [Statement], got ' + printActualType(statements) + ')'); + } + this.type = 'Script'; + this.directives = directives; + this.statements = statements; + } +}; + +exports.Setter = class { + constructor(arg, ...extraArgs) { + const { name, param, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('Setter constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'name', 'param'])) { + throw new TypeError('Argument to Setter constructor has wrong keys: expected {name, param, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof name === 'undefined' || (name.type !== 'ComputedPropertyName') && (name.type !== 'StaticPropertyName')) { + throw new TypeError('Field "name" of Setter constructor argument is of incorrect type (expected one of {ComputedPropertyName, StaticPropertyName}, got ' + printActualType(name) + ')'); + } + if (typeof param === 'undefined' || (param.type !== 'BindingWithDefault') && ((param.type !== 'BindingIdentifier') && ((param.type !== 'ArrayBinding') && (param.type !== 'ObjectBinding')))) { + throw new TypeError('Field "param" of Setter constructor argument is of incorrect type (expected one of {BindingWithDefault, BindingIdentifier, ArrayBinding, ObjectBinding}, got ' + printActualType(param) + ')'); + } + if (typeof body === 'undefined' || body.type !== 'FunctionBody') { + throw new TypeError('Field "body" of Setter constructor argument is of incorrect type (expected FunctionBody, got ' + printActualType(body) + ')'); + } + this.type = 'Setter'; + this.name = name; + this.param = param; + this.body = body; + } +}; + +exports.ShorthandProperty = class { + constructor(arg, ...extraArgs) { + const { name } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ShorthandProperty constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['name'])) { + throw new TypeError('Argument to ShorthandProperty constructor has wrong keys: expected {name}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof name === 'undefined' || name.type !== 'IdentifierExpression') { + throw new TypeError('Field "name" of ShorthandProperty constructor argument is of incorrect type (expected IdentifierExpression, got ' + printActualType(name) + ')'); + } + this.type = 'ShorthandProperty'; + this.name = name; + } +}; + +exports.SpreadElement = class { + constructor(arg, ...extraArgs) { + const { expression } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('SpreadElement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['expression'])) { + throw new TypeError('Argument to SpreadElement constructor has wrong keys: expected {expression}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(expression)) { + throw new TypeError('Field "expression" of SpreadElement constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')'); + } + this.type = 'SpreadElement'; + this.expression = expression; + } +}; + +exports.SpreadProperty = class { + constructor(arg, ...extraArgs) { + const { expression } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('SpreadProperty constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['expression'])) { + throw new TypeError('Argument to SpreadProperty constructor has wrong keys: expected {expression}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(expression)) { + throw new TypeError('Field "expression" of SpreadProperty constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')'); + } + this.type = 'SpreadProperty'; + this.expression = expression; + } +}; + +exports.StaticMemberAssignmentTarget = class { + constructor(arg, ...extraArgs) { + const { object, property } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('StaticMemberAssignmentTarget constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['object', 'property'])) { + throw new TypeError('Argument to StaticMemberAssignmentTarget constructor has wrong keys: expected {object, property}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof object === 'undefined' || (isNotExpression(object)) && (object.type !== 'Super')) { + throw new TypeError('Field "object" of StaticMemberAssignmentTarget constructor argument is of incorrect type (expected one of {Expression, Super}, got ' + printActualType(object) + ')'); + } + if (typeof property !== 'string') { + throw new TypeError('Field "property" of StaticMemberAssignmentTarget constructor argument is of incorrect type (expected string, got ' + printActualType(property) + ')'); + } + this.type = 'StaticMemberAssignmentTarget'; + this.object = object; + this.property = property; + } +}; + +exports.StaticMemberExpression = class { + constructor(arg, ...extraArgs) { + const { object, property } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('StaticMemberExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['object', 'property'])) { + throw new TypeError('Argument to StaticMemberExpression constructor has wrong keys: expected {object, property}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof object === 'undefined' || (isNotExpression(object)) && (object.type !== 'Super')) { + throw new TypeError('Field "object" of StaticMemberExpression constructor argument is of incorrect type (expected one of {Expression, Super}, got ' + printActualType(object) + ')'); + } + if (typeof property !== 'string') { + throw new TypeError('Field "property" of StaticMemberExpression constructor argument is of incorrect type (expected string, got ' + printActualType(property) + ')'); + } + this.type = 'StaticMemberExpression'; + this.object = object; + this.property = property; + } +}; + +exports.StaticPropertyName = class { + constructor(arg, ...extraArgs) { + const { value } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('StaticPropertyName constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['value'])) { + throw new TypeError('Argument to StaticPropertyName constructor has wrong keys: expected {value}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof value !== 'string') { + throw new TypeError('Field "value" of StaticPropertyName constructor argument is of incorrect type (expected string, got ' + printActualType(value) + ')'); + } + this.type = 'StaticPropertyName'; + this.value = value; + } +}; + +exports.Super = 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('Super constructor takes no arguments'); + } + this.type = 'Super'; + } +}; + +exports.SwitchCase = class { + constructor(arg, ...extraArgs) { + const { test, consequent } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('SwitchCase constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['consequent', 'test'])) { + throw new TypeError('Argument to SwitchCase constructor has wrong keys: expected {test, consequent}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(test)) { + throw new TypeError('Field "test" of SwitchCase constructor argument is of incorrect type (expected Expression, got ' + printActualType(test) + ')'); + } + if (!Array.isArray(consequent) || consequent.some(f => isNotStatement(f))) { + throw new TypeError('Field "consequent" of SwitchCase constructor argument is of incorrect type (expected [Statement], got ' + printActualType(consequent) + ')'); + } + this.type = 'SwitchCase'; + this.test = test; + this.consequent = consequent; + } +}; + +exports.SwitchDefault = class { + constructor(arg, ...extraArgs) { + const { consequent } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('SwitchDefault constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['consequent'])) { + throw new TypeError('Argument to SwitchDefault constructor has wrong keys: expected {consequent}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (!Array.isArray(consequent) || consequent.some(f => isNotStatement(f))) { + throw new TypeError('Field "consequent" of SwitchDefault constructor argument is of incorrect type (expected [Statement], got ' + printActualType(consequent) + ')'); + } + this.type = 'SwitchDefault'; + this.consequent = consequent; + } +}; + +exports.SwitchStatement = class { + constructor(arg, ...extraArgs) { + const { discriminant, cases } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('SwitchStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['cases', 'discriminant'])) { + throw new TypeError('Argument to SwitchStatement constructor has wrong keys: expected {discriminant, cases}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(discriminant)) { + throw new TypeError('Field "discriminant" of SwitchStatement constructor argument is of incorrect type (expected Expression, got ' + printActualType(discriminant) + ')'); + } + if (!Array.isArray(cases) || cases.some(f => typeof f === 'undefined' || f.type !== 'SwitchCase')) { + throw new TypeError('Field "cases" of SwitchStatement constructor argument is of incorrect type (expected [SwitchCase], got ' + printActualType(cases) + ')'); + } + this.type = 'SwitchStatement'; + this.discriminant = discriminant; + this.cases = cases; + } +}; + +exports.SwitchStatementWithDefault = class { + constructor(arg, ...extraArgs) { + const { discriminant, preDefaultCases, defaultCase, postDefaultCases } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('SwitchStatementWithDefault constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['defaultCase', 'discriminant', 'postDefaultCases', 'preDefaultCases'])) { + throw new TypeError('Argument to SwitchStatementWithDefault constructor has wrong keys: expected {discriminant, preDefaultCases, defaultCase, postDefaultCases}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(discriminant)) { + throw new TypeError('Field "discriminant" of SwitchStatementWithDefault constructor argument is of incorrect type (expected Expression, got ' + printActualType(discriminant) + ')'); + } + if (!Array.isArray(preDefaultCases) || preDefaultCases.some(f => typeof f === 'undefined' || f.type !== 'SwitchCase')) { + throw new TypeError('Field "preDefaultCases" of SwitchStatementWithDefault constructor argument is of incorrect type (expected [SwitchCase], got ' + printActualType(preDefaultCases) + ')'); + } + if (typeof defaultCase === 'undefined' || defaultCase.type !== 'SwitchDefault') { + throw new TypeError('Field "defaultCase" of SwitchStatementWithDefault constructor argument is of incorrect type (expected SwitchDefault, got ' + printActualType(defaultCase) + ')'); + } + if (!Array.isArray(postDefaultCases) || postDefaultCases.some(f => typeof f === 'undefined' || f.type !== 'SwitchCase')) { + throw new TypeError('Field "postDefaultCases" of SwitchStatementWithDefault constructor argument is of incorrect type (expected [SwitchCase], got ' + printActualType(postDefaultCases) + ')'); + } + this.type = 'SwitchStatementWithDefault'; + this.discriminant = discriminant; + this.preDefaultCases = preDefaultCases; + this.defaultCase = defaultCase; + this.postDefaultCases = postDefaultCases; + } +}; + +exports.TemplateElement = class { + constructor(arg, ...extraArgs) { + const { rawValue } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('TemplateElement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['rawValue'])) { + throw new TypeError('Argument to TemplateElement constructor has wrong keys: expected {rawValue}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof rawValue !== 'string') { + throw new TypeError('Field "rawValue" of TemplateElement constructor argument is of incorrect type (expected string, got ' + printActualType(rawValue) + ')'); + } + this.type = 'TemplateElement'; + this.rawValue = rawValue; + } +}; + +exports.TemplateExpression = class { + constructor(arg, ...extraArgs) { + const { tag, elements } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('TemplateExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['elements', 'tag'])) { + throw new TypeError('Argument to TemplateExpression constructor has wrong keys: expected {tag, elements}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof tag === 'undefined' || tag !== null && (isNotExpression(tag))) { + throw new TypeError('Field "tag" of TemplateExpression constructor argument is of incorrect type (expected null or Expression, got ' + printActualType(tag) + ')'); + } + if (!Array.isArray(elements) || elements.some(f => typeof f === 'undefined' || (isNotExpression(f)) && (f.type !== 'TemplateElement'))) { + throw new TypeError('Field "elements" of TemplateExpression constructor argument is of incorrect type (expected [one of {Expression, TemplateElement}], got ' + printActualType(elements) + ')'); + } + this.type = 'TemplateExpression'; + this.tag = tag; + this.elements = elements; + } +}; + +exports.ThisExpression = 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('ThisExpression constructor takes no arguments'); + } + this.type = 'ThisExpression'; + } +}; + +exports.ThrowStatement = class { + constructor(arg, ...extraArgs) { + const { expression } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('ThrowStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['expression'])) { + throw new TypeError('Argument to ThrowStatement constructor has wrong keys: expected {expression}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(expression)) { + throw new TypeError('Field "expression" of ThrowStatement constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')'); + } + this.type = 'ThrowStatement'; + this.expression = expression; + } +}; + +exports.TryCatchStatement = class { + constructor(arg, ...extraArgs) { + const { body, catchClause } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('TryCatchStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'catchClause'])) { + throw new TypeError('Argument to TryCatchStatement constructor has wrong keys: expected {body, catchClause}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof body === 'undefined' || body.type !== 'Block') { + throw new TypeError('Field "body" of TryCatchStatement constructor argument is of incorrect type (expected Block, got ' + printActualType(body) + ')'); + } + if (typeof catchClause === 'undefined' || catchClause.type !== 'CatchClause') { + throw new TypeError('Field "catchClause" of TryCatchStatement constructor argument is of incorrect type (expected CatchClause, got ' + printActualType(catchClause) + ')'); + } + this.type = 'TryCatchStatement'; + this.body = body; + this.catchClause = catchClause; + } +}; + +exports.TryFinallyStatement = class { + constructor(arg, ...extraArgs) { + const { body, catchClause, finalizer } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('TryFinallyStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'catchClause', 'finalizer'])) { + throw new TypeError('Argument to TryFinallyStatement constructor has wrong keys: expected {body, catchClause, finalizer}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof body === 'undefined' || body.type !== 'Block') { + throw new TypeError('Field "body" of TryFinallyStatement constructor argument is of incorrect type (expected Block, got ' + printActualType(body) + ')'); + } + if (typeof catchClause === 'undefined' || catchClause !== null && (catchClause.type !== 'CatchClause')) { + throw new TypeError('Field "catchClause" of TryFinallyStatement constructor argument is of incorrect type (expected null or CatchClause, got ' + printActualType(catchClause) + ')'); + } + if (typeof finalizer === 'undefined' || finalizer.type !== 'Block') { + throw new TypeError('Field "finalizer" of TryFinallyStatement constructor argument is of incorrect type (expected Block, got ' + printActualType(finalizer) + ')'); + } + this.type = 'TryFinallyStatement'; + this.body = body; + this.catchClause = catchClause; + this.finalizer = finalizer; + } +}; + +exports.UnaryExpression = class { + constructor(arg, ...extraArgs) { + const { operator, operand } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('UnaryExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['operand', 'operator'])) { + throw new TypeError('Argument to UnaryExpression constructor has wrong keys: expected {operator, operand}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof operator === 'undefined' || ['+', '-', '!', '~', 'typeof', 'void', 'delete'].indexOf(operator) === -1) { + throw new TypeError('Field "operator" of UnaryExpression constructor argument is of incorrect type (expected one of {"+", "-", "!", "~", "typeof", "void", "delete"}, got ' + printActualType(operator) + ')'); + } + if (isNotExpression(operand)) { + throw new TypeError('Field "operand" of UnaryExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(operand) + ')'); + } + this.type = 'UnaryExpression'; + this.operator = operator; + this.operand = operand; + } +}; + +exports.UpdateExpression = class { + constructor(arg, ...extraArgs) { + const { isPrefix, operator, operand } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('UpdateExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['isPrefix', 'operand', 'operator'])) { + throw new TypeError('Argument to UpdateExpression constructor has wrong keys: expected {isPrefix, operator, operand}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof isPrefix !== 'boolean') { + throw new TypeError('Field "isPrefix" of UpdateExpression constructor argument is of incorrect type (expected boolean, got ' + printActualType(isPrefix) + ')'); + } + if (typeof operator === 'undefined' || ['++', '--'].indexOf(operator) === -1) { + throw new TypeError('Field "operator" of UpdateExpression constructor argument is of incorrect type (expected one of {"++", "--"}, got ' + printActualType(operator) + ')'); + } + if (typeof operand === 'undefined' || (operand.type !== 'AssignmentTargetIdentifier') && ((operand.type !== 'ComputedMemberAssignmentTarget') && (operand.type !== 'StaticMemberAssignmentTarget'))) { + throw new TypeError('Field "operand" of UpdateExpression constructor argument is of incorrect type (expected one of {AssignmentTargetIdentifier, ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget}, got ' + printActualType(operand) + ')'); + } + this.type = 'UpdateExpression'; + this.isPrefix = isPrefix; + this.operator = operator; + this.operand = operand; + } +}; + +exports.VariableDeclaration = class { + constructor(arg, ...extraArgs) { + const { kind, declarators } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('VariableDeclaration constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['declarators', 'kind'])) { + throw new TypeError('Argument to VariableDeclaration constructor has wrong keys: expected {kind, declarators}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof kind === 'undefined' || ['var', 'let', 'const'].indexOf(kind) === -1) { + throw new TypeError('Field "kind" of VariableDeclaration constructor argument is of incorrect type (expected one of {"var", "let", "const"}, got ' + printActualType(kind) + ')'); + } + if (!Array.isArray(declarators) || declarators.some(f => typeof f === 'undefined' || f.type !== 'VariableDeclarator')) { + throw new TypeError('Field "declarators" of VariableDeclaration constructor argument is of incorrect type (expected [VariableDeclarator], got ' + printActualType(declarators) + ')'); + } + this.type = 'VariableDeclaration'; + this.kind = kind; + this.declarators = declarators; + } +}; + +exports.VariableDeclarationStatement = class { + constructor(arg, ...extraArgs) { + const { declaration } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('VariableDeclarationStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['declaration'])) { + throw new TypeError('Argument to VariableDeclarationStatement constructor has wrong keys: expected {declaration}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof declaration === 'undefined' || declaration.type !== 'VariableDeclaration') { + throw new TypeError('Field "declaration" of VariableDeclarationStatement constructor argument is of incorrect type (expected VariableDeclaration, got ' + printActualType(declaration) + ')'); + } + this.type = 'VariableDeclarationStatement'; + this.declaration = declaration; + } +}; + +exports.VariableDeclarator = class { + constructor(arg, ...extraArgs) { + const { binding, init } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('VariableDeclarator constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['binding', 'init'])) { + throw new TypeError('Argument to VariableDeclarator 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 VariableDeclarator constructor argument is of incorrect type (expected one of {BindingIdentifier, ArrayBinding, ObjectBinding}, got ' + printActualType(binding) + ')'); + } + if (typeof init === 'undefined' || init !== null && (isNotExpression(init))) { + throw new TypeError('Field "init" of VariableDeclarator constructor argument is of incorrect type (expected null or Expression, got ' + printActualType(init) + ')'); + } + this.type = 'VariableDeclarator'; + this.binding = binding; + this.init = init; + } +}; + +exports.WhileStatement = class { + constructor(arg, ...extraArgs) { + const { test, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('WhileStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'test'])) { + throw new TypeError('Argument to WhileStatement constructor has wrong keys: expected {test, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(test)) { + throw new TypeError('Field "test" of WhileStatement constructor argument is of incorrect type (expected Expression, got ' + printActualType(test) + ')'); + } + if (isNotStatement(body)) { + throw new TypeError('Field "body" of WhileStatement constructor argument is of incorrect type (expected Statement, got ' + printActualType(body) + ')'); + } + this.type = 'WhileStatement'; + this.test = test; + this.body = body; + } +}; + +exports.WithStatement = class { + constructor(arg, ...extraArgs) { + const { object, body } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('WithStatement constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['body', 'object'])) { + throw new TypeError('Argument to WithStatement constructor has wrong keys: expected {object, body}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(object)) { + throw new TypeError('Field "object" of WithStatement constructor argument is of incorrect type (expected Expression, got ' + printActualType(object) + ')'); + } + if (isNotStatement(body)) { + throw new TypeError('Field "body" of WithStatement constructor argument is of incorrect type (expected Statement, got ' + printActualType(body) + ')'); + } + this.type = 'WithStatement'; + this.object = object; + this.body = body; + } +}; + +exports.YieldExpression = class { + constructor(arg, ...extraArgs) { + const { expression } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('YieldExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['expression'])) { + throw new TypeError('Argument to YieldExpression constructor has wrong keys: expected {expression}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (typeof expression === 'undefined' || expression !== null && (isNotExpression(expression))) { + throw new TypeError('Field "expression" of YieldExpression constructor argument is of incorrect type (expected null or Expression, got ' + printActualType(expression) + ')'); + } + this.type = 'YieldExpression'; + this.expression = expression; + } +}; + +exports.YieldGeneratorExpression = class { + constructor(arg, ...extraArgs) { + const { expression } = arg; + if (extraArgs.length !== 0) { + throw new TypeError('YieldGeneratorExpression constructor takes exactly one argument (' + (1 + extraArgs.length) + ' given)'); + } + if (!arrayEquals(Object.keys(arg).sort(), ['expression'])) { + throw new TypeError('Argument to YieldGeneratorExpression constructor has wrong keys: expected {expression}, got {' + Object.keys(arg).join(', ') + '}'); + } + if (isNotExpression(expression)) { + throw new TypeError('Field "expression" of YieldGeneratorExpression constructor argument is of incorrect type (expected Expression, got ' + printActualType(expression) + ')'); + } + this.type = 'YieldGeneratorExpression'; + this.expression = expression; + } +}; diff --git a/node_modules/shift-ast/gen/index.d.ts b/node_modules/shift-ast/gen/index.d.ts new file mode 100644 index 0000000..d81e540 --- /dev/null +++ b/node_modules/shift-ast/gen/index.d.ts @@ -0,0 +1,707 @@ +// Generated by scripts/generate-dts.js. + +/** + * Copyright 2019 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. + */ + +type Init = Pick>; + +export type Node = ArrayAssignmentTarget | ArrayBinding | ArrayExpression | ArrowExpression | AssignmentExpression | AssignmentTargetIdentifier | AssignmentTargetPropertyIdentifier | AssignmentTargetPropertyProperty | AssignmentTargetWithDefault | AwaitExpression | BinaryExpression | BindingIdentifier | BindingPropertyIdentifier | BindingPropertyProperty | BindingWithDefault | Block | BlockStatement | BreakStatement | CallExpression | CatchClause | ClassDeclaration | ClassElement | ClassExpression | CompoundAssignmentExpression | ComputedMemberAssignmentTarget | ComputedMemberExpression | ComputedPropertyName | ConditionalExpression | ContinueStatement | DataProperty | DebuggerStatement | Directive | DoWhileStatement | EmptyStatement | Export | ExportAllFrom | ExportDefault | ExportFrom | ExportFromSpecifier | ExportLocalSpecifier | ExportLocals | ExpressionStatement | ForAwaitStatement | ForInStatement | ForOfStatement | ForStatement | FormalParameters | FunctionBody | FunctionDeclaration | FunctionExpression | Getter | IdentifierExpression | IfStatement | Import | ImportNamespace | ImportSpecifier | LabeledStatement | LiteralBooleanExpression | LiteralInfinityExpression | LiteralNullExpression | LiteralNumericExpression | LiteralRegExpExpression | LiteralStringExpression | Method | Module | NewExpression | NewTargetExpression | ObjectAssignmentTarget | ObjectBinding | ObjectExpression | ReturnStatement | Script | Setter | ShorthandProperty | SpreadElement | SpreadProperty | StaticMemberAssignmentTarget | StaticMemberExpression | StaticPropertyName | Super | SwitchCase | SwitchDefault | SwitchStatement | SwitchStatementWithDefault | TemplateElement | TemplateExpression | ThisExpression | ThrowStatement | TryCatchStatement | TryFinallyStatement | UnaryExpression | UpdateExpression | VariableDeclaration | VariableDeclarationStatement | VariableDeclarator | WhileStatement | WithStatement | YieldExpression | YieldGeneratorExpression; + +export type Expression = ArrayExpression | ArrowExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ClassExpression | CompoundAssignmentExpression | ConditionalExpression | FunctionExpression | IdentifierExpression | LiteralBooleanExpression | LiteralInfinityExpression | LiteralNullExpression | LiteralNumericExpression | LiteralRegExpExpression | LiteralStringExpression | ComputedMemberExpression | StaticMemberExpression | NewExpression | NewTargetExpression | ObjectExpression | TemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | YieldGeneratorExpression; + +export type Statement = BlockStatement | BreakStatement | ClassDeclaration | ContinueStatement | DebuggerStatement | EmptyStatement | ExpressionStatement | FunctionDeclaration | IfStatement | DoWhileStatement | ForAwaitStatement | ForInStatement | ForOfStatement | ForStatement | WhileStatement | LabeledStatement | ReturnStatement | SwitchStatement | SwitchStatementWithDefault | ThrowStatement | TryCatchStatement | TryFinallyStatement | VariableDeclarationStatement | WithStatement; + + +export class ArrayAssignmentTarget { + type: 'ArrayAssignmentTarget'; + elements: Array; + rest: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget | null; + constructor(init: Init); +} + +export class ArrayBinding { + type: 'ArrayBinding'; + elements: Array; + rest: BindingIdentifier | ArrayBinding | ObjectBinding | null; + constructor(init: Init); +} + +export class ArrayExpression { + type: 'ArrayExpression'; + elements: Array; + constructor(init: Init); +} + +export class ArrowExpression { + type: 'ArrowExpression'; + isAsync: boolean; + params: FormalParameters; + body: Expression | FunctionBody; + constructor(init: Init); +} + +export class AssignmentExpression { + type: 'AssignmentExpression'; + binding: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget; + expression: Expression; + constructor(init: Init); +} + +export class AssignmentTargetIdentifier { + type: 'AssignmentTargetIdentifier'; + name: string; + constructor(init: Init); +} + +export class AssignmentTargetPropertyIdentifier { + type: 'AssignmentTargetPropertyIdentifier'; + binding: AssignmentTargetIdentifier; + init: Expression | null; + constructor(init: Init); +} + +export class AssignmentTargetPropertyProperty { + type: 'AssignmentTargetPropertyProperty'; + name: ComputedPropertyName | StaticPropertyName; + binding: AssignmentTargetWithDefault | ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget; + constructor(init: Init); +} + +export class AssignmentTargetWithDefault { + type: 'AssignmentTargetWithDefault'; + binding: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget; + init: Expression; + constructor(init: Init); +} + +export class AwaitExpression { + type: 'AwaitExpression'; + expression: Expression; + constructor(init: Init); +} + +export class BinaryExpression { + type: 'BinaryExpression'; + left: Expression; + operator: '==' | '!=' | '===' | '!==' | '<' | '<=' | '>' | '>=' | 'in' | 'instanceof' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | '**' | ',' | '||' | '&&' | '|' | '^' | '&'; + right: Expression; + constructor(init: Init); +} + +export class BindingIdentifier { + type: 'BindingIdentifier'; + name: string; + constructor(init: Init); +} + +export class BindingPropertyIdentifier { + type: 'BindingPropertyIdentifier'; + binding: BindingIdentifier; + init: Expression | null; + constructor(init: Init); +} + +export class BindingPropertyProperty { + type: 'BindingPropertyProperty'; + name: ComputedPropertyName | StaticPropertyName; + binding: BindingWithDefault | BindingIdentifier | ArrayBinding | ObjectBinding; + constructor(init: Init); +} + +export class BindingWithDefault { + type: 'BindingWithDefault'; + binding: BindingIdentifier | ArrayBinding | ObjectBinding; + init: Expression; + constructor(init: Init); +} + +export class Block { + type: 'Block'; + statements: Array; + constructor(init: Init); +} + +export class BlockStatement { + type: 'BlockStatement'; + block: Block; + constructor(init: Init); +} + +export class BreakStatement { + type: 'BreakStatement'; + label: string | null; + constructor(init: Init); +} + +export class CallExpression { + type: 'CallExpression'; + callee: Expression | Super; + arguments: Array; + constructor(init: Init); +} + +export class CatchClause { + type: 'CatchClause'; + binding: BindingIdentifier | ArrayBinding | ObjectBinding | null; + body: Block; + constructor(init: Init); +} + +export class ClassDeclaration { + type: 'ClassDeclaration'; + name: BindingIdentifier; + super: Expression | null; + elements: Array; + constructor(init: Init); +} + +export class ClassElement { + type: 'ClassElement'; + isStatic: boolean; + method: Getter | Method | Setter; + constructor(init: Init); +} + +export class ClassExpression { + type: 'ClassExpression'; + name: BindingIdentifier | null; + super: Expression | null; + elements: Array; + constructor(init: Init); +} + +export class CompoundAssignmentExpression { + type: 'CompoundAssignmentExpression'; + binding: AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget; + operator: '+=' | '-=' | '*=' | '/=' | '%=' | '**=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&='; + expression: Expression; + constructor(init: Init); +} + +export class ComputedMemberAssignmentTarget { + type: 'ComputedMemberAssignmentTarget'; + object: Expression | Super; + expression: Expression; + constructor(init: Init); +} + +export class ComputedMemberExpression { + type: 'ComputedMemberExpression'; + object: Expression | Super; + expression: Expression; + constructor(init: Init); +} + +export class ComputedPropertyName { + type: 'ComputedPropertyName'; + expression: Expression; + constructor(init: Init); +} + +export class ConditionalExpression { + type: 'ConditionalExpression'; + test: Expression; + consequent: Expression; + alternate: Expression; + constructor(init: Init); +} + +export class ContinueStatement { + type: 'ContinueStatement'; + label: string | null; + constructor(init: Init); +} + +export class DataProperty { + type: 'DataProperty'; + name: ComputedPropertyName | StaticPropertyName; + expression: Expression; + constructor(init: Init); +} + +export class DebuggerStatement { + type: 'DebuggerStatement'; + constructor(init?: Init); +} + +export class Directive { + type: 'Directive'; + rawValue: string; + constructor(init: Init); +} + +export class DoWhileStatement { + type: 'DoWhileStatement'; + body: Statement; + test: Expression; + constructor(init: Init); +} + +export class EmptyStatement { + type: 'EmptyStatement'; + constructor(init?: Init); +} + +export class Export { + type: 'Export'; + declaration: ClassDeclaration | FunctionDeclaration | VariableDeclaration; + constructor(init: Init); +} + +export class ExportAllFrom { + type: 'ExportAllFrom'; + moduleSpecifier: string; + constructor(init: Init); +} + +export class ExportDefault { + type: 'ExportDefault'; + body: ClassDeclaration | Expression | FunctionDeclaration; + constructor(init: Init); +} + +export class ExportFrom { + type: 'ExportFrom'; + namedExports: Array; + moduleSpecifier: string; + constructor(init: Init); +} + +export class ExportFromSpecifier { + type: 'ExportFromSpecifier'; + name: string; + exportedName: string | null; + constructor(init: Init); +} + +export class ExportLocalSpecifier { + type: 'ExportLocalSpecifier'; + name: IdentifierExpression; + exportedName: string | null; + constructor(init: Init); +} + +export class ExportLocals { + type: 'ExportLocals'; + namedExports: Array; + constructor(init: Init); +} + +export class ExpressionStatement { + type: 'ExpressionStatement'; + expression: Expression; + constructor(init: Init); +} + +export class ForAwaitStatement { + type: 'ForAwaitStatement'; + left: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget | VariableDeclaration; + right: Expression; + body: Statement; + constructor(init: Init); +} + +export class ForInStatement { + type: 'ForInStatement'; + left: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget | VariableDeclaration; + right: Expression; + body: Statement; + constructor(init: Init); +} + +export class ForOfStatement { + type: 'ForOfStatement'; + left: ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget | VariableDeclaration; + right: Expression; + body: Statement; + constructor(init: Init); +} + +export class ForStatement { + type: 'ForStatement'; + init: Expression | VariableDeclaration | null; + test: Expression | null; + update: Expression | null; + body: Statement; + constructor(init: Init); +} + +export class FormalParameters { + type: 'FormalParameters'; + items: Array; + rest: BindingIdentifier | ArrayBinding | ObjectBinding | null; + constructor(init: Init); +} + +export class FunctionBody { + type: 'FunctionBody'; + directives: Array; + statements: Array; + constructor(init: Init); +} + +export class FunctionDeclaration { + type: 'FunctionDeclaration'; + isAsync: boolean; + isGenerator: boolean; + name: BindingIdentifier; + params: FormalParameters; + body: FunctionBody; + constructor(init: Init); +} + +export class FunctionExpression { + type: 'FunctionExpression'; + isAsync: boolean; + isGenerator: boolean; + name: BindingIdentifier | null; + params: FormalParameters; + body: FunctionBody; + constructor(init: Init); +} + +export class Getter { + type: 'Getter'; + name: ComputedPropertyName | StaticPropertyName; + body: FunctionBody; + constructor(init: Init); +} + +export class IdentifierExpression { + type: 'IdentifierExpression'; + name: string; + constructor(init: Init); +} + +export class IfStatement { + type: 'IfStatement'; + test: Expression; + consequent: Statement; + alternate: Statement | null; + constructor(init: Init); +} + +export class Import { + type: 'Import'; + defaultBinding: BindingIdentifier | null; + namedImports: Array; + moduleSpecifier: string; + constructor(init: Init); +} + +export class ImportNamespace { + type: 'ImportNamespace'; + defaultBinding: BindingIdentifier | null; + namespaceBinding: BindingIdentifier; + moduleSpecifier: string; + constructor(init: Init); +} + +export class ImportSpecifier { + type: 'ImportSpecifier'; + name: string | null; + binding: BindingIdentifier; + constructor(init: Init); +} + +export class LabeledStatement { + type: 'LabeledStatement'; + label: string; + body: Statement; + constructor(init: Init); +} + +export class LiteralBooleanExpression { + type: 'LiteralBooleanExpression'; + value: boolean; + constructor(init: Init); +} + +export class LiteralInfinityExpression { + type: 'LiteralInfinityExpression'; + constructor(init?: Init); +} + +export class LiteralNullExpression { + type: 'LiteralNullExpression'; + constructor(init?: Init); +} + +export class LiteralNumericExpression { + type: 'LiteralNumericExpression'; + value: number; + constructor(init: Init); +} + +export class LiteralRegExpExpression { + type: 'LiteralRegExpExpression'; + pattern: string; + global: boolean; + ignoreCase: boolean; + multiLine: boolean; + dotAll: boolean; + unicode: boolean; + sticky: boolean; + constructor(init: Init); +} + +export class LiteralStringExpression { + type: 'LiteralStringExpression'; + value: string; + constructor(init: Init); +} + +export class Method { + type: 'Method'; + isAsync: boolean; + isGenerator: boolean; + name: ComputedPropertyName | StaticPropertyName; + params: FormalParameters; + body: FunctionBody; + constructor(init: Init); +} + +export class Module { + type: 'Module'; + directives: Array; + items: Array; + constructor(init: Init); +} + +export class NewExpression { + type: 'NewExpression'; + callee: Expression; + arguments: Array; + constructor(init: Init); +} + +export class NewTargetExpression { + type: 'NewTargetExpression'; + constructor(init?: Init); +} + +export class ObjectAssignmentTarget { + type: 'ObjectAssignmentTarget'; + properties: Array; + rest: AssignmentTargetIdentifier | ComputedMemberAssignmentTarget | StaticMemberAssignmentTarget | null; + constructor(init: Init); +} + +export class ObjectBinding { + type: 'ObjectBinding'; + properties: Array; + rest: BindingIdentifier | null; + constructor(init: Init); +} + +export class ObjectExpression { + type: 'ObjectExpression'; + properties: Array; + constructor(init: Init); +} + +export class ReturnStatement { + type: 'ReturnStatement'; + expression: Expression | null; + constructor(init: Init); +} + +export class Script { + type: 'Script'; + directives: Array; + statements: Array; + constructor(init: Init