Files
cdnjs/ajax/libs/gorillascript/0.7.2/gorillascript.js
T

59298 lines
2.0 MiB
Plaintext

;(function (root) {
var GorillaScript = (function (realRequire) {
function require(path) {
var has = Object.prototype.hasOwnProperty;
if (has.call(require._cache, path)) {
return require._cache[path];
} else if (has.call(require, path)) {
var func = require[path];
delete require[path];
return require._cache[path] = func.call({});
} else if (realRequire) {
return realRequire(path);
}
}
require._cache = {};
require['./utils'] = function () {
var module = { exports: this };
var exports = this;
(function (GLOBAL) {
"use strict";
var __create, __genericFunc, __getInstanceof, __in, __isArray, __isObject, __name, __num, __owns, __slice, __strnum, __toArray, __typeof, _ref, Cache, fs, inspect, path, WeakMap;
__create = typeof Object.create === "function" ? Object.create
: function (x) {
function F() {}
F.prototype = x;
return new F();
};
__genericFunc = function (numArgs, make) {
var any, cache, result;
cache = WeakMap();
any = {};
function generic() {
var _ref, current, i, item, type;
current = cache;
for (i = numArgs - 1; i >= 0; --i) {
if ((_ref = arguments[i]) != null) {
type = _ref;
} else {
type = any;
}
item = current.get(type);
if (item == null) {
item = i === 0 ? make.apply(this, arguments) : WeakMap();
current.set(type, item);
}
current = item;
}
return current;
}
result = generic();
result.generic = generic;
return result;
};
__getInstanceof = (function () {
function isAny() {
return true;
}
function isStr(x) {
return typeof x === "string";
}
function isNum(x) {
return typeof x === "number";
}
function isFunc(x) {
return typeof x === "function";
}
function isBool(x) {
return typeof x === "boolean";
}
return function (ctor) {
if (ctor == null) {
return isAny;
} else {
switch (ctor) {
case String: return isStr;
case Number: return isNum;
case Function: return isFunc;
case Boolean: return isBool;
case Array: return __isArray;
case Object: return __isObject;
default:
return function (_x) {
return _x instanceof ctor;
};
}
}
};
}());
__in = typeof Array.prototype.indexOf === "function"
? (function () {
var indexOf;
indexOf = Array.prototype.indexOf;
return function (child, parent) {
return indexOf.call(parent, child) !== -1;
};
}())
: function (child, parent) {
var i, len;
len = +parent.length;
i = -1;
while (++i < len) {
if (child === parent[i] && i in parent) {
return true;
}
}
return false;
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__isObject = function (x) {
return typeof x === "object" && x !== null;
};
__name = function (func) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
return func.displayName || func.name || "";
};
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__owns = Object.prototype.hasOwnProperty;
__slice = Array.prototype.slice;
__strnum = function (strnum) {
var type;
type = typeof strnum;
if (type === "string") {
return strnum;
} else if (type === "number") {
return String(strnum);
} else {
throw TypeError("Expected a string or number, got " + __typeof(strnum));
}
};
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
WeakMap = typeof GLOBAL.WeakMap === "function" ? GLOBAL.WeakMap
: (WeakMap = (function () {
var _WeakMap_prototype, defProp, isExtensible;
function WeakMap() {
var _this;
_this = this instanceof WeakMap ? this : __create(_WeakMap_prototype);
_this._keys = [];
_this._values = [];
_this._chilly = [];
_this._uid = createUid();
return _this;
}
_WeakMap_prototype = WeakMap.prototype;
WeakMap.displayName = "WeakMap";
function uidRand() {
return Math.random().toString(36).slice(2);
}
function createUid() {
return __strnum(uidRand()) + "-" + __strnum(new Date().getTime()) + "-" + __strnum(uidRand()) + "-" + __strnum(uidRand());
}
isExtensible = Object.isExtensible || function () {
return true;
};
function check(key) {
var chilly, uid;
uid = this._uid;
if (__owns.call(key, uid)) {
chilly = this._chilly;
if (chilly.indexOf(key) === -1) {
chilly.push(key);
this._keys.push(key);
this._values.push(key[uid]);
}
}
}
_WeakMap_prototype.get = function (key) {
var _ref, index;
if (Object(key) !== key) {
throw TypeError("Invalid value used as weak map key");
}
if (isExtensible(key)) {
if (__owns.call(key, _ref = this._uid)) {
return key[_ref];
}
} else {
check.call(this, key);
index = this._keys.indexOf(key);
if (index === -1) {
return;
} else {
return this._values[index];
}
}
};
_WeakMap_prototype.has = function (key) {
if (Object(key) !== key) {
throw TypeError("Invalid value used as weak map key");
}
if (isExtensible(key)) {
return __owns.call(key, this._uid);
} else {
check.call(this, key);
return this._keys.indexOf(key) !== -1;
}
};
if (typeof Object.defineProperty === "function") {
defProp = Object.defineProperty;
} else {
defProp = function (o, k, d) {
o[k] = d.value;
};
}
_WeakMap_prototype.set = function (key, value) {
var index, keys;
if (Object(key) !== key) {
throw TypeError("Invalid value used as weak map key");
}
if (isExtensible(key)) {
defProp(key, this._uid, { configurable: true, writable: true, enumerable: false, value: value });
} else {
check.call(this, key);
keys = this._keys;
index = keys.indexOf(key);
if (index === -1) {
index = keys.length;
keys[index] = key;
}
this._values[index] = value;
}
};
_WeakMap_prototype["delete"] = function (key) {
var index, keys;
if (Object(key) !== key) {
throw TypeError("Invalid value used as weak map key");
}
if (isExtensible(key)) {
delete key[this._uid];
} else {
check.call(this, key);
keys = this._keys;
index = keys.indexOf(key);
if (index !== -1) {
keys.splice(index, 1);
this._values.splice(index, 1);
}
}
};
return WeakMap;
}()));
if ((_ref = require("util")) != null) {
inspect = _ref.inspect;
}
path = require("path");
fs = require("fs");
function stringRepeat(text, count) {
if (__num(count) < 1) {
return "";
} else if (count === 1) {
return text;
} else if (__num(count) & 1) {
return __strnum(text) + __strnum(stringRepeat(text, __num(count) - 1));
} else {
return stringRepeat(__strnum(text) + __strnum(text), __num(count) / 2);
}
}
exports.stringRepeat = stringRepeat;
exports.padLeft = function (text, len, padding) {
return __strnum(stringRepeat(padding, __num(len) - __num(text.length))) + __strnum(text);
};
exports.padRight = function (text, len, padding) {
return __strnum(text) + __strnum(stringRepeat(padding, __num(len) - __num(text.length)));
};
exports.Cache = Cache = __genericFunc(2, function (TKey, TValue) {
var _instanceof_TKey, _instanceof_TValue;
_instanceof_TKey = __getInstanceof(TKey);
_instanceof_TValue = __getInstanceof(TValue);
return (function () {
var _Cache_prototype;
function Cache() {
var _this;
_this = this instanceof Cache ? this : __create(_Cache_prototype);
_this.weakmap = WeakMap();
return _this;
}
_Cache_prototype = Cache.prototype;
Cache.displayName = "Cache<" + (TKey != null ? __name(TKey) : "") + ", " + (TValue != null ? __name(TValue) : "") + ">";
_Cache_prototype.get = function (key) {
if (!_instanceof_TKey(key)) {
throw TypeError("Expected key to be a " + __name(TKey) + ", got " + __typeof(key));
}
return this.weakmap.get(key);
};
_Cache_prototype.getOrAdd = function (key, factory) {
var value, weakmap;
if (!_instanceof_TKey(key)) {
throw TypeError("Expected key to be a " + __name(TKey) + ", got " + __typeof(key));
}
if (typeof factory !== "function") {
throw TypeError("Expected factory to be a Function, got " + __typeof(factory));
}
weakmap = this.weakmap;
value = weakmap.get(key);
if (value === void 0) {
value = factory(key);
if (!_instanceof_TValue(value)) {
throw Error("Expected factory result to be a " + __name(TValue) + ", got " + __typeof(value));
}
weakmap.set(key, value);
}
return value;
};
return Cache;
}());
});
exports.quote = function (value) {
if (typeof value !== "string") {
throw TypeError("Expected value to be a String, got " + __typeof(value));
}
if (inspect) {
return inspect(value);
} else if (value.indexOf("'") === -1) {
return "'" + __strnum(JSON.stringify(value).slice(1, -1)) + "'";
} else {
return JSON.stringify(value);
}
};
exports.unique = function (items) {
var _arr, _i, _len, item, result;
result = [];
for (_arr = __toArray(items), _i = 0, _len = _arr.length; _i < _len; ++_i) {
item = _arr[_i];
if (!__in(item, result)) {
result.push(item);
}
}
return result;
};
function findPackageJson(dir) {
var filepath, parent;
filepath = path.join(dir, "package.json");
if (fs.existsSync(filepath)) {
return filepath;
} else {
parent = path.normalize(path.join(dir, ".."));
if (parent !== dir) {
return findPackageJson(parent);
}
}
}
exports.getPackageVersion = function (filename) {
var packageJsonFilename, version;
if (typeof filename !== "string" || !fs || !path) {
return "";
}
try {
packageJsonFilename = findPackageJson(path.dirname(filename));
} catch (e) {}
if (!packageJsonFilename) {
return "";
}
try {
version = JSON.parse(fs.readFileSync(packageJsonFilename)).version;
} catch (e) {}
if (typeof version === "string") {
return version;
} else {
return "";
}
};
}.call(this, typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : this));
return module.exports;
};
require['./jsutils'] = function () {
var module = { exports: this };
var exports = this;
(function () {
"use strict";
var __bind, __create, __in, __isArray, __lte, __num, __owns, __slice, __strnum, __toArray, __typeof, isAcceptableIdent, padLeft, toJSSource;
__bind = function (parent, child) {
var func;
if (parent == null) {
throw TypeError("Expected parent to be an object, got " + __typeof(parent));
}
func = parent[child];
if (typeof func !== "function") {
throw Error("Trying to bind child '" + String(child) + "' which is not a function");
}
return function () {
return func.apply(parent, arguments);
};
};
__create = typeof Object.create === "function" ? Object.create
: function (x) {
function F() {}
F.prototype = x;
return new F();
};
__in = typeof Array.prototype.indexOf === "function"
? (function () {
var indexOf;
indexOf = Array.prototype.indexOf;
return function (child, parent) {
return indexOf.call(parent, child) !== -1;
};
}())
: function (child, parent) {
var i, len;
len = +parent.length;
i = -1;
while (++i < len) {
if (child === parent[i] && i in parent) {
return true;
}
}
return false;
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__lte = function (x, y) {
var type;
type = typeof x;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof y) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof y);
} else {
return x <= y;
}
};
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__owns = Object.prototype.hasOwnProperty;
__slice = Array.prototype.slice;
__strnum = function (strnum) {
var type;
type = typeof strnum;
if (type === "string") {
return strnum;
} else if (type === "number") {
return String(strnum);
} else {
throw TypeError("Expected a string or number, got " + __typeof(strnum));
}
};
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
padLeft = require("./utils").padLeft;
isAcceptableIdent = (function () {
var IDENTIFIER_REGEX, IDENTIFIER_UNICODE_REGEX, RESERVED;
IDENTIFIER_REGEX = /^[a-zA-Z_\$][a-zA-Z_\$0-9]*$/;
IDENTIFIER_UNICODE_REGEX = /^[a-zA-Z_\$\u00a0-\uffff][a-zA-Z_\$0-9\u00a0-\uffff]*$/;
RESERVED = [
"arguments",
"break",
"case",
"catch",
"class",
"const",
"continue",
"debugger",
"default",
"delete",
"do",
"else",
"enum",
"export",
"extends",
"eval",
"false",
"finally",
"for",
"function",
"if",
"implements",
"import",
"in",
"Infinity",
"instanceof",
"interface",
"let",
"NaN",
"new",
"null",
"package",
"private",
"protected",
"public",
"return",
"static",
"super",
"switch",
"this",
"throw",
"true",
"try",
"typeof",
"undefined",
"var",
"void",
"while",
"with",
"yield"
];
return function (name, allowUnicode) {
var regex;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (allowUnicode == null) {
allowUnicode = false;
} else if (typeof allowUnicode !== "boolean") {
throw TypeError("Expected allowUnicode to be a Boolean, got " + __typeof(allowUnicode));
}
if (allowUnicode) {
regex = IDENTIFIER_UNICODE_REGEX;
} else {
regex = IDENTIFIER_REGEX;
}
return regex.test(name) && !__in(name, RESERVED);
};
}());
toJSSource = (function () {
var LARGE_CHARACTER_SIZE, LARGE_CONTAINER_SIZE, types;
function indent(sb, amount, space) {
var i;
if (space == null) {
space = " ";
}
for (i = 0, __num(amount); i < amount; ++i) {
sb(space);
}
}
function moreIndent(options) {
var _o;
_o = __create(options);
_o.indent = __num(options.indent) + 1;
return _o;
}
LARGE_CHARACTER_SIZE = 50;
LARGE_CONTAINER_SIZE = 7;
function isLarge(value) {
var i, k, v;
if (value == null) {
return false;
} else if (value instanceof RegExp) {
return isLarge(value.source);
} else if (value instanceof Date) {
return false;
} else if (__isArray(value)) {
switch (value.length) {
case 0: return false;
case 1: return isLarge(value[0]);
default: return true;
}
} else {
switch (typeof value) {
case "string": return __num(value.length) >= LARGE_CHARACTER_SIZE;
case "number":
case "boolean": return false;
case "object":
i = -1;
for (k in value) {
if (__owns.call(value, k)) {
++i;
v = value[k];
if (i >= 1 || isLarge(k) || isLarge(v)) {
return true;
}
}
}
return false;
default: return true;
}
}
}
types = {
"null": function (_p, sb) {
sb("null");
},
"undefined": function (_p, sb) {
sb("void 0");
},
number: function (value, sb) {
sb(value === 0 ? (1 / __num(value) < 0 ? "-0" : "0")
: isFinite(value) ? String(value)
: value !== value ? "0/0"
: __num(value) > 0 ? "1/0"
: "-1/0");
},
regexp: function (regex, sb) {
sb("/");
sb(regex.source.replace(/(\\\\)*\\?\//g, "$1\\/") || "(?:)");
sb("/");
if (regex.global) {
sb("g");
}
if (regex.ignoreCase) {
sb("i");
}
if (regex.multiline) {
sb("m");
}
},
string: (function () {
var DOUBLE_QUOTE_REGEX, SINGLE_QUOTE_REGEX;
function escapeHelper(m) {
switch (m) {
case "\b": return "\\b";
case "\t": return "\\t";
case "\n": return "\\n";
case "\f": return "\\f";
case "\r": return "\\r";
case "\n": return "\\n";
case '"': return '\\"';
case "'": return "\\'";
case "\\": return "\\\\";
default:
return "\\u" + __strnum(padLeft(m.charCodeAt(0).toString(16), 4, "0"));
}
}
DOUBLE_QUOTE_REGEX = /[\u0000-\u001f"\\\u0080-\uffff]/g;
SINGLE_QUOTE_REGEX = /[\u0000-\u001f'\\\u0080-\uffff]/g;
function doubleQuote(value) {
return '"' + __strnum(value.replace(DOUBLE_QUOTE_REGEX, escapeHelper)) + '"';
}
function singleQuote(value) {
return "'" + __strnum(value.replace(SINGLE_QUOTE_REGEX, escapeHelper)) + "'";
}
function shorter(x, y) {
if (__lte(x.length, y.length)) {
return x;
} else {
return y;
}
}
return function (string, sb) {
return sb(string.indexOf('"') === -1 ? doubleQuote(string)
: string.indexOf("'") === -1 ? singleQuote(string)
: shorter(doubleQuote(string), singleQuote(string)));
};
}()),
boolean: function (bool, sb) {
return sb(bool ? "true" : "false");
},
date: function (date, sb) {
sb("new Date(");
sb(String(date.getTime()));
return sb(")");
},
array: function (array, sb, options) {
var _arr, _len, childOptions, hasIndent, i, item, len;
hasIndent = "indent" in options;
if (array.length === 0) {
return sb("[]");
} else if (hasIndent && __num(array.length) > 1 && (__num(array.length) >= LARGE_CONTAINER_SIZE || (function () {
var _arr, _i, _len, item;
for (_arr = __toArray(array), _i = 0, _len = _arr.length; _i < _len; ++_i) {
item = _arr[_i];
if (isLarge(item)) {
return true;
}
}
return false;
}()))) {
sb("[\n");
childOptions = moreIndent(options);
for (_arr = __toArray(array), i = 0, len = _arr.length; i < len; ++i) {
item = _arr[i];
indent(sb, childOptions.indent);
toJSSource(item, sb, childOptions);
if (i < len - 1) {
sb(",");
}
sb("\n");
}
indent(sb, options.indent);
return sb("]");
} else {
sb("[");
for (_arr = __toArray(array), i = 0, _len = _arr.length; i < _len; ++i) {
item = _arr[i];
if (i > 0) {
sb(",");
if (hasIndent) {
sb(" ");
}
}
toJSSource(item, sb, options);
}
return sb("]");
}
},
object: (function () {
function writeSafeKey(key, sb, options) {
var num;
if (isAcceptableIdent(key)) {
sb(key);
} else {
num = Number(key);
if (num === num && String(num) === key) {
sb(key);
} else {
toJSSource(key, sb, options);
}
}
}
return function (obj, sb, options) {
var _arr, _len, _ref, childOptions, hasIndent, i, key, len, pairs, value;
_arr = [];
for (key in obj) {
if (__owns.call(obj, key)) {
value = obj[key];
_arr.push({ key: key, value: value });
}
}
pairs = _arr;
hasIndent = "indent" in options;
if (pairs.length === 0) {
return sb("{}");
} else if (hasIndent && pairs.length > 1 && (pairs.length >= LARGE_CONTAINER_SIZE || (function () {
var _arr, _i, _len, _ref, key, value;
for (_arr = __toArray(pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
key = (_ref = _arr[_i]).key;
value = _ref.value;
if (isLarge(key) || isLarge(value)) {
return true;
}
}
return false;
}()))) {
sb("{\n");
childOptions = moreIndent(options);
for (i = 0, len = pairs.length; i < len; ++i) {
key = (_ref = pairs[i]).key;
value = _ref.value;
indent(sb, childOptions.indent);
writeSafeKey(key, sb, childOptions);
sb(": ");
toJSSource(value, sb, childOptions);
if (i < len - 1) {
sb(",");
}
sb("\n");
}
indent(sb, options.indent);
return sb("}");
} else {
sb("{");
for (i = 0, _len = pairs.length; i < _len; ++i) {
key = (_ref = pairs[i]).key;
value = _ref.value;
if (i > 0) {
sb(",");
if (hasIndent) {
sb(" ");
}
}
writeSafeKey(key, sb, options);
sb(":");
if (hasIndent) {
sb(" ");
}
toJSSource(value, sb, options);
}
return sb("}");
}
};
}())
};
return function (value, sb, options) {
var _ref, arr, handler;
if (sb == null) {
sb = null;
} else if (typeof sb !== "function") {
throw TypeError("Expected sb to be one of Function or null, got " + __typeof(sb));
}
if (options == null) {
options = {};
}
if (sb == null) {
arr = [];
toJSSource(
value,
__bind(arr, "push"),
options
);
return arr.join("");
} else {
if (value === null) {
types["null"](value, sb, options);
} else if (__isArray(value)) {
types.array(value, sb, options);
} else if (value instanceof RegExp) {
types.regexp(value, sb, options);
} else if (value instanceof Date) {
types.date(value, sb, options);
} else {
if (__owns.call(types, _ref = typeof value)) {
handler = types[_ref];
}
if (typeof handler !== "function") {
throw Error("Cannot convert " + __typeof(value) + " to JS source");
}
handler(value, sb, options);
}
return;
}
};
}());
exports.toJSSource = toJSSource;
exports.isAcceptableIdent = isAcceptableIdent;
}.call(this));
return module.exports;
};
require['./types'] = function () {
var module = { exports: this };
var exports = this;
(function () {
"use strict";
var __cmp, __create, __isArray, __lte, __name, __num, __owns, __slice, __str, __strnum, __throw, __toArray, __typeof, inspect, Type, util;
__cmp = function (left, right) {
var type;
if (left === right) {
return 0;
} else {
type = typeof left;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof right) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof right);
} else if (left < right) {
return -1;
} else {
return 1;
}
}
};
__create = typeof Object.create === "function" ? Object.create
: function (x) {
function F() {}
F.prototype = x;
return new F();
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__lte = function (x, y) {
var type;
type = typeof x;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof y) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof y);
} else {
return x <= y;
}
};
__name = function (func) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
return func.displayName || func.name || "";
};
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__owns = Object.prototype.hasOwnProperty;
__slice = Array.prototype.slice;
__str = function (str) {
if (typeof str !== "string") {
throw TypeError("Expected a string, got " + __typeof(str));
} else {
return str;
}
};
__strnum = function (strnum) {
var type;
type = typeof strnum;
if (type === "string") {
return strnum;
} else if (type === "number") {
return String(strnum);
} else {
throw TypeError("Expected a string or number, got " + __typeof(strnum));
}
};
__throw = function (err) {
throw err;
};
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
util = require("util");
if (util != null) {
inspect = util.inspect;
}
module.exports = Type = (function () {
var _Type_prototype, any, AnyType, arrayBase, ComplementType, fromJSONTypes, functionBase, GenericType, getId, none, NoneType, ObjectType, SimpleType, UnionType;
function Type() {
var _this;
_this = this instanceof Type ? this : __create(_Type_prototype);
throw TypeError("Type should not be instantiated");
}
_Type_prototype = Type.prototype;
Type.displayName = "Type";
_Type_prototype.isSubsetOf = function () {
throw Error("Not implemented: " + __name(this.constructor) + ".isSubsetOf()");
};
_Type_prototype.isSupersetOf = function (other) {
return other.isSubsetOf(this);
};
_Type_prototype.overlaps = function () {
throw Error("Not implemented: " + __name(this.constructor) + ".overlaps()");
};
_Type_prototype.compare = function () {
throw Error("Not implemented: " + __name(this.constructor) + ".compare()");
};
_Type_prototype.equals = function () {
throw Error("Not implemented: " + __name(this.constructor) + ".equals()");
};
_Type_prototype.union = function () {
throw Error("Not implemented: " + __name(this.constructor) + ".union()");
};
_Type_prototype.intersect = function () {
throw Error("Not implemented: " + __name(this.constructor) + ".intersect()");
};
_Type_prototype.complement = function () {
var _ref;
if ((_ref = this._complement) == null) {
return this._complement = ComplementType(this);
} else {
return _ref;
}
};
_Type_prototype.array = function () {
var _ref;
if ((_ref = this._array) == null) {
return this._array = Type.generic(arrayBase, this);
} else {
return _ref;
}
};
_Type_prototype["function"] = function () {
var _ref, args;
args = __slice.call(arguments);
if ((_ref = this._function) == null) {
return this._function = Type.generic.apply(Type, [functionBase, this].concat(__toArray(args)));
} else {
return _ref;
}
};
function contains(alpha, bravo) {
var _arr, _i, item;
for (_arr = __toArray(alpha), _i = _arr.length; _i--; ) {
item = _arr[_i];
if (item.equals(bravo)) {
return true;
}
}
return false;
}
function union(alpha, bravo) {
var a, alphaLen, b, bravoLen, cmp, i, j, result;
if (alpha === bravo) {
return alpha;
}
result = [];
alphaLen = alpha.length;
bravoLen = bravo.length;
i = 0;
j = 0;
while (i < __num(alphaLen) && j < __num(bravoLen)) {
a = alpha[i];
b = bravo[j];
cmp = a.compare(b);
if (cmp === 0) {
result.push(a);
++i;
++j;
} else if (__num(cmp) < 0) {
result.push(a);
++i;
} else {
result.push(b);
++j;
}
}
for (; i < __num(alphaLen); ++i) {
result.push(alpha[i]);
}
for (; j < __num(bravoLen); ++j) {
result.push(bravo[j]);
}
switch (result.length) {
case alphaLen: return alpha;
case bravoLen: return bravo;
default: return result;
}
}
function intersect(alpha, bravo) {
var a, alphaLen, b, bravoLen, cmp, i, j, result;
if (alpha === bravo) {
return alpha;
}
alphaLen = alpha.length;
bravoLen = bravo.length;
result = [];
i = 0;
j = 0;
while (i < __num(alphaLen) && j < __num(bravoLen)) {
a = alpha[i];
b = bravo[j];
cmp = a.compare(b);
if (cmp === 0) {
result.push(a);
++i;
++j;
} else if (__num(cmp) < 0) {
++i;
} else {
++j;
}
}
switch (result.length) {
case alphaLen: return alpha;
case bravoLen: return bravo;
default: return result;
}
}
function relativeComplement(alpha, bravo) {
var a, alphaLen, bravoLen, cmp, i, j, result;
if (alpha === bravo) {
return [];
}
result = [];
alphaLen = alpha.length;
if (alphaLen === 0) {
return result;
}
bravoLen = bravo.length;
if (bravoLen === 0) {
return alpha;
}
i = 0;
j = 0;
while (i < __num(alphaLen) && j < __num(bravoLen)) {
a = alpha[i];
cmp = a.compare(bravo[j]);
if (cmp === 0) {
++i;
++j;
} else if (__num(cmp) < 0) {
result.push(a);
++i;
} else {
++j;
}
}
for (; i < __num(alphaLen); ++i) {
result.push(alpha[i]);
}
if (result.length === alphaLen) {
return alpha;
} else {
return result;
}
}
function isSubsetOf(alpha, bravo) {
var alphaLen, bravoLen, i, j;
if (alpha === bravo) {
return true;
}
alphaLen = alpha.length;
if (alphaLen === 0) {
return true;
}
bravoLen = bravo.length;
if (!__lte(alphaLen, bravoLen)) {
return false;
} else {
i = 0;
j = 0;
while (j < __num(bravoLen)) {
if (alpha[i].equals(bravo[j])) {
++i;
if (i >= __num(alphaLen)) {
return true;
}
++j;
} else {
++j;
}
}
return false;
}
}
function overlaps(alpha, bravo) {
var alphaLen, bravoLen, cmp, i, j;
alphaLen = alpha.length;
if (alpha === bravo && __num(alphaLen) > 0) {
return true;
}
bravoLen = bravo.length;
i = 0;
j = 0;
while (i < __num(alphaLen) && j < __num(bravoLen)) {
cmp = alpha[i].compare(bravo[j]);
if (cmp === 0) {
return true;
} else if (__num(cmp) < 0) {
++i;
} else {
++j;
}
}
return false;
}
function compare(alpha, bravo) {
var _ref, i, len;
if (alpha !== bravo) {
len = alpha.length;
if (_ref = __cmp(len, bravo.length)) {
return _ref;
}
for (i = 0, __num(len); i < len; ++i) {
if (_ref = alpha[i].compare(bravo[i])) {
return _ref;
}
}
}
return 0;
}
function equals(alpha, bravo) {
var i, len;
if (alpha !== bravo) {
len = alpha.length;
if (len !== bravo.length) {
return false;
}
for (i = 0, __num(len); i < len; ++i) {
if (!alpha[i].equals(bravo[i])) {
return false;
}
}
}
return true;
}
function typeComparer(a, b) {
return a.compare(b);
}
function makeUnionType(types, needsSort) {
switch (types.length) {
case 0: return none;
case 1: return types[0];
default:
if (needsSort) {
types.sort(typeComparer);
}
return UnionType(types);
}
}
fromJSONTypes = {};
function fromJSON(x) {
var type;
if (typeof x === "string") {
return fromJSON({ type: "simple", name: x });
} else {
type = x.type;
if (typeof type !== "string") {
throw TypeError("Unspecified type");
} else if (!__owns.call(fromJSONTypes, type)) {
throw TypeError("Unknown serialization type: " + __strnum(type));
} else {
return fromJSONTypes[type](x);
}
}
}
Type.fromJSON = fromJSON;
getId = (function () {
var id;
id = -1;
return function () {
++id;
return id;
};
}());
SimpleType = (function (Type) {
var _SimpleType_prototype, _Type_prototype2;
function SimpleType(name) {
var _this;
_this = this instanceof SimpleType ? this : __create(_SimpleType_prototype);
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
_this.name = name;
_this.id = getId();
return _this;
}
_Type_prototype2 = Type.prototype;
_SimpleType_prototype = SimpleType.prototype = __create(_Type_prototype2);
_SimpleType_prototype.constructor = SimpleType;
SimpleType.displayName = "SimpleType";
if (typeof Type.extended === "function") {
Type.extended(SimpleType);
}
_SimpleType_prototype.toString = function () {
return this.name;
};
_SimpleType_prototype.equals = function (other) {
return this === other;
};
_SimpleType_prototype.compare = function (other) {
if (this === other) {
return 0;
} else if (other instanceof SimpleType) {
return __cmp(this.name, other.name) || __cmp(this.id, other.id);
} else {
return __cmp("SimpleType", other.constructor.displayName);
}
};
_SimpleType_prototype.union = function (other) {
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof SimpleType) {
if (this === other) {
return this;
} else {
return makeUnionType(
[this, other],
true
);
}
} else {
return other.union(this);
}
};
_SimpleType_prototype.intersect = function (other) {
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof SimpleType) {
if (this === other) {
return this;
} else {
return none;
}
} else {
return other.intersect(this);
}
};
_SimpleType_prototype.isSubsetOf = function (other) {
var _this;
_this = this;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof SimpleType) {
return this === other;
} else if (other instanceof UnionType) {
return (function () {
var _arr, _i, type;
for (_arr = __toArray(other.types), _i = _arr.length; _i--; ) {
type = _arr[_i];
if (_this === type) {
return true;
}
}
return false;
}());
} else if (other instanceof ComplementType) {
return !this.isSubsetOf(other.untype);
} else {
return other === any;
}
};
_SimpleType_prototype.overlaps = function (other) {
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof SimpleType) {
return this === other;
} else {
return other.overlaps(this);
}
};
_SimpleType_prototype.inspect = function () {
var _this;
_this = this;
return (function () {
var _else, k, v;
_else = true;
for (k in Type) {
if (__owns.call(Type, k)) {
_else = false;
v = Type[k];
if (v === _this) {
return "Type." + k;
}
}
}
return "Type.make(" + __strnum(inspect(_this.name)) + ")";
}());
};
_SimpleType_prototype.toJSON = function () {
var _this;
_this = this;
return (function () {
var _else, k, v;
_else = true;
for (k in Type) {
if (__owns.call(Type, k)) {
_else = false;
v = Type[k];
if (v === _this) {
return k;
}
}
}
throw Error("Cannot serialize custom type: " + String(_this));
}());
};
fromJSONTypes.simple = function (_p) {
var name;
name = _p.name;
return __owns.call(Type, name) && Type[name] || __throw(Error("Unknown type: " + String(name)));
};
return SimpleType;
}(Type));
Type.make = function (name) {
return SimpleType(name);
};
GenericType = (function (Type) {
var _GenericType_prototype, _Type_prototype2;
function GenericType(base, args) {
var _i, _ref, _this;
_this = this instanceof GenericType ? this : __create(_GenericType_prototype);
if (!(base instanceof SimpleType)) {
throw TypeError("Expected base to be a " + __name(SimpleType) + ", got " + __typeof(base));
}
_this.base = base;
if (!__isArray(args)) {
throw TypeError("Expected args to be an Array, got " + __typeof(args));
} else {
for (_i = args.length; _i--; ) {
if (!(args[_i] instanceof Type)) {
throw TypeError("Expected " + ("args[" + _i + "]") + " to be a " + __name(Type) + ", got " + __typeof(args[_i]));
}
}
}
if (args.length === 0) {
throw Error("Must provide at least one generic type argument");
}
_this.id = getId();
_this.args = args.slice();
if (_this.base === arrayBase && args.length === 1) {
if ((_ref = args[0]._array) != null) {
return _ref;
}
args[0]._array = _this;
} else if (_this.base === functionBase && args.length === 1) {
if ((_ref = args[0]._function) != null) {
return _ref;
}
args[0]._function = _this;
}
return _this;
}
_Type_prototype2 = Type.prototype;
_GenericType_prototype = GenericType.prototype = __create(_Type_prototype2);
_GenericType_prototype.constructor = GenericType;
GenericType.displayName = "GenericType";
if (typeof Type.extended === "function") {
Type.extended(GenericType);
}
function become(alpha, bravo) {
if (!__lte(alpha.id, bravo.id)) {
return become(bravo, alpha);
}
bravo.base = alpha.base;
bravo.args = alpha.args;
bravo.id = alpha.id;
}
_GenericType_prototype.toString = function () {
var _ref, _this;
_this = this;
if ((_ref = this._name) == null) {
return this._name = (function () {
var _arr, _len, arg, i, sb;
if (_this.base === arrayBase && _this.args.length === 1) {
if (_this.args[0] === any) {
return "[]";
} else {
return "[" + String(_this.args[0]) + "]";
}
} else if (_this.base === functionBase && _this.args.length === 1) {
if (_this.args[0] === any) {
return "->";
} else {
return "-> " + String(_this.args[0]);
}
} else {
sb = [];
sb.push(String(_this.base));
sb.push("<");
for (_arr = __toArray(_this.args), i = 0, _len = _arr.length; i < _len; ++i) {
arg = _arr[i];
if (i > 0) {
sb.push(",");
if (arg !== any && _this.args[i - 1] !== any) {
sb.push(" ");
}
}
if (arg !== any) {
sb.push(String(arg));
}
}
sb.push(">");
return sb.join("");
}
}());
} else {
return _ref;
}
};
_GenericType_prototype.equals = function (other) {
if (other === this) {
return true;
} else if (other instanceof GenericType) {
if (this.id === other.id) {
return true;
} else if (this.base === other.base && equals(this.args, other.args)) {
become(this, other);
return true;
} else {
return false;
}
} else {
return false;
}
};
_GenericType_prototype.compare = function (other) {
var _ref, cmp;
if (other === this) {
return 0;
} else if (other instanceof GenericType) {
if (this.id === other.id) {
return 0;
} else {
if (_ref = this.base.compare(other.base)) {
return _ref;
}
cmp = compare(this.args, other.args);
if (!cmp) {
become(this, other);
}
return cmp;
}
} else {
return __cmp("GenericType", other.constructor.displayName);
}
};
_GenericType_prototype.union = function (other) {
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof GenericType) {
if (this.equals(other)) {
return this;
} else if (this.isSubsetOf(other)) {
return other;
} else if (other.isSubsetOf(this)) {
return this;
} else {
return makeUnionType(
[this, other],
true
);
}
} else if (other instanceof SimpleType) {
return makeUnionType(
[this, other],
true
);
} else {
return other.union(this);
}
};
_GenericType_prototype.intersect = function (other) {
var arg, args, i, isOther, isThis, len, newArg, newArgs, otherArg, otherArgs;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof GenericType) {
if (this.base !== other.base) {
return none;
} else if (this.equals(other)) {
return this;
} else {
args = this.args;
otherArgs = other.args;
len = args.length;
if (len !== otherArgs.length) {
return none;
} else {
isThis = true;
isOther = true;
newArgs = [];
for (i = 0, __num(len); i < len; ++i) {
arg = args[i];
otherArg = otherArgs[i];
newArg = args[i].intersect(otherArgs[i]);
if (isThis && arg !== newArg) {
isThis = false;
}
if (isOther && otherArg !== newArg) {
isOther = false;
}
newArgs.push(newArg);
}
if (isThis) {
return this;
} else if (isOther) {
return other;
} else {
return GenericType(this.base, newArgs);
}
}
}
} else if (other instanceof SimpleType) {
return none;
} else {
return other.intersect(this);
}
};
_GenericType_prototype.isSubsetOf = function (other) {
var _this, args, i, len, otherArgs;
_this = this;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof GenericType) {
if (this.base !== other.base) {
return false;
} else if (this.equals(other)) {
return true;
} else {
args = this.args;
otherArgs = other.args;
len = args.length;
if (len !== otherArgs.length) {
return false;
} else {
for (i = 0, __num(len); i < len; ++i) {
if (!args[i].isSubsetOf(otherArgs[i])) {
return false;
}
}
return true;
}
}
} else if (other instanceof UnionType) {
return (function () {
var _arr, _i, type;
for (_arr = __toArray(other.types), _i = _arr.length; _i--; ) {
type = _arr[_i];
if (_this.isSubsetOf(type)) {
return true;
}
}
return false;
}());
} else if (other instanceof ComplementType) {
return !this.isSubsetOf(other.untype);
} else {
return other === any;
}
};
_GenericType_prototype.overlaps = function (other) {
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof GenericType) {
if (this.base !== other.base) {
return false;
} else {
return this.args.length === other.args.length;
}
} else if (other instanceof SimpleType) {
return false;
} else {
return other.overlaps(this);
}
};
_GenericType_prototype.inspect = function (depth) {
var _arr, _i, _len, arg, sb;
if (depth != null) {
depth = __num(depth) - 1;
}
sb = ["Type.generic("];
sb.push(inspect(this.base, null, depth));
for (_arr = __toArray(this.args), _i = 0, _len = _arr.length; _i < _len; ++_i) {
arg = _arr[_i];
sb.push(", ");
sb.push(inspect(arg, null, depth));
}
sb.push(")");
return sb.join("");
};
_GenericType_prototype.toJSON = function () {
var _this;
_this = this;
return (function () {
var _else, k, v;
_else = true;
for (k in Type) {
if (__owns.call(Type, k)) {
_else = false;
v = Type[k];
if (v === _this) {
return k;
}
}
}
return { type: "generic", base: _this.base, args: _this.args };
}());
};
fromJSONTypes.generic = function (_p) {
var args, base, baseType;
base = _p.base;
args = _p.args;
baseType = Type.fromJSON(base);
if (baseType === arrayBase && args.length === 1) {
return Type.fromJSON(args[0]).array();
} else if (baseType === functionBase && args.length === 1) {
return Type.fromJSON(args[0])["function"]();
} else {
return GenericType(baseType, (function () {
var _arr, _arr2, _i, _len, arg;
for (_arr = [], _arr2 = __toArray(args), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
arg = _arr2[_i];
_arr.push(Type.fromJSON(arg));
}
return _arr;
}()));
}
};
return GenericType;
}(Type));
Type.generic = function (base) {
var args;
args = __slice.call(arguments, 1);
return GenericType(
typeof base === "string" ? Type.make(base) : base,
args
);
};
ObjectType = (function (Type) {
var _ObjectType_prototype, _Type_prototype2;
function ObjectType(data) {
var _this, k, pairs, v;
_this = this instanceof ObjectType ? this : __create(_ObjectType_prototype);
if (typeof data !== "object" || data === null) {
throw TypeError("Expected data to be an Object, got " + __typeof(data));
}
pairs = [];
for (k in data) {
if (__owns.call(data, k)) {
v = data[k];
if (!(v instanceof Type)) {
throw TypeError("Expected data[" + __str(JSON.stringify(k)) + "] to be a Type, got " + __typeof(v));
}
if (v !== any) {
pairs.push([k, v]);
}
}
}
pairs.sort(function (a, b) {
return __cmp(a[0], b[0]);
});
if (pairs.length === 0 && Type.object != null) {
return Type.object;
}
_this.pairs = pairs;
_this.id = getId();
return _this;
}
_Type_prototype2 = Type.prototype;
_ObjectType_prototype = ObjectType.prototype = __create(_Type_prototype2);
_ObjectType_prototype.constructor = ObjectType;
ObjectType.displayName = "ObjectType";
if (typeof Type.extended === "function") {
Type.extended(ObjectType);
}
_ObjectType_prototype.toString = function () {
var _ref, _this;
_this = this;
if ((_ref = this._name) == null) {
return this._name = "{" + __strnum((function () {
var _arr, _arr2, _i, _len, _ref, k, v;
for (_arr = [], _arr2 = __toArray(_this.pairs), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
k = (_ref = _arr2[_i])[0];
v = _ref[1];
_arr.push(__strnum(k) + ": " + String(v));
}
return _arr;
}()).join(", ")) + "}";
} else {
return _ref;
}
};
function become(alpha, bravo) {
if (!__lte(alpha.id, bravo.id)) {
return become(bravo, alpha);
}
bravo.pairs = alpha.pairs;
bravo.id = alpha.id;
}
_ObjectType_prototype.equals = function (other) {
var _arr, _len, i, otherPair, otherPairs, pair, pairs;
if (other === this) {
return true;
} else if (other instanceof ObjectType) {
pairs = this.pairs;
otherPairs = other.pairs;
if (pairs === otherPairs) {
return true;
} else if (pairs.length !== otherPairs.length) {
return false;
} else {
for (_arr = __toArray(pairs), i = 0, _len = _arr.length; i < _len; ++i) {
pair = _arr[i];
otherPair = otherPairs[i];
if (pair[0] !== otherPair[0] || !pair[1].equals(otherPair[1])) {
return false;
}
}
become(this, other);
return true;
}
} else {
return false;
}
};
_ObjectType_prototype.compare = function (other) {
var _arr, _len, cmp, i, otherPair, otherPairs, pair, pairs;
if (this === other) {
return 0;
} else if (other instanceof ObjectType) {
pairs = this.pairs;
otherPairs = other.pairs;
if (pairs === otherPairs) {
return 0;
} else {
cmp = __cmp(pairs.length, otherPairs.length);
if (cmp) {
return cmp;
} else {
for (_arr = __toArray(pairs), i = 0, _len = _arr.length; i < _len; ++i) {
pair = _arr[i];
otherPair = otherPairs[i];
cmp = __cmp(pair[0], otherPair[0]) || pair[1].compare(otherPair[1]);
if (cmp) {
return cmp;
}
}
become(this, other);
return 0;
}
}
} else {
return __cmp("ObjectType", other.constructor.displayName);
}
};
_ObjectType_prototype.union = function (other) {
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof ObjectType) {
if (this.equals(other)) {
return this;
} else if (this.isSubsetOf(other)) {
return other;
} else if (other.isSubsetOf(this)) {
return this;
} else {
return makeUnionType(
[this, other],
true
);
}
} else if (other instanceof SimpleType || other instanceof GenericType) {
return makeUnionType(
[this, other],
true
);
} else {
return other.union(this);
}
};
_ObjectType_prototype.intersect = function (other) {
var _arr, _i, _len, _ref, k, merged, v;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof ObjectType) {
if (this.equals(other)) {
return this;
} else if (this.isSubsetOf(other)) {
return this;
} else if (other.isSubsetOf(this)) {
return other;
} else {
merged = {};
for (_arr = __toArray(this.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
k = (_ref = _arr[_i])[0];
v = _ref[1];
merged[k] = v;
}
for (_arr = __toArray(other.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
k = (_ref = _arr[_i])[0];
v = _ref[1];
if (__owns.call(merged, k)) {
merged[k] = merged[k].intersect(v);
} else {
merged[k] = v;
}
}
return ObjectType(merged);
}
} else if (other instanceof SimpleType || other instanceof GenericType) {
return none;
} else {
return other.intersect(this);
}
};
_ObjectType_prototype.isSubsetOf = function (other) {
var _arr, _i, _len, _ref, _this, i, len, otherK, otherPairs, otherV, pair, pairs;
_this = this;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof ObjectType) {
if (this === other || other === Type.object) {
return true;
} else if (this === Type.object) {
return false;
} else {
pairs = this.pairs;
otherPairs = other.pairs;
if (pairs === other.pairs) {
return true;
} else {
i = 0;
len = pairs.length;
for (_arr = __toArray(otherPairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
otherK = (_ref = _arr[_i])[0];
otherV = _ref[1];
for (; i <= __num(len); ++i) {
if (i === len) {
return false;
}
pair = pairs[i];
if (pair[0] === otherK) {
if (pair[1].isSubsetOf(otherV)) {
++i;
break;
} else {
return false;
}
} else if (!__lte(pair[0], otherK)) {
return false;
}
}
}
if (i === len) {
become(this, other);
}
return true;
}
}
} else if (other instanceof UnionType) {
return (function () {
var _arr, _i, type;
for (_arr = __toArray(other.types), _i = _arr.length; _i--; ) {
type = _arr[_i];
if (_this.isSubsetOf(type)) {
return true;
}
}
return false;
}());
} else if (other instanceof ComplementType) {
return !this.isSubsetOf(other.untype);
} else {
return other === any;
}
};
_ObjectType_prototype.overlaps = function (other) {
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof ObjectType) {
return true;
} else if (other instanceof SimpleType || other instanceof GenericType) {
return false;
} else {
return other.overlaps(this);
}
};
_ObjectType_prototype.value = function (key) {
var _arr, _i, pair, pairKey;
if (typeof key !== "string") {
throw TypeError("Expected key to be a String, got " + __typeof(key));
}
for (_arr = __toArray(this.pairs), _i = _arr.length; _i--; ) {
pair = _arr[_i];
pairKey = pair[0];
if (pairKey === key) {
return pair[1];
} else if (pairKey < key) {
return Type.any;
}
}
return Type.any;
};
_ObjectType_prototype.inspect = function (depth) {
var _arr, _i, _len, _ref, k, obj, v;
if (this === Type.object) {
return "Type.object";
} else {
obj = {};
for (_arr = __toArray(this.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
k = (_ref = _arr[_i])[0];
v = _ref[1];
obj[k] = v;
}
return "Type.makeObject(" + __strnum(inspect(obj, null, depth != null ? __num(depth) - 1 : null)) + ")";
}
};
_ObjectType_prototype.toJSON = function () {
var _arr, _i, _len, _ref, k, pairs, v;
if (this.pairs.length === 0) {
return "object";
} else {
pairs = {};
for (_arr = __toArray(this.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
k = (_ref = _arr[_i])[0];
v = _ref[1];
pairs[k] = v;
}
return { type: "object", pairs: pairs };
}
};
fromJSONTypes.object = function (_p) {
var deserializedPairs, k, pairs, v;
pairs = _p.pairs;
deserializedPairs = {};
for (k in pairs) {
if (__owns.call(pairs, k)) {
v = pairs[k];
deserializedPairs[k] = Type.fromJSON(v);
}
}
return ObjectType(deserializedPairs);
};
return ObjectType;
}(Type));
Type.makeObject = function (data) {
return ObjectType(data);
};
UnionType = (function (Type) {
var _Type_prototype2, _UnionType_prototype;
function UnionType(types) {
var _i, _this;
_this = this instanceof UnionType ? this : __create(_UnionType_prototype);
if (!__isArray(types)) {
throw TypeError("Expected types to be an Array, got " + __typeof(types));
} else {
for (_i = types.length; _i--; ) {
if (!(types[_i] instanceof Type)) {
throw TypeError("Expected " + ("types[" + _i + "]") + " to be a " + __name(Type) + ", got " + __typeof(types[_i]));
}
}
}
_this.types = types;
if (types.length <= 1) {
throw Error("Must provide at least 2 types to UnionType");
}
_this.id = getId();
return _this;
}
_Type_prototype2 = Type.prototype;
_UnionType_prototype = UnionType.prototype = __create(_Type_prototype2);
_UnionType_prototype.constructor = UnionType;
UnionType.displayName = "UnionType";
if (typeof Type.extended === "function") {
Type.extended(UnionType);
}
_UnionType_prototype.toString = function () {
var _ref;
if ((_ref = this._name) == null) {
return this._name = "(" + __strnum(this.types.join("|")) + ")";
} else {
return _ref;
}
};
function become(alpha, bravo) {
if (!__lte(alpha.id, bravo.id)) {
return become(bravo, alpha);
}
bravo.types = alpha.types;
return bravo.id = alpha.id;
}
_UnionType_prototype.equals = function (other) {
if (other === this) {
return true;
} else if (other instanceof UnionType) {
if (this.id === other.id) {
return true;
} else if (this.types === other.types || equals(this.types, other.types)) {
become(this, other);
return true;
} else {
return false;
}
} else {
return false;
}
};
_UnionType_prototype.compare = function (other) {
var cmp;
if (other === this) {
return 0;
} else if (other instanceof UnionType) {
if (this.id === other.id) {
return 0;
} else if (this.types === other.types) {
become(this, other);
return 0;
} else {
cmp = compare(this.types, other.types);
if (cmp === 0) {
become(this, other);
}
return cmp;
}
} else {
return __cmp("UnionType", other.constructor.displayName);
}
};
_UnionType_prototype.union = function (other) {
var _arr, _i, _len, newTypes, type, types;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof SimpleType || other instanceof GenericType) {
types = union(this.types, [other]);
if (types === this.types) {
return this;
} else {
return makeUnionType(types);
}
} else if (other instanceof ObjectType) {
if (other === Type.object) {
newTypes = [other];
for (_arr = __toArray(this.types), _i = 0, _len = _arr.length; _i < _len; ++_i) {
type = _arr[_i];
if (type instanceof ObjectType) {
if (type === Type.object) {
return this;
}
} else {
newTypes.push(type);
}
}
return makeUnionType(newTypes);
} else {
newTypes = [other];
for (_arr = __toArray(this.types), _i = 0, _len = _arr.length; _i < _len; ++_i) {
type = _arr[_i];
if (type instanceof ObjectType) {
if (other.isSubsetOf(type)) {
return this;
} else if (!type.isSubsetOf(other)) {
newTypes.push(type);
}
} else {
newTypes.push(type);
}
}
return makeUnionType(newTypes);
}
} else if (other instanceof UnionType) {
types = union(this.types, other.types);
if (types === this.types) {
return this;
} else if (types === other.types) {
return other;
} else {
return makeUnionType(types);
}
} else {
return other.union(this);
}
};
_UnionType_prototype.intersect = function (other) {
var types;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof SimpleType || other instanceof GenericType || other instanceof ObjectType) {
return makeUnionType(intersect(this.types, [other]));
} else if (other instanceof UnionType) {
types = intersect(this.types, other.types);
if (types === this.types) {
return this;
} else if (types === other.types) {
return other;
} else {
return makeUnionType(types);
}
} else {
return other.intersect(this);
}
};
_UnionType_prototype.isSubsetOf = function (other) {
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof UnionType) {
return isSubsetOf(this.types, other.types);
} else if (other instanceof ComplementType) {
return !this.overlaps(other.untype);
} else {
return other === any;
}
};
_UnionType_prototype.overlaps = function (other) {
var _this;
_this = this;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof SimpleType) {
return contains(this.types, other);
} else if (other instanceof GenericType || other instanceof ObjectType) {
return (function () {
var _arr, _i, type;
for (_arr = __toArray(_this.types), _i = _arr.length; _i--; ) {
type = _arr[_i];
if (type.overlaps(other)) {
return true;
}
}
return false;
}());
} else if (other instanceof UnionType) {
return overlaps(this.types, other.types);
} else {
return other.overlaps(this);
}
};
_UnionType_prototype.inspect = function (depth) {
var _this;
_this = this;
return "(" + __strnum((function () {
var _arr, _arr2, _i, _len, type;
for (_arr = [], _arr2 = __toArray(_this.types), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
type = _arr2[_i];
_arr.push(inspect(type, null, depth != null ? __num(depth) - 1 : null));
}
return _arr;
}()).join(").union(")) + ")";
};
_UnionType_prototype.toJSON = function () {
var _this;
_this = this;
return (function () {
var _else, k, v;
_else = true;
for (k in Type) {
if (__owns.call(Type, k)) {
_else = false;
v = Type[k];
if (v === _this) {
return k;
}
}
}
return { type: "union", types: _this.types };
}());
};
fromJSONTypes.union = function (_p) {
var _arr, _i, current, type, types;
types = _p.types;
current = Type.none;
for (_arr = __toArray(types), _i = _arr.length; _i--; ) {
type = _arr[_i];
current = current.union(Type.fromJSON(type));
}
return current;
};
return UnionType;
}(Type));
ComplementType = (function (Type) {
var _ComplementType_prototype, _Type_prototype2;
function ComplementType(untype) {
var _this;
_this = this instanceof ComplementType ? this : __create(_ComplementType_prototype);
if (!(untype instanceof Type)) {
throw TypeError("Expected untype to be a " + __name(Type) + ", got " + __typeof(untype));
}
_this.untype = untype;
_this.id = getId();
return _this;
}
_Type_prototype2 = Type.prototype;
_ComplementType_prototype = ComplementType.prototype = __create(_Type_prototype2);
_ComplementType_prototype.constructor = ComplementType;
ComplementType.displayName = "ComplementType";
if (typeof Type.extended === "function") {
Type.extended(ComplementType);
}
_ComplementType_prototype.toString = function () {
var _ref;
if ((_ref = this._name) == null) {
return this._name = "any \\ " + String(this.untype);
} else {
return _ref;
}
};
function become(alpha, bravo) {
if (!__lte(alpha.id, bravo.id)) {
return become(bravo, alpha);
}
bravo.id = alpha.id;
return bravo.untype = alpha.untype;
}
_ComplementType_prototype.equals = function (other) {
if (this === other) {
return true;
} else if (other instanceof ComplementType) {
if (this.id === other.id) {
return true;
} else if (this.untype.equals(other.untype)) {
become(this, other);
return true;
} else {
return false;
}
} else {
return false;
}
};
_ComplementType_prototype.compare = function (other) {
var cmp;
if (this === other) {
return 0;
} else if (other instanceof ComplementType) {
if (this.id === other.id) {
return 0;
} else {
cmp = this.untype.compare(other.untype);
if (cmp === 0) {
become(this, other);
}
return cmp;
}
} else {
return __cmp("ComplementType", other.constructor.displayName);
}
};
function getUntypes(untype) {
if (untype instanceof UnionType) {
return untype.types;
} else {
return [untype];
}
}
_ComplementType_prototype.union = function (other) {
var myUntypes, untypes;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof SimpleType || other instanceof GenericType || other instanceof ObjectType) {
myUntypes = getUntypes(this.untype);
untypes = relativeComplement(myUntypes, [other]);
if (untypes === myUntypes) {
return this;
} else {
return makeUnionType(untypes).complement();
}
} else if (other instanceof UnionType) {
myUntypes = getUntypes(this.untype);
untypes = relativeComplement(myUntypes, other.types);
if (untypes === myUntypes) {
return this;
} else {
return makeUnionType(untypes).complement();
}
} else if (other instanceof ComplementType) {
return this.untype.intersect(other.untype).complement();
} else {
return other.union(this);
}
};
_ComplementType_prototype.intersect = function (other) {
var types;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof SimpleType || other instanceof GenericType || other instanceof ObjectType) {
if (contains(getUntypes(this.untype), other)) {
return none;
} else {
return other;
}
} else if (other instanceof UnionType) {
types = relativeComplement(other.types, getUntypes(this.untype));
if (types === other.types) {
return other;
} else {
return makeUnionType(types);
}
} else if (other instanceof ComplementType) {
return this.untype.union(other.untype).complement();
} else {
return other.intersect(this);
}
};
_ComplementType_prototype.isSubsetOf = function (other) {
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof ComplementType) {
return other.untype.isSubsetOf(this.untype);
} else {
return other === any;
}
};
_ComplementType_prototype.overlaps = function (other) {
var _this;
_this = this;
if (!(other instanceof Type)) {
throw TypeError("Expected other to be a " + __name(Type) + ", got " + __typeof(other));
}
if (other instanceof SimpleType || other instanceof GenericType) {
return !this.untype.overlaps(other);
} else if (other instanceof ObjectType) {
return (function () {
var _arr, _i, untype;
for (_arr = getUntypes(_this.untype), _i = _arr.length; _i--; ) {
untype = _arr[_i];
if (untype instanceof ObjectType && other.isSubsetOf(untype)) {
return false;
}
}
return true;
}());
} else if (other instanceof UnionType) {
return relativeComplement(other.types, getUntypes(this.untype)).length > 0;
} else if (other instanceof ComplementType) {
return true;
} else {
return other.overlaps(this);
}
};
_ComplementType_prototype.complement = function () {
return this.untype;
};
_ComplementType_prototype.inspect = function (depth) {
return __strnum(this.untype.inspect(depth)) + ".complement()";
};
_ComplementType_prototype.toJSON = function () {
var _this;
_this = this;
return (function () {
var _else, k, v;
_else = true;
for (k in Type) {
if (__owns.call(Type, k)) {
_else = false;
v = Type[k];
if (v === _this) {
return k;
}
}
}
return { type: "complement", untype: _this.complement() };
}());
};
fromJSONTypes.complement = function (_p) {
var untype;
untype = _p.untype;
return Type.fromJSON(untype).complement();
};
return ComplementType;
}(Type));
any = Type.any = new (AnyType = (function (Type) {
var _AnyType_prototype, _Type_prototype2;
function AnyType() {
var _this;
_this = this instanceof AnyType ? this : __create(_AnyType_prototype);
if (any) {
throw Error("Cannot instantiate more than once");
}
return _this;
}
_Type_prototype2 = Type.prototype;
_AnyType_prototype = AnyType.prototype = __create(_Type_prototype2);
_AnyType_prototype.constructor = AnyType;
AnyType.displayName = "AnyType";
if (typeof Type.extended === "function") {
Type.extended(AnyType);
}
_AnyType_prototype.toString = function () {
return "any";
};
_AnyType_prototype.equals = function (other) {
return this === other;
};
_AnyType_prototype.compare = function (other) {
if (this === other) {
return 0;
} else {
return __cmp("AnyType", other.constructor.displayName);
}
};
_AnyType_prototype.union = function (other) {
return this;
};
_AnyType_prototype.intersect = function (other) {
return other;
};
_AnyType_prototype.isSubsetOf = function (other) {
return this === other;
};
_AnyType_prototype.overlaps = function (other) {
return true;
};
_AnyType_prototype.complement = function () {
return none;
};
_AnyType_prototype.inspect = function () {
return "Type.any";
};
_AnyType_prototype.toJSON = function () {
return "any";
};
fromJSONTypes.any = function () {
return any;
};
return AnyType;
}(Type)))();
none = Type.none = new (NoneType = (function (Type) {
var _NoneType_prototype, _Type_prototype2;
function NoneType() {
var _this;
_this = this instanceof NoneType ? this : __create(_NoneType_prototype);
if (none) {
throw Error("Cannot instantiate more than once");
}
return _this;
}
_Type_prototype2 = Type.prototype;
_NoneType_prototype = NoneType.prototype = __create(_Type_prototype2);
_NoneType_prototype.constructor = NoneType;
NoneType.displayName = "NoneType";
if (typeof Type.extended === "function") {
Type.extended(NoneType);
}
_NoneType_prototype.toString = function () {
return "none";
};
_NoneType_prototype.equals = function (other) {
return this === other;
};
_NoneType_prototype.compare = function (other) {
if (this === other) {
return 0;
} else {
return __cmp("NoneType", other.constructor.displayName);
}
};
_NoneType_prototype.union = function (other) {
return other;
};
_NoneType_prototype.intersect = function (other) {
return this;
};
_NoneType_prototype.isSubsetOf = function (other) {
return true;
};
_NoneType_prototype.overlaps = function (other) {
return false;
};
_NoneType_prototype.complement = function () {
return any;
};
_NoneType_prototype.inspect = function () {
return "Type.none";
};
_NoneType_prototype.toJSON = function () {
return "none";
};
fromJSONTypes.none = function () {
return none;
};
return NoneType;
}(Type)))();
arrayBase = Type.arrayBase = Type.make("Array");
functionBase = Type.functionBase = Type.make("Function");
Type["undefined"] = Type.make("undefined");
Type["null"] = Type.make("null");
Type.boolean = Type.make("Boolean");
Type.string = Type.make("String");
Type.stringArray = Type.string.array();
Type.number = Type.make("Number");
Type.numberArray = Type.number.array();
Type.array = any.array();
Type.args = Type.make("Arguments");
Type.object = Type.makeObject({});
Type["function"] = any["function"]();
Type.regexp = Type.make("RegExp");
Type.date = Type.make("Date");
Type.error = Type.make("Error");
Type.promise = Type.makeObject({ then: Type.any["function"](Type["function"], Type["function"]) });
Type.numeric = Type.number.union(Type["undefined"]).union(Type["null"]).union(Type.boolean);
Type.stringOrNumber = Type.string.union(Type.number);
Type.arrayLike = Type.array.union(Type.args);
Type.undefinedOrNull = Type["undefined"].union(Type["null"]);
Type.notUndefinedOrNull = Type.undefinedOrNull.complement();
Type.primitive = Type.undefinedOrNull.union(Type.boolean).union(Type.string).union(Type.number);
Type.nonPrimitive = Type.primitive.complement();
Type.alwaysFalsy = Type.undefinedOrNull;
Type.potentiallyTruthy = Type.alwaysFalsy.complement();
Type.potentiallyFalsy = Type.alwaysFalsy.union(Type.number).union(Type.string).union(Type.boolean);
Type.alwaysTruthy = Type.potentiallyFalsy.complement();
return Type;
}());
}.call(this));
return module.exports;
};
require['./jsast'] = function () {
var module = { exports: this };
var exports = this;
(function () {
"use strict";
var __create, __import, __in, __isArray, __lt, __lte, __name, __num, __owns, __slice, __strnum, __toArray, __typeof, _ref, Arguments, Arr, Binary, Block, BlockExpression, BlockStatement, Break, Call, Comment, Const, Continue, Debugger, DoWhile, Eval, Expression, For, ForIn, fromJSON, Func, getIndent, Ident, If, IfExpression, IfStatement, INDENT, inspect, isAcceptableIdent, Level, Node, Noop, Obj, padLeft, Regex, Return, Root, Statement, Switch, This, Throw, toJSSource, TryCatch, TryFinally, Unary, util, While;
__create = typeof Object.create === "function" ? Object.create
: function (x) {
function F() {}
F.prototype = x;
return new F();
};
__import = function (dest, source) {
var k;
for (k in source) {
if (__owns.call(source, k)) {
dest[k] = source[k];
}
}
return dest;
};
__in = typeof Array.prototype.indexOf === "function"
? (function () {
var indexOf;
indexOf = Array.prototype.indexOf;
return function (child, parent) {
return indexOf.call(parent, child) !== -1;
};
}())
: function (child, parent) {
var i, len;
len = +parent.length;
i = -1;
while (++i < len) {
if (child === parent[i] && i in parent) {
return true;
}
}
return false;
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__lt = function (x, y) {
var type;
type = typeof x;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof y) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof y);
} else {
return x < y;
}
};
__lte = function (x, y) {
var type;
type = typeof x;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof y) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof y);
} else {
return x <= y;
}
};
__name = function (func) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
return func.displayName || func.name || "";
};
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__owns = Object.prototype.hasOwnProperty;
__slice = Array.prototype.slice;
__strnum = function (strnum) {
var type;
type = typeof strnum;
if (type === "string") {
return strnum;
} else if (type === "number") {
return String(strnum);
} else {
throw TypeError("Expected a string or number, got " + __typeof(strnum));
}
};
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
util = require("util");
if (util != null) {
inspect = util.inspect;
}
padLeft = require("./utils").padLeft;
isAcceptableIdent = (_ref = require("./jsutils")).isAcceptableIdent;
toJSSource = _ref.toJSSource;
Level = (function () {
this.block = 1;
this.insideParentheses = 2;
this.sequence = 3;
this.assignment = 4;
this.inlineCondition = 5;
this.logicalOr = 6;
this.logicalAnd = 7;
this.bitwiseOr = 8;
this.bitwiseAnd = 9;
this.bitwiseXor = 10;
this.equality = 11;
this.relational = 12;
this.bitwiseShift = 13;
this.addition = 14;
this.multiplication = 15;
this.unary = 16;
this.increment = 17;
this.callOrAccess = 18;
this.newCall = 19;
return this;
}.call({}));
INDENT = " ";
function incIndent(options) {
var clone;
clone = __create(options);
clone.indent = __num(clone.indent) + 1;
return clone;
}
getIndent = (function () {
var cache;
cache = [""];
return function (indent) {
var i, result;
if (__num(indent) >= cache.length) {
result = cache[cache.length - 1];
for (i = cache.length, __num(indent); i <= indent; ++i) {
result = __strnum(result) + INDENT;
cache.push(result);
}
}
return cache[indent];
};
}());
function wrapStringHandler(callback) {
function cb(item) {
var len, parts, s;
s = String(item);
parts = s.split(/(?:\r\n?|[\n\u2028\u2029])/g);
if (parts.length === 1) {
cb.column = __num(cb.column) + __num(parts[0].length);
} else {
len = parts.length;
cb.line = __num(cb.line) + (__num(len) - 1);
cb.column = __num(parts[__num(len) - 1].length) + 1;
}
callback(s);
}
cb.line = 1;
cb.column = 1;
cb.indent = function (count) {
callback(getIndent(count));
cb.column = __num(cb.column) + __num(count);
};
return cb;
}
function StringWriter(callback) {
var sb;
return sb = wrapStringHandler(callback);
}
function StringBuilder() {
var data, sb;
data = [];
sb = wrapStringHandler(function (item) {
data.push(item);
});
sb.toString = function () {
var text;
switch (data.length) {
case 0: return "";
case 1: return data[0];
default:
text = data.join("");
data.splice(0, data.length, text);
return text;
}
};
return sb;
}
exports.Node = Node = (function () {
var _Node_prototype;
function Node() {
var _this;
_this = this instanceof Node ? this : __create(_Node_prototype);
throw Error("Node cannot be instantiated directly");
}
_Node_prototype = Node.prototype;
Node.displayName = "Node";
_Node_prototype.toString = function (options) {
var sb;
if (options == null) {
options = {};
}
sb = StringBuilder();
this.compileAsStatement(
__import(
{ indent: 0, bare: true },
options
),
true,
sb
);
return sb.toString();
};
_Node_prototype.compile = function () {
throw Error("Not implemented: " + __name(this.constructor) + ".compile()");
};
_Node_prototype.maybeToStatement = function () {
if (typeof this.toStatement === "function") {
return this.toStatement();
} else {
return this;
}
};
_Node_prototype.isConst = function () {
return false;
};
_Node_prototype.isNoop = function () {
return false;
};
_Node_prototype.constValue = function () {
throw Error(__strnum(this.constructor.name) + " has no const value");
};
_Node_prototype.isLarge = function () {
return true;
};
_Node_prototype.isSmall = function () {
return !this.isLarge();
};
_Node_prototype.mutateLast = function () {
return this;
};
_Node_prototype.exitType = function () {
return null;
};
_Node_prototype.last = function () {
return this;
};
_Node_prototype.toJSON = function () {
return [this.constructor.name, this.pos.line, this.pos.column, this.pos.file || 0].concat(__toArray(this._toJSON()));
};
_Node_prototype._toJSON = function () {
return [];
};
return Node;
}());
exports.Expression = Expression = (function (Node) {
var _Expression_prototype, _Node_prototype;
function Expression() {
var _this;
_this = this instanceof Expression ? this : __create(_Expression_prototype);
throw Error("Expression cannot be instantiated directly");
}
_Node_prototype = Node.prototype;
_Expression_prototype = Expression.prototype = __create(_Node_prototype);
_Expression_prototype.constructor = Expression;
Expression.displayName = "Expression";
if (typeof Node.extended === "function") {
Node.extended(Expression);
}
_Expression_prototype.compileAsBlock = function (options, level, lineStart, sb) {
this.compile(options, level, lineStart, sb);
};
_Expression_prototype.compileAsStatement = function (options, lineStart, sb) {
if (typeof this.toStatement === "function") {
this.toStatement().compileAsStatement(options, lineStart, sb);
} else {
this.compile(options, Level.block, lineStart, sb);
sb(";");
}
};
_Expression_prototype.isLarge = function () {
return false;
};
_Expression_prototype.mutateLast = function (func) {
return func(this);
};
return Expression;
}(Node));
exports.Statement = Statement = (function (Node) {
var _Node_prototype, _Statement_prototype;
function Statement() {
var _this;
_this = this instanceof Statement ? this : __create(_Statement_prototype);
throw Error("Expression cannot be instantiated directly");
}
_Node_prototype = Node.prototype;
_Statement_prototype = Statement.prototype = __create(_Node_prototype);
_Statement_prototype.constructor = Statement;
Statement.displayName = "Statement";
if (typeof Node.extended === "function") {
Node.extended(Statement);
}
_Statement_prototype.compileAsStatement = function (options, lineStart, sb) {
return this.compile(options, Level.block, lineStart, sb);
};
return Statement;
}(Node));
exports.Access = function (pos, parent) {
var _i, _len, child, children, current;
children = __slice.call(arguments, 2);
current = parent;
for (_i = 0, _len = children.length; _i < _len; ++_i) {
child = children[_i];
current = Binary(pos, current, ".", child);
}
return current;
};
function makePos(line, column, file) {
var pos;
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (file == null) {
file = void 0;
} else if (typeof file !== "string" && typeof file !== "number") {
throw TypeError("Expected file to be one of String or Number or undefined, got " + __typeof(file));
}
pos = { line: line, column: column };
if (file) {
if (typeof file !== "string") {
throw TypeError("Must provide a valid string for file");
}
pos.file = file;
}
return pos;
}
exports.Arguments = Arguments = (function (Expression) {
var _Arguments_prototype, _Expression_prototype;
function Arguments(pos) {
var _this;
_this = this instanceof Arguments ? this : __create(_Arguments_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
return _this;
}
_Expression_prototype = Expression.prototype;
_Arguments_prototype = Arguments.prototype = __create(_Expression_prototype);
_Arguments_prototype.constructor = Arguments;
Arguments.displayName = "Arguments";
if (typeof Expression.extended === "function") {
Expression.extended(Arguments);
}
_Arguments_prototype.compile = function (options, level, lineStart, sb) {
var _ref;
if ((_ref = options.sourcemap) != null) {
_ref.add(
sb.line,
sb.column,
this.pos.line,
this.pos.column,
this.pos.file
);
}
sb("arguments");
};
_Arguments_prototype.compileAsBlock = function (options, level, lineStart, sb) {
Noop(this.pos).compileAsBlock(options, level, lineStart, sb);
};
_Arguments_prototype.walk = function () {
return this;
};
_Arguments_prototype.isNoop = function () {
return true;
};
_Arguments_prototype.inspect = function (depth) {
return inspectHelper(depth, "Arguments", this.pos);
};
Arguments.fromJSON = function (line, column, file) {
return Arguments(makePos(line, column, file));
};
return Arguments;
}(Expression));
function walkArray(array, walker) {
var _arr, _i, _len, changed, item, newItem, result;
if (!__isArray(array)) {
throw TypeError("Expected array to be an Array, got " + __typeof(array));
}
if (typeof walker !== "function") {
throw TypeError("Expected walker to be a Function, got " + __typeof(walker));
}
changed = false;
for (_arr = [], _i = 0, _len = array.length; _i < _len; ++_i) {
item = array[_i];
newItem = walker(item);
if (newItem == null) {
newItem = item.walk(walker);
}
if (item !== newItem) {
changed = true;
}
_arr.push(newItem);
}
result = _arr;
if (changed) {
return result;
} else {
return array;
}
}
function decDepth(depth) {
if (depth != null) {
return __num(depth) - 1;
} else {
return null;
}
}
function inspectHelper(depth, name, pos) {
var _arr, _i, _len, arg, args, d, found, hasLarge, parts;
args = __slice.call(arguments, 3);
d = decDepth(depth);
found = false;
for (_i = args.length; _i--; ) {
arg = args[_i];
if (!arg || arg instanceof Noop || __isArray(arg) && arg.length === 0) {
args.pop();
} else {
break;
}
}
for (_arr = [], _i = 0, _len = args.length; _i < _len; ++_i) {
arg = args[_i];
_arr.push(inspect(arg, null, d));
}
parts = _arr;
hasLarge = (function () {
var _i, _len, part;
for (_i = 0, _len = parts.length; _i < _len; ++_i) {
part = parts[_i];
if (parts.length > 50 || part.indexOf("\n") !== -1) {
return true;
}
}
return false;
}());
if (hasLarge) {
parts = (function () {
var _arr, _i, _len, part;
for (_arr = [], _i = 0, _len = parts.length; _i < _len; ++_i) {
part = parts[_i];
_arr.push(" " + __strnum(part.split("\n").join("\n ")));
}
return _arr;
}());
return __strnum(name) + "(\n" + __strnum(parts.join(",\n")) + ")";
} else {
return __strnum(name) + "(" + __strnum(parts.join(", ")) + ")";
}
}
function simplifyArray(array, childDefaultValue, keepTrailing) {
var _len, i, item, lastNoop, result;
if (!__isArray(array)) {
throw TypeError("Expected array to be an Array, got " + __typeof(array));
}
if (keepTrailing == null) {
keepTrailing = false;
} else if (typeof keepTrailing !== "boolean") {
throw TypeError("Expected keepTrailing to be a Boolean, got " + __typeof(keepTrailing));
}
if (array.length === 0) {
return array;
} else {
result = [];
lastNoop = -1;
for (i = 0, _len = array.length; i < _len; ++i) {
item = array[i];
if (item instanceof Noop) {
lastNoop = i;
} else {
lastNoop = -1;
}
result.push(simplify(item, childDefaultValue));
}
if (!keepTrailing && lastNoop !== -1) {
result.splice(lastNoop, 1/0);
}
return result;
}
}
function simplify(obj, defaultValue) {
if (__isArray(obj)) {
return simplifyArray(obj);
} else if (obj instanceof Noop) {
return defaultValue;
} else {
return obj;
}
}
exports.Arr = Arr = (function (Expression) {
var _Arr_prototype, _Expression_prototype;
function Arr(pos, elements) {
var _i, _this;
_this = this instanceof Arr ? this : __create(_Arr_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (elements == null) {
elements = [];
} else if (!__isArray(elements)) {
throw TypeError("Expected elements to be an Array, got " + __typeof(elements));
} else {
for (_i = elements.length; _i--; ) {
if (!(elements[_i] instanceof Expression)) {
throw TypeError("Expected " + ("elements[" + _i + "]") + " to be a " + __name(Expression) + ", got " + __typeof(elements[_i]));
}
}
}
_this.elements = elements;
return _this;
}
_Expression_prototype = Expression.prototype;
_Arr_prototype = Arr.prototype = __create(_Expression_prototype);
_Arr_prototype.constructor = Arr;
Arr.displayName = "Arr";
if (typeof Expression.extended === "function") {
Expression.extended(Arr);
}
function compileLarge(elements, options, level, lineStart, sb) {
var _arr, childOptions, i, item, len;
childOptions = incIndent(options);
for (_arr = __toArray(elements), i = 0, len = _arr.length; i < len; ++i) {
item = _arr[i];
sb("\n");
sb.indent(childOptions.indent);
item.compile(childOptions, Level.sequence, false, sb);
if (i < len - 1) {
sb(",");
}
}
sb("\n");
sb.indent(options.indent);
}
function compileSmall(elements, options, level, lineStart, sb) {
var _arr, _len, i, item;
for (_arr = __toArray(elements), i = 0, _len = _arr.length; i < _len; ++i) {
item = _arr[i];
if (i > 0) {
sb(",");
if (!options.minify) {
sb(" ");
}
}
item.compile(options, Level.sequence, false, sb);
}
}
_Arr_prototype.compile = function (options, level, lineStart, sb) {
var _ref, f;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
sb("[");
if (!options.minify && this.shouldCompileLarge()) {
f = compileLarge;
} else {
f = compileSmall;
}
f(
this.elements,
options,
level,
lineStart,
sb
);
sb("]");
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_Arr_prototype.compileAsBlock = function (options, level, lineStart, sb) {
return BlockExpression(this.pos, this.elements).compileAsBlock(options, level, lineStart, sb);
};
_Arr_prototype.compileAsStatement = function (options, lineStart, sb) {
BlockStatement(this.pos, this.elements).compile(options, Level.block, lineStart, sb);
};
_Arr_prototype.shouldCompileLarge = function () {
switch (this.elements.length) {
case 0: return false;
case 1: return this.elements[0].isLarge();
default: return this.isLarge();
}
};
_Arr_prototype.isSmall = function () {
switch (this.elements.length) {
case 0: return true;
case 1: return this.elements[0].isSmall();
default: return false;
}
};
_Arr_prototype.isLarge = function () {
var _ref, _this;
_this = this;
if ((_ref = this._isLarge) == null) {
return this._isLarge = __num(this.elements.length) > 4 || (function () {
var _arr, _i, element;
for (_arr = __toArray(_this.elements), _i = _arr.length; _i--; ) {
element = _arr[_i];
if (!element.isSmall()) {
return true;
}
}
return false;
}());
} else {
return _ref;
}
};
_Arr_prototype.isNoop = function () {
var _ref, _this;
_this = this;
if ((_ref = this._isNoop) == null) {
return this._isNoop = (function () {
var _arr, _i, element;
for (_arr = __toArray(_this.elements), _i = _arr.length; _i--; ) {
element = _arr[_i];
if (!element.isNoop()) {
return false;
}
}
return true;
}());
} else {
return _ref;
}
};
_Arr_prototype.walk = function (walker) {
var elements;
elements = walkArray(this.elements, walker);
if (this.elements !== elements) {
return Arr(this.pos, elements);
} else {
return this;
}
};
_Arr_prototype.inspect = function (depth) {
return inspectHelper(depth, "Arr", this.pos, this.elements);
};
_Arr_prototype._toJSON = function () {
return simplifyArray(this.elements, 0);
};
Arr.fromJSON = function (line, column, file) {
var elements;
elements = __slice.call(arguments, 3);
return Arr(
makePos(line, column, file),
arrayFromJSON(elements)
);
};
return Arr;
}(Expression));
exports.Assign = function (pos, left, right) {
return Binary(pos, left, "=", right);
};
exports.BinaryChain = function (pos, op) {
var _i, _len, arg, args, current, i, left, right;
args = __slice.call(arguments, 2);
if (op === "+") {
for (i = args.length - 2; i >= 0; --i) {
left = args[i];
right = args[i + 1];
if ((typeof left === "string" || left instanceof Const && typeof left.value === "string") && (typeof right === "string" || right instanceof Const && typeof right.value === "string")) {
args.splice(i, 2, __strnum(typeof left === "string" ? left : left.value) + __strnum(typeof right === "string" ? right : right.value));
}
}
}
current = args[0];
for (_i = 1, _len = args.length; _i < _len; ++_i) {
arg = args[_i];
current = Binary(pos, current, op, arg);
}
return current;
};
exports.And = function (pos) {
var _end, args, current, i;
args = __slice.call(arguments, 1);
if (args.length === 0) {
return Const(pos, true);
} else {
current = args[0];
for (i = 1, _end = args.length; i < _end; ++i) {
current = Binary(pos, current, "&&", args[i]);
}
return current;
}
};
exports.Or = function (pos) {
var _end, args, current, i;
args = __slice.call(arguments, 1);
if (args.length === 0) {
return Const(pos, false);
} else {
current = args[0];
for (i = 1, _end = args.length; i < _end; ++i) {
current = Binary(pos, current, "||", args[i]);
}
return current;
}
};
function toConst(pos, value) {
if (value instanceof Node) {
throw Error("Cannot convert " + __typeof(value) + " to a Const");
} else if (value instanceof RegExp) {
return Regex(pos, value.source, value.flags);
} else {
return Const(pos, value);
}
}
function isNegative(value) {
if (typeof value !== "number") {
throw TypeError("Expected value to be a Number, got " + __typeof(value));
}
return value < 0 || value === 0 && 1 / value < 0;
}
exports.Binary = Binary = (function (Expression) {
var _Binary_prototype, _Expression_prototype, _o, ASSIGNMENT_OPS, LEVEL_TO_ASSOCIATIVITY, OPERATOR_PRECEDENCE;
function Binary(pos, left, op, right) {
var _this;
_this = this instanceof Binary ? this : __create(_Binary_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (left == null) {
left = Noop(pos);
}
if (typeof op !== "string") {
throw TypeError("Expected op to be a String, got " + __typeof(op));
}
_this.op = op;
if (right == null) {
right = Noop(pos);
}
if (!__owns.call(OPERATOR_PRECEDENCE, op)) {
throw Error("Unknown binary operator: " + __strnum(toJSSource(op)));
}
if (!(left instanceof Expression)) {
left = toConst(pos, left);
}
if (!(right instanceof Expression)) {
right = toConst(pos, right);
}
_this.left = left;
_this.right = right;
return _this;
}
_Expression_prototype = Expression.prototype;
_Binary_prototype = Binary.prototype = __create(_Expression_prototype);
_Binary_prototype.constructor = Binary;
Binary.displayName = "Binary";
if (typeof Expression.extended === "function") {
Expression.extended(Binary);
}
function compileAccess(op, left, right, options, level, lineStart, sb) {
var dotAccess, stringLeft, wrap;
dotAccess = right instanceof Const && typeof right.value === "string" && isAcceptableIdent(right.value);
wrap = !__lte(level, Level.callOrAccess);
if (wrap) {
sb("(");
}
if (left instanceof Const && typeof left.value === "number") {
stringLeft = toJSSource(left.value);
if (isNegative(left.value) || !isFinite(left.value)) {
sb("(");
sb(stringLeft);
sb(")");
} else {
sb(stringLeft);
if (dotAccess && stringLeft.indexOf("e") === -1 && stringLeft.indexOf(".") === -1) {
sb(".");
}
}
} else if (left.isConst() && left.constValue() === void 0) {
sb("(");
(left instanceof Const ? left : Const(left.pos, void 0)).compile(options, Level.insideParentheses, false, sb);
sb(")");
} else {
left.compile(options, Level.callOrAccess, lineStart, sb);
}
if (dotAccess) {
sb(".");
sb(right.value);
} else {
sb("[");
right.compile(options, Level.insideParentheses, false, sb);
sb("]");
}
if (wrap) {
sb(")");
}
}
function compileOther(op, left, right, options, level, lineStart, sb) {
var associativity, opLevel, spaced, wrap;
opLevel = OPERATOR_PRECEDENCE[op];
associativity = LEVEL_TO_ASSOCIATIVITY[opLevel];
if (associativity === "paren") {
wrap = !__lt(level, opLevel);
} else {
wrap = !__lte(level, opLevel);
}
if (wrap) {
sb("(");
}
left.compile(
options,
associativity === "right" && left instanceof Binary && OPERATOR_PRECEDENCE[left.op] === opLevel ? __num(opLevel) + 1 : opLevel,
lineStart && !wrap,
sb
);
spaced = !options.minify || /^\w/.test(op);
if (spaced) {
sb(" ");
}
sb(op);
if (spaced) {
sb(" ");
}
right.compile(
options,
associativity === "left" && right instanceof Binary && OPERATOR_PRECEDENCE[right.op] === opLevel ? __num(opLevel) + 1 : opLevel,
false,
sb
);
if (wrap) {
sb(")");
}
}
_Binary_prototype.compile = function (options, level, lineStart, sb) {
var _ref, f;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
if (this.op === ".") {
f = compileAccess;
} else {
f = compileOther;
}
f(
this.op,
this.left,
this.right,
options,
level,
lineStart,
sb
);
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_Binary_prototype.compileAsBlock = function (options, level, lineStart, sb) {
var _ref;
if (__owns.call(ASSIGNMENT_OPS, this.op) || (_ref = this.op) === "." || _ref === "&&" || _ref === "||") {
_Expression_prototype.compileAsBlock.call(
this,
options,
level,
lineStart,
sb
);
} else {
BlockExpression(this.pos, [this.left, this.right]).compileAsBlock(options, level, lineStart, sb);
}
};
_Binary_prototype.compileAsStatement = function (options, lineStart, sb) {
var _this, left, op;
_this = this;
left = this.left;
op = this.op;
if (__owns.call(ASSIGNMENT_OPS, op)) {
if (left instanceof Ident && typeof this.right.toStatement === "function" && false) {
this.right.toStatement().mutateLast(
function (node) {
return Binary(_this.pos, left, op, node);
},
{ noop: true }
).compileAsStatement(options, lineStart, sb);
} else {
_Expression_prototype.compileAsStatement.call(this, options, lineStart, sb);
}
} else if (this.op === "&&") {
IfStatement(this.pos, this.left, this.right).compileAsStatement(options, lineStart, sb);
} else if (this.op === "||") {
IfStatement(
this.pos,
Unary(this.pos, "!", this.left),
this.right
).compileAsStatement(options, lineStart, sb);
} else if (op === ".") {
_Expression_prototype.compileAsStatement.call(this, options, lineStart, sb);
} else {
BlockStatement(this.pos, [this.left, this.right]).compileAsStatement(options, lineStart, sb);
}
};
ASSIGNMENT_OPS = {
"=": true,
"+=": true,
"-=": true,
"*=": true,
"/=": true,
"%=": true,
"<<=": true,
">>=": true,
">>>=": true,
"&=": true,
"^=": true,
"|=": true
};
OPERATOR_PRECEDENCE = {
".": Level.callOrAccess,
"*": Level.multiplication,
"/": Level.multiplication,
"%": Level.multiplication,
"+": Level.addition,
"-": Level.addition,
"<<": Level.bitwiseShift,
">>": Level.bitwiseShift,
">>>": Level.bitwiseShift,
"<": Level.relational,
"<=": Level.relational,
">": Level.relational,
">=": Level.relational,
"in": Level.relational,
"instanceof": Level.relational,
"==": Level.equality,
"!=": Level.equality,
"===": Level.equality,
"!==": Level.equality,
"&": Level.bitwiseAnd,
"^": Level.bitwiseXor,
"|": Level.bitwiseOr,
"&&": Level.logicalAnd,
"||": Level.logicalOr,
"=": Level.assignment,
"+=": Level.assignment,
"-=": Level.assignment,
"*=": Level.assignment,
"/=": Level.assignment,
"%=": Level.assignment,
"<<=": Level.assignment,
">>=": Level.assignment,
">>>=": Level.assignment,
"&=": Level.assignment,
"^=": Level.assignment,
"|=": Level.assignment
};
LEVEL_TO_ASSOCIATIVITY = (_o = {}, _o[Level.equality] = "paren", _o[Level.relational] = "paren", _o[Level.addition] = "left", _o[Level.multiplication] = "left", _o[Level.bitwiseAnd] = "none", _o[Level.bitwiseOr] = "none", _o[Level.bitwiseXor] = "none", _o[Level.bitwiseShift] = "left", _o[Level.assignment] = "right", _o);
_Binary_prototype.isLarge = function () {
var _ref;
if ((_ref = this._isLarge) == null) {
return this._isLarge = !this.left.isSmall() || !this.right.isSmall();
} else {
return _ref;
}
};
_Binary_prototype.isSmall = function () {
var _ref;
if ((_ref = this._isSmall) == null) {
return this._isSmall = this.left.isSmall() && this.right.isSmall();
} else {
return _ref;
}
};
_Binary_prototype.isNoop = function () {
var _ref;
if ((_ref = this._isNoop) == null) {
return this._isNoop = !__owns.call(ASSIGNMENT_OPS, this.op) && this.op !== "." && this.left.isNoop() && this.right.isNoop();
} else {
return _ref;
}
};
_Binary_prototype.walk = function (walker) {
var _ref, changed, left, right;
changed = false;
if ((_ref = walker(this.left)) != null) {
left = _ref;
} else {
left = this.left.walk(walker);
}
if ((_ref = walker(this.right)) != null) {
right = _ref;
} else {
right = this.right.walk(walker);
}
if (this.left !== left || this.right !== right) {
return Binary(this.pos, left, this.op, right);
} else {
return this;
}
};
_Binary_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"Binary",
this.pos,
this.left,
this.op,
this.right
);
};
_Binary_prototype._toJSON = function () {
var result;
result = [
simplify(this.left, 0),
this.op
];
if (simplify(this.right)) {
result.push.apply(result, __toArray(this.right.toJSON()));
}
return result;
};
Binary.fromJSON = function (line, column, file, left, op) {
var right;
right = __slice.call(arguments, 5);
return Binary(
makePos(line, column, file),
fromJSON(left),
op,
fromJSON(right)
);
};
return Binary;
}(Expression));
exports.BlockStatement = BlockStatement = (function (Statement) {
var _BlockStatement_prototype, _Statement_prototype;
function BlockStatement(pos, body, label) {
var _i, _i2, _len, _this, item, result, statement;
_this = this instanceof BlockStatement ? this : __create(_BlockStatement_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (body == null) {
body = [];
} else if (!__isArray(body)) {
throw TypeError("Expected body to be an Array, got " + __typeof(body));
} else {
for (_i = body.length; _i--; ) {
if (!(body[_i] instanceof Node)) {
throw TypeError("Expected " + ("body[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(body[_i]));
}
}
}
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
_this.label = label;
result = [];
for (_i2 = 0, _len = body.length; _i2 < _len; ++_i2) {
item = body[_i2];
statement = item.maybeToStatement();
if (statement instanceof BlockStatement && !statement.label && (statement.pos.file === pos.file || !statement.pos.file)) {
result.push.apply(result, __toArray(statement.body));
} else if (!(statement instanceof Noop)) {
result.push(statement);
}
if (statement.exitType() != null) {
break;
}
}
switch (result.length) {
case 0: return Noop(pos);
case 1:
if (pos.file && !result[0].pos.file) {
result[0].pos.file = pos.file;
}
return result[0];
}
_this.body = result;
return _this;
}
_Statement_prototype = Statement.prototype;
_BlockStatement_prototype = BlockStatement.prototype = __create(_Statement_prototype);
_BlockStatement_prototype.constructor = BlockStatement;
BlockStatement.displayName = "BlockStatement";
if (typeof Statement.extended === "function") {
Statement.extended(BlockStatement);
}
_BlockStatement_prototype.compile = function (options, level, lineStart, sb) {
var _arr, _arr2, _i, _len, _ref, childOptions, i, item, minify, node, nodes;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
for (_arr = [], _arr2 = __toArray(this.body), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
node = _arr2[_i];
if (!node.isNoop()) {
_arr.push(node);
}
}
nodes = _arr;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
if (this.label != null) {
childOptions = incIndent(options);
} else {
childOptions = options;
}
minify = options.minify;
if (this.label != null) {
this.label.compile(options, level, lineStart, sb);
lineStart = false;
sb(":");
if (!minify) {
sb(" ");
}
sb("{");
if (!minify) {
sb("\n");
sb.indent(childOptions.indent);
lineStart = true;
}
}
for (i = 0, _len = nodes.length; i < _len; ++i) {
item = nodes[i];
if (i > 0 && !minify) {
sb("\n");
sb.indent(childOptions.indent);
lineStart = true;
}
item.compileAsStatement(childOptions, lineStart, sb);
lineStart = false;
}
if (this.label != null) {
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb("}");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_BlockStatement_prototype.walk = function (walker) {
var _ref, body, label;
body = walkArray(this.body, walker);
if (this.label != null) {
if ((_ref = walker(this.label)) != null) {
label = _ref;
} else {
label = this.label.walk(walker);
}
} else {
label = this.label;
}
if (this.body !== body || this.label !== label) {
return Block(this.pos, body, label);
} else {
return this;
}
};
_BlockStatement_prototype.mutateLast = function (func, options) {
var body, last, newLast;
last = this.last();
newLast = last.mutateLast(func, options);
if (last !== newLast) {
body = __slice.call(this.body, 0, -1);
body.push(newLast);
return Block(this.pos, body);
} else {
return this;
}
};
_BlockStatement_prototype.exitType = function () {
return this.last().exitType();
};
_BlockStatement_prototype.last = function () {
var _ref;
return (_ref = this.body)[__num(_ref.length) - 1];
};
_BlockStatement_prototype.isNoop = function () {
var _ref, _this;
_this = this;
if ((_ref = this._isNoop) == null) {
return this._isNoop = (function () {
var _arr, _i, node;
for (_arr = __toArray(_this.body), _i = _arr.length; _i--; ) {
node = _arr[_i];
if (!node.isNoop()) {
return false;
}
}
return true;
}());
} else {
return _ref;
}
};
_BlockStatement_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"BlockStatement",
this.pos,
this.body,
this.label
);
};
_BlockStatement_prototype._toJSON = function () {
return [this.label || 0].concat(__toArray(this.body));
};
BlockStatement.fromJSON = function (line, column, file, label) {
var body;
body = __slice.call(arguments, 4);
return BlockStatement(
makePos(line, column, file),
arrayFromJSON(body),
label ? fromJSON(label) : null
);
};
return BlockStatement;
}(Statement));
exports.BlockExpression = BlockExpression = (function (Expression) {
var _BlockExpression_prototype, _Expression_prototype;
function BlockExpression(pos, body) {
var _i, _this, i, item, len, result;
_this = this instanceof BlockExpression ? this : __create(_BlockExpression_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (body == null) {
body = [];
} else if (!__isArray(body)) {
throw TypeError("Expected body to be an Array, got " + __typeof(body));
} else {
for (_i = body.length; _i--; ) {
if (!(body[_i] instanceof Expression)) {
throw TypeError("Expected " + ("body[" + _i + "]") + " to be a " + __name(Expression) + ", got " + __typeof(body[_i]));
}
}
}
result = [];
for (i = 0, len = body.length; i < len; ++i) {
item = body[i];
if (i === len - 1 || !(!item instanceof Noop)) {
if (item instanceof BlockExpression && (item.pos.file === pos.file || !item.pos.file)) {
result.push.apply(result, __toArray(item.body));
if (i < len - 1 && result[result.length - 1] instanceof Noop) {
result.pop();
}
} else if (!(item instanceof Noop)) {
result.push(item);
}
}
}
switch (result.length) {
case 0: return Noop(pos);
case 1:
if (pos.file && !result[0].pos.file) {
result[0].pos.file = pos.file;
}
return result[0];
}
_this.body = result;
return _this;
}
_Expression_prototype = Expression.prototype;
_BlockExpression_prototype = BlockExpression.prototype = __create(_Expression_prototype);
_BlockExpression_prototype.constructor = BlockExpression;
BlockExpression.displayName = "BlockExpression";
if (typeof Expression.extended === "function") {
Expression.extended(BlockExpression);
}
_BlockExpression_prototype.toStatement = function () {
return BlockStatement(this.pos, this.body);
};
_BlockExpression_prototype.compile = function (options, level, lineStart, sb) {
var _arr, _arr2, _len, _ref, i, item, len, node, nodes, wrap;
if (level === Level.block) {
this.toStatement().compile(options, level, lineStart, sb);
} else {
for (_arr = [], _arr2 = __toArray(this.body), i = 0, len = _arr2.length; i < len; ++i) {
node = _arr2[i];
if (!node.isNoop() || i === len - 1) {
_arr.push(node);
}
}
nodes = _arr;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
wrap = !__lte(level, Level.insideParentheses) && nodes.length > 1;
if (wrap) {
sb("(");
}
for (i = 0, _len = nodes.length; i < _len; ++i) {
item = nodes[i];
if (i > 0) {
sb(",");
if (!options.minify) {
sb(" ");
}
}
item.compile(
options,
wrap ? Level.sequence : level,
false,
sb
);
}
if (wrap) {
sb(")");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
}
};
_BlockExpression_prototype.compileAsBlock = function (options, level, lineStart, sb) {
var _arr, _arr2, _len, _ref, i, item, len, node, nodes, wrap;
if (level === Level.block) {
this.compile(options, level, lineStart, sb);
} else {
for (_arr = [], _arr2 = __toArray(this.body), i = 0, len = _arr2.length; i < len; ++i) {
node = _arr2[i];
if (!node.isNoop()) {
_arr.push(node);
}
}
nodes = _arr;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
wrap = !__lte(level, Level.insideParentheses) && nodes.length > 1;
if (wrap) {
sb("(");
}
for (i = 0, _len = nodes.length; i < _len; ++i) {
item = nodes[i];
if (i > 0) {
sb(", ");
}
item.compileAsBlock(
options,
wrap ? Level.sequence : level,
false,
sb
);
}
if (wrap) {
sb(")");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
}
};
_BlockExpression_prototype.isLarge = function () {
var _ref, _this;
_this = this;
if ((_ref = this._isLarge) == null) {
return this._isLarge = __num(this.body.length) > 4 || (function () {
var _arr, _i, part;
for (_arr = __toArray(_this.body), _i = _arr.length; _i--; ) {
part = _arr[_i];
if (part.isLarge()) {
return true;
}
}
return false;
}());
} else {
return _ref;
}
};
_BlockExpression_prototype.isSmall = function () {
return false;
};
_BlockExpression_prototype.isNoop = function () {
var _ref, _this;
_this = this;
if ((_ref = this._isNoop) == null) {
return this._isNoop = (function () {
var _arr, _i, node;
for (_arr = __toArray(_this.body), _i = _arr.length; _i--; ) {
node = _arr[_i];
if (!node.isNoop()) {
return false;
}
}
return true;
}());
} else {
return _ref;
}
};
_BlockExpression_prototype.walk = BlockStatement.prototype.walk;
_BlockExpression_prototype.last = function () {
var _ref;
return (_ref = this.body)[__num(_ref.length) - 1];
};
_BlockExpression_prototype.inspect = function (depth) {
return inspectHelper(depth, "BlockExpression", this.pos, this.body);
};
_BlockExpression_prototype._toJSON = function () {
return this.body;
};
BlockExpression.fromJSON = function (line, column, file) {
var body;
body = __slice.call(arguments, 3);
return BlockExpression(
makePos(line, column, file),
arrayFromJSON(body)
);
};
return BlockExpression;
}(Expression));
Block = exports.Block = function (pos, body, label) {
var _i;
if (body == null) {
body = [];
} else if (!__isArray(body)) {
throw TypeError("Expected body to be an Array, got " + __typeof(body));
} else {
for (_i = body.length; _i--; ) {
if (!(body[_i] instanceof Node)) {
throw TypeError("Expected " + ("body[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(body[_i]));
}
}
}
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
if (body.length === 0) {
return Noop(pos);
} else if (label == null && (function () {
var _i2, item;
for (_i2 = body.length; _i2--; ) {
item = body[_i2];
if (!(item instanceof Expression)) {
return false;
}
}
return true;
}())) {
return BlockExpression(pos, body);
} else {
return BlockStatement(pos, body, label);
}
};
exports.Break = Break = (function (Statement) {
var _Break_prototype, _Statement_prototype;
function Break(pos, label) {
var _this;
_this = this instanceof Break ? this : __create(_Break_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
_this.label = label;
return _this;
}
_Statement_prototype = Statement.prototype;
_Break_prototype = Break.prototype = __create(_Statement_prototype);
_Break_prototype.constructor = Break;
Break.displayName = "Break";
if (typeof Statement.extended === "function") {
Statement.extended(Break);
}
_Break_prototype.compile = function (options, level, lineStart, sb) {
var _ref;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
sb("break");
if (this.label != null) {
sb(" ");
this.label.compile(options, Level.insideParentheses, false, sb);
}
sb(";");
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile(this.pos.file);
}
};
_Break_prototype.walk = function () {
return this;
};
_Break_prototype.exitType = function () {
return "break";
};
_Break_prototype.walk = function (walker) {
var _ref, label;
if (this.label != null) {
if ((_ref = walker(this.label)) != null) {
label = _ref;
} else {
label = this.label.walk(walker);
}
} else {
label = this.label;
}
if (label !== this.label) {
return Break(this.pos, label);
} else {
return this;
}
};
_Break_prototype.inspect = function (depth) {
return inspectHelper(depth, "Break", this.pos, this.label);
};
_Break_prototype.isLarge = function () {
return false;
};
_Break_prototype._toJSON = function () {
if (this.label != null) {
return [this.label];
} else {
return [];
}
};
Break.fromJSON = function (line, column, file, label) {
return Break(
makePos(line, column, file),
label ? fromJSON(label) : null
);
};
return Break;
}(Statement));
exports.Call = Call = (function (Expression) {
var _Call_prototype, _Expression_prototype;
function Call(pos, func, args, isNew) {
var _i, _this;
_this = this instanceof Call ? this : __create(_Call_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (func == null) {
func = Noop(pos);
} else if (!(func instanceof Expression)) {
throw TypeError("Expected func to be a " + __name(Expression) + ", got " + __typeof(func));
}
_this.func = func;
if (args == null) {
args = [];
} else if (!__isArray(args)) {
throw TypeError("Expected args to be an Array, got " + __typeof(args));
} else {
for (_i = args.length; _i--; ) {
if (!(args[_i] instanceof Expression)) {
throw TypeError("Expected " + ("args[" + _i + "]") + " to be a " + __name(Expression) + ", got " + __typeof(args[_i]));
}
}
}
_this.args = args;
if (isNew == null) {
isNew = false;
} else if (typeof isNew !== "boolean") {
throw TypeError("Expected isNew to be a Boolean, got " + __typeof(isNew));
}
_this.isNew = isNew;
return _this;
}
_Expression_prototype = Expression.prototype;
_Call_prototype = Call.prototype = __create(_Expression_prototype);
_Call_prototype.constructor = Call;
Call.displayName = "Call";
if (typeof Expression.extended === "function") {
Expression.extended(Call);
}
function compileLarge(args, options, level, lineStart, sb) {
var _arr, childOptions, i, item, len;
sb("(");
childOptions = incIndent(options);
for (_arr = __toArray(args), i = 0, len = _arr.length; i < len; ++i) {
item = _arr[i];
sb("\n");
sb.indent(childOptions.indent);
item.compile(childOptions, Level.sequence, false, sb);
if (i < len - 1) {
sb(",");
}
}
sb("\n");
sb.indent(options.indent);
sb(")");
}
function compileSmall(args, options, level, lineStart, sb) {
var _arr, _len, arg, i;
sb("(");
for (_arr = __toArray(args), i = 0, _len = _arr.length; i < _len; ++i) {
arg = _arr[i];
if (i > 0) {
sb(",");
if (!options.minify) {
sb(" ");
}
}
arg.compile(options, Level.sequence, false, sb);
}
sb(")");
}
_Call_prototype.compile = function (options, level, lineStart, sb) {
var _ref, f, wrap;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
wrap = !__lte(level, Level.callOrAccess) || !this.isNew && (this.func instanceof Func || this.func instanceof Binary && this.func.op === "." && this.func.left instanceof Func);
if (wrap) {
sb("(");
}
if (this.isNew) {
sb("new ");
}
this.func.compile(
options,
this.isNew ? Level.newCall : Level.callOrAccess,
lineStart && !wrap && !this.isNew,
sb
);
if (!options.minify && this.shouldCompileLarge()) {
f = compileLarge;
} else {
f = compileSmall;
}
f(
this.args,
options,
level,
lineStart,
sb
);
if (wrap) {
sb(")");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_Call_prototype.shouldCompileLarge = function () {
var _this;
_this = this;
if (__num(this.args.length) > 4) {
return true;
} else {
return (function () {
var _arr, _i, _len, arg;
for (_arr = __toArray(_this.args), _len = _arr.length, _i = _len - 2; _i >= 0; --_i) {
arg = _arr[_i];
if (!arg.isSmall()) {
return true;
}
}
return false;
}());
}
};
_Call_prototype.hasLargeArgs = function () {
var _ref, _this;
_this = this;
if ((_ref = this._hasLargeArgs) == null) {
return this._hasLargeArgs = __num(this.args.length) > 4 ? true
: (function () {
var _arr, _i, arg;
for (_arr = __toArray(_this.args), _i = _arr.length; _i--; ) {
arg = _arr[_i];
if (!arg.isSmall()) {
return true;
}
}
return false;
}());
} else {
return _ref;
}
};
_Call_prototype.isLarge = function () {
return this.func.isLarge() || this.hasLargeArgs();
};
_Call_prototype.isSmall = function () {
var _ref, _this;
_this = this;
if ((_ref = this._isSmall) == null) {
return this._isSmall = !this.func.isSmall() ? false
: (function () {
switch (_this.args.length) {
case 0: return true;
case 1: return _this.args[0].isSmall();
default: return false;
}
}());
} else {
return _ref;
}
};
_Call_prototype.walk = function (walker) {
var _ref, args, func;
if ((_ref = walker(this.func)) != null) {
func = _ref;
} else {
func = this.func.walk(walker);
}
args = walkArray(this.args, walker);
if (this.func !== func || this.args !== args) {
return Call(this.pos, func, args, this.isNew);
} else {
return this;
}
};
_Call_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"Call",
this.pos,
this.func,
this.args,
this.isNew
);
};
_Call_prototype._toJSON = function () {
return [
simplify(this.func, 0),
this.isNew ? 1 : 0
].concat(__toArray(simplifyArray(this.args, 0)));
};
Call.fromJSON = function (line, column, file, func, isNew) {
var args;
args = __slice.call(arguments, 5);
return Call(
makePos(line, column, file),
fromJSON(func),
arrayFromJSON(args),
!!isNew
);
};
return Call;
}(Expression));
exports.Comment = Comment = (function (Statement) {
var _Comment_prototype, _Statement_prototype;
function Comment(pos, text) {
var _this;
_this = this instanceof Comment ? this : __create(_Comment_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (typeof text !== "string") {
throw TypeError("Expected text to be a String, got " + __typeof(text));
}
_this.text = text;
if (text.substring(0, 2) !== "/*") {
throw Error("Expected text to start with '/*'");
}
if (text.slice(-2) !== "*/") {
throw Error("Expected text to end with '*/'");
}
return _this;
}
_Statement_prototype = Statement.prototype;
_Comment_prototype = Comment.prototype = __create(_Statement_prototype);
_Comment_prototype.constructor = Comment;
Comment.displayName = "Comment";
if (typeof Statement.extended === "function") {
Statement.extended(Comment);
}
_Comment_prototype.compile = function (options, level, lineStart, sb) {
var _arr, _len, i, line, lines;
lines = this.text.split("\n");
for (_arr = __toArray(lines), i = 0, _len = _arr.length; i < _len; ++i) {
line = _arr[i];
if (i > 0) {
sb("\n");
if (!options.minify) {
sb.indent(options.indent);
}
}
sb(line);
}
};
_Comment_prototype.isConst = function () {
return true;
};
_Comment_prototype.constValue = function () {
return;
};
_Comment_prototype.isNoop = function () {
return false;
};
_Comment_prototype.walk = function () {
return this;
};
_Comment_prototype.inspect = function (depth) {
return inspectHelper("Comment", this.pos, this.text);
};
_Comment_prototype._toJSON = function () {
return [this.text];
};
Comment.fromJSON = function (line, column, file, text) {
return Comment(
makePos(line, column, file),
text
);
};
return Comment;
}(Statement));
exports.Const = Const = (function (Expression) {
var _Const_prototype, _Expression_prototype;
function Const(pos, value) {
var _this;
_this = this instanceof Const ? this : __create(_Const_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (value != null && typeof value !== "boolean" && typeof value !== "number" && typeof value !== "string") {
throw TypeError("Expected value to be one of undefined or null or Boolean or Number or String, got " + __typeof(value));
}
_this.value = value;
return _this;
}
_Expression_prototype = Expression.prototype;
_Const_prototype = Const.prototype = __create(_Expression_prototype);
_Const_prototype.constructor = Const;
Const.displayName = "Const";
if (typeof Expression.extended === "function") {
Expression.extended(Const);
}
_Const_prototype.compile = function (options, level, lineStart, sb) {
var _ref, value, wrap;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
value = this.value;
if (value === void 0 && options.undefinedName != null) {
sb(options.undefinedName);
} else {
wrap = !__lt(level, Level.increment) && (value === void 0 || typeof value === "number" && !isFinite(value));
if (wrap) {
sb("(");
}
sb(toJSSource(value));
if (wrap) {
sb(")");
}
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_Const_prototype.compileAsBlock = function (options, level, lineStart, sb) {
Noop(this.pos).compileAsBlock(options, level, lineStart, sb);
};
_Const_prototype.isConst = function () {
return true;
};
_Const_prototype.isNoop = Const.prototype.isConst;
_Const_prototype.constValue = function () {
return this.value;
};
_Const_prototype.walk = function () {
return this;
};
_Const_prototype.inspect = function (depth) {
return "Const(" + __strnum(inspect(this.value, null, decDepth(depth))) + ")";
};
_Const_prototype._toJSON = function () {
if (typeof this.value === "number" && !isFinite(this.value)) {
return [
__num(this.value) > 0 ? 1 : __num(this.value) < 0 ? -1 : 0,
1
];
} else if (this.value === 0 && isNegative(this.value)) {
return [0, 2];
} else if (this.value === void 0) {
return [];
} else {
return [this.value];
}
};
Const.fromJSON = function (line, column, file, value, state) {
return Const(
makePos(line, column, file),
state === 1 ? __num(value) / 0 : value === 0 && state === 2 ? -0 : value
);
};
return Const;
}(Expression));
exports.Continue = Continue = (function (Statement) {
var _Continue_prototype, _Statement_prototype;
function Continue(pos, label) {
var _this;
_this = this instanceof Continue ? this : __create(_Continue_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
_this.label = label;
return _this;
}
_Statement_prototype = Statement.prototype;
_Continue_prototype = Continue.prototype = __create(_Statement_prototype);
_Continue_prototype.constructor = Continue;
Continue.displayName = "Continue";
if (typeof Statement.extended === "function") {
Statement.extended(Continue);
}
_Continue_prototype.compile = function (options, level, lineStart, sb) {
var _ref;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
sb("continue");
if (this.label != null) {
sb(" ");
this.label.compile(options, Level.insideParentheses, false, sb);
}
sb(";");
if (options.sourcemap != null && this.pos.file) {
return options.sourcemap.popFile();
}
};
_Continue_prototype.walk = function () {
return this;
};
_Continue_prototype.exitType = function () {
return "continue";
};
_Continue_prototype.isLarge = function () {
return false;
};
_Continue_prototype.walk = function (walker) {
var _ref, label;
if (this.label != null) {
if ((_ref = walker(this.label)) != null) {
label = _ref;
} else {
label = this.label.walk(walker);
}
} else {
label = this.label;
}
if (label !== this.label) {
return Continue(this.pop, label);
} else {
return this;
}
};
_Continue_prototype.inspect = function (depth) {
return inspectHelper(depth, "Continue", this.pos, this.label);
};
_Continue_prototype._toJSON = function () {
if (this.label != null) {
return [this.label];
} else {
return [];
}
};
Continue.fromJSON = function (line, column, file, label) {
return Continue(
makePos(line, column, file),
label ? fromJSON(label) : null
);
};
return Continue;
}(Statement));
exports.Debugger = Debugger = (function (Statement) {
var _Debugger_prototype, _Statement_prototype;
function Debugger(pos) {
var _this;
_this = this instanceof Debugger ? this : __create(_Debugger_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
return _this;
}
_Statement_prototype = Statement.prototype;
_Debugger_prototype = Debugger.prototype = __create(_Statement_prototype);
_Debugger_prototype.constructor = Debugger;
Debugger.displayName = "Debugger";
if (typeof Statement.extended === "function") {
Statement.extended(Debugger);
}
_Debugger_prototype.compile = function (options, level, lineStart, sb) {
var _ref;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
if ((_ref = options.sourcemap) != null) {
_ref.add(
sb.line,
sb.column,
this.pos.line,
this.pos.column,
this.pos.file
);
}
return sb("debugger;");
};
_Debugger_prototype.walk = function () {
return this;
};
_Debugger_prototype.isLarge = function () {
return false;
};
_Debugger_prototype.inspect = function (depth) {
return inspectHelper(depth, "Debugger", this.pos);
};
Debugger.fromJSON = function (line, column, file) {
return Debugger(makePos(line, column, file));
};
return Debugger;
}(Statement));
exports.DoWhile = DoWhile = (function (Statement) {
var _DoWhile_prototype, _Statement_prototype;
function DoWhile(pos, body, test, label) {
var _this;
_this = this instanceof DoWhile ? this : __create(_DoWhile_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (body == null) {
body = Noop(pos);
} else if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (test == null) {
test = Noop(pos);
} else if (!(test instanceof Expression)) {
throw TypeError("Expected test to be a " + __name(Expression) + ", got " + __typeof(test));
}
_this.test = test;
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
_this.label = label;
_this.body = body.maybeToStatement();
if (test.isConst() && !test.constValue()) {
return Block(pos, [_this.body], label);
}
return _this;
}
_Statement_prototype = Statement.prototype;
_DoWhile_prototype = DoWhile.prototype = __create(_Statement_prototype);
_DoWhile_prototype.constructor = DoWhile;
DoWhile.displayName = "DoWhile";
if (typeof Statement.extended === "function") {
Statement.extended(DoWhile);
}
_DoWhile_prototype.compile = function (options, level, lineStart, sb) {
var _ref, minify;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
minify = options.minify;
if (this.label != null) {
this.label.compile(options, level, lineStart, sb);
lineStart = false;
sb(":");
if (!minify) {
sb(" ");
}
}
sb("do");
if (this.body.isNoop()) {
sb(";");
} else {
if (!minify) {
sb(" ");
}
sb("{");
if (!minify) {
sb("\n");
sb.indent(__num(options.indent) + 1);
lineStart = true;
}
this.body.compileAsStatement(incIndent(options), lineStart, sb);
lineStart = false;
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb("}");
}
if (!minify) {
sb(" ");
}
sb("while");
if (!minify) {
sb(" ");
}
sb("(");
this.test.compile(options, Level.insideParentheses, false, sb);
sb(");");
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_DoWhile_prototype.walk = function (walker) {
var _ref, body, label, test;
if ((_ref = walker(this.body)) != null) {
body = _ref;
} else {
body = this.body.walk(walker);
}
if ((_ref = walker(this.test)) != null) {
test = _ref;
} else {
test = this.test.walk(walker);
}
if (this.label != null) {
if ((_ref = walker(this.label)) != null) {
label = _ref;
} else {
label = this.label.walk(walker);
}
} else {
label = this.label;
}
if (body !== this.body || test !== this.test || label !== this.label) {
return DoWhile(this.pos, body, test, label);
} else {
return this;
}
};
_DoWhile_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"DoWhile",
this.pos,
this.body,
this.test,
this.label
);
};
_DoWhile_prototype._toJSON = function () {
return [
this.label || 0,
simplify(this.test, 0),
simplify(this.body, 0)
];
};
DoWhile.fromJSON = function (line, column, file, label, test, body) {
return DoWhile(
makePos(line, column, file),
fromJSON(body),
fromJSON(test),
label ? fromJSON(label) : null
);
};
return DoWhile;
}(Statement));
exports.Eval = Eval = (function (Expression) {
var _Eval_prototype, _Expression_prototype;
function Eval(pos, code) {
var _this;
_this = this instanceof Eval ? this : __create(_Eval_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (code == null) {
code = Noop(pos);
}
if (!(code instanceof Expression)) {
code = toConst(pos, code);
}
_this.code = code;
return _this;
}
_Expression_prototype = Expression.prototype;
_Eval_prototype = Eval.prototype = __create(_Expression_prototype);
_Eval_prototype.constructor = Eval;
Eval.displayName = "Eval";
if (typeof Expression.extended === "function") {
Expression.extended(Eval);
}
_Eval_prototype.compile = function (options, level, lineStart, sb) {
var _ref;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
if (this.code instanceof Const) {
sb(String(this.code.value));
} else {
sb("eval(");
this.code.compile(options, Level.sequence, false, sb);
sb(")");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_Eval_prototype.walk = function (walker) {
var _ref, code;
if ((_ref = walker(this.code)) != null) {
code = _ref;
} else {
code = this.code.walk(walker);
}
if (code !== this.code) {
return Eval(this.pops, code);
} else {
return this;
}
};
_Eval_prototype.inspect = function (depth) {
return inspectHelper(depth, "Eval", this.pos, this.code);
};
_Eval_prototype._toJSON = function () {
return [simplify(this.code, 0)];
};
Eval.fromJSON = function (line, column, file, code) {
return Eval(
makePos(line, column, file),
fromJSON(code)
);
};
return Eval;
}(Expression));
exports.For = For = (function (Statement) {
var _For_prototype, _Statement_prototype;
function For(pos, init, test, step, body, label) {
var _this;
_this = this instanceof For ? this : __create(_For_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (init == null) {
init = Noop(pos);
} else if (!(init instanceof Expression)) {
throw TypeError("Expected init to be a " + __name(Expression) + ", got " + __typeof(init));
}
_this.init = init;
if (test == null) {
test = Const(pos, true);
}
if (step == null) {
step = Noop(pos);
} else if (!(step instanceof Expression)) {
throw TypeError("Expected step to be a " + __name(Expression) + ", got " + __typeof(step));
}
_this.step = step;
if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
_this.label = label;
if (!(test instanceof Expression)) {
test = toConst(pos, test);
}
if (test.isConst() && !test.constValue()) {
return init;
}
_this.test = test;
_this.body = body.maybeToStatement();
return _this;
}
_Statement_prototype = Statement.prototype;
_For_prototype = For.prototype = __create(_Statement_prototype);
_For_prototype.constructor = For;
For.displayName = "For";
if (typeof Statement.extended === "function") {
Statement.extended(For);
}
_For_prototype.compile = function (options, level, lineStart, sb) {
var _ref, minify, test;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
if (this.test.isConst() && typeof this.test.constValue() !== "boolean") {
test = Const(this.pos, !!this.test.constValue());
} else {
test = this.test;
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
minify = options.minify;
if (this.label != null) {
this.label.compile(options, level, lineStart, sb);
sb(":");
if (!minify) {
sb(" ");
}
}
if (this.init.isNoop() && this.step.isNoop()) {
sb("while");
if (!minify) {
sb(" ");
}
sb("(");
test.compile(options, Level.insideParentheses, false, sb);
} else {
sb("for");
if (!minify) {
sb(" ");
}
sb("(");
if (!this.init.isNoop()) {
this.init.compileAsBlock(options, Level.insideParentheses, false, sb);
}
sb(";");
if (!minify) {
sb(" ");
}
if (!test.isConst() || !test.constValue()) {
test.compile(options, Level.insideParentheses, false, sb);
}
sb(";");
if (!minify) {
sb(" ");
}
if (!this.step.isNoop()) {
this.step.compileAsBlock(options, Level.insideParentheses, false, sb);
}
}
sb(")");
if (this.body.isNoop()) {
sb(";");
} else {
if (!minify) {
sb(" ");
}
sb("{");
if (!minify) {
sb("\n");
sb.indent(__num(options.indent) + 1);
}
this.body.compileAsStatement(incIndent(options), !minify, sb);
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb("}");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_For_prototype.walk = function (walker) {
var _ref, body, init, label, step, test;
if ((_ref = walker(this.init)) != null) {
init = _ref;
} else {
init = this.init.walk(walker);
}
if ((_ref = walker(this.test)) != null) {
test = _ref;
} else {
test = this.test.walk(walker);
}
if ((_ref = walker(this.step)) != null) {
step = _ref;
} else {
step = this.step.walk(walker);
}
if ((_ref = walker(this.body)) != null) {
body = _ref;
} else {
body = this.body.walk(walker);
}
if (this.label != null) {
if ((_ref = walker(this.label)) != null) {
label = _ref;
} else {
label = this.label.walk(walker);
}
} else {
label = this.label;
}
if (init !== this.init || test !== this.test || step !== this.step || body !== this.body || label !== this.label) {
return For(
this.pos,
init,
test,
step,
body,
label
);
} else {
return this;
}
};
_For_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"For",
this.pos,
this.init,
this.test,
this.step,
this.body,
this.label
);
};
_For_prototype._toJSON = function () {
var result;
result = [
this.label || 0,
simplify(this.init, 0),
simplify(this.test, 0),
simplify(this.step, 0)
];
if (simplify(this.body)) {
result.push.apply(result, __toArray(this.body.toJSON()));
}
return result;
};
For.fromJSON = function (line, column, file, label, init, test, step) {
var body;
body = __slice.call(arguments, 7);
return For(
makePos(line, column, file),
fromJSON(init),
fromJSON(test),
fromJSON(step),
fromJSON(body),
label ? fromJSON(label) : null
);
};
return For;
}(Statement));
exports.ForIn = ForIn = (function (Statement) {
var _ForIn_prototype, _Statement_prototype;
function ForIn(pos, key, object, body, label) {
var _this;
_this = this instanceof ForIn ? this : __create(_ForIn_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (!(key instanceof Ident)) {
throw TypeError("Expected key to be a " + __name(Ident) + ", got " + __typeof(key));
}
_this.key = key;
if (object == null) {
object = Noop(line, column);
} else if (!(object instanceof Expression)) {
throw TypeError("Expected object to be a " + __name(Expression) + ", got " + __typeof(object));
}
_this.object = object;
if (body == null) {
body = Noop(line, column);
} else if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
_this.label = label;
_this.body = body.maybeToStatement();
return _this;
}
_Statement_prototype = Statement.prototype;
_ForIn_prototype = ForIn.prototype = __create(_Statement_prototype);
_ForIn_prototype.constructor = ForIn;
ForIn.displayName = "ForIn";
if (typeof Statement.extended === "function") {
Statement.extended(ForIn);
}
_ForIn_prototype.compile = function (options, level, lineStart, sb) {
var _ref, minify;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
minify = options.minify;
if (this.label != null) {
this.label.compile(options, level, lineStart, sb);
sb(":");
if (!minify) {
sb(" ");
}
}
sb("for");
if (!minify) {
sb(" ");
}
sb("(");
this.key.compile(options, Level.insideParentheses, false, sb);
sb(" in ");
this.object.compile(options, Level.insideParentheses, false, sb);
sb(")");
if (this.body.isNoop()) {
sb(";");
} else {
if (!minify) {
sb(" ");
}
sb("{");
if (!minify) {
sb("\n");
sb.indent(__num(options.indent) + 1);
}
this.body.compileAsStatement(incIndent(options), !minify, sb);
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb("}");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_ForIn_prototype.walk = function (walker) {
var _ref, body, key, label, object;
if ((_ref = walker(this.key)) != null) {
key = _ref;
} else {
key = this.key.walk(walker);
}
if ((_ref = walker(this.object)) != null) {
object = _ref;
} else {
object = this.object.walk(walker);
}
if ((_ref = walker(this.body)) != null) {
body = _ref;
} else {
body = this.body.walk(walker);
}
if (this.label != null) {
if ((_ref = walker(this.label)) != null) {
label = _ref;
} else {
label = this.label.walk(walker);
}
} else {
label = this.label;
}
if (key !== this.key || object !== this.object || body !== this.body || label !== this.label) {
return ForIn(this.pos, key, object, body);
} else {
return this;
}
};
_ForIn_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"ForIn",
this.pos,
this.key,
this.object,
this.body,
this.label
);
};
_ForIn_prototype._toJSON = function () {
var result;
result = [
this.label || 0,
this.key,
simplify(this.object, 0)
];
if (simplify(this.body)) {
result.push.apply(result, __toArray(this.body.toJSON()));
}
return result;
};
ForIn.fromJSON = function (line, column, file, label, key, object) {
var body;
body = __slice.call(arguments, 6);
return ForIn(
makePos(line, column, file),
fromJSON(key),
fromJSON(object),
fromJSON(body),
label ? fromJSON(label) : null
);
};
return ForIn;
}(Statement));
function validateFuncParamsAndVariables(params, variables) {
var _arr, _i, names, param, variable;
names = [];
for (_arr = __toArray(params), _i = _arr.length; _i--; ) {
param = _arr[_i];
if (__in(param.name, names)) {
throw Error("Duplicate parameter: " + __strnum(param.name));
}
names.push(param.name);
}
for (_arr = __toArray(variables), _i = _arr.length; _i--; ) {
variable = _arr[_i];
if (__in(variable, names)) {
throw Error("Duplicate variable: " + __strnum(variable));
}
names.push(variable);
}
}
function compileFuncBody(options, sb, declarations, variables, body, lineStart) {
var _arr, _i, _len, declaration, i, minify, variable;
minify = options.minify;
for (_arr = __toArray(declarations), _i = 0, _len = _arr.length; _i < _len; ++_i) {
declaration = _arr[_i];
if (!minify) {
sb.indent(options.indent);
}
sb(toJSSource(declaration));
sb(";");
lineStart = false;
if (!minify) {
sb("\n");
lineStart = true;
}
}
if (__num(variables.length) > 0) {
if (!minify) {
sb.indent(options.indent);
}
sb("var ");
for (_arr = __toArray(variables), i = 0, _len = _arr.length; i < _len; ++i) {
variable = _arr[i];
if (i > 0) {
sb(",");
if (!minify) {
sb(" ");
}
}
Ident(body.pos, variables[i], true).compile(options, Level.insideParentheses, false, sb);
}
sb(";");
lineStart = false;
if (!minify) {
sb("\n");
lineStart = true;
}
}
if (!body.isNoop()) {
if (!minify) {
sb.indent(options.indent);
}
body.compileAsStatement(options, lineStart, sb);
if (!minify) {
sb("\n");
}
}
}
function compileFunc(options, sb, name, params, declarations, variables, body) {
var _arr, _len, i, minify, param;
sb("function");
minify = options.minify;
if (!minify || name != null) {
sb(" ");
}
if (name != null) {
name.compile(options, Level.insideParentheses, false, sb);
}
sb("(");
for (_arr = __toArray(params), i = 0, _len = _arr.length; i < _len; ++i) {
param = _arr[i];
if (i > 0) {
sb(",");
if (!minify) {
sb(" ");
}
}
param.compile(options, Level.insideParentheses, false, sb);
}
sb(")");
if (!minify) {
sb(" ");
}
sb("{");
if (variables.length || declarations.length || !body.isNoop()) {
if (!minify) {
sb("\n");
}
compileFuncBody(
incIndent(options),
sb,
declarations,
variables,
body,
!minify
);
if (!minify) {
sb.indent(options.indent);
}
}
return sb("}");
}
exports.Func = Func = (function (Expression) {
var _Expression_prototype, _Func_prototype;
function Func(pos, name, params, variables, body, declarations) {
var _i, _i2, _i3, _this;
_this = this instanceof Func ? this : __create(_Func_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (name == null) {
name = null;
} else if (!(name instanceof Ident)) {
throw TypeError("Expected name to be one of null or " + __name(Ident) + ", got " + __typeof(name));
}
_this.name = name;
if (params == null) {
params = [];
} else if (!__isArray(params)) {
throw TypeError("Expected params to be an Array, got " + __typeof(params));
} else {
for (_i = params.length; _i--; ) {
if (!(params[_i] instanceof Ident)) {
throw TypeError("Expected " + ("params[" + _i + "]") + " to be a " + __name(Ident) + ", got " + __typeof(params[_i]));
}
}
}
_this.params = params;
if (variables == null) {
variables = [];
} else if (!__isArray(variables)) {
throw TypeError("Expected variables to be an Array, got " + __typeof(variables));
} else {
for (_i2 = variables.length; _i2--; ) {
if (typeof variables[_i2] !== "string") {
throw TypeError("Expected " + ("variables[" + _i2 + "]") + " to be a String, got " + __typeof(variables[_i2]));
}
}
}
_this.variables = variables;
if (body == null) {
body = Noop(line, column);
} else if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
_this.body = body;
if (declarations == null) {
declarations = [];
} else if (!__isArray(declarations)) {
throw TypeError("Expected declarations to be an Array, got " + __typeof(declarations));
} else {
for (_i3 = declarations.length; _i3--; ) {
if (typeof declarations[_i3] !== "string") {
throw TypeError("Expected " + ("declarations[" + _i3 + "]") + " to be a String, got " + __typeof(declarations[_i3]));
}
}
}
_this.declarations = declarations;
validateFuncParamsAndVariables(params, variables);
return _this;
}
_Expression_prototype = Expression.prototype;
_Func_prototype = Func.prototype = __create(_Expression_prototype);
_Func_prototype.constructor = Func;
Func.displayName = "Func";
if (typeof Expression.extended === "function") {
Expression.extended(Func);
}
_Func_prototype.compile = function (options, level, lineStart, sb) {
var _ref, wrap;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
wrap = lineStart && !this.name;
if (wrap) {
sb("(");
}
compileFunc(
options,
sb,
this.name,
this.params,
this.declarations,
this.variables,
this.body
);
if (wrap) {
sb(")");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_Func_prototype.compileAsStatement = function (options, lineStart, sb) {
this.compile(options, Level.block, lineStart, sb);
if (!lineStart || !this.name) {
sb(";");
}
};
_Func_prototype.isLarge = function () {
return true;
};
_Func_prototype.isNoop = function () {
return this.name == null;
};
_Func_prototype.walk = function (walker) {
var _ref, body, name, params;
if (this.name) {
if ((_ref = walker(this.name)) != null) {
name = _ref;
} else {
name = this.name.walk(walker);
}
} else {
name = this.name;
}
params = walkArray(this.params, walker);
body = this.body.walk(walker);
if (name !== this.name || params !== this.params || body !== this.body) {
return Func(
this.pos,
name,
params,
this.variables,
body,
this.declarations,
this.meta
);
} else {
return this;
}
};
_Func_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"Func",
this.pos,
this.name,
this.params,
this.variables,
this.body,
this.declarations,
this.meta
);
};
_Func_prototype._toJSON = function () {
var result;
result = [
this.name || 0,
simplifyArray(this.params, 0),
simplifyArray(this.variables, 0),
simplifyArray(this.declarations, 0)
];
if (simplify(this.body)) {
result.push.apply(result, __toArray(this.body.toJSON()));
}
return result;
};
Func.fromJSON = function (line, column, file, name, params, variables, declarations) {
var body;
body = __slice.call(arguments, 7);
return Func(
makePos(line, column, file),
name ? fromJSON(name) : void 0,
arrayFromJSON(params),
variables,
fromJSON(body),
declarations
);
};
return Func;
}(Expression));
exports.Ident = Ident = (function (Expression) {
var _Expression_prototype, _Ident_prototype;
function Ident(pos, name, allowUnacceptable) {
var _this;
_this = this instanceof Ident ? this : __create(_Ident_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
_this.name = name;
if (allowUnacceptable == null) {
allowUnacceptable = false;
} else if (typeof allowUnacceptable !== "boolean") {
throw TypeError("Expected allowUnacceptable to be a Boolean, got " + __typeof(allowUnacceptable));
}
if (!allowUnacceptable && !isAcceptableIdent(name, true)) {
throw Error("Not an acceptable identifier name: " + name);
}
return _this;
}
_Expression_prototype = Expression.prototype;
_Ident_prototype = Ident.prototype = __create(_Expression_prototype);
_Ident_prototype.constructor = Ident;
Ident.displayName = "Ident";
if (typeof Expression.extended === "function") {
Expression.extended(Ident);
}
function unicodeReplacer(m) {
return "\\u" + __strnum(padLeft(m.charCodeAt(0).toString(16), 4, "0"));
}
_Ident_prototype.compile = function (options, level, lineStart, sb) {
var _ref;
if ((_ref = options.sourcemap) != null) {
_ref.add(
sb.line,
sb.column,
this.pos.line,
this.pos.column,
this.pos.file
);
}
sb(this.name.replace(/[\u0000-\u001f\u0080-\uffff]/g, unicodeReplacer));
};
_Ident_prototype.compileAsBlock = function (options, level, lineStart, sb) {
Noop(this.pos).compileAsBlock(options, level, lineStart, sb);
};
_Ident_prototype.walk = function () {
return this;
};
_Ident_prototype.inspect = function (depth) {
return inspectHelper(depth, "Ident", this.pos, this.name);
};
_Ident_prototype.isNoop = function () {
return true;
};
_Ident_prototype._toJSON = function () {
return [this.name];
};
Ident.fromJSON = function (line, column, file, name) {
return Ident(
makePos(line, column, file),
name
);
};
return Ident;
}(Expression));
exports.IfStatement = IfStatement = (function (Statement) {
var _IfStatement_prototype, _Statement_prototype;
function IfStatement(pos, test, whenTrue, whenFalse, label) {
var _this;
_this = this instanceof IfStatement ? this : __create(_IfStatement_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (test == null) {
test = Noop(pos);
} else if (!(test instanceof Expression)) {
throw TypeError("Expected test to be a " + __name(Expression) + ", got " + __typeof(test));
}
if (whenTrue == null) {
whenTrue = Noop(pos);
} else if (!(whenTrue instanceof Node)) {
throw TypeError("Expected whenTrue to be a " + __name(Node) + ", got " + __typeof(whenTrue));
}
if (whenFalse == null) {
whenFalse = Noop(pos);
} else if (!(whenFalse instanceof Node)) {
throw TypeError("Expected whenFalse to be a " + __name(Node) + ", got " + __typeof(whenFalse));
}
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
_this.label = label;
if (test instanceof Unary && test.op === "!" && test.node instanceof Unary && test.node.op === "!") {
test = test.node.node;
}
if (test.isConst()) {
if (test.constValue()) {
return Block(pos, [whenTrue], label);
} else {
return Block(pos, [whenFalse], label);
}
} else {
whenTrue = whenTrue.maybeToStatement();
whenFalse = whenFalse.maybeToStatement();
if (whenTrue instanceof Noop) {
if (whenFalse instanceof Noop) {
return test.maybeToStatement();
} else {
return IfStatement.call(
_this,
pos,
Unary(test.pos, "!", test),
whenFalse,
whenTrue,
label
);
}
} else if (whenFalse instanceof Noop && whenTrue instanceof IfStatement && whenTrue.whenFalse instanceof Noop && whenTrue.label == null) {
_this.test = Binary(pos, test, "&&", whenTrue.test);
_this.whenTrue = whenTrue.whenTrue;
_this.whenFalse = whenFalse;
} else {
_this.test = test;
_this.whenTrue = whenTrue;
_this.whenFalse = whenFalse;
}
}
return _this;
}
_Statement_prototype = Statement.prototype;
_IfStatement_prototype = IfStatement.prototype = __create(_Statement_prototype);
_IfStatement_prototype.constructor = IfStatement;
IfStatement.displayName = "IfStatement";
if (typeof Statement.extended === "function") {
Statement.extended(IfStatement);
}
_IfStatement_prototype.compile = function (options, level, lineStart, sb) {
var _ref, childOptions, minify, whenFalse;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
if (this.whenTrue.isNoop()) {
if (this.whenFalse.isNoop()) {
this.test.compileAsStatement(options, true, sb);
} else {
IfStatement(
this.pos,
Unary(this.test.pos, "!", this.test),
this.whenFalse,
this.whenTrue,
this.label
).compile(options, level, lineStart, sb);
}
} else {
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
minify = options.minify;
if (this.label != null) {
this.label.compile(options, level, lineStart, sb);
sb(":");
if (!minify) {
sb(" ");
}
}
sb("if");
if (!minify) {
sb(" ");
}
sb("(");
this.test.compile(options, Level.insideParentheses, false, sb);
sb(")");
if (!minify) {
sb(" ");
}
sb("{");
childOptions = incIndent(options);
if (!minify) {
sb("\n");
sb.indent(childOptions.indent);
}
this.whenTrue.compileAsStatement(childOptions, !minify, sb);
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb("}");
whenFalse = this.whenFalse;
if (!whenFalse.isNoop()) {
if (!minify) {
sb(" ");
}
sb("else");
if (whenFalse instanceof IfStatement && whenFalse.label == null) {
sb(" ");
whenFalse.compile(options, level, false, sb);
} else {
if (!minify) {
sb(" ");
}
sb("{");
if (!minify) {
sb("\n");
sb.indent(childOptions.indent);
}
whenFalse.compileAsStatement(childOptions, !minify, sb);
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb("}");
}
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
}
};
_IfStatement_prototype.walk = function (walker) {
var _ref, label, test, whenFalse, whenTrue;
if ((_ref = walker(this.test)) != null) {
test = _ref;
} else {
test = this.test.walk(walker);
}
if ((_ref = walker(this.whenTrue)) != null) {
whenTrue = _ref;
} else {
whenTrue = this.whenTrue.walk(walker);
}
if ((_ref = walker(this.whenFalse)) != null) {
whenFalse = _ref;
} else {
whenFalse = this.whenFalse.walk(walker);
}
if (this.label != null) {
if ((_ref = walker(this.label)) != null) {
label = _ref;
} else {
label = this.label.walk(walker);
}
} else {
label = this.label;
}
if (test !== this.test || whenTrue !== this.whenTrue || whenFalse !== this.whenFalse || label !== this.label) {
return If(
this.pos,
test,
whenTrue,
whenFalse,
label
);
} else {
return this;
}
};
_IfStatement_prototype.mutateLast = function (func, options) {
var whenFalse, whenTrue;
whenTrue = this.whenTrue.mutateLast(func, options);
whenFalse = this.whenFalse.mutateLast(func, options);
if (whenTrue !== this.whenTrue || whenFalse !== this.whenFalse) {
return If(
this.pos,
this.test,
whenTrue,
whenFalse,
this.label
);
} else {
return this;
}
};
_IfStatement_prototype.exitType = function () {
var falseExit, trueExit;
if (this._exitType === void 0) {
trueExit = this.whenTrue.exitType();
falseExit = this.whenFalse.exitType();
return this._exitType = trueExit === falseExit ? trueExit : null;
} else {
return this._exitType;
}
};
_IfStatement_prototype.isNoop = function () {
var _ref;
if ((_ref = this._isNoop) == null) {
return this._isNoop = this.test.isNoop() && this.whenTrue.isNoop() && this.whenFalse.isNoop();
} else {
return _ref;
}
};
_IfStatement_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"IfStatement",
this.pos,
this.test,
this.whenTrue,
this.whenFalse
);
};
_IfStatement_prototype._toJSON = function () {
var result;
result = [
this.label || 0,
simplify(this.test, 0),
simplify(this.whenTrue, 0)
];
if (simplify(this.whenFalse)) {
result.push.apply(result, __toArray(this.whenFalse.toJSON()));
}
return result;
};
IfStatement.fromJSON = function (line, column, file, label, test, whenTrue) {
var whenFalse;
whenFalse = __slice.call(arguments, 6);
return IfStatement(
makePos(line, column, file),
fromJSON(test),
fromJSON(whenTrue),
fromJSON(whenFalse),
label ? fromJSON(label) : null
);
};
return IfStatement;
}(Statement));
exports.IfExpression = IfExpression = (function (Expression) {
var _Expression_prototype, _IfExpression_prototype;
function IfExpression(pos, test, whenTrue, whenFalse) {
var _this;
_this = this instanceof IfExpression ? this : __create(_IfExpression_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (test == null) {
test = Noop(pos);
} else if (!(test instanceof Expression)) {
throw TypeError("Expected test to be a " + __name(Expression) + ", got " + __typeof(test));
}
if (whenTrue == null) {
whenTrue = Noop(pos);
}
if (whenFalse == null) {
whenFalse = Noop(pos);
}
if (!(whenTrue instanceof Expression)) {
whenTrue = toConst(pos, whenTrue);
}
if (!(whenFalse instanceof Expression)) {
whenFalse = toConst(pos, whenFalse);
}
if (test instanceof Unary && test.op === "!" && test.node instanceof Unary && test.node.op === "!") {
test = test.node.node;
}
if (test.isConst()) {
if (test.constValue()) {
return whenTrue;
} else {
return whenFalse;
}
} else if (whenFalse instanceof Noop && whenTrue instanceof IfExpression && whenTrue.whenFalse instanceof Noop) {
_this.test = Binary(pos, test, "&&", whenTrue.test);
_this.whenTrue = whenTrue.whenTrue;
_this.whenFalse = whenFalse;
} else {
_this.test = test;
_this.whenTrue = whenTrue;
_this.whenFalse = whenFalse;
}
return _this;
}
_Expression_prototype = Expression.prototype;
_IfExpression_prototype = IfExpression.prototype = __create(_Expression_prototype);
_IfExpression_prototype.constructor = IfExpression;
IfExpression.displayName = "IfExpression";
if (typeof Expression.extended === "function") {
Expression.extended(IfExpression);
}
_IfExpression_prototype.toStatement = function () {
return IfStatement(this.pos, this.test, this.whenTrue, this.whenFalse);
};
function compileSmall(test, whenTrue, whenFalse, options, lineStart, sb) {
var minify;
minify = options.minify;
test.compile(options, Level.inlineCondition, lineStart, sb);
sb(minify ? "?" : " ? ");
whenTrue.compile(options, Level.inlineCondition, false, sb);
sb(minify ? ":" : " : ");
whenFalse.compile(options, Level.inlineCondition, false, sb);
}
function compileLarge(test, whenTrue, whenFalse, options, lineStart, sb) {
var childOptions, largeWhenTrue, wrapTest, wrapWhenTrue;
childOptions = incIndent(options);
wrapTest = test instanceof IfExpression;
if (wrapTest) {
sb("(");
}
test.compile(
childOptions,
wrapTest ? Level.insideParentheses : Level.inlineCondition,
lineStart && !wrapTest,
sb
);
if (wrapTest) {
sb(")");
}
largeWhenTrue = whenTrue.isLarge();
if (largeWhenTrue) {
sb("\n");
sb.indent(childOptions.indent);
sb("? ");
} else {
sb(" ? ");
}
wrapWhenTrue = whenTrue instanceof IfExpression;
if (wrapWhenTrue) {
sb("(");
}
whenTrue.compile(
childOptions,
wrapWhenTrue ? Level.insideParentheses : Level.inlineCondition,
false,
sb
);
if (wrapWhenTrue) {
sb(")");
}
sb("\n");
sb.indent(childOptions.indent);
sb(": ");
if (whenFalse instanceof IfExpression) {
compileLarge(
whenFalse.test,
whenFalse.whenTrue,
whenFalse.whenFalse,
options,
false,
sb
);
} else {
whenFalse.compile(childOptions, Level.inlineCondition, false, sb);
}
}
_IfExpression_prototype.compile = function (options, level, lineStart, sb) {
var _ref, f, wrap;
if (level === Level.block) {
this.toStatement().compile(options, level, lineStart, sb);
} else {
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
wrap = !__lte(level, Level.inlineCondition);
if (wrap) {
sb("(");
}
if (!options.minify && (this.whenTrue.isLarge() || this.whenFalse.isLarge())) {
f = compileLarge;
} else {
f = compileSmall;
}
f(
this.test,
this.whenTrue,
this.whenFalse,
options,
!wrap && lineStart,
sb
);
if (wrap) {
sb(")");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
}
};
_IfExpression_prototype.compileAsBlock = function (options, level, lineStart, sb) {
if (this.whenTrue.isNoop()) {
if (this.whenFalse.isNoop()) {
this.test.compileAsBlock(options, level, lineStart, sb);
} else {
Binary(this.pos, this.test, "||", this.whenFalse).compileAsBlock(options, level, lineStart, sb);
}
} else if (this.whenFalse.isNoop()) {
Binary(this.pos, this.test, "&&", this.whenTrue).compileAsBlock(options, level, lineStart, sb);
} else {
this.compile(options, level, lineStart, sb);
}
};
_IfExpression_prototype.isLarge = function () {
var _ref;
if ((_ref = this._isLarge) == null) {
return this._isLarge = !this.test.isSmall() || !this.whenTrue.isSmall() || !this.whenFalse.isSmall();
} else {
return _ref;
}
};
_IfExpression_prototype.isSmall = function () {
return false;
};
_IfExpression_prototype.isNoop = function () {
var _ref;
if ((_ref = this._isNoop) == null) {
return this._isNoop = this.test.isNoop() && this.whenTrue.isNoop() && this.whenFalse.isNoop();
} else {
return _ref;
}
};
_IfExpression_prototype.walk = IfStatement.prototype.walk;
_IfExpression_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"IfExpression",
this.pos,
this.test,
this.whenTrue,
this.whenFalse
);
};
_IfExpression_prototype._toJSON = function () {
var result;
result = [
simplify(this.test, 0),
simplify(this.whenTrue, 0)
];
if (simplify(this.whenFalse)) {
result.push.apply(result, __toArray(this.whenFalse.toJSON()));
}
return result;
};
IfExpression.fromJSON = function (line, column, file, test, whenTrue) {
var whenFalse;
whenFalse = __slice.call(arguments, 5);
return IfExpression(
makePos(line, column, file),
fromJSON(test),
fromJSON(whenTrue),
fromJSON(whenFalse)
);
};
return IfExpression;
}(Expression));
If = exports.If = function (pos, test, whenTrue, whenFalse, label) {
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (whenTrue instanceof Statement || whenFalse instanceof Statement || label != null) {
return IfStatement(
pos,
test,
whenTrue,
whenFalse,
label
);
} else {
return IfExpression(pos, test, whenTrue, whenFalse);
}
};
exports.Noop = Noop = (function (Expression) {
var _Expression_prototype, _Noop_prototype;
function Noop(pos) {
var _this;
_this = this instanceof Noop ? this : __create(_Noop_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
return _this;
}
_Expression_prototype = Expression.prototype;
_Noop_prototype = Noop.prototype = __create(_Expression_prototype);
_Noop_prototype.constructor = Noop;
Noop.displayName = "Noop";
if (typeof Expression.extended === "function") {
Expression.extended(Noop);
}
_Noop_prototype.compileAsStatement = function () {};
_Noop_prototype.compile = function (options, level, lineStart, sb) {
if (!__lte(level, Level.block)) {
Const(this.pos, void 0).compile(options, level, lineStart, sb);
}
};
_Noop_prototype.isConst = function () {
return true;
};
_Noop_prototype.isNoop = Noop.prototype.isConst;
_Noop_prototype.constValue = function () {
return;
};
_Noop_prototype.walk = function () {
return this;
};
_Noop_prototype.mutateLast = function (func, options) {
if (options != null ? options.noop : void 0) {
return func(this);
} else {
return this;
}
};
_Noop_prototype.inspect = function (depth) {
return inspectHelper(depth, "Noop", this.pos);
};
Noop.fromJSON = function (line, column, file) {
return Noop(makePos(line, column, file));
};
return Noop;
}(Expression));
exports.Obj = Obj = (function (Expression) {
var _Expression_prototype, _Obj_prototype, ObjPair;
function Obj(pos, elements) {
var _i, _this;
_this = this instanceof Obj ? this : __create(_Obj_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (elements == null) {
elements = [];
} else if (!__isArray(elements)) {
throw TypeError("Expected elements to be an Array, got " + __typeof(elements));
} else {
for (_i = elements.length; _i--; ) {
if (!(elements[_i] instanceof ObjPair)) {
throw TypeError("Expected " + ("elements[" + _i + "]") + " to be a " + __name(ObjPair) + ", got " + __typeof(elements[_i]));
}
}
}
_this.elements = elements;
validateUniqueKeys(elements);
return _this;
}
_Expression_prototype = Expression.prototype;
_Obj_prototype = Obj.prototype = __create(_Expression_prototype);
_Obj_prototype.constructor = Obj;
Obj.displayName = "Obj";
if (typeof Expression.extended === "function") {
Expression.extended(Obj);
}
function validateUniqueKeys(elements) {
var _arr, _i, key, keys, pair;
keys = [];
for (_arr = __toArray(elements), _i = _arr.length; _i--; ) {
pair = _arr[_i];
key = pair.key;
if (__in(key, keys)) {
throw Error("Found duplicate key: " + __strnum(toJSSource(key)));
}
keys.push(key);
}
}
function toSafeKey(key) {
var num;
if (isAcceptableIdent(key)) {
return key;
} else {
num = Number(key);
if (num === num && String(num) === key) {
return key;
} else {
return toJSSource(key);
}
}
}
function compileLarge(elements, options, sb) {
var _arr, childOptions, element, i, key, len;
childOptions = incIndent(options);
for (_arr = __toArray(elements), i = 0, len = _arr.length; i < len; ++i) {
element = _arr[i];
sb("\n");
sb.indent(childOptions.indent);
key = element.key;
sb(toSafeKey(key));
sb(": ");
element.value.compile(childOptions, Level.sequence, false, sb);
if (i < len - 1) {
sb(",");
}
}
sb("\n");
sb.indent(options.indent);
}
function compileSmall(elements, options, sb) {
var _arr, _len, element, i, key, minify;
if (elements.length) {
minify = options.minify;
if (!minify) {
sb(" ");
}
for (_arr = __toArray(elements), i = 0, _len = _arr.length; i < _len; ++i) {
element = _arr[i];
if (i > 0) {
sb(",");
if (!minify) {
sb(" ");
}
}
key = element.key;
sb(toSafeKey(key));
sb(":");
if (!minify) {
sb(" ");
}
element.value.compile(options, Level.sequence, false, sb);
}
if (!minify) {
sb(" ");
}
}
}
_Obj_prototype.compile = function (options, level, lineStart, sb) {
var _ref, f, wrap;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
wrap = lineStart;
if (wrap) {
sb("(");
}
sb("{");
if (!options.minify && this.shouldCompileLarge()) {
f = compileLarge;
} else {
f = compileSmall;
}
f(this.elements, options, sb);
sb("}");
if (wrap) {
sb(")");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_Obj_prototype.compileAsBlock = function (options, level, lineStart, sb) {
var _this;
_this = this;
BlockExpression(this.pos, (function () {
var _arr, _arr2, _i, _len, element;
for (_arr = [], _arr2 = __toArray(_this.elements), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
element = _arr2[_i];
_arr.push(element.value);
}
return _arr;
}())).compileAsBlock(options, level, lineStart, sb);
};
_Obj_prototype.compileAsStatement = function (options, lineStart, sb) {
var _this;
_this = this;
BlockStatement(this.pos, (function () {
var _arr, _arr2, _i, _len, element;
for (_arr = [], _arr2 = __toArray(_this.elements), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
element = _arr2[_i];
_arr.push(element.value);
}
return _arr;
}())).compileAsStatement(options, lineStart, sb);
};
_Obj_prototype.shouldCompileLarge = function () {
switch (this.elements.length) {
case 0: return false;
case 1: return this.elements[0].isLarge();
default: return this.isLarge();
}
};
_Obj_prototype.isSmall = function () {
switch (this.elements.length) {
case 0: return true;
case 1: return this.elements[0].isSmall();
default: return false;
}
};
_Obj_prototype.isLarge = function () {
var _ref, _this;
_this = this;
if ((_ref = this._isLarge) == null) {
return this._isLarge = __num(this.elements.length) > 4 || (function () {
var _arr, _i, element;
for (_arr = __toArray(_this.elements), _i = _arr.length; _i--; ) {
element = _arr[_i];
if (!element.isSmall()) {
return true;
}
}
return false;
}());
} else {
return _ref;
}
};
_Obj_prototype.isNoop = function () {
var _ref, _this;
_this = this;
if ((_ref = this._isNoop) == null) {
return this._isNoop = (function () {
var _arr, _i, element;
for (_arr = __toArray(_this.elements), _i = _arr.length; _i--; ) {
element = _arr[_i];
if (!element.isNoop()) {
return false;
}
}
return true;
}());
} else {
return _ref;
}
};
_Obj_prototype.walk = function (walker) {
var elements;
elements = walkArray(this.elements, walker);
if (elements !== this.elements) {
return Obj(this.pos, elements);
} else {
return this;
}
};
_Obj_prototype.inspect = function (depth) {
return inspectHelper(depth, "Obj", this.pos, this.elements);
};
_Obj_prototype._toJSON = function () {
var _arr, _i, _len, pair, pos, result;
result = [];
for (_arr = __toArray(this.elements), _i = 0, _len = _arr.length; _i < _len; ++_i) {
pair = _arr[_i];
pos = pair.pos;
result.push(
pos.line,
pos.column,
pos.file,
pair.key,
simplify(pair.value)
);
}
return result;
};
Obj.fromJSON = function (line, column, file) {
var _end, elementData, i, key, pColumn, pFile, pLine, resultPairs, value;
elementData = __slice.call(arguments, 3);
resultPairs = [];
for (i = 0, _end = elementData.length; i < _end; i += 5) {
pLine = elementData[i];
pColumn = elementData[i + 1];
pFile = elementData[i + 2];
key = elementData[i + 3];
value = elementData[i + 4];
resultPairs.push(ObjPair(
makePos(pLine, pColumn, pFile),
key,
fromJSON(value)
));
}
return Obj(
makePos(line, column, file),
resultPairs
);
};
Obj.Pair = ObjPair = (function () {
var _ObjPair_prototype;
function ObjPair(pos, key, value) {
var _this;
_this = this instanceof ObjPair ? this : __create(_ObjPair_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (typeof key !== "string") {
throw TypeError("Expected key to be a String, got " + __typeof(key));
}
_this.key = key;
if (value == null) {
value = Noop(line, column);
}
if (!(value instanceof Expression)) {
value = toConst(pos, value);
}
_this.value = value;
return _this;
}
_ObjPair_prototype = ObjPair.prototype;
ObjPair.displayName = "ObjPair";
_ObjPair_prototype.isSmall = function () {
return this.value.isSmall();
};
_ObjPair_prototype.isLarge = function () {
return this.value.isLarge();
};
_ObjPair_prototype.isNoop = function () {
return this.value.isNoop();
};
_ObjPair_prototype.walk = function (walker) {
var _ref, value;
if ((_ref = walker(this.value)) != null) {
value = _ref;
} else {
value = this.value.walk(walker);
}
if (value !== this.value) {
return ObjPair(this.pos, this.key, value);
} else {
return this;
}
};
_ObjPair_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"Pair",
this.pos,
this.key,
this.value
);
};
return ObjPair;
}());
return Obj;
}(Expression));
exports.Regex = Regex = (function (Expression) {
var _Expression_prototype, _Regex_prototype;
function Regex(pos, source, flags) {
var _this;
_this = this instanceof Regex ? this : __create(_Regex_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (typeof source !== "string") {
throw TypeError("Expected source to be a String, got " + __typeof(source));
}
_this.source = source;
if (flags == null) {
flags = "";
} else if (typeof flags !== "string") {
throw TypeError("Expected flags to be a String, got " + __typeof(flags));
}
_this.flags = flags;
return _this;
}
_Expression_prototype = Expression.prototype;
_Regex_prototype = Regex.prototype = __create(_Expression_prototype);
_Regex_prototype.constructor = Regex;
Regex.displayName = "Regex";
if (typeof Expression.extended === "function") {
Expression.extended(Regex);
}
_Regex_prototype.compile = function (options, level, lineStart, sb) {
var _ref;
if ((_ref = options.sourcemap) != null) {
_ref.add(
sb.line,
sb.column,
this.pos.line,
this.pos.column,
this.pos.file
);
}
sb("/");
sb(this.source.replace(/(\\\\)*\\?\//g, "$1\\/") || "(?:)");
sb("/");
sb(this.flags);
};
_Regex_prototype.compileAsBlock = function (options, level, lineStart, sb) {
Noop(this.pos).compileAsBlock(options, level, lineStart, sb);
};
_Regex_prototype.isNoop = function () {
return true;
};
_Regex_prototype.walk = function () {
return this;
};
_Regex_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"Regex",
this.pos,
this.source,
this.flags
);
};
_Regex_prototype._toJSON = function () {
return [this.source, this.flags];
};
Regex.fromJSON = function (line, column, file, source, flags) {
return Regex(
makePos(line, column, file),
source,
flags
);
};
return Regex;
}(Expression));
exports.Return = Return = (function (Statement) {
var _Return_prototype, _Statement_prototype;
function Return(pos, node) {
var _this;
_this = this instanceof Return ? this : __create(_Return_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (node == null) {
node = Noop(pos);
} else if (!(node instanceof Expression)) {
throw TypeError("Expected node to be a " + __name(Expression) + ", got " + __typeof(node));
}
_this.node = node;
if (typeof node.toStatement === "function") {
return node.toStatement().mutateLast(
function (n) {
return Return(pos, n);
},
{ noop: true }
);
}
return _this;
}
_Statement_prototype = Statement.prototype;
_Return_prototype = Return.prototype = __create(_Statement_prototype);
_Return_prototype.constructor = Return;
Return.displayName = "Return";
if (typeof Statement.extended === "function") {
Statement.extended(Return);
}
_Return_prototype.compile = function (options, level, lineStart, sb) {
var _ref;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
sb("return");
if (!this.node.isConst() || this.node.constValue() !== void 0) {
sb(" ");
this.node.compile(options, Level.insideParentheses, false, sb);
}
sb(";");
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_Return_prototype.walk = function (walker) {
var _ref, node;
if ((_ref = walker(this.node)) != null) {
node = _ref;
} else {
node = this.node.walk(walker);
}
if (node !== this.node) {
return Return(this.pos, node);
} else {
return this;
}
};
_Return_prototype.exitType = function () {
return "return";
};
_Return_prototype.isSmall = function () {
return this.node.isSmall();
};
_Return_prototype.isLarge = function () {
return this.node.isLarge();
};
_Return_prototype.inspect = function (depth) {
return inspectHelper(depth, "Return", this.pos, this.node);
};
_Return_prototype.mutateLast = function (func, options) {
var node;
if (options != null ? options["return"] : void 0) {
node = this.node.mutateLast(func, options);
if (node !== this.node) {
return Return(this.pos, node);
} else {
return this;
}
} else {
return this;
}
};
_Return_prototype._toJSON = function () {
if (simplify(this.node)) {
return this.node.toJSON();
} else {
return [];
}
};
Return.fromJSON = function (line, column, file) {
var node;
node = __slice.call(arguments, 3);
return Return(
makePos(line, column, file),
fromJSON(node)
);
};
return Return;
}(Statement));
exports.Root = Root = (function () {
var _Root_prototype;
function Root(pos, body, variables, declarations) {
var _i, _i2, _this;
_this = this instanceof Root ? this : __create(_Root_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (body == null) {
body = Noop(pos);
} else if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
_this.body = body;
if (variables == null) {
variables = [];
} else if (!__isArray(variables)) {
throw TypeError("Expected variables to be an Array, got " + __typeof(variables));
} else {
for (_i = variables.length; _i--; ) {
if (typeof variables[_i] !== "string") {
throw TypeError("Expected " + ("variables[" + _i + "]") + " to be a String, got " + __typeof(variables[_i]));
}
}
}
_this.variables = variables;
if (declarations == null) {
declarations = [];
} else if (!__isArray(declarations)) {
throw TypeError("Expected declarations to be an Array, got " + __typeof(declarations));
} else {
for (_i2 = declarations.length; _i2--; ) {
if (typeof declarations[_i2] !== "string") {
throw TypeError("Expected " + ("declarations[" + _i2 + "]") + " to be a String, got " + __typeof(declarations[_i2]));
}
}
}
_this.declarations = declarations;
validateFuncParamsAndVariables([], variables);
return _this;
}
_Root_prototype = Root.prototype;
Root.displayName = "Root";
_Root_prototype.compile = function (options) {
var _ref, code, endCompileTime, endUglifyTime, fs, minified, oldWarn_function, os, path, sb, startTime, tmpMap, UglifyJS, writer;
if (options == null) {
options = {};
}
if (!options.indent) {
options.indent = 0;
}
if (!options.uglify && typeof options.writer === "function") {
writer = options.writer;
}
if (writer) {
sb = StringWriter(writer);
} else {
sb = StringBuilder();
}
startTime = new Date().getTime();
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
compileFuncBody(
options,
sb,
this.declarations,
this.variables,
this.body,
true
);
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
endCompileTime = new Date().getTime();
if (typeof options.progress === "function") {
options.progress("compile", __num(endCompileTime) - __num(startTime));
}
endUglifyTime = 0;
if (writer == null) {
code = sb.toString();
if (options.uglify) {
fs = require("fs");
if (options.sourcemap != null) {
path = require("path");
os = require("os");
tmpMap = path.join(os.tmpDir(), "gs-" + Math.random() * 4294967296 + ".map");
fs.writeFileSync(tmpMap, options.sourcemap.toString(), "utf8");
}
UglifyJS = require("uglify-js");
if ((_ref = UglifyJS.AST_Node) != null) {
oldWarn_function = _ref.warn_function;
}
if (typeof oldWarn_function === "function") {
UglifyJS.AST_Node.warn_function = function () {};
}
minified = UglifyJS.minify(code, {
fromString: true,
inSourceMap: tmpMap,
outSourceMap: (_ref = options.sourcemap) != null ? _ref.generatedFile : void 0
});
if (oldWarn_function != null) {
UglifyJS.AST_Node.warn_function = oldWarn_function;
}
if (tmpMap != null) {
fs.unlinkSync(tmpMap);
}
code = minified.code;
endUglifyTime = new Date().getTime();
if (typeof options.progress === "function") {
options.progress("uglify", endUglifyTime - __num(endCompileTime));
}
if (options.sourcemap != null) {
options.sourcemap = minified.map;
}
}
if (typeof options.writer === "function") {
options.writer(code);
code = "";
}
}
return {
compileTime: __num(endCompileTime) - __num(startTime),
uglifyTime: options.uglify ? endUglifyTime - __num(endCompileTime) : void 0,
code: code || ""
};
};
_Root_prototype.toString = function (options) {
if (options == null) {
options = {};
}
return this.compile(options).code;
};
_Root_prototype.isLarge = function () {
return true;
};
_Root_prototype.walk = function (walker) {
var body;
body = this.body.walk(walker);
if (body !== this.body) {
return Root(this.pos, body, this.variables, this.declarations);
} else {
return this;
}
};
_Root_prototype.mutateLast = function (func, options) {
var body;
body = this.body.mutateLast(func, options);
if (body !== this.body) {
return Root(this.pos, body, this.variables, this.declarations);
} else {
return this;
}
};
_Root_prototype.exitType = function () {
return this.last().exitType();
};
_Root_prototype.last = function () {
var _ref;
return (_ref = this.body)[__num(_ref.length) - 1];
};
_Root_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"Root",
this.pos,
this.body,
this.variables,
this.declarations
);
};
_Root_prototype._toJSON = function () {
var result;
result = [
simplifyArray(this.variables, 0),
simplifyArray(this.declarations, 0)
];
if (simplify(this.body)) {
result.push.apply(result, __toArray(this.body.toJSON()));
}
return result;
};
Root.fromJSON = function (line, column, file, variables, declarations) {
var body;
body = __slice.call(arguments, 5);
return Root(
makePos(line, column, file),
fromJSON(body),
variables,
declarations
);
};
return Root;
}());
exports.This = This = (function (Expression) {
var _Expression_prototype, _This_prototype;
function This(pos) {
var _this;
_this = this instanceof This ? this : __create(_This_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
return _this;
}
_Expression_prototype = Expression.prototype;
_This_prototype = This.prototype = __create(_Expression_prototype);
_This_prototype.constructor = This;
This.displayName = "This";
if (typeof Expression.extended === "function") {
Expression.extended(This);
}
_This_prototype.compile = function (options, level, lineStart, sb) {
var _ref;
if ((_ref = options.sourcemap) != null) {
_ref.add(
sb.line,
sb.column,
this.pos.line,
this.pos.column,
this.pos.file
);
}
sb("this");
};
_This_prototype.compileAsBlock = function (options, level, lineStart, sb) {
Noop(this.pos).compileAsBlock(options, level, lineStart, sb);
};
_This_prototype.isNoop = function () {
return true;
};
_This_prototype.walk = function () {
return this;
};
_This_prototype.inspect = function (depth) {
return inspectHelper(depth, "This", this.pos);
};
This.fromJSON = function (line, column, file) {
return This(makePos(line, column, file));
};
return This;
}(Expression));
exports.Throw = Throw = (function (Statement) {
var _Statement_prototype, _Throw_prototype;
function Throw(pos, node) {
var _this;
_this = this instanceof Throw ? this : __create(_Throw_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (node == null) {
node = Noop(line, column);
} else if (!(node instanceof Expression)) {
throw TypeError("Expected node to be a " + __name(Expression) + ", got " + __typeof(node));
}
_this.node = node;
if (typeof node.toStatement === "function") {
return node.toStatement().mutateLast(
function (n) {
return Throw(_this.pos, n);
},
{ noop: true }
);
}
return _this;
}
_Statement_prototype = Statement.prototype;
_Throw_prototype = Throw.prototype = __create(_Statement_prototype);
_Throw_prototype.constructor = Throw;
Throw.displayName = "Throw";
if (typeof Statement.extended === "function") {
Statement.extended(Throw);
}
_Throw_prototype.compile = function (options, level, lineStart, sb) {
var _ref;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
sb("throw ");
this.node.compile(options, Level.insideParentheses, false, sb);
sb(";");
if (options.sourcemap != null && this.pos.file) {
return options.sourcemap.popFile();
}
};
_Throw_prototype.walk = function (walker) {
var _ref, node;
if ((_ref = walker(this.node)) != null) {
node = _ref;
} else {
node = this.node.walk(walker);
}
if (node !== this.node) {
return Throw(this.pos, node);
} else {
return this;
}
};
_Throw_prototype.exitType = function () {
return "throw";
};
_Throw_prototype.isSmall = function () {
return this.node.isSmall();
};
_Throw_prototype.isLarge = function () {
return this.node.isLarge();
};
_Throw_prototype.inspect = function (depth) {
return inspectHelper(depth, "Throw", this.pos, this.node);
};
_Throw_prototype._toJSON = function () {
if (simplify(this.node)) {
return this.node.toJSON();
} else {
return [];
}
};
Throw.fromJSON = function (line, column, file) {
var node;
node = __slice.call(arguments, 3);
return Throw(
makePos(line, column, file),
fromJSON(node)
);
};
return Throw;
}(Statement));
exports.Switch = Switch = (function (Statement) {
var _Statement_prototype, _Switch_prototype, SwitchCase;
function Switch(pos, node, cases, defaultCase, label) {
var _i, _this;
_this = this instanceof Switch ? this : __create(_Switch_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (node == null) {
node = Noop(pos);
}
if (cases == null) {
cases = [];
} else if (!__isArray(cases)) {
throw TypeError("Expected cases to be an Array, got " + __typeof(cases));
} else {
for (_i = cases.length; _i--; ) {
if (!(cases[_i] instanceof SwitchCase)) {
throw TypeError("Expected " + ("cases[" + _i + "]") + " to be a " + __name(SwitchCase) + ", got " + __typeof(cases[_i]));
}
}
}
_this.cases = cases;
if (defaultCase == null) {
defaultCase = Noop(pos);
} else if (!(defaultCase instanceof Node)) {
throw TypeError("Expected defaultCase to be a " + __name(Node) + ", got " + __typeof(defaultCase));
}
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
_this.label = label;
if (!(node instanceof Expression)) {
node = toConst(pos, node);
}
_this.node = node;
_this.defaultCase = defaultCase.maybeToStatement();
return _this;
}
_Statement_prototype = Statement.prototype;
_Switch_prototype = Switch.prototype = __create(_Statement_prototype);
_Switch_prototype.constructor = Switch;
Switch.displayName = "Switch";
if (typeof Statement.extended === "function") {
Statement.extended(Switch);
}
_Switch_prototype.compile = function (options, level, lineStart, sb) {
var _arr, _i, _len, _ref, case_, childOptions, minify;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
minify = options.minify;
if (this.label != null) {
this.label.compile(options, level, lineStart, sb);
sb(":");
if (!minify) {
sb(" ");
}
}
sb("switch");
if (!minify) {
sb(" ");
}
sb("(");
this.node.compile(options, Level.insideParentheses, false, sb);
sb(")");
if (!minify) {
sb(" ");
}
sb("{");
childOptions = incIndent(options);
for (_arr = __toArray(this.cases), _i = 0, _len = _arr.length; _i < _len; ++_i) {
case_ = _arr[_i];
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb("case ");
case_.node.compile(options, Level.insideParentheses, false, sb);
sb(":");
if (!case_.body.isNoop()) {
if (case_.node.isSmall() && case_.body.isSmall()) {
if (!minify) {
sb(" ");
}
case_.body.compileAsStatement(options, true, sb);
} else {
if (!minify) {
sb("\n");
sb.indent(childOptions.indent);
}
case_.body.compileAsStatement(childOptions, true, sb);
}
}
}
if (!this.defaultCase.isNoop()) {
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb("default:");
if (this.defaultCase.isSmall()) {
if (!minify) {
sb(" ");
}
this.defaultCase.compileAsStatement(options, true, sb);
} else {
if (!minify) {
sb("\n");
sb.indent(childOptions.indent);
}
this.defaultCase.compileAsStatement(childOptions, true, sb);
}
}
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb("}");
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_Switch_prototype.walk = function (walker) {
var _ref, cases, defaultCase, label, node;
if ((_ref = walker(this.node)) != null) {
node = _ref;
} else {
node = this.node.walk(walker);
}
cases = walkArray(this.cases, walker);
if ((_ref = walker(this.defaultCase)) != null) {
defaultCase = _ref;
} else {
defaultCase = this.defaultCase.walk(walker);
}
if (this.label != null) {
if ((_ref = walker(this.label)) != null) {
label = _ref;
} else {
label = this.label.walk(walker);
}
} else {
label = this.label;
}
if (node !== this.node || cases !== this.cases || defaultCase !== this.defaultCase || label !== this.label) {
return Switch(
this.pos,
node,
cases,
defaultCase,
label
);
} else {
return this;
}
};
_Switch_prototype.inspect = function (depth) {
return this.inspectHelper(
depth,
"Switch",
this.pos,
this.node,
this.cases,
this.defaultCase,
this.label
);
};
_Switch_prototype._toJSON = function () {
var _arr, _i, _len, case_, result;
result = [
this.label || 0,
simplify(this.node, 0)
];
for (_arr = __toArray(this.cases), _i = 0, _len = _arr.length; _i < _len; ++_i) {
case_ = _arr[_i];
result.push(
case_.pos.line,
case_.pos.column,
case_.pos.file,
simplify(case_.node, 0),
simplify(case_.body, 0)
);
}
if (!(this.defaultCase instanceof Noop)) {
result.push(simplify(this.defaultCase, 0));
}
return result;
};
Switch.fromJSON = function (line, column, file, label, node) {
var caseData, cBody, cColumn, cFile, cLine, cNode, defaultCase, i, len, resultCases;
caseData = __slice.call(arguments, 5);
len = caseData.length;
switch (len % 5) {
case 0:
break;
case 1:
--len;
defaultCase = caseData[len];
break;
default: throw Error("Unknown number of arguments passed to fromJSON");
}
resultCases = [];
for (i = 0; i < len; i += 5) {
cLine = caseData[i];
cColumn = caseData[i + 1];
cFile = caseData[i + 2];
cNode = caseData[i + 3];
cBody = caseData[i + 4];
resultCases.push(SwitchCase(
makePos(cLine, cColumn, cFile),
fromJSON(cNode),
fromJSON(cBody)
));
}
return Switch(
makePos(line, column, file),
fromJSON(node),
resultCases,
fromJSON(defaultCase),
label ? fromJSON(label) : null
);
};
Switch.Case = SwitchCase = (function () {
var _SwitchCase_prototype;
function SwitchCase(pos, node, body) {
var _this;
_this = this instanceof SwitchCase ? this : __create(_SwitchCase_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (node == null) {
node = Noop(pos);
}
if (body == null) {
body = Noop(pos);
} else if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (!(node instanceof Expression)) {
node = toConst(pos, node);
}
_this.node = node;
_this.body = body.maybeToStatement();
return _this;
}
_SwitchCase_prototype = SwitchCase.prototype;
SwitchCase.displayName = "SwitchCase";
_SwitchCase_prototype.isLarge = function () {
return true;
};
_SwitchCase_prototype.isSmall = function () {
return false;
};
_SwitchCase_prototype.walk = function (walker) {
var _ref, body, node;
if ((_ref = walker(this.node)) != null) {
node = _ref;
} else {
node = this.node.walk(walker);
}
if ((_ref = walker(this.body)) != null) {
body = _ref;
} else {
body = this.body.walk(walker);
}
if (node !== this.node || body !== this.body) {
return SwitchCase(this.pos, node, body);
} else {
return this;
}
};
_SwitchCase_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"Case",
this.pos,
this.node,
this.body
);
};
return SwitchCase;
}());
return Switch;
}(Statement));
exports.TryCatch = TryCatch = (function (Statement) {
var _Statement_prototype, _TryCatch_prototype;
function TryCatch(pos, tryBody, catchIdent, catchBody, label) {
var _this;
_this = this instanceof TryCatch ? this : __create(_TryCatch_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (tryBody == null) {
tryBody = Noop(pos);
} else if (!(tryBody instanceof Node)) {
throw TypeError("Expected tryBody to be a " + __name(Node) + ", got " + __typeof(tryBody));
}
if (!(catchIdent instanceof Ident)) {
throw TypeError("Expected catchIdent to be a " + __name(Ident) + ", got " + __typeof(catchIdent));
}
_this.catchIdent = catchIdent;
if (catchBody == null) {
catchBody = Noop(pos);
} else if (!(catchBody instanceof Node)) {
throw TypeError("Expected catchBody to be a " + __name(Node) + ", got " + __typeof(catchBody));
}
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
_this.label = label;
_this.tryBody = tryBody.maybeToStatement();
if (_this.tryBody.isNoop()) {
return _this.tryBody;
}
_this.catchBody = catchBody.maybeToStatement();
return _this;
}
_Statement_prototype = Statement.prototype;
_TryCatch_prototype = TryCatch.prototype = __create(_Statement_prototype);
_TryCatch_prototype.constructor = TryCatch;
TryCatch.displayName = "TryCatch";
if (typeof Statement.extended === "function") {
Statement.extended(TryCatch);
}
_TryCatch_prototype.compile = function (options, level, lineStart, sb) {
var _ref, childOptions, minify;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
minify = options.minify;
if (this.label != null) {
this.label.compile(options, level, lineStart, sb);
sb(":");
if (!minify) {
sb(" ");
}
}
sb(minify ? "try{" : "try {\n");
childOptions = incIndent(options);
if (!minify) {
sb.indent(childOptions.indent);
}
this.tryBody.compileAsStatement(childOptions, true, sb);
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb(minify ? "}catch(" : "} catch (");
this.catchIdent.compile(options, Level.insideParentheses, false, sb);
sb(minify ? "){" : ") {");
if (!this.catchBody.isNoop()) {
if (!minify) {
sb("\n");
sb.indent(childOptions.indent);
}
this.catchBody.compileAsStatement(childOptions, true, sb);
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
}
sb("}");
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_TryCatch_prototype.walk = function (walker) {
var _ref, catchBody, catchIdent, label, tryBody;
if ((_ref = walker(this.tryBody)) != null) {
tryBody = _ref;
} else {
tryBody = this.tryBody.walk(walker);
}
if ((_ref = walker(this.catchIdent)) != null) {
catchIdent = _ref;
} else {
catchIdent = this.catchIdent.walk(walker);
}
if ((_ref = walker(this.catchBody)) != null) {
catchBody = _ref;
} else {
catchBody = this.catchBody.walk(walker);
}
if (this.label != null) {
if ((_ref = walker(this.label)) != null) {
label = _ref;
} else {
label = this.label.walk(walker);
}
} else {
label = this.label;
}
if (tryBody !== this.tryBody || catchIdent !== this.catchIdent || catchBody !== this.catchBody || label !== this.label) {
return TryCatch(
this.pos,
tryBody,
catchIdent,
catchBody,
label
);
} else {
return this;
}
};
_TryCatch_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"TryCatch",
this.pos,
this.tryBody,
this.catchIdent,
this.catchBody,
this.label
);
};
_TryCatch_prototype._toJSON = function () {
var result;
result = [
this.label || 0,
simplify(this.tryBody, 0),
this.catchIdent
];
if (simplify(this.catchBody)) {
result.push.apply(result, __toArray(this.catchBody.toJSON()));
}
return result;
};
TryCatch.fromJSON = function (line, column, file, label, tryBody, catchIdent) {
var catchBody;
catchBody = __slice.call(arguments, 6);
return TryCatch(
makePos(line, column, file),
fromJSON(tryBody),
fromJSON(catchIdent),
fromJSON(catchBody),
label ? fromJSON(label) : null
);
};
return TryCatch;
}(Statement));
exports.TryFinally = TryFinally = (function (Statement) {
var _Statement_prototype, _TryFinally_prototype;
function TryFinally(pos, tryBody, finallyBody, label) {
var _this;
_this = this instanceof TryFinally ? this : __create(_TryFinally_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (tryBody == null) {
tryBody = Noop(pos);
} else if (!(tryBody instanceof Node)) {
throw TypeError("Expected tryBody to be a " + __name(Node) + ", got " + __typeof(tryBody));
}
if (finallyBody == null) {
finallyBody = Noop(pos);
} else if (!(finallyBody instanceof Node)) {
throw TypeError("Expected finallyBody to be a " + __name(Node) + ", got " + __typeof(finallyBody));
}
if (label == null) {
label = null;
} else if (!(label instanceof Ident)) {
throw TypeError("Expected label to be one of " + (__name(Ident) + " or null") + ", got " + __typeof(label));
}
_this.label = label;
_this.tryBody = tryBody.maybeToStatement();
_this.finallyBody = finallyBody.maybeToStatement();
if (label == null) {
if (_this.tryBody.isNoop()) {
return _this.finallyBody;
} else if (_this.finallyBody.isNoop()) {
return _this.tryBody;
}
}
return _this;
}
_Statement_prototype = Statement.prototype;
_TryFinally_prototype = TryFinally.prototype = __create(_Statement_prototype);
_TryFinally_prototype.constructor = TryFinally;
TryFinally.displayName = "TryFinally";
if (typeof Statement.extended === "function") {
Statement.extended(TryFinally);
}
_TryFinally_prototype.compile = function (options, level, lineStart, sb) {
var _ref, childOptions, minify;
if (level !== Level.block) {
throw Error("Cannot compile a statement except on the Block level");
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
minify = options.minify;
if (this.label != null) {
this.label.compile(options, level, lineStart, sb);
sb(":");
if (!minify) {
sb(" ");
}
}
sb(minify ? "try{" : "try {\n");
childOptions = incIndent(options);
if (!minify) {
sb.indent(childOptions.indent);
}
if (this.tryBody instanceof TryCatch && this.tryBody.label == null) {
this.tryBody.tryBody.compileAsStatement(childOptions, true, sb);
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb(minify ? "}catch(" : "} catch (");
this.tryBody.catchIdent.compile(options, Level.insideParentheses, false, sb);
sb(minify ? "){" : ") {");
if (!this.tryBody.catchBody.isNoop()) {
if (!minify) {
sb("\n");
sb.indent(childOptions.indent);
}
this.tryBody.catchBody.compileAsStatement(childOptions, true, sb);
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
}
} else {
this.tryBody.compileAsStatement(childOptions, true, sb);
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
}
sb(minify ? "}finally{" : "} finally {\n");
if (!minify) {
sb.indent(childOptions.indent);
}
this.finallyBody.compileAsStatement(childOptions, true, sb);
if (!minify) {
sb("\n");
sb.indent(options.indent);
}
sb("}");
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_TryFinally_prototype.walk = function (walker) {
var _ref, finallyBody, label, tryBody;
if ((_ref = walker(this.tryBody)) != null) {
tryBody = _ref;
} else {
tryBody = this.tryBody.walk(walker);
}
if ((_ref = walker(this.finallyBody)) != null) {
finallyBody = _ref;
} else {
finallyBody = this.finallyBody.walk(walker);
}
if (this.label != null) {
if ((_ref = walker(this.label)) != null) {
label = _ref;
} else {
label = this.label.walk(walker);
}
} else {
label = this.label;
}
if (tryBody !== this.tryBody || finallyBody !== this.finallyBody || label !== this.label) {
return TryFinally(this.pos, tryBody, finallyBody, label);
} else {
return this;
}
};
_TryFinally_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"TryFinally",
this.pos,
this.tryBody,
this.finallyBody,
this.label
);
};
_TryFinally_prototype._toJSON = function () {
var result;
result = [
this.label || 0,
simplify(this.tryBody, 0)
];
if (simplify(this.finallyBody)) {
result.push.apply(result, __toArray(this.finallyBody.toJSON()));
}
return result;
};
TryFinally.fromJSON = function (line, column, file, label, tryBody) {
var finallyBody;
finallyBody = __slice.call(arguments, 5);
return TryFinally(
makePos(line, column, file),
fromJSON(tryBody),
fromJSON(finallyBody),
label ? fromJSON(label) : null
);
};
return TryFinally;
}(Statement));
exports.Unary = Unary = (function (Expression) {
var _Expression_prototype, _Unary_prototype, ASSIGNMENT_OPERATORS, KNOWN_OPERATORS;
function Unary(pos, op, node) {
var _this;
_this = this instanceof Unary ? this : __create(_Unary_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (typeof op !== "string") {
throw TypeError("Expected op to be a String, got " + __typeof(op));
}
_this.op = op;
if (node == null) {
node = Noop(pos);
}
if (!__in(op, KNOWN_OPERATORS)) {
throw Error("Unknown unary operator: " + op);
}
if (!(node instanceof Expression)) {
node = toConst(line, column, node);
}
if (op === "delete" && (!(node instanceof Binary) || node.op !== ".")) {
throw Error("Cannot use delete operator on a non-access");
}
_this.node = node;
return _this;
}
_Expression_prototype = Expression.prototype;
_Unary_prototype = Unary.prototype = __create(_Expression_prototype);
_Unary_prototype.constructor = Unary;
Unary.displayName = "Unary";
if (typeof Expression.extended === "function") {
Expression.extended(Unary);
}
_Unary_prototype.compile = function (options, level, lineStart, sb) {
var _ref, op;
op = this.op;
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.pushFile(this.pos.file);
}
if ((_ref = options.sourcemap) != null) {
_ref.add(sb.line, sb.column, this.pos.line, this.pos.column);
}
if (op === "++post" || op === "--post") {
this.node.compile(options, Level.unary, false, sb);
sb(op.substring(0, 2));
} else {
sb(op);
if (op === "typeof" || op === "void" || op === "delete" || (op === "+" || op === "-" || op === "++" || op === "--") && (this.node instanceof Unary && (op === "+" || op === "-" || op === "++" || op === "--") || this.node instanceof Const && typeof this.node.value === "number" && isNegative(this.node.value))) {
sb(" ");
}
this.node.compile(options, Level.unary, false, sb);
}
if (options.sourcemap != null && this.pos.file) {
options.sourcemap.popFile();
}
};
_Unary_prototype.compileAsBlock = function (options, level, lineStart, sb) {
var op;
op = this.op;
if (__owns.call(ASSIGNMENT_OPERATORS, op)) {
this.compile(options, level, lineStart, sb);
} else {
this.node.compileAsBlock(options, level, lineStart, sb);
}
};
_Unary_prototype.compileAsStatement = function (options, lineStart, sb) {
var op;
op = this.op;
if (__owns.call(ASSIGNMENT_OPERATORS, op)) {
_Expression_prototype.compileAsStatement.call(this, options, lineStart, sb);
} else {
this.node.compileAsStatement(options, lineStart, sb);
}
};
KNOWN_OPERATORS = [
"++",
"--",
"++post",
"--post",
"!",
"~",
"+",
"-",
"typeof",
"void",
"delete"
];
ASSIGNMENT_OPERATORS = {
"++": true,
"--": true,
"++post": true,
"--post": true,
"delete": true
};
_Unary_prototype.isLarge = function () {
return this.node.isLarge();
};
_Unary_prototype.isSmall = function () {
return this.node.isSmall();
};
_Unary_prototype.isNoop = function () {
var _ref;
if ((_ref = this._isNoop) == null) {
return this._isNoop = !__owns.call(ASSIGNMENT_OPERATORS, this.op) && this.node.isNoop();
} else {
return _ref;
}
};
_Unary_prototype.walk = function (walker) {
var _ref, node;
if ((_ref = walker(this.node)) != null) {
node = _ref;
} else {
node = this.node.walk(walker);
}
if (node !== this.node) {
return Unary(this.pos, this.op, node);
} else {
return this;
}
};
_Unary_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"Unary",
this.pos,
this.op,
this.node
);
};
_Unary_prototype._toJSON = function () {
var result;
result = [this.op];
if (simplify(this.node)) {
result.push.apply(result, __toArray(this.node.toJSON()));
}
return result;
};
Unary.fromJSON = function (line, column, file, op) {
var node;
node = __slice.call(arguments, 4);
return Unary(
makePos(line, column, file),
op,
fromJSON(node)
);
};
return Unary;
}(Expression));
While = exports.While = function (pos, test, body, label) {
return For(
pos,
null,
test,
null,
body,
label
);
};
fromJSON = exports.fromJSON = function (obj) {
var _ref, type;
if (!obj) {
return Noop(makePos(0, 0));
}
if (__isArray(obj)) {
if (obj.length === 0) {
return Noop(makePos(0, 0));
}
type = obj[0];
if (__num(obj.length) < 1 || typeof type !== "string") {
throw Error("Expected an array with a string as its first item");
}
if (!__owns.call(exports, type)) {
throw Error("Unknown node type: " + __strnum(obj.type));
}
return (_ref = exports[type]).fromJSON.apply(_ref, __toArray(__slice.call(obj, 1)));
} else if (typeof obj === "object" && obj !== null) {
if (typeof obj.type !== "string") {
throw Error("Expected an object with a string 'type' key");
}
if (!__owns.call(exports, obj.type)) {
throw Error("Unknown node type: " + __strnum(obj.type));
}
return exports[obj.type].fromJSON(obj);
} else {
throw TypeError("Must provide an object or array to deserialize");
}
};
function arrayFromJSON(array) {
var _arr, _arr2, _i, _len, item;
if (array == null) {
return [];
} else if (__isArray(array)) {
for (_arr = [], _arr2 = __toArray(array), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
item = _arr2[_i];
_arr.push(fromJSON(item));
}
return _arr;
} else {
throw Error("Expected an array, got " + __typeof(array));
}
}
}.call(this));
return module.exports;
};
require['./parser'] = function () {
var module = { exports: this };
var exports = this;
(function (GLOBAL) {
"use strict";
var __bind, __cmp, __create, __curry, __defer, __generatorToPromise, __genericFunc, __getInstanceof, __import, __in, __int, __isArray, __isObject, __lt, __lte, __name, __num, __owns, __promise, __slice, __str, __strnum, __toArray, __typeof, _arr, _Block, _DefineMacro, _FunctionBody, _i, _len, _Name, _o, _ref, _ref2, _SomeEmptyLinesWithCheckIndent, _Symbol, AccessMultiNode, AccessNode, addParamToScope, AnyArrayLiteral, AnyObjectLiteral, ArgsNode, ArgumentsLiteral, ArrayLiteral, ArrayNode, ArrayParameter, ArrayType, AssignmentAsExpression, AssignNode, Ast, AsterixChar, AstExpression, AstStatement, AtSignChar, BackslashChar, BackslashEscapeSequence, BackslashStringLiteral, BasicInvocationOrAccess, BinaryDigit, BinaryNode, BinaryNumber, BinaryOperationByPrecedence, Block, BlockNode, Body, BodyNoEnd, BodyNoIndent, BodyNoIndentNoEnd, BodyWithIndent, BOM, Box, BracketedObjectKey, BreakNode, cache, CallNode, CaretChar, CheckStop, CloseCurlyBrace, CloseCurlyBraceChar, ClosedArguments, CloseParenthesis, CloseSquareBracket, Colon, ColonChar, ColonEmbeddedClose, ColonEmbeddedCloseWrite, ColonEqual, ColonNewline, Comma, CommaChar, CommaOrNewline, CommaOrSomeEmptyLinesWithCheckIndent, CommentNode, concat, cons, ConstantLiteral, ConstNode, ConstObjectKey, ContinueNode, convertInvocationOrAccess, CountIndent, CurrentArrayLength, CustomOperatorCloseParenthesis, DebuggerNode, DecimalDigit, DecimalNumber, DedentedBody, DefineConstLiteral, DefineHelper, DefineMacro, DefineOperator, DefineSyntax, DefNode, disallowEmbeddedText, DollarSign, DollarSignChar, DoubleColonChar, DoubleQuote, DoubleStringArrayLiteral, DoubleStringLiteral, DoubleStringLiteralInner, DualObjectKey, EmbeddedBlock, EmbeddedClose, EmbeddedCloseComment, EmbeddedCloseWrite, EmbeddedLiteralText, EmbeddedLiteralTextInnerPart, EmbeddedLiteralTextInnerPartWithBlock, EmbeddedOpen, EmbeddedOpenComment, EmbeddedOpenWrite, EmbeddedRootGeneratorP, EmbeddedRootInnerP, EmbeddedRootP, EmbeddedWriteExpression, EmbedWriteNode, EmptyLine, EmptyLines, EndNoIndent, EqualChar, EqualSign, EqualSignChar, Eval, EvalNode, ExclamationPointChar, Expression, ExpressionAsStatement, ExpressionOrAssignment, ExpressionOrAssignmentOrBody, ForInNode, ForNode, fromCharCode, FunctionBody, FunctionDeclaration, FunctionGlyph, FunctionLiteral, FunctionNode, FunctionType, GeneratorBody, GeneratorBodyNoEnd, GeneratorFunctionBody, getPackageVersion, getReservedIdents, GetSetToken, GreaterThan, GreaterThanChar, HashSignChar, HexDigit, HexEscapeSequence, HexNumber, Identifier, IdentifierNameConst, IdentifierNameConstOrNumberLiteral, IdentifierOrAccess, IdentifierOrSimpleAccess, IdentifierOrSimpleAccessPart, IdentifierOrSimpleAccessStart, IdentifierOrThisAccess, IdentifierParameter, IdentNode, IfNode, inAst, IndentedUnclosedArrayLiteral, IndentedUnclosedArrayLiteralInner, IndentedUnclosedObjectLiteral, IndentedUnclosedObjectLiteralInner, INDENTS, inEvilAst, inExpression, inFunctionTypeParams, inMacro, inStatement, InvocationArguments, InvocationOrAccess, InvocationOrAccessPart, KeyValuePair, KvpParameter, LessThan, LessThanChar, Letter, LicenseComment, Line, Literal, Logic, MacroAccessNode, MacroBody, MacroContext, MacroError, MacroHolder, macroName, MacroName, MacroNames, MacroOptions, MacroSyntax, MacroSyntaxChoiceParameters, MacroSyntaxParameter, MacroSyntaxParameters, MacroSyntaxParameterType, makeAlterStack, makeEmbeddedRule, MapLiteral, MaybeAsType, MaybeAtSignChar, MaybeComma, MaybeCommaOrNewline, MaybeComment, MaybeExclamationPointChar, MaybeNotToken, MaybeQuestionMarkChar, MaybeSpreadToken, MaybeUnderscores, MethodDeclaration, MinusChar, multiple, mutate, Name, NameChar, NameOrSymbol, NamePart, NameStart, Node, nodeType, NoNewlineIfNoIndent, NonUnionType, NoSpace, NoSpaceNewline, NotColon, NotColonUnlessNoIndentAndNewline, NotEmbeddedOpenComment, NotEmbeddedOpenWrite, Nothing, NothingNode, notInFunctionTypeParams, NumberChar, NumberLiteral, ObjectKey, ObjectKeyColon, ObjectLiteral, ObjectNode, ObjectParameter, ObjectType, ObjectTypePair, OctalDigit, OctalNumber, oneOf, oneOrMore, oneOrMoreOf, OpenCurlyBrace, OpenCurlyBraceChar, OpenParenthesis, OpenSquareBracket, OpenSquareBracketChar, ParamDualObjectKey, Parameter, ParameterOrNothing, Parameters, ParameterSequence, ParamNode, ParamSingularObjectKey, Parenthetical, parse, Parser, ParserError, PercentSign, PercentSignChar, Period, PeriodOrDoubleColonChar, Pipe, PipeChar, PlusChar, PlusOrMinusChar, PostfixUnaryOperation, PrefixUnaryOperation, preventUnclosedObjectLiteral, PrimaryExpression, PropertyDualObjectKey, PropertyOrDualObjectKey, PropertyOrDualObjectKeyOrMethodDeclaration, quote, RadixNumber, RegexLiteral, RegexpNode, ReturnNode, RootInnerP, RootNode, RootP, Scope, Semicolon, SemicolonChar, Semicolons, separatedList, sequential, setImmediate, SetLiteral, Shebang, SHORT_CIRCUIT, SingleEscapeCharacter, SingleQuote, SingleStringLiteral, SingularObjectKey, SomeEmptyLines, SomeEmptyLinesWithCheckIndent, Space, SpaceChar, SpaceChars, SpreadNode, SpreadOrExpression, Stack, Statement, StringInterpolation, StringLiteral, stringRepeat, SuperInvocation, SuperNode, SwitchNode, Symbol, symbol, SymbolChar, SyntaxChoiceNode, SyntaxManyNode, SyntaxParamNode, SyntaxSequenceNode, ThisLiteral, ThisNode, ThisOrShorthandLiteral, ThisOrShorthandLiteralPeriod, ThisShorthandLiteral, ThrowNode, TmpNode, TmpWrapperNode, trimRight, TripleDoubleQuote, TripleDoubleStringArrayLiteral, TripleDoubleStringLine, TripleDoubleStringLiteral, TripleSingleQuote, TripleSingleStringLine, TripleSingleStringLiteral, TryCatchNode, TryFinallyNode, Type, TypeFunctionNode, TypeGenericNode, TypeObjectNode, TypeReference, TypeUnionNode, UnaryNode, UnclosedArguments, UnclosedArrayLiteralElement, UnclosedObjectLiteral, UnclosedObjectLiteralsAllowed, Underscore, UnicodeEscapeSequence, unique, unusedCaches, UseMacro, VarNode, WeakMap, word, wordOrSymbol, YieldNode, Zero, zeroOrMore, zeroOrMoreOf;
__bind = function (parent, child) {
var func;
if (parent == null) {
throw TypeError("Expected parent to be an object, got " + __typeof(parent));
}
func = parent[child];
if (typeof func !== "function") {
throw Error("Trying to bind child '" + String(child) + "' which is not a function");
}
return function () {
return func.apply(parent, arguments);
};
};
__cmp = function (left, right) {
var type;
if (left === right) {
return 0;
} else {
type = typeof left;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof right) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof right);
} else if (left < right) {
return -1;
} else {
return 1;
}
}
};
__create = typeof Object.create === "function" ? Object.create
: function (x) {
function F() {}
F.prototype = x;
return new F();
};
__curry = function (numArgs, f) {
var currier;
if (typeof numArgs !== "number") {
throw TypeError("Expected numArgs to be a Number, got " + __typeof(numArgs));
}
if (typeof f !== "function") {
throw TypeError("Expected f to be a Function, got " + __typeof(f));
}
if (numArgs > 1) {
currier = function (args) {
var ret;
if (__num(args.length) >= numArgs) {
return f.apply(this, args);
} else {
ret = function () {
if (arguments.length === 0) {
return ret;
} else {
return currier.call(this, args.concat(__slice.call(arguments)));
}
};
return ret;
}
};
return currier([]);
} else {
return f;
}
};
__defer = (function () {
function __defer() {
var deferred, isError, value;
isError = false;
value = null;
deferred = [];
function complete(newIsError, newValue) {
var funcs;
if (deferred) {
funcs = deferred;
deferred = null;
isError = newIsError;
value = newValue;
if (funcs.length) {
setImmediate(function () {
var _end, i;
for (i = 0, _end = funcs.length; i < _end; ++i) {
funcs[i]();
}
});
}
}
}
return {
promise: {
then: function (onFulfilled, onRejected, allowSync) {
var _ref, fulfill, promise, reject;
if (allowSync !== true) {
allowSync = void 0;
}
promise = (_ref = __defer()).promise;
fulfill = _ref.fulfill;
reject = _ref.reject;
function step() {
var f, result;
try {
if (isError) {
f = onRejected;
} else {
f = onFulfilled;
}
if (typeof f === "function") {
result = f(value);
if (result && typeof result.then === "function") {
result.then(fulfill, reject, allowSync);
} else {
fulfill(result);
}
} else {
(isError ? reject : fulfill)(value);
}
} catch (e) {
reject(e);
}
}
if (deferred) {
deferred.push(step);
} else if (allowSync) {
step();
} else {
setImmediate(step);
}
return promise;
},
sync: function () {
var result, state;
state = 0;
result = 0;
this.then(
function (ret) {
state = 1;
return result = ret;
},
function (err) {
state = 2;
return result = err;
},
true
);
switch (state) {
case 0: throw Error("Promise did not execute synchronously");
case 1: return result;
case 2: throw result;
default: throw Error("Unknown state");
}
}
},
fulfill: function (value) {
complete(false, value);
},
reject: function (reason) {
complete(true, reason);
}
};
}
__defer.fulfilled = function (value) {
var d;
d = __defer();
d.fulfill(value);
return d.promise;
};
__defer.rejected = function (reason) {
var d;
d = __defer();
d.reject(reason);
return d.promise;
};
return __defer;
}());
__generatorToPromise = function (generator, allowSync) {
if (typeof generator !== "object" || generator === null) {
throw TypeError("Expected generator to be an Object, got " + __typeof(generator));
} else {
if (typeof generator.send !== "function") {
throw TypeError("Expected generator.send to be a Function, got " + __typeof(generator.send));
}
if (typeof generator["throw"] !== "function") {
throw TypeError("Expected generator.throw to be a Function, got " + __typeof(generator["throw"]));
}
}
if (allowSync == null) {
allowSync = false;
} else if (typeof allowSync !== "boolean") {
throw TypeError("Expected allowSync to be a Boolean, got " + __typeof(allowSync));
}
function continuer(verb, arg) {
var item;
try {
item = generator[verb](arg);
} catch (e) {
return __defer.rejected(e);
}
if (item.done) {
return __defer.fulfilled(item.value);
} else {
return item.value.then(callback, errback, allowSync);
}
}
function callback(value) {
return continuer("send", value);
}
function errback(value) {
return continuer("throw", value);
}
return callback(void 0);
};
__genericFunc = function (numArgs, make) {
var any, cache, result;
cache = WeakMap();
any = {};
function generic() {
var _ref, current, i, item, type;
current = cache;
for (i = numArgs - 1; i >= 0; --i) {
if ((_ref = arguments[i]) != null) {
type = _ref;
} else {
type = any;
}
item = current.get(type);
if (item == null) {
item = i === 0 ? make.apply(this, arguments) : WeakMap();
current.set(type, item);
}
current = item;
}
return current;
}
result = generic();
result.generic = generic;
return result;
};
__getInstanceof = (function () {
function isAny() {
return true;
}
function isStr(x) {
return typeof x === "string";
}
function isNum(x) {
return typeof x === "number";
}
function isFunc(x) {
return typeof x === "function";
}
function isBool(x) {
return typeof x === "boolean";
}
return function (ctor) {
if (ctor == null) {
return isAny;
} else {
switch (ctor) {
case String: return isStr;
case Number: return isNum;
case Function: return isFunc;
case Boolean: return isBool;
case Array: return __isArray;
case Object: return __isObject;
default:
return function (_x) {
return _x instanceof ctor;
};
}
}
};
}());
__import = function (dest, source) {
var k;
for (k in source) {
if (__owns.call(source, k)) {
dest[k] = source[k];
}
}
return dest;
};
__in = typeof Array.prototype.indexOf === "function"
? (function () {
var indexOf;
indexOf = Array.prototype.indexOf;
return function (child, parent) {
return indexOf.call(parent, child) !== -1;
};
}())
: function (child, parent) {
var i, len;
len = +parent.length;
i = -1;
while (++i < len) {
if (child === parent[i] && i in parent) {
return true;
}
}
return false;
};
__int = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else if (num % 1 !== 0) {
throw TypeError("Expected an integer, got " + num);
} else {
return num;
}
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__isObject = function (x) {
return typeof x === "object" && x !== null;
};
__lt = function (x, y) {
var type;
type = typeof x;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof y) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof y);
} else {
return x < y;
}
};
__lte = function (x, y) {
var type;
type = typeof x;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof y) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof y);
} else {
return x <= y;
}
};
__name = function (func) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
return func.displayName || func.name || "";
};
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__owns = Object.prototype.hasOwnProperty;
__promise = function (value, allowSync) {
var factory;
if (allowSync == null) {
allowSync = false;
} else if (typeof allowSync !== "boolean") {
throw TypeError("Expected allowSync to be a Boolean, got " + __typeof(allowSync));
}
if (typeof value === "function") {
factory = function () {
return __generatorToPromise(value.apply(this, arguments));
};
factory.sync = function () {
return __generatorToPromise(
value.apply(this, arguments),
true
).sync();
};
return factory;
} else {
return __generatorToPromise(value, allowSync);
}
};
__slice = Array.prototype.slice;
__str = function (str) {
if (typeof str !== "string") {
throw TypeError("Expected a string, got " + __typeof(str));
} else {
return str;
}
};
__strnum = function (strnum) {
var type;
type = typeof strnum;
if (type === "string") {
return strnum;
} else if (type === "number") {
return String(strnum);
} else {
throw TypeError("Expected a string or number, got " + __typeof(strnum));
}
};
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
setImmediate = typeof GLOBAL.setImmediate === "function" ? GLOBAL.setImmediate
: typeof process !== "undefined" && typeof process.nextTick === "function"
? (function () {
var nextTick;
nextTick = process.nextTick;
return function (func) {
var args;
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
args = __slice.call(arguments, 1);
if (args.length) {
return nextTick(function () {
func.apply(void 0, __toArray(args));
});
} else {
return nextTick(func);
}
};
}())
: function (func) {
var args;
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
args = __slice.call(arguments, 1);
if (args.length) {
return setTimeout(
function () {
func.apply(void 0, __toArray(args));
},
0
);
} else {
return setTimeout(func, 0);
}
};
WeakMap = typeof GLOBAL.WeakMap === "function" ? GLOBAL.WeakMap
: (WeakMap = (function () {
var _WeakMap_prototype, defProp, isExtensible;
function WeakMap() {
var _this;
_this = this instanceof WeakMap ? this : __create(_WeakMap_prototype);
_this._keys = [];
_this._values = [];
_this._chilly = [];
_this._uid = createUid();
return _this;
}
_WeakMap_prototype = WeakMap.prototype;
WeakMap.displayName = "WeakMap";
function uidRand() {
return Math.random().toString(36).slice(2);
}
function createUid() {
return __strnum(uidRand()) + "-" + __strnum(new Date().getTime()) + "-" + __strnum(uidRand()) + "-" + __strnum(uidRand());
}
isExtensible = Object.isExtensible || function () {
return true;
};
function check(key) {
var chilly, uid;
uid = this._uid;
if (__owns.call(key, uid)) {
chilly = this._chilly;
if (chilly.indexOf(key) === -1) {
chilly.push(key);
this._keys.push(key);
this._values.push(key[uid]);
}
}
}
_WeakMap_prototype.get = function (key) {
var _ref, index;
if (Object(key) !== key) {
throw TypeError("Invalid value used as weak map key");
}
if (isExtensible(key)) {
if (__owns.call(key, _ref = this._uid)) {
return key[_ref];
}
} else {
check.call(this, key);
index = this._keys.indexOf(key);
if (index === -1) {
return;
} else {
return this._values[index];
}
}
};
_WeakMap_prototype.has = function (key) {
if (Object(key) !== key) {
throw TypeError("Invalid value used as weak map key");
}
if (isExtensible(key)) {
return __owns.call(key, this._uid);
} else {
check.call(this, key);
return this._keys.indexOf(key) !== -1;
}
};
if (typeof Object.defineProperty === "function") {
defProp = Object.defineProperty;
} else {
defProp = function (o, k, d) {
o[k] = d.value;
};
}
_WeakMap_prototype.set = function (key, value) {
var index, keys;
if (Object(key) !== key) {
throw TypeError("Invalid value used as weak map key");
}
if (isExtensible(key)) {
defProp(key, this._uid, { configurable: true, writable: true, enumerable: false, value: value });
} else {
check.call(this, key);
keys = this._keys;
index = keys.indexOf(key);
if (index === -1) {
index = keys.length;
keys[index] = key;
}
this._values[index] = value;
}
};
_WeakMap_prototype["delete"] = function (key) {
var index, keys;
if (Object(key) !== key) {
throw TypeError("Invalid value used as weak map key");
}
if (isExtensible(key)) {
delete key[this._uid];
} else {
check.call(this, key);
keys = this._keys;
index = keys.indexOf(key);
if (index !== -1) {
keys.splice(index, 1);
this._values.splice(index, 1);
}
}
};
return WeakMap;
}()));
Node = require("./parser-nodes");
Scope = require("./parser-scope");
MacroContext = require("./parser-macrocontext");
MacroHolder = require("./parser-macroholder");
Type = require("./types");
stringRepeat = require("./utils").stringRepeat;
addParamToScope = require("./parser-utils").addParamToScope;
quote = (_ref = require("./utils")).quote;
unique = _ref.unique;
getPackageVersion = _ref.getPackageVersion;
AccessNode = Node.Access;
AccessMultiNode = Node.AccessMulti;
ArgsNode = Node.Args;
ArrayNode = Node.Array;
AssignNode = Node.Assign;
BinaryNode = Node.Binary;
BlockNode = Node.Block;
BreakNode = Node.Break;
CallNode = Node.Call;
CommentNode = Node.Comment;
ConstNode = Node.Const;
ContinueNode = Node.Continue;
DebuggerNode = Node.Debugger;
DefNode = Node.Def;
EmbedWriteNode = Node.EmbedWrite;
EvalNode = Node.Eval;
ForNode = Node.For;
ForInNode = Node.ForIn;
FunctionNode = Node.Function;
IdentNode = Node.Ident;
IfNode = Node.If;
MacroAccessNode = Node.MacroAccess;
NothingNode = Node.Nothing;
ObjectNode = Node.Object;
ParamNode = Node.Param;
RegexpNode = Node.Regexp;
ReturnNode = Node.Return;
RootNode = Node.Root;
SpreadNode = Node.Spread;
SuperNode = Node.Super;
SwitchNode = Node.Switch;
SyntaxChoiceNode = Node.SyntaxChoice;
SyntaxManyNode = Node.SyntaxMany;
SyntaxParamNode = Node.SyntaxParam;
SyntaxSequenceNode = Node.SyntaxSequence;
ThisNode = Node.This;
ThrowNode = Node.Throw;
TmpNode = Node.Tmp;
TmpWrapperNode = Node.TmpWrapper;
TryCatchNode = Node.TryCatch;
TryFinallyNode = Node.TryFinally;
TypeFunctionNode = Node.TypeFunction;
TypeGenericNode = Node.TypeGeneric;
TypeObjectNode = Node.TypeObject;
TypeUnionNode = Node.TypeUnion;
UnaryNode = Node.Unary;
VarNode = Node.Var;
YieldNode = Node.Yield;
ParserError = (function (Error) {
var _Error_prototype, _ParserError_prototype;
function ParserError(message, parser, index) {
var _this, err, pos;
_this = this instanceof ParserError ? this : __create(_ParserError_prototype);
if (message == null) {
message = "";
} else if (typeof message !== "string") {
throw TypeError("Expected message to be a String, got " + __typeof(message));
}
if (parser == null) {
parser = null;
} else if (!(parser instanceof Parser)) {
throw TypeError("Expected parser to be one of " + (__name(Parser) + " or null") + ", got " + __typeof(parser));
}
if (index == null) {
index = 0;
} else if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
_this.index = index;
if (parser) {
_this.source = parser.source;
_this.filename = parser.options.filename;
pos = parser.getPosition(index);
_this.line = pos.line;
_this.column = pos.column;
_this.message = message + (" at " + (_this.filename ? __strnum(_this.filename) + ":" : "") + __strnum(_this.line) + ":" + __strnum(_this.column));
} else {
_this.line = 0;
_this.column = 0;
}
err = Error.call(_this, _this.message);
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(_this, ParserError);
} else if ("stack" in err) {
_this.stack = err.stack;
}
return _this;
}
_Error_prototype = Error.prototype;
_ParserError_prototype = ParserError.prototype = __create(_Error_prototype);
_ParserError_prototype.constructor = ParserError;
ParserError.displayName = "ParserError";
if (typeof Error.extended === "function") {
Error.extended(ParserError);
}
_ParserError_prototype.name = "ParserError";
return ParserError;
}(Error));
MacroError = (function (Error) {
var _Error_prototype, _MacroError_prototype;
function MacroError(inner, parser, index) {
var _this, err, msg, pos;
_this = this instanceof MacroError ? this : __create(_MacroError_prototype);
if (inner == null) {
inner = "";
} else if (!(inner instanceof Error) && typeof inner !== "string") {
throw TypeError("Expected inner to be one of " + (__name(Error) + " or String") + ", got " + __typeof(inner));
}
if (parser == null) {
parser = null;
} else if (!(parser instanceof Parser)) {
throw TypeError("Expected parser to be one of " + (__name(Parser) + " or null") + ", got " + __typeof(parser));
}
if (index == null) {
index = 0;
} else if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
_this.index = index;
if (parser) {
_this.source = parser.source;
_this.filename = parser.options.filename;
pos = parser.getPosition(index);
_this.line = pos.line;
_this.column = pos.column;
msg = [];
if (inner instanceof Error) {
if (__typeof(inner) !== "Error") {
msg.push(__typeof(inner));
msg.push(": ");
}
msg.push(String(inner.message));
} else {
msg.push(String(inner));
}
msg.push(" at ");
if (_this.filename) {
msg.push(String(_this.filename));
msg.push(":");
}
_this._message = msg.join("");
msg.push(_this.line);
msg.push(":");
msg.push(_this.column);
_this.message = msg.join("");
} else {
_this.line = 0;
_this.column = 0;
_this._message = "";
_this.message = "";
}
err = Error.call(_this, _this.message);
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(_this, MacroError);
} else if ("stack" in err) {
_this.stack = err.stack;
}
if (inner instanceof Error) {
_this.inner = inner;
}
return _this;
}
_Error_prototype = Error.prototype;
_MacroError_prototype = MacroError.prototype = __create(_Error_prototype);
_MacroError_prototype.constructor = MacroError;
MacroError.displayName = "MacroError";
if (typeof Error.extended === "function") {
Error.extended(MacroError);
}
_MacroError_prototype.name = "MacroError";
_MacroError_prototype.setPosition = function (line, column) {
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
return;
};
return MacroError;
}(Error));
Box = (function () {
var _Box_prototype;
function Box(index, value) {
var _this;
_this = this instanceof Box ? this : __create(_Box_prototype);
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
_this.index = index;
_this.value = value;
if (index % 1 !== 0 || index < 0) {
throw RangeError("Expected index to be a non-negative integer, got " + index);
}
return _this;
}
_Box_prototype = Box.prototype;
Box.displayName = "Box";
return Box;
}());
cache = (function () {
var id;
id = -1;
return function (rule) {
var cacheKey;
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
cacheKey = ++id;
function f(parser, index) {
var _ref, _ref2, cache, indent, indentCache, inner, item, result;
cache = parser.cache;
indent = parser.indent.peek();
if ((_ref = cache[indent]) != null) {
indentCache = _ref;
} else {
indentCache = cache[indent] = [];
}
if ((_ref = indentCache[_ref2 = index % 16]) != null) {
inner = _ref;
} else {
inner = indentCache[_ref2] = [];
}
item = inner[cacheKey];
if (item && item.start === index) {
return item.result;
} else {
result = rule(parser, index);
inner[cacheKey] = { start: index, result: result };
return result;
}
}
return f;
};
}());
function identity(x) {
return x;
}
function makeReturn(x) {
return function () {
return x;
};
}
function wrap(name, func) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
return func;
}
fromCharCode = (function () {
var f;
f = String.fromCharCode;
return function (charCode) {
if (charCode > 65535) {
return "" + f((charCode - 65536 >> 10) + 55296) + f((charCode - 65536) % 1024 + 56320);
} else {
return f(charCode);
}
};
}());
function processCharCodes(codes, array, start) {
var _i, _len, code;
if (!__isArray(codes)) {
throw TypeError("Expected codes to be an Array, got " + __typeof(codes));
}
if (array == null) {
array = [];
}
if (start == null) {
start = 0;
}
for (_len = codes.length, _i = __int(start), _i < 0 && (_i += _len); _i < _len; ++_i) {
code = codes[_i];
array.push(fromCharCode(code));
}
return array;
}
function codesToString(codes) {
if (!__isArray(codes)) {
throw TypeError("Expected codes to be an Array, got " + __typeof(codes));
}
return processCharCodes(codes).join("");
}
makeAlterStack = __genericFunc(1, function (T) {
var _instanceof_T;
_instanceof_T = __getInstanceof(T);
return function (name, value) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (!_instanceof_T(value)) {
throw TypeError("Expected value to be a " + __name(T) + ", got " + __typeof(value));
}
return function (rule) {
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
return function (parser, index) {
var stack;
stack = parser[name];
stack.push(value);
try {
return rule(parser, index);
} finally {
stack.pop();
}
};
};
};
});
function charsToFakeSet(array) {
var _arr, _end, _i, _len, c, item, obj;
obj = __create(null);
for (_arr = __toArray(array), _i = 0, _len = _arr.length; _i < _len; ++_i) {
item = _arr[_i];
if (typeof item === "number") {
obj[item] = true;
} else {
for (c = __num(item[0]), _end = __num(item[1]); c <= _end; ++c) {
obj[c] = true;
}
}
}
return obj;
}
function stackWrap(func) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
func.stack = Error().stack;
return func;
}
function character(name, expected) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (typeof expected !== "number") {
throw TypeError("Expected expected to be a Number, got " + __typeof(expected));
}
return stackWrap(function (parser, index) {
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
if (parser.source.charCodeAt(index) === expected) {
return Box(index + 1, expected);
} else {
return parser.fail(name, index);
}
});
}
function characters(name, expected) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (typeof expected !== "object" || expected === null) {
throw TypeError("Expected expected to be an Object, got " + __typeof(expected));
}
return stackWrap(function (parser, index) {
var c;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
c = parser.source.charCodeAt(index);
if (expected[c]) {
return Box(index + 1, c);
} else {
return parser.fail(name, index);
}
});
}
mutate = __curry(2, function (mutator, rule) {
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
if (mutator === identity) {
return rule;
}
if (typeof mutator !== "function") {
mutator = makeReturn(mutator);
}
function f(parser, index) {
var result;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
result = rule(parser, index);
if (result) {
return Box(result.index, mutator(result.value, parser, index, result.index));
}
}
f.rule = rule;
f.mutator = mutator;
return stackWrap(f);
});
function bool(rule) {
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
if (typeof rule.mutator === "function" && typeof rule.rule === "function") {
return bool(rule.rule);
} else {
return mutate(
function (x) {
return !!x;
},
rule
);
}
}
multiple = __genericFunc(1, function (T) {
return function (rule, minimum, maximum, ignoreValue) {
var mutator;
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
if (minimum == null) {
minimum = 0;
} else if (typeof minimum !== "number") {
throw TypeError("Expected minimum to be a Number, got " + __typeof(minimum));
}
if (maximum == null) {
maximum = 1/0;
} else if (typeof maximum !== "number") {
throw TypeError("Expected maximum to be a Number, got " + __typeof(maximum));
}
if (ignoreValue == null) {
ignoreValue = false;
} else if (typeof ignoreValue !== "boolean") {
throw TypeError("Expected ignoreValue to be a Boolean, got " + __typeof(ignoreValue));
}
if (minimum % 1 !== 0 || minimum < 0) {
throw RangeError("Expected minimum to be a non-negative integer, got " + minimum);
}
if (maximum !== 1/0 && maximum % 1 !== 0 || maximum < minimum) {
throw RangeError("Expected maximum to be Infinity or an integer of at least " + minimum + ", got " + maximum);
}
mutator = identity;
if (typeof rule.mutator === "function" && typeof rule.rule === "function" && false) {
mutator = rule.mutator;
rule = rule.rule;
}
if (ignoreValue) {
return stackWrap(function (parser, index) {
var count, item, newIndex;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
count = 0;
while (count < maximum) {
item = rule(parser, index);
if (!item) {
if (count < minimum) {
return;
} else {
break;
}
}
++count;
newIndex = item.index;
if (newIndex === index) {
throw Error("Infinite loop detected");
} else {
index = newIndex;
}
}
return Box(index, count);
});
} else if (mutator === identity) {
return stackWrap(function (parser, index) {
var count, item, newIndex, result;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
result = [];
count = 0;
while (count < maximum) {
item = rule(parser, index);
if (!item) {
if (count < minimum) {
return;
} else {
break;
}
}
result[count] = item.value;
++count;
newIndex = item.index;
if (newIndex === index) {
throw Error("Infinite loop detected");
} else {
index = newIndex;
}
}
return Box(index, result);
});
} else {
return stackWrap(mutate(
function (items, parser, index) {
var _arr, _arr2, _i, _len, item;
for (_arr = [], _arr2 = __toArray(items), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
item = _arr2[_i];
_arr.push(mutator(item.value, parser, item.startIndex, item.endIndex));
}
return _arr;
},
function (parser, index) {
var count, item, newIndex, result;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
result = [];
count = 0;
while (count < maximum) {
item = rule(parser, index);
if (!item) {
if (count < minimum) {
return;
} else {
break;
}
}
newIndex = item.index;
result[count] = { startIndex: index, endIndex: newIndex, value: item.value };
if (newIndex === index) {
throw Error("Infinite loop detected");
} else {
index = newIndex;
}
++count;
}
return Box(index, result);
}
));
}
};
});
zeroOrMore = __genericFunc(1, function (T) {
return function (rule, ignoreValue) {
return multiple.generic(T)(rule, 0, 1/0, ignoreValue);
};
});
oneOrMore = __genericFunc(1, function (T) {
return function (rule, ignoreValue) {
return multiple.generic(T)(rule, 1, 1/0, ignoreValue);
};
});
function maybe(rule, defaultValue) {
var MISSING, mutator, subrule;
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
MISSING = {};
if (typeof rule.mutator === "function" && typeof rule.rule === "function" && false) {
subrule = rule.rule;
mutator = rule.mutator;
return mutate(
typeof defaultValue === "function"
? function (value, parser, startIndex, endIndex) {
if (value === MISSING) {
return defaultValue(parser, startIndex);
} else {
return mutator(value, parser, startIndex, endIndex);
}
}
: function (value, parser, startIndex, endIndex) {
if (value === MISSING) {
return defaultValue;
} else {
return mutator(value, parser, startIndex, endIndex);
}
},
stackWrap(function (parser, index) {
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
return subrule(parser, index) || Box(index, MISSING);
})
);
} else if (typeof defaultValue === "function") {
return mutate(
function (value, parser, startIndex, endIndex) {
if (value === MISSING) {
return defaultValue(parser, startIndex);
} else {
return value;
}
},
stackWrap(function (parser, index) {
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
return rule(parser, index) || Box(index, MISSING);
})
);
} else {
return stackWrap(function (parser, index) {
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
return rule(parser, index) || Box(index, defaultValue);
});
}
}
oneOf = __genericFunc(1, function (T) {
return function () {
var _arr, _i, _i2, _i3, _len, _len2, expandedRules, func, rule, rules, subrule;
rules = __slice.call(arguments);
if (!__isArray(rules)) {
throw TypeError("Expected rules to be an Array, got " + __typeof(rules));
} else {
for (_i = rules.length; _i--; ) {
if (typeof rules[_i] !== "function") {
throw TypeError("Expected " + ("rules[" + _i + "]") + " to be a Function, got " + __typeof(rules[_i]));
}
}
}
switch (rules.length) {
case 0: throw Error("Expected rules to be non-empty");
case 1: return rules[0];
default:
expandedRules = [];
for (_i2 = 0, _len = rules.length; _i2 < _len; ++_i2) {
rule = rules[_i2];
if (rule.oneOf) {
for (_arr = __toArray(rule.oneOf), _i3 = 0, _len2 = _arr.length; _i3 < _len2; ++_i3) {
subrule = _arr[_i3];
expandedRules.push(subrule);
}
} else {
expandedRules.push(rule);
}
}
func = function (parser, index) {
var _len, i, result, rule;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
for (i = 0, _len = expandedRules.length; i < _len; ++i) {
rule = expandedRules[i];
result = rule(parser, index);
if (result) {
return result;
}
}
};
func.oneOf = expandedRules;
return stackWrap(func);
}
};
});
zeroOrMoreOf = __genericFunc(1, function (T) {
return function () {
var rules;
rules = __slice.call(arguments);
return zeroOrMore.generic(T)(oneOf.generic(T).apply(void 0, __toArray(rules)));
};
});
oneOrMoreOf = __genericFunc(1, function (T) {
return function () {
var rules;
rules = __slice.call(arguments);
return oneOrMore.generic(T)(oneOf.generic(T).apply(void 0, __toArray(rules)));
};
});
function check(rule) {
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
if (typeof rule.mutator === "function" && typeof rule.rule === "function" && false) {
rule = rule.rule;
}
return function (parser, index) {
var result;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
result = rule(parser, index);
if (result) {
return Box(index);
}
};
}
SHORT_CIRCUIT = {};
sequential = __genericFunc(1, function (T) {
return function () {
var _len, hasMutations, hasOther, i, item, items, key, keys, mapping, mutations, mutator, rule, rules, shortCircuitIndex, thisIndex;
items = __slice.call(arguments);
if (items.length === 0) {
throw Error("Expected items to be non-empty");
}
if (items.length === 1) {
if (__isArray(items[0])) {
if (items[0][0] === "this") {
return items[0][1];
}
} else if (typeof items[0] === "function") {
rule = items[0];
return function (parser, index) {
var item;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
item = rule(parser, index);
if (!item) {
return;
}
return Box(item.index);
};
}
}
rules = [];
mapping = [];
keys = [];
mutations = [];
thisIndex = -1;
hasOther = false;
shortCircuitIndex = 1/0;
hasMutations = false;
for (i = 0, _len = items.length; i < _len; ++i) {
item = items[i];
key = void 0;
rule = void 0;
if (__isArray(item)) {
if (item.length !== 2) {
throw Error("Found an array with " + __strnum(item.length) + " length at index #" + i);
}
if (typeof item[0] !== "string") {
throw TypeError("Array in index #" + i + " has an improper key: " + __typeof(item[0]));
}
if (typeof item[1] !== "function") {
throw TypeError("Array in index #" + i + " has an improper rule: " + __typeof(item[1]));
}
key = item[0];
if (__in(key, keys)) {
throw Error("Can only have one " + __str(JSON.stringify(key)) + " key in sequential");
}
keys.push(key);
rule = item[1];
if (key === "this") {
thisIndex = rules.length;
} else {
hasOther = true;
}
} else if (typeof item === "function") {
rule = item;
} else if (item === SHORT_CIRCUIT) {
if (shortCircuitIndex !== 1/0) {
throw Error("Can only have one SHORT_CIRCUIT per sequential");
}
shortCircuitIndex = i;
continue;
} else {
throw TypeError("Found a non-array, non-function in index #" + i + ": " + __typeof(item));
}
if (key && typeof rule.mutator === "function" && typeof rule.rule === "function" && false) {
hasMutations = true;
mutations.push(rule.mutator);
rules.push(rule.rule);
} else {
mutations.push(null);
rules.push(rule);
}
mapping.push(key);
}
if (thisIndex !== -1) {
if (hasOther) {
throw Error("Cannot specify both the 'this' key and another key");
}
if (!hasMutations) {
return stackWrap(function (parser, index) {
var _len, i, item, result, rule;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
for (i = 0, _len = rules.length; i < _len; ++i) {
rule = rules[i];
item = rule(parser, index);
if (!item) {
if (i < shortCircuitIndex) {
return;
} else {
throw SHORT_CIRCUIT;
}
}
index = item.index;
if (i === thisIndex) {
result = item.value;
}
}
return Box(index, result);
});
} else {
mutator = mutations[thisIndex];
return stackWrap(mutate(
function (item, parser, index) {
return mutator(item.value, parser, item.startIndex, item.endIndex);
},
function (parser, index) {
var _len, i, item, result, rule, valueIndex;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
valueIndex = 0;
for (i = 0, _len = rules.length; i < _len; ++i) {
rule = rules[i];
item = rule(parser, index);
if (!item) {
if (i < shortCircuitIndex) {
return;
} else {
throw SHORT_CIRCUIT;
}
}
if (i === thisIndex) {
result = { value: item.value, startIndex: index, endIndex: item.index };
}
index = item.index;
}
return Box(index, result);
}
));
}
} else if (hasOther) {
if (hasMutations) {
return stackWrap(mutate(
function (value, parser, index) {
var _len, i, item, key, mutator, result;
result = {};
for (i = 0, _len = keys.length; i < _len; ++i) {
key = keys[i];
if (key) {
item = value[key];
mutator = mutations[i];
if (mutator) {
result[key] = mutator(item.value, parser, item.startIndex, item.endIndex);
} else {
result[key] = item.value;
}
}
}
return result;
},
function (parser, index) {
var _len, i, indexes, item, key, result, rule;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
result = {};
indexes = {};
for (i = 0, _len = rules.length; i < _len; ++i) {
rule = rules[i];
item = rule(parser, index);
if (!item) {
if (i < shortCircuitIndex) {
return;
} else {
throw SHORT_CIRCUIT;
}
}
key = mapping[i];
if (key) {
result[key] = { value: item.value, startIndex: index, endIndex: item.index };
}
index = item.index;
}
return Box(index, result);
}
));
} else {
return stackWrap(function (parser, index) {
var i, item, key, length, rule, value;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
value = {};
i = 0;
length = rules.length;
for (; i < length; ++i) {
rule = rules[i];
item = rule(parser, index);
if (!item) {
if (i < shortCircuitIndex) {
return;
} else {
throw SHORT_CIRCUIT;
}
}
index = item.index;
key = mapping[i];
if (key) {
value[key] = item.value;
}
}
return Box(index, value);
});
}
} else {
if (hasMutations) {
throw Error("Cannot use a mutator on a sequential without keys");
}
return stackWrap(function (parser, index) {
var _len, i, item, rule;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
for (i = 0, _len = rules.length; i < _len; ++i) {
rule = rules[i];
item = rule(parser, index);
if (!item) {
if (i < shortCircuitIndex) {
return;
} else {
throw SHORT_CIRCUIT;
}
}
index = item.index;
}
return Box(index);
});
}
};
});
cons = __genericFunc(1, function (T) {
return function (headRule, tailRule) {
if (typeof headRule !== "function") {
throw TypeError("Expected headRule to be a Function, got " + __typeof(headRule));
}
if (typeof tailRule !== "function") {
throw TypeError("Expected tailRule to be a Function, got " + __typeof(tailRule));
}
return stackWrap(function (parser, index) {
var head, tail;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
head = headRule(parser, index);
if (!head) {
return;
}
tail = tailRule(parser, head.index);
if (!tail) {
return;
}
return Box(tail.index, [head.value].concat(tail.value));
});
};
});
concat = __genericFunc(1, function (T) {
return function (leftRule, rightRule) {
if (typeof leftRule !== "function") {
throw TypeError("Expected leftRule to be a Function, got " + __typeof(leftRule));
}
if (typeof rightRule !== "function") {
throw TypeError("Expected rightRule to be a Function, got " + __typeof(rightRule));
}
return stackWrap(function (parser, index) {
var left, right;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
left = leftRule(parser, index);
if (!left) {
return;
}
right = rightRule(parser, left.index);
if (!right) {
return;
}
return Box(right.index, left.value.concat(right.value));
});
};
});
function nothingRule(parser, index) {
return Box(index);
}
separatedList = __genericFunc(1, function (T) {
return function (itemRule, separatorRule, tailRule) {
if (typeof itemRule !== "function") {
throw TypeError("Expected itemRule to be a Function, got " + __typeof(itemRule));
}
if (separatorRule == null) {
separatorRule = nothingRule;
} else if (typeof separatorRule !== "function") {
throw TypeError("Expected separatorRule to be a Function, got " + __typeof(separatorRule));
}
if (tailRule == null) {
tailRule = itemRule;
} else if (typeof tailRule !== "function") {
throw TypeError("Expected tailRule to be a Function, got " + __typeof(tailRule));
}
return stackWrap(function (parser, index) {
var currentIndex, head, i, item, newIndex, result, separator;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
head = itemRule(parser, index);
if (!head) {
return;
}
currentIndex = head.index;
result = [head.value];
i = 0;
for (; ; ++i) {
separator = separatorRule(parser, currentIndex);
if (!separator) {
break;
}
item = tailRule(parser, separator.index);
if (!item) {
break;
}
newIndex = item.index;
if (newIndex === currentIndex) {
throw Error("Infinite loop detected");
} else {
currentIndex = newIndex;
}
result.push(item.value);
}
return Box(currentIndex, result);
});
};
});
function except(rule) {
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
if (typeof rule.mutator === "function" && typeof rule.rule === "function" && false) {
rule = rule.rule;
}
return stackWrap(function (parser, index) {
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
if (!rule(parser, index)) {
return Box(index);
}
});
}
function anyExcept(rule) {
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
if (typeof rule.mutator === "function" && typeof rule.rule === "function" && false) {
rule = rule.rule;
}
return stackWrap(function (parser, index) {
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
if (!rule(parser, index)) {
return AnyChar(parser, index);
}
});
}
multiple.generic = function () {
return multiple;
};
oneOf.generic = function () {
return oneOf;
};
sequential.generic = function () {
return sequential;
};
cons.generic = function () {
return cons;
};
concat.generic = function () {
return concat;
};
separatedList.generic = function () {
return separatedList;
};
SpaceChar = characters("space", charsToFakeSet([
9,
11,
12,
32,
160,
5760,
6158,
[8192, 8202],
8239,
8287,
12288,
65263
]));
SpaceChars = cache(zeroOrMore(SpaceChar, true));
Zero = character('"0"', 48);
DecimalDigit = characters("[0-9]", charsToFakeSet([[48, 57]]));
Period = character('"."', 46);
ColonChar = character('":"', 58);
DoubleColonChar = cache((_ref = sequential(ColonChar, ColonChar), mutate("::")(_ref)));
PipeChar = character('"|"', 124);
EqualChar = character('"="', 61);
MinusChar = character('"-"', 45);
PlusChar = character('"+"', 43);
PlusOrMinusChar = characters("[+\\-]", charsToFakeSet([43, 45]));
Letter = characters("letter", charsToFakeSet([
[65, 90],
[97, 122],
170,
181,
186,
[192, 214],
[216, 246],
[248, 705],
[710, 721],
[736, 740],
748,
750,
[880, 884],
886,
887,
[890, 893],
902,
[904, 906],
908,
[910, 929],
[931, 1013],
[1015, 1153],
[1162, 1317],
[1329, 1366],
1369,
[1377, 1415],
[1488, 1514],
[1520, 1522],
[1569, 1610],
1646,
1647,
[1649, 1747],
1749,
1765,
1766,
1774,
1775,
[1786, 1788],
1791,
1808,
[1810, 1839],
[1869, 1957],
1969,
[1994, 2026],
2036,
2037,
2042,
[2048, 2069],
2074,
2084,
2088,
[2308, 2361],
2365,
2384,
[2392, 2401],
2417,
2418,
[2425, 2431],
[2437, 2444],
2447,
2448,
[2451, 2472],
[2474, 2480],
2482,
[2486, 2489],
2493,
2510,
2524,
2525,
[2527, 2529],
2544,
2545,
[2565, 2570],
2575,
2576,
[2579, 2600],
[2602, 2608],
2610,
2611,
2613,
2614,
2616,
2617,
[2649, 2652],
2654,
[2674, 2676],
[2693, 2701],
[2703, 2705],
[2707, 2728],
[2730, 2736],
2738,
2739,
[2741, 2745],
2749,
2768,
2784,
2785,
[2821, 2828],
2831,
2832,
[2835, 2856],
[2858, 2864],
2866,
2867,
[2869, 2873],
2877,
2908,
2909,
[2911, 2913],
2929,
2947,
[2949, 2954],
[2958, 2960],
[2962, 2965],
2969,
2970,
2972,
2974,
2975,
2979,
2980,
[2984, 2986],
[2990, 3001],
3024,
[3077, 3084],
[3086, 3088],
[3090, 3112],
[3114, 3123],
[3125, 3129],
3133,
3160,
3161,
3168,
3169,
[3205, 3212],
[3214, 3216],
[3218, 3240],
[3242, 3251],
[3253, 3257],
3261,
3294,
3296,
3297,
[3333, 3340],
[3342, 3344],
[3346, 3368],
[3370, 3385],
3389,
3424,
3425,
[3450, 3455],
[3461, 3478],
[3482, 3505],
[3507, 3515],
3517,
[3520, 3526],
[3585, 3632],
3634,
3635,
[3648, 3654],
3713,
3714,
3716,
3719,
3720,
3722,
3725,
[3732, 3735],
[3737, 3743],
[3745, 3747],
3749,
3751,
3754,
3755,
[3757, 3760],
3762,
3763,
3773,
[3776, 3780],
3782,
3804,
3805,
3840,
[3904, 3911],
[3913, 3948],
[3976, 3979],
[4096, 4138],
4159,
[4176, 4181],
[4186, 4189],
4193,
4197,
4198,
[4206, 4208],
[4213, 4225],
4238,
[4256, 4293],
[4304, 4346],
4348,
[4352, 4680],
[4682, 4685],
[4688, 4694],
4696,
[4698, 4701],
[4704, 4744],
[4746, 4749],
[4752, 4784],
[4786, 4789],
[4792, 4798],
4800,
[4802, 4805],
[4808, 4822],
[4824, 4880],
[4882, 4885],
[4888, 4954],
[4992, 5007],
[5024, 5108],
[5121, 5740],
[5743, 5759],
[5761, 5786],
[5792, 5866],
[5888, 5900],
[5902, 5905],
[5920, 5937],
[5952, 5969],
[5984, 5996],
[5998, 6000],
[6016, 6067],
6103,
6108,
[6176, 6263],
[6272, 6312],
6314,
[6320, 6389],
[6400, 6428],
[6480, 6509],
[6512, 6516],
[6528, 6571],
[6593, 6599],
[6656, 6678],
[6688, 6740],
6823,
[6917, 6963],
[6981, 6987],
[7043, 7072],
7086,
7087,
[7168, 7203],
[7245, 7247],
[7258, 7293],
[7401, 7404],
[7406, 7409],
[7424, 7615],
[7680, 7957],
[7960, 7965],
[7968, 8005],
[8008, 8013],
[8016, 8023],
8025,
8027,
8029,
[8031, 8061],
[8064, 8116],
[8118, 8124],
8126,
[8130, 8132],
[8134, 8140],
[8144, 8147],
[8150, 8155],
[8160, 8172],
[8178, 8180],
[8182, 8188],
8305,
8319,
[8336, 8340],
8450,
8455,
[8458, 8467],
8469,
[8473, 8477],
8484,
8486,
8488,
[8490, 8493],
[8495, 8505],
[8508, 8511],
[8517, 8521],
8526,
8579,
8580,
[11264, 11310],
[11312, 11358],
[11360, 11492],
[11499, 11502],
[11520, 11557],
[11568, 11621],
11631,
[11648, 11670],
[11680, 11686],
[11688, 11694],
[11696, 11702],
[11704, 11710],
[11712, 11718],
[11720, 11726],
[11728, 11734],
[11736, 11742],
11823,
12293,
12294,
[12337, 12341],
12347,
12348,
[12353, 12438],
[12445, 12447],
[12449, 12538],
[12540, 12543],
[12549, 12589],
[12593, 12686],
[12704, 12727],
[12784, 12799],
[13312, 19893],
[19968, 40907],
[40960, 42124],
[42192, 42237],
[42240, 42508],
[42512, 42527],
42538,
42539,
[42560, 42591],
[42594, 42606],
[42623, 42647],
[42656, 42725],
[42775, 42783],
[42786, 42888],
42891,
42892,
[43003, 43009],
[43011, 43013],
[43015, 43018],
[43020, 43042],
[43072, 43123],
[43138, 43187],
[43250, 43255],
43259,
[43274, 43301],
[43312, 43334],
[43360, 43388],
[43396, 43442],
43471,
[43520, 43560],
[43584, 43586],
[43588, 43595],
[43616, 43638],
43642,
[43648, 43695],
43697,
43701,
43702,
[43705, 43709],
43712,
43714,
[43739, 43741],
[43968, 44002],
[44032, 55203],
[55216, 55238],
[55243, 55291],
[63744, 64045],
[64048, 64109],
[64112, 64217],
[64256, 64262],
[64275, 64279],
64285,
[64287, 64296],
[64298, 64310],
[64312, 64316],
64318,
64320,
64321,
64323,
64324,
[64326, 64433],
[64467, 64829],
[64848, 64911],
[64914, 64967],
[65008, 65019],
[65136, 65140],
[65142, 65262],
[65264, 65276],
[65313, 65338],
[65345, 65370],
[65382, 65470],
[65474, 65479],
[65482, 65487],
[65490, 65495],
[65498, 65500]
]));
NumberChar = characters("number", charsToFakeSet([
[48, 57],
178,
179,
185,
[188, 190],
[1632, 1641],
[1776, 1785],
[1984, 1993],
[2406, 2415],
[2534, 2543],
[2548, 2553],
[2662, 2671],
[2790, 2799],
[2918, 2927],
[3046, 3058],
[3174, 3183],
[3192, 3198],
[3302, 3311],
[3430, 3445],
[3664, 3673],
[3792, 3801],
[3872, 3891],
[4160, 4169],
[4240, 4249],
[4969, 4988],
[5870, 5872],
[6112, 6121],
[6128, 6137],
[6160, 6169],
[6470, 6479],
[6608, 6618],
[6784, 6793],
[6800, 6809],
[6992, 7001],
[7088, 7097],
[7232, 7241],
[7248, 7257],
8304,
[8308, 8313],
[8320, 8329],
[8528, 8578],
[8581, 8585],
[9312, 9371],
[9450, 9471],
[10102, 10131],
11517,
12295,
[12321, 12329],
[12344, 12346],
[12690, 12693],
[12832, 12841],
[12881, 12895],
[12928, 12937],
[12977, 12991],
[42528, 42537],
[42726, 42735],
[43056, 43061],
[43216, 43225],
[43264, 43273],
[43472, 43481],
[43600, 43609],
[44016, 44025],
[65296, 65305]
]));
Underscore = character('"_"', 95);
DollarSignChar = character('"$"', 36);
AtSignChar = character('"@"', 64);
HashSignChar = character('"#"', 35);
PercentSignChar = character('"%"', 37);
EqualSignChar = character('"="', 61);
SymbolChar = characters("symbolic", charsToFakeSet([
33,
35,
37,
38,
42,
43,
45,
47,
[60, 63],
92,
94,
96,
124,
126,
127,
[128, 159],
[161, 169],
[171, 177],
180,
[182, 184],
187,
191,
215,
247,
[706, 709],
[722, 735],
[741, 747],
749,
[751, 879],
885,
888,
889,
[894, 901],
903,
907,
909,
930,
1014,
[1154, 1161],
[1318, 1328],
1367,
1368,
[1370, 1376],
[1416, 1487],
[1515, 1519],
[1523, 1568],
[1611, 1631],
[1642, 1645],
1648,
1748,
[1750, 1764],
[1767, 1773],
1789,
1790,
[1792, 1807],
1809,
[1840, 1868],
[1958, 1968],
[1970, 1983],
[2027, 2035],
[2038, 2041],
[2043, 2047],
[2070, 2073],
[2075, 2083],
[2085, 2087],
[2089, 2307],
[2362, 2364],
[2366, 2383],
[2385, 2391],
[2402, 2405],
2416,
[2419, 2424],
[2432, 2436],
2445,
2446,
2449,
2450,
2473,
2481,
[2483, 2485],
[2490, 2492],
[2494, 2509],
[2511, 2523],
2526,
[2530, 2533],
2546,
2547,
[2554, 2564],
[2571, 2574],
2577,
2578,
2601,
2609,
2612,
2615,
[2618, 2648],
2653,
[2655, 2661],
2672,
2673,
[2677, 2692],
2702,
2706,
2729,
2737,
2740,
[2746, 2748],
[2750, 2767],
[2769, 2783],
[2786, 2789],
[2800, 2820],
2829,
2830,
2833,
2834,
2857,
2865,
2868,
[2874, 2876],
[2878, 2907],
2910,
[2914, 2917],
2928,
[2930, 2946],
2948,
[2955, 2957],
2961,
[2966, 2968],
2971,
2973,
[2976, 2978],
[2981, 2983],
[2987, 2989],
[3002, 3023],
[3025, 3045],
[3059, 3076],
3085,
3089,
3113,
3124,
[3130, 3132],
[3134, 3159],
[3162, 3167],
[3170, 3173],
[3184, 3191],
[3199, 3204],
3213,
3217,
3241,
3252,
[3258, 3260],
[3262, 3293],
3295,
[3298, 3301],
[3312, 3332],
3341,
3345,
3369,
[3386, 3388],
[3390, 3423],
[3426, 3429],
[3446, 3449],
[3456, 3460],
[3479, 3481],
3506,
3516,
3518,
3519,
[3527, 3584],
3633,
[3636, 3647],
[3655, 3663],
[3674, 3712],
3715,
3717,
3718,
3721,
3723,
3724,
[3726, 3731],
3736,
3744,
3748,
3750,
3752,
3753,
3756,
3761,
[3764, 3772],
3774,
3775,
3781,
[3783, 3791],
3802,
3803,
[3806, 3839],
[3841, 3871],
[3892, 3903],
3912,
[3949, 3975],
[3980, 4095],
[4139, 4158],
[4170, 4175],
[4182, 4185],
[4190, 4192],
[4194, 4196],
[4199, 4205],
[4209, 4212],
[4226, 4237],
4239,
[4250, 4255],
[4294, 4303],
4347,
[4349, 4351],
4681,
4686,
4687,
4695,
4697,
4702,
4703,
4745,
4750,
4751,
4785,
4790,
4791,
4799,
4801,
4806,
4807,
4823,
4881,
4886,
4887,
[4955, 4968],
[4989, 4991],
[5008, 5023],
[5109, 5120],
5741,
5742,
[5787, 5791],
[5867, 5869],
[5873, 5887],
5901,
[5906, 5919],
[5938, 5951],
[5970, 5983],
5997,
[6001, 6015],
[6068, 6102],
[6104, 6107],
[6109, 6111],
[6122, 6127],
[6138, 6157],
6159,
[6170, 6175],
[6264, 6271],
6313,
[6315, 6319],
[6390, 6399],
[6429, 6469],
6510,
6511,
[6517, 6527],
[6572, 6592],
[6600, 6607],
[6619, 6655],
[6679, 6687],
[6741, 6783],
[6794, 6799],
[6810, 6822],
[6824, 6916],
[6964, 6980],
[6988, 6991],
[7002, 7042],
[7073, 7085],
[7098, 7167],
[7204, 7231],
[7242, 7244],
[7294, 7400],
7405,
[7410, 7423],
[7616, 7679],
7958,
7959,
7966,
7967,
8006,
8007,
8014,
8015,
8024,
8026,
8028,
8030,
8062,
8063,
8117,
8125,
[8127, 8129],
8133,
[8141, 8143],
8148,
8149,
[8156, 8159],
[8173, 8177],
8181,
[8189, 8191],
[8203, 8231],
[8234, 8238],
[8240, 8286],
[8288, 8303],
8306,
8307,
[8314, 8318],
[8330, 8335],
[8341, 8449],
[8451, 8454],
8456,
8457,
8468,
[8470, 8472],
[8478, 8483],
8485,
8487,
8489,
8494,
8506,
8507,
[8512, 8516],
[8522, 8525],
8527,
[8586, 9311],
[9372, 9449],
[9472, 10101],
[10132, 11263],
11311,
11359,
[11493, 11498],
[11503, 11516],
11518,
11519,
[11558, 11567],
[11622, 11630],
[11632, 11647],
[11671, 11679],
11687,
11695,
11703,
11711,
11719,
11727,
11735,
[11743, 11822],
[11824, 12287],
[12289, 12292],
[12296, 12320],
[12330, 12336],
12342,
12343,
[12349, 12352],
[12439, 12444],
12448,
12539,
[12544, 12548],
[12590, 12592],
[12687, 12689],
[12694, 12703],
[12728, 12783],
[12800, 12831],
[12842, 12880],
[12896, 12927],
[12938, 12976],
[12992, 13311],
[19894, 19967],
[40908, 40959],
[42125, 42191],
42238,
42239,
[42509, 42511],
[42540, 42559],
42592,
42593,
[42607, 42622],
[42648, 42655],
[42736, 42774],
42784,
42785,
42889,
42890,
[42893, 43002],
43010,
43014,
43019,
[43043, 43055],
[43062, 43071],
[43124, 43137],
[43188, 43215],
[43226, 43249],
[43256, 43258],
[43260, 43263],
[43302, 43311],
[43335, 43359],
[43389, 43395],
[43443, 43470],
[43482, 43519],
[43561, 43583],
43587,
[43596, 43599],
[43610, 43615],
[43639, 43641],
[43643, 43647],
43696,
[43698, 43700],
43703,
43704,
43710,
43711,
43713,
[43715, 43738],
[43742, 43967],
[44003, 44015],
[44026, 44031],
[55204, 55215],
[55239, 55242],
[55292, 63743],
64046,
64047,
64110,
64111,
[64218, 64255],
[64263, 64274],
[64280, 64284],
64286,
64297,
64311,
64317,
64319,
64322,
64325,
[64434, 64466],
[64830, 64847],
64912,
64913,
[64968, 65007],
[65020, 65135],
65141,
[65277, 65295],
[65306, 65312],
[65339, 65344],
[65371, 65381],
[65471, 65473],
65480,
65481,
65488,
65489,
65496,
65497,
[65501, 65535]
]));
DoubleQuote = character("'\"'", 34);
SingleQuote = character('"\'"', 39);
TripleDoubleQuote = cache(multiple(DoubleQuote, 3, 3, true));
TripleSingleQuote = cache(multiple(SingleQuote, 3, 3, true));
SemicolonChar = character('";"', 59);
AsterixChar = character('"*"', 42);
CaretChar = character('"^"', 94);
OpenSquareBracketChar = character('"["', 91);
OpenCurlyBraceChar = character('"{"', 123);
CloseCurlyBraceChar = character('"}"', 125);
BackslashChar = character('"\\\\"', 92);
CommaChar = character('","', 44);
function AnyChar(parser, index) {
var c, source;
source = parser.source;
if (index >= source.length) {
return parser.fail("any", index);
} else {
c = source.charCodeAt(index);
if (c === 13 && source.charCodeAt(+index + 1) === 10) {
++index;
c = 10;
}
return Box(+index + 1, c);
}
}
function Newline(parser, index) {
var c, source;
source = parser.source;
c = source.charCodeAt(index);
if (c === 13) {
if (source.charCodeAt(+index + 1) === 10) {
++index;
c = 10;
}
} else if (c !== 10 && c !== 8232 && c !== 8233) {
return;
}
return Box(+index + 1, c);
}
function Eof(parser, index) {
if (index >= parser.source.length) {
return Box(index);
}
}
CheckStop = oneOf(Newline, Eof, function (parser, index) {
return EmbeddedClose(parser, index) || EmbeddedCloseWrite(parser, index);
});
MaybeComment = cache((function () {
function SingleLineComment(parser, index) {
var _ref, len, source;
source = parser.source;
if (source.charCodeAt(index) === 47 && source.charCodeAt(+index + 1) === 47) {
len = source.length;
index -= -2;
for (; ; ++index) {
if (index >= len || (_ref = source.charCodeAt(index)) === 13 || _ref === 10 || _ref === 8232 || _ref === 8233) {
return Box(index);
}
}
}
}
function MultiLineComment(parser, index) {
var len, source, startIndex;
source = parser.source;
startIndex = index;
if (source.charCodeAt(index) === 47 && source.charCodeAt(+index + 1) === 42 && source.charCodeAt(+index + 2) !== 33) {
len = source.length;
index -= -2;
for (; ; ++index) {
if (index >= len) {
throw ParserError("Multi-line comment never ends", parser, startIndex);
}
if (source.charCodeAt(index) === 42 && source.charCodeAt(+index + 1) === 47) {
return Space(parser, +index + 2);
}
}
}
}
return maybe(oneOf(SingleLineComment, MultiLineComment));
}()));
Space = cache(sequential(SpaceChars, MaybeComment));
function withSpace(rule) {
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
return sequential(Space, ["this", rule]);
}
NoSpace = cache(except(SpaceChar));
EmptyLine = cache(withSpace(Newline));
EmptyLines = cache(zeroOrMore(EmptyLine, true));
SomeEmptyLines = cache(oneOrMore(EmptyLine, true));
NoSpaceNewline = except(EmptyLine);
OpenParenthesis = cache(withSpace(character('"("', 40)));
CloseParenthesis = cache(withSpace(character('")"', 41)));
OpenSquareBracket = cache(withSpace(OpenSquareBracketChar));
CloseSquareBracket = cache(withSpace(character('"]"', 93)));
OpenCurlyBrace = cache(withSpace(OpenCurlyBraceChar));
CloseCurlyBrace = cache(withSpace(CloseCurlyBraceChar));
EqualSign = withSpace(EqualSignChar);
PercentSign = cache(withSpace(PercentSignChar));
DollarSign = cache(withSpace(DollarSignChar));
Comma = cache(withSpace(CommaChar));
MaybeComma = cache(maybe(Comma));
CommaOrNewline = oneOf(
sequential(
["this", Comma],
EmptyLines
),
SomeEmptyLines
);
MaybeCommaOrNewline = cache(maybe(CommaOrNewline));
_SomeEmptyLinesWithCheckIndent = sequential(SomeEmptyLines, CheckIndent);
SomeEmptyLinesWithCheckIndent = cache(function (parser, index) {
if (parser.options.noindent) {
return EmptyLines(parser, index);
} else {
return _SomeEmptyLinesWithCheckIndent(parser, index);
}
});
CommaOrSomeEmptyLinesWithCheckIndent = cache(oneOf(
sequential(Comma, maybe(SomeEmptyLinesWithCheckIndent)),
SomeEmptyLinesWithCheckIndent
));
ExclamationPointChar = cache(character('"!"', 33));
MaybeExclamationPointChar = cache(maybe(ExclamationPointChar));
MaybeAtSignChar = cache(maybe(AtSignChar));
Colon = cache(sequential(
Space,
["this", ColonChar],
except(ColonChar)
));
ColonNewline = cache(sequential(Colon, Space, ["this", Newline]));
NotColon = cache(except(Colon));
NotColonUnlessNoIndentAndNewline = cache(function (parser, index) {
var options;
options = parser.options;
if (options.noindent) {
if (ColonNewline(parser, index)) {
return Box(index);
} else if (options.embedded && (ColonEmbeddedClose(parser, index) || ColonEmbeddedCloseWrite(parser, index))) {
return Box(index);
}
}
return NotColon(parser, index);
});
NameStart = cache(oneOf(Letter, Underscore, DollarSignChar));
NameChar = cache(oneOf(NameStart, NumberChar));
NamePart = cache(oneOrMore(NameChar));
Nothing = cache(function (parser, index) {
return Box(index, parser.Nothing(index));
});
Expression = function (parser, index) {
return Expression(parser, index);
};
Statement = function (parser, index) {
return Statement(parser, index);
};
Body = function (parser, index) {
return Body(parser, index);
};
BodyNoEnd = function (parser, index) {
return BodyNoEnd(parser, index);
};
Logic = function (parser, index) {
return Logic(parser, index);
};
function End(parser, index) {
if (parser.options.noindent) {
return EndNoIndent(parser, index);
} else {
return Box(index);
}
}
_Name = cache((_ref = separatedList(
cons(NameStart, zeroOrMore(NameChar)),
MinusChar,
NamePart
), mutate(function (items) {
var _arr, _i, _len, item, parts;
parts = processCharCodes(items[0]);
for (_arr = __toArray(items), _i = 1, _len = _arr.length; _i < _len; ++_i) {
item = _arr[_i];
parts.push(fromCharCode(item[0]).toUpperCase());
processCharCodes(item, parts, 1);
}
return parts.join("");
})(_ref)));
Name = cache(withSpace(_Name));
_Symbol = cache((_ref = oneOrMore(SymbolChar), mutate(codesToString)(_ref)));
Symbol = cache(withSpace(_Symbol));
ColonEqual = cache(withSpace((_ref = sequential(ColonChar, EqualSignChar), mutate(":=")(_ref))));
NameOrSymbol = cache(withSpace(oneOf(
(_ref = withSpace(oneOrMoreOf(_Name, _Symbol)), mutate(function (parts) {
return parts.join("");
})(_ref)),
ColonEqual
)));
MacroName = cache(withSpace(sequential(
["this", NameOrSymbol],
NotColonUnlessNoIndentAndNewline
)));
MacroNames = separatedList.generic(String)(MacroName, Comma);
UseMacro = cache(function (parser, index) {
var m, name, result;
name = MacroName(parser, index);
if (!name) {
return;
}
m = parser.getMacroByName(name.value);
if (!m) {
return;
}
result = m(parser, index);
if (!result) {
throw SHORT_CIRCUIT;
}
return result;
});
function ruleEqual(rule, text) {
var failureMessage;
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
if (typeof text !== "string") {
throw TypeError("Expected text to be a String, got " + __typeof(text));
}
failureMessage = JSON.stringify(text);
return function (parser, index) {
var result;
result = rule(parser, index);
if (result && result.value === text) {
return result;
} else {
return parser.fail(failureMessage, index);
}
};
}
function memoize(func) {
var cache;
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
cache = __create(null);
return function (key) {
if (typeof key !== "string") {
throw TypeError("Expected key to be a String, got " + __typeof(key));
}
if (__owns.call(cache, key)) {
return cache[key];
} else {
return cache[key] = func(key);
}
};
}
word = memoize(function (text) {
if (typeof text !== "string") {
throw TypeError("Expected text to be a String, got " + __typeof(text));
}
return ruleEqual(Name, text);
});
symbol = memoize(function (text) {
if (typeof text !== "string") {
throw TypeError("Expected text to be a String, got " + __typeof(text));
}
return ruleEqual(Symbol, text);
});
macroName = memoize(function (text) {
if (typeof text !== "string") {
throw TypeError("Expected text to be a String, got " + __typeof(text));
}
return ruleEqual(MacroName, text);
});
wordOrSymbol = memoize(function (text) {
var _arr, _len, _ref, i, part, parts;
if (typeof text !== "string") {
throw TypeError("Expected text to be a String, got " + __typeof(text));
}
parts = [Space];
for (_arr = __toArray(text.split(/([a-z]+)/ig)), i = 0, _len = _arr.length; i < _len; ++i) {
part = _arr[i];
if (part) {
parts.push(ruleEqual(
i % 2 === 0 ? _Symbol : _Name,
part
));
}
}
_ref = sequential.apply(void 0, __toArray(parts));
return mutate(text)(_ref);
});
INDENTS = (_o = __create(null), _o[9] = 4, _o[32] = 1, _o);
_ref = zeroOrMore(SpaceChar);
CountIndent = mutate(function (spaces) {
var _arr, _i, c, count, indent;
count = 0;
for (_arr = __toArray(spaces), _i = _arr.length; _i--; ) {
c = _arr[_i];
indent = INDENTS[c];
if (!indent) {
throw Error("Unexpected indent char: " + __str(JSON.stringify(c)));
}
count += __num(indent);
}
return count;
})(_ref);
function IndentationRequired(parser, index) {
if (!parser.options.noindent) {
return Box(index);
}
}
function CheckIndent(parser, index) {
var count;
count = CountIndent(parser, index);
if (parser.options.noindent || count.value === parser.indent.peek()) {
return count;
}
}
function Advance(parser, index) {
var count, countValue, indent;
if (parser.options.noindent) {
throw Error("Can't use Advance if in noindent mode");
}
count = CountIndent(parser, index);
countValue = count.value;
indent = parser.indent;
if (!__lte(countValue, indent.peek())) {
indent.push(countValue);
return Box(index, countValue);
}
}
function MaybeAdvance(parser, index) {
var count;
count = CountIndent(parser, index);
parser.indent.push(count.value);
return Box(index, count.value);
}
function PushFakeIndent(n) {
if (typeof n !== "number") {
throw TypeError("Expected n to be a Number, got " + __typeof(n));
}
return function (parser, index) {
var indent;
indent = parser.indent;
indent.push(+indent.peek() + n);
return Box(index, 0);
};
}
function PopIndent(parser, index) {
var indent;
indent = parser.indent;
if (indent.canPop()) {
indent.pop();
return Box(index);
} else {
throw ParserError("Unexpected dedent", parser, index);
}
}
function retainIndent(rule) {
if (typeof rule !== "function") {
throw TypeError("Expected rule to be a Function, got " + __typeof(rule));
}
return function (parser, index) {
var _end, count, i, indent;
indent = parser.indent;
count = indent.count();
try {
return rule(parser, index);
} finally {
for (i = __num(count), _end = __num(indent.count()); i < _end; ++i) {
indent.pop();
}
}
};
}
ThisLiteral = cache((_ref = word("this"), mutate(function (_p, parser, index) {
return parser.This(index);
})(_ref)));
ThisShorthandLiteral = cache((_ref = withSpace(AtSignChar), mutate(function (_p, parser, index) {
return parser.This(index);
})(_ref)));
ArgumentsLiteral = cache((_ref = word("arguments"), mutate(function (_p, parser, index) {
return parser.Args(index);
})(_ref)));
ThisOrShorthandLiteral = cache(oneOf.generic(ThisNode)(ThisLiteral, ThisShorthandLiteral));
ThisOrShorthandLiteralPeriod = oneOf.generic(ThisNode)(
sequential(
["this", ThisLiteral],
Period
),
sequential(
["this", ThisShorthandLiteral],
maybe(Period)
)
);
getReservedIdents = (function () {
var RESERVED_IDENTS, RESERVED_IDENTS_NOINDENT;
RESERVED_IDENTS = [
"as",
"AST",
"arguments",
"break",
"case",
"catch",
"class",
"const",
"continue",
"debugger",
"default",
"delete",
"do",
"else",
"enum",
"eval",
"export",
"extends",
"false",
"finally",
"for",
"function",
"if",
"import",
"Infinity",
"instanceof",
"in",
"let",
"macro",
"mutable",
"NaN",
"new",
"not",
"null",
"package",
"private",
"protected",
"public",
"return",
"static",
"super",
"switch",
"then",
"this",
"throw",
"true",
"try",
"typeof",
"undefined",
"var",
"void",
"while",
"with",
"yield"
];
RESERVED_IDENTS_NOINDENT = __toArray(RESERVED_IDENTS).concat(["end"]).sort();
return function (options) {
if (options && options.noindent) {
return RESERVED_IDENTS_NOINDENT;
} else {
return RESERVED_IDENTS;
}
};
}());
MaybeSpreadToken = cache(maybe(withSpace((_ref = sequential(Period, Period, Period), mutate("...")(_ref)))));
SpreadOrExpression = cache((_ref = sequential(
["spread", MaybeSpreadToken],
["node", Expression]
), mutate(function (_p, parser, index) {
var node, spread;
spread = _p.spread;
node = _p.node;
if (spread === "...") {
return parser.Spread(index, node);
} else {
return node;
}
})(_ref)));
ClosedArguments = cache(sequential(
NoSpace,
OpenParenthesis,
Space,
[
"this",
concat.generic(Node)(
maybe(
sequential(
[
"this",
separatedList.generic(Node)(SpreadOrExpression, Comma)
],
MaybeComma
),
function () {
return [];
}
),
maybe(
retainIndent(sequential.generic(Array)(
SomeEmptyLines,
MaybeAdvance,
[
"this",
maybe(
sequential(CheckIndent, [
"this",
separatedList.generic(Node)(SpreadOrExpression, CommaOrSomeEmptyLinesWithCheckIndent)
]),
function () {
return [];
}
)
],
EmptyLines,
MaybeCommaOrNewline,
PopIndent
)),
function () {
return [];
}
)
)
],
CloseParenthesis
));
UnclosedArguments = cache(sequential(
oneOf(
sequential(SpaceChar, Space),
check(Newline)
),
[
"this",
concat.generic(Node)(
separatedList.generic(Node)(SpreadOrExpression, Comma),
oneOf.generic(Array)(
sequential(IndentationRequired, Comma, SomeEmptyLines, [
"this",
retainIndent(sequential(
Advance,
CheckIndent,
[
"this",
separatedList.generic(Node)(SpreadOrExpression, CommaOrSomeEmptyLinesWithCheckIndent)
],
MaybeComma,
PopIndent
))
]),
mutate(function () {
return [];
})(MaybeComma)
)
)
]
));
InvocationArguments = cache(oneOf(ClosedArguments, UnclosedArguments));
Identifier = cache(oneOf(
(_ref = sequential(
function (parser, index) {
if (parser.inAst.peek()) {
return Box(index);
}
},
DollarSign,
NoSpace,
["this", InvocationArguments]
), mutate(function (args, parser, index) {
return parser.Call(
index,
parser.Ident(index, "$"),
args
);
})(_ref)),
function (parser, index) {
var name;
name = Name(parser, index);
if (!name || __in(name.value, getReservedIdents(parser.options)) || parser.hasMacroOrOperator(name.value || parser.scope.peek().hasConst(name.value))) {
return parser.fail("identifier", index);
} else {
return Box(name.index, parser.Ident(index, name.value));
}
}
));
function makeDigitsRule(digit) {
var _ref;
if (typeof digit !== "function") {
throw TypeError("Expected digit to be a Function, got " + __typeof(digit));
}
_ref = separatedList(oneOrMore(digit), oneOrMore(Underscore, true));
return mutate(function (parts) {
var _arr, _i, _len, part, result;
result = [];
for (_arr = __toArray(parts), _i = 0, _len = _arr.length; _i < _len; ++_i) {
part = _arr[_i];
processCharCodes(part, result);
}
return result.join("");
})(_ref);
}
MaybeUnderscores = cache(zeroOrMore(Underscore, true));
function parseRadixNumber(integer, fraction, radix, exponent) {
var _i, _len, c, currentValue, i;
if (typeof integer !== "string") {
throw TypeError("Expected integer to be a String, got " + __typeof(integer));
}
if (typeof fraction !== "string") {
throw TypeError("Expected fraction to be a String, got " + __typeof(fraction));
}
if (typeof radix !== "number") {
throw TypeError("Expected radix to be a Number, got " + __typeof(radix));
}
if (exponent == null) {
exponent = 0;
} else if (typeof exponent !== "number") {
throw TypeError("Expected exponent to be a Number, got " + __typeof(exponent));
}
if (exponent % 1 !== 0) {
throw RangeError("Expected exponent to be an integer, got " + exponent);
}
while (exponent > 0) {
integer += __strnum(fraction.charAt(0) || "0");
fraction = fraction.substring(1);
--exponent;
}
while (exponent < 0) {
fraction = __strnum(integer.slice(-1)) + fraction;
integer = integer.slice(0, -1);
++exponent;
}
currentValue = 0;
for (_i = 0, _len = integer.length; _i < _len; ++_i) {
c = integer.charAt(_i);
currentValue = currentValue * radix + parseInt(c, radix);
}
if (fraction) {
for (i = 0, _len = fraction.length; i < _len; ++i) {
c = fraction.charAt(i);
currentValue += parseInt(c, radix) / Math.pow(radix, i + 1);
}
}
return currentValue;
}
DecimalNumber = cache((function () {
var _ref, _ref2, DecimalDigits;
DecimalDigits = makeDigitsRule(DecimalDigit);
_ref = sequential(
["integer", DecimalDigits],
[
"fraction",
maybe(
sequential(MaybeUnderscores, Period, MaybeUnderscores, ["this", DecimalDigits]),
""
)
],
[
"exponent",
maybe(
(_ref2 = sequential(
characters("[Ee]", charsToFakeSet([69, 101])),
["sign", maybe(PlusOrMinusChar)],
["digits", DecimalDigits]
), mutate(function (_p) {
var digits, e, sign;
e = _p.e;
sign = _p.sign;
digits = _p.digits;
return (sign ? fromCharCode(sign) : "") + __strnum(digits);
})(_ref2)),
""
)
],
maybe(sequential(Underscore, maybe(NamePart)))
);
return mutate(function (_p, parser, index, endIndex) {
var exponent, fraction, integer, value;
integer = _p.integer;
fraction = _p.fraction;
exponent = _p.exponent;
value = parseRadixNumber(integer, fraction, 10, exponent ? parseInt(exponent, 10) : 0);
if (!isFinite(value)) {
throw ParserError(
"Unable to parse number " + __strnum(quote(parser.source.substring(index, endIndex))),
parser,
index
);
}
return parser.Const(index, value);
})(_ref);
}()));
function makeRadixNumber(radix, separator, digit) {
var _ref, digits;
if (typeof radix !== "number") {
throw TypeError("Expected radix to be a Number, got " + __typeof(radix));
}
if (typeof separator !== "function") {
throw TypeError("Expected separator to be a Function, got " + __typeof(separator));
}
if (typeof digit !== "function") {
throw TypeError("Expected digit to be a Function, got " + __typeof(digit));
}
digits = makeDigitsRule(digit);
_ref = sequential(
Zero,
["separator", separator],
SHORT_CIRCUIT,
["integer", digits],
[
"fraction",
maybe(
sequential(MaybeUnderscores, Period, MaybeUnderscores, ["this", digits]),
""
)
],
MaybeUnderscores
);
return mutate(function (_p, parser, index, endIndex) {
var fraction, integer, separator, value;
separator = _p.separator;
integer = _p.integer;
fraction = _p.fraction;
value = parseRadixNumber(integer, fraction, radix);
if (!isFinite(value)) {
throw ParserError(
"Unable to parse number " + __strnum(quote(parser.source.substring(index, endIndex))),
parser,
index
);
}
return parser.Const(index, value);
})(_ref);
}
HexDigit = characters("[0-9A-Fa-f]", charsToFakeSet([
[48, 57],
[65, 70],
[97, 102]
]));
HexNumber = cache(makeRadixNumber(
16,
characters("[Xx]", charsToFakeSet([88, 120])),
HexDigit
));
OctalDigit = characters("[0-7]", charsToFakeSet([[48, 55]]));
OctalNumber = cache(makeRadixNumber(
8,
characters("[Oo]", charsToFakeSet([79, 111])),
HexDigit
));
BinaryDigit = characters("[01]", charsToFakeSet([48, 49]));
BinaryNumber = cache(makeRadixNumber(
2,
characters("[Bb]", charsToFakeSet([66, 98])),
HexDigit
));
RadixNumber = cache((function () {
var digitsCache, R, Radix;
digitsCache = [];
function getDigitsRule(radix) {
var _ref;
if ((_ref = digitsCache[radix]) == null) {
return digitsCache[radix] = (function () {
var _end, digit, i, letterEnd, name, set;
switch (radix) {
case 2:
digit = BinaryDigit;
break;
case 8:
digit = OctalDigit;
break;
case 10:
digit = DecimalDigit;
break;
case 16:
digit = HexDigit;
break;
default:
set = __create(null);
for (i = 0, _end = __num(radix) > 10 ? __num(radix) : 10; i < _end; ++i) {
set[i + 48] = true;
}
for (i = 0, _end = (__num(radix) > 36 ? __num(radix) : 36) - 10; i < _end; ++i) {
set[i + 65] = true;
set[i + 97] = true;
}
name = ["[0-"];
name.push(String.fromCharCode((__num(radix) > 9 ? __num(radix) : 9) + 48));
if (__num(radix) >= 10) {
letterEnd = (__num(radix) > 36 ? __num(radix) : 36) - 10;
name.push("A-");
name.push(String.fromCharCode(letterEnd + 65));
name.push("a-");
name.push(String.fromCharCode(letterEnd + 97));
}
name.push("]");
digit = characters(name.join(""), set);
}
return makeDigitsRule(digit);
}());
} else {
return _ref;
}
}
Radix = multiple(DecimalDigit, 1, 2);
R = characters("[Rr]", charsToFakeSet([82, 114]));
return function (parser, index) {
var currentIndex, digitsRule, fraction, integer, period, radix, radixNum, radixValue, separator, trailing, value;
radix = Radix(parser, index);
if (!radix) {
return;
}
radixValue = codesToString(radix.value);
separator = R(parser, radix.index);
if (!separator) {
return;
}
radixNum = parseInt(radixValue, 10);
if (!isFinite(radixNum)) {
throw ParserError("Unable to parse radix " + __strnum(quote(radixValue)), parser, index);
} else if (radixNum < 2) {
throw ParserError("Radix must be at least 2, got " + radixNum, parser, index);
} else if (radixNum > 36) {
throw ParserError("Radix must be at most 36, got " + radixNum, parser, index);
}
digitsRule = getDigitsRule(radixNum);
integer = digitsRule(parser, separator.index);
if (!integer) {
parser.fail("integer after radix", separator.index);
throw SHORT_CIRCUIT;
}
currentIndex = MaybeUnderscores(parser, integer.index).index;
period = Period(parser, currentIndex);
if (period) {
fraction = digitsRule(parser, MaybeUnderscores(parser, period.index).index);
if (fraction) {
value = parseRadixNumber(integer.value, fraction.value, radixNum);
currentIndex = fraction.index;
}
}
if (value == null) {
value = parseRadixNumber(integer.value, "", radixNum);
}
if (!isFinite(value)) {
throw ParserError(
"Unable to parse number " + __strnum(quote(parser.source.substring(index, currentIndex))),
parser,
index
);
}
trailing = MaybeUnderscores(parser, currentIndex);
return Box(trailing.index, parser.Const(index, value));
};
}()));
NumberLiteral = cache(withSpace(oneOf(
HexNumber,
OctalNumber,
BinaryNumber,
RadixNumber,
DecimalNumber
)));
IdentifierNameConst = cache(function (parser, index) {
var name;
name = Name(parser, index);
if (name) {
return Box(name.index, parser.Const(index, name.value));
}
});
IdentifierNameConstOrNumberLiteral = cache(oneOf(IdentifierNameConst, NumberLiteral));
function makeConstLiteral(name, value) {
var _ref;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
_ref = word(name);
return mutate(function (_p, parser, index) {
return parser.Const(index, value);
})(_ref);
}
_ref = sequential(
character('"x"', 120),
SHORT_CIRCUIT,
[
"this",
multiple(HexDigit, 2, 2)
]
);
HexEscapeSequence = mutate(function (digits) {
return parseInt(codesToString(digits), 16);
})(_ref);
UnicodeEscapeSequence = sequential(
character('"u"', 117),
SHORT_CIRCUIT,
[
"this",
oneOf(
(_ref = multiple(HexDigit, 4, 4), mutate(function (digits) {
return parseInt(codesToString(digits), 16);
})(_ref)),
(_ref = sequential(
OpenCurlyBraceChar,
[
"this",
multiple(HexDigit, 1, 6)
],
CloseCurlyBraceChar
), mutate(function (digits, parser, index) {
var inner, value;
inner = codesToString(digits);
value = parseInt(inner, 16);
if (value > 1114111) {
throw ParserError("Unicode escape sequence too large: '\\u{" + inner + "}'", parser, index);
}
return value;
})(_ref))
)
]
);
SingleEscapeCharacter = (function () {
var _o, ESCAPED_CHARACTERS;
ESCAPED_CHARACTERS = (_o = __create(null), _o[98] = 8, _o[102] = 12, _o[114] = 13, _o[110] = 10, _o[116] = 9, _o[118] = 11, _o);
return oneOf(mutate(0)(Zero), mutate(function (c) {
return ESCAPED_CHARACTERS[c] || c;
})(AnyChar));
}());
BackslashEscapeSequence = sequential(BackslashChar, SHORT_CIRCUIT, [
"this",
oneOf(HexEscapeSequence, UnicodeEscapeSequence, SingleEscapeCharacter)
]);
inExpression = makeAlterStack.generic(String)("position", "expression");
inStatement = makeAlterStack.generic(String)("position", "statement");
AssignmentAsExpression = inExpression(function (parser, index) {
return Assignment(parser, index);
});
ExpressionOrAssignment = cache(oneOf(AssignmentAsExpression, Expression));
ExpressionOrAssignmentOrBody = cache(oneOf(ExpressionOrAssignment, Body));
StringInterpolation = sequential(DollarSignChar, NoSpace, SHORT_CIRCUIT, [
"this",
oneOf(Identifier, sequential(
OpenParenthesis,
[
"this",
oneOf(Expression, Nothing)
],
CloseParenthesis
))
]);
SingleStringLiteral = cache((_ref = sequential(
SingleQuote,
SHORT_CIRCUIT,
[
"this",
zeroOrMoreOf(BackslashEscapeSequence, anyExcept(oneOf(SingleQuote, Newline)))
],
SingleQuote
), mutate(function (codes, parser, index) {
return parser.Const(index, codesToString(codes));
})(_ref)));
DoubleStringLiteralInner = zeroOrMoreOf(BackslashEscapeSequence, StringInterpolation, anyExcept(oneOf(DoubleQuote, Newline)));
function doubleStringLiteralHandler(parts, parser, index) {
var _arr, _i, _len, currentLiteral, part, stringParts;
stringParts = [];
currentLiteral = [];
for (_arr = __toArray(parts), _i = 0, _len = _arr.length; _i < _len; ++_i) {
part = _arr[_i];
if (typeof part === "number") {
currentLiteral.push(part);
} else if (!(part instanceof NothingNode)) {
stringParts.push(parser.Const(index, codesToString(currentLiteral)));
currentLiteral = [];
stringParts.push(part);
}
}
if (currentLiteral.length > 0) {
stringParts.push(parser.Const(index, codesToString(currentLiteral)));
}
return stringParts;
}
DoubleStringLiteral = cache((_ref = sequential(
DoubleQuote,
SHORT_CIRCUIT,
["this", DoubleStringLiteralInner],
DoubleQuote
), mutate(function (parts, parser, index) {
var _arr, _arr2, _i, _len, part, stringParts;
for (_arr = [], _arr2 = __toArray(doubleStringLiteralHandler(parts, parser, index)), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
part = _arr2[_i];
if (!part.isConstValue("")) {
_arr.push(part);
}
}
stringParts = _arr;
if (stringParts.length === 0) {
return parser.Const(index, "");
} else if (stringParts.length === 1 && stringParts[0].isConstType("string")) {
return stringParts[0];
} else {
return parser.string(index, stringParts);
}
})(_ref)));
DoubleStringArrayLiteral = cache((_ref = sequential(
PercentSignChar,
DoubleQuote,
SHORT_CIRCUIT,
["this", DoubleStringLiteralInner],
DoubleQuote
), mutate(function (parts, parser, index) {
var stringParts;
stringParts = doubleStringLiteralHandler(parts, parser, index);
return parser.Array(index, stringParts);
})(_ref)));
function StringIndent(parser, index) {
var c, count, currentIndent, currentIndex, indentValue;
count = 0;
currentIndent = parser.indent.peek();
currentIndex = index;
while (count < __num(currentIndent)) {
c = SpaceChar(parser, currentIndex);
if (!c) {
break;
}
currentIndex = c.index;
indentValue = INDENTS[c.value];
if (!indentValue) {
throw Error("Unexpected indent char: " + __str(JSON.stringify(c.value)));
}
count += +indentValue;
}
if (count > __num(currentIndent)) {
throw ParserError("Mixed tabs and spaces in string literal", parser, currentIndex);
} else if (count === currentIndent || Newline(parser, currentIndex)) {
return Box(currentIndex, count);
}
}
if (typeof String.prototype.trimRight === "function") {
trimRight = function (x) {
return x.trimRight();
};
} else {
trimRight = function (x) {
return x.replace(/\s+$/, "");
};
}
_ref = zeroOrMoreOf(BackslashEscapeSequence, anyExcept(oneOf(TripleSingleQuote, Newline)));
TripleSingleStringLine = mutate(function (codes) {
return [trimRight(codesToString(codes))];
})(_ref);
_ref = zeroOrMoreOf(BackslashEscapeSequence, StringInterpolation, anyExcept(oneOf(TripleDoubleQuote, Newline)));
TripleDoubleStringLine = mutate(function (parts) {
var _arr, _i, _len, currentLiteral, part, stringParts;
stringParts = [];
currentLiteral = [];
for (_arr = __toArray(parts), _i = 0, _len = _arr.length; _i < _len; ++_i) {
part = _arr[_i];
if (typeof part === "number") {
currentLiteral.push(part);
} else if (!(part instanceof NothingNode)) {
if (currentLiteral.length > 0) {
stringParts.push(codesToString(currentLiteral));
currentLiteral = [];
}
stringParts.push(part);
}
}
if (currentLiteral.length > 0) {
stringParts.push(trimRight(codesToString(currentLiteral)));
}
return stringParts;
})(_ref);
function tripleStringHandler(x, parser, index) {
var _end, _len, i, j, len, line, lines, part, stringParts;
lines = [x.first];
if (lines[0].length === 0 || lines[0].length === 1 && lines[0][0] === "") {
lines.shift();
}
for (j = 1, _end = __num(x.numEmptyLines); j < _end; ++j) {
lines.push([""]);
}
lines.push.apply(lines, __toArray(x.rest));
len = lines.length;
if (len > 0 && (lines[len - 1].length === 0 || lines[len - 1].length === 1 && lines[len - 1][0] === "")) {
lines.pop();
--len;
}
stringParts = [];
for (j = 0, _len = lines.length; j < _len; ++j) {
line = lines[j];
if (j > 0) {
stringParts.push("\n");
}
stringParts.push.apply(stringParts, __toArray(line));
}
for (i = stringParts.length - 2; i >= 0; --i) {
if (typeof stringParts[i] === "string" && typeof stringParts[i + 1] === "string") {
stringParts.splice(i, 2, "" + stringParts[i] + stringParts[i + 1]);
}
}
for (i = 0, _len = stringParts.length; i < _len; ++i) {
part = stringParts[i];
if (typeof part === "string") {
stringParts[i] = parser.Const(index, part);
}
}
return stringParts;
}
function makeTripleString(quote, line) {
var _ref;
if (typeof quote !== "function") {
throw TypeError("Expected quote to be a Function, got " + __typeof(quote));
}
if (typeof line !== "function") {
throw TypeError("Expected line to be a Function, got " + __typeof(line));
}
_ref = sequential(
quote,
SHORT_CIRCUIT,
["first", line],
[
"numEmptyLines",
zeroOrMore(
sequential(Space, ["this", Newline]),
true
)
],
[
"rest",
maybe(
retainIndent(sequential(
MaybeAdvance,
[
"this",
maybe(
separatedList(
sequential(StringIndent, ["this", line]),
Newline
),
function () {
return [];
}
)
],
maybe(Newline),
PopIndent
)),
function () {
return [];
}
)
],
quote
);
return mutate(function (parts, parser, index) {
var _arr, _arr2, _i, _len, part, stringParts;
for (_arr = [], _arr2 = __toArray(tripleStringHandler(parts, parser, index)), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
part = _arr2[_i];
if (!part.isConstValue("")) {
_arr.push(part);
}
}
stringParts = _arr;
if (stringParts.length === 0) {
return parser.Const(index, "");
} else if (stringParts.length === 1 && stringParts[0].isConstType("string")) {
return stringParts[0];
} else {
return parser.string(index, stringParts);
}
})(_ref);
}
TripleSingleStringLiteral = cache(makeTripleString(TripleSingleQuote, TripleSingleStringLine));
TripleDoubleStringLiteral = cache(makeTripleString(TripleDoubleQuote, TripleDoubleStringLine));
TripleDoubleStringArrayLiteral = cache((_ref = sequential(
PercentSignChar,
TripleDoubleQuote,
SHORT_CIRCUIT,
["first", TripleDoubleStringLine],
[
"numEmptyLines",
zeroOrMore(
sequential(Space, ["this", Newline]),
true
)
],
[
"rest",
maybe(
retainIndent(sequential(
MaybeAdvance,
[
"this",
maybe(
sequential(StringIndent, [
"this",
separatedList(TripleDoubleStringLine, sequential(Newline, StringIndent))
]),
function () {
return [];
}
)
],
maybe(Newline),
PopIndent
)),
function () {
return [];
}
)
],
TripleDoubleQuote
), mutate(function (parts, parser, index) {
var stringParts;
stringParts = tripleStringHandler(parts, parser, index);
return parser.Array(index, stringParts);
})(_ref)));
BackslashStringLiteral = cache(sequential(BackslashChar, NoSpace, ["this", IdentifierNameConst]));
StringLiteral = cache(withSpace(oneOf(
BackslashStringLiteral,
TripleSingleStringLiteral,
TripleDoubleStringLiteral,
TripleDoubleStringArrayLiteral,
SingleStringLiteral,
DoubleStringLiteral,
DoubleStringArrayLiteral
)));
RegexLiteral = cache((function () {
var _ref, _ref2, LowerR, NOTHING, RegexComment, RegexFlags, RegexSpace;
LowerR = character('"r"', 114);
_ref = zeroOrMore(NameChar);
RegexFlags = mutate(codesToString)(_ref);
NOTHING = {};
_ref = sequential(HashSignChar, zeroOrMore(anyExcept(Newline), true));
RegexComment = mutate(NOTHING)(_ref);
_ref = oneOf(SpaceChar, Newline);
RegexSpace = mutate(NOTHING)(_ref);
return withSpace((_ref = sequential(
LowerR,
[
"text",
oneOf(
sequential(
TripleDoubleQuote,
SHORT_CIRCUIT,
[
"this",
zeroOrMoreOf(
(_ref2 = sequential(BackslashChar, DollarSignChar), mutate(36)(_ref2)),
RegexSpace,
RegexComment,
StringInterpolation,
anyExcept(TripleDoubleQuote)
)
],
TripleDoubleQuote
),
sequential(
TripleSingleQuote,
SHORT_CIRCUIT,
[
"this",
zeroOrMoreOf(RegexSpace, RegexComment, anyExcept(TripleSingleQuote))
],
TripleSingleQuote
),
sequential(
DoubleQuote,
SHORT_CIRCUIT,
[
"this",
zeroOrMoreOf(
(_ref2 = sequential(DoubleQuote, DoubleQuote), mutate(34)(_ref2)),
(_ref2 = sequential(BackslashChar, DollarSignChar), mutate(36)(_ref2)),
StringInterpolation,
anyExcept(oneOf(DoubleQuote, Newline, DollarSignChar))
)
],
DoubleQuote
),
sequential(
SingleQuote,
SHORT_CIRCUIT,
[
"this",
zeroOrMoreOf(
(_ref2 = sequential(SingleQuote, SingleQuote), mutate(39)(_ref2)),
anyExcept(oneOf(SingleQuote, Newline))
)
],
SingleQuote
)
)
],
["flags", RegexFlags]
), mutate(function (_p, parser, index) {
var _arr, _i, _len, currentLiteral, flag, flags, part, seenFlags, stringParts, text;
text = _p.text;
flags = _p.flags;
stringParts = [];
currentLiteral = [];
for (_arr = __toArray(text), _i = 0, _len = _arr.length; _i < _len; ++_i) {
part = _arr[_i];
if (typeof part === "number") {
currentLiteral.push(part);
} else if (part !== NOTHING && !(part instanceof NothingNode)) {
if (currentLiteral.length > 0) {
stringParts.push(parser.Const(index, codesToString(currentLiteral)));
currentLiteral = [];
}
stringParts.push(part);
}
}
if (currentLiteral.length > 0) {
stringParts.push(parser.Const(index, codesToString(currentLiteral)));
}
if (stringParts.length === 0) {
text = parser.Const(index, "");
} else if (stringParts.length === 1 && stringParts[0].isConstType("string")) {
text = stringParts[0];
} else {
text = parser.string(index, stringParts);
}
if (text.isConst()) {
try {
RegExp(String(text.constValue()));
} catch (e) {
throw ParserError(e.message, parser, index);
}
}
seenFlags = [];
for (_arr = __toArray(flags), _i = 0, _len = _arr.length; _i < _len; ++_i) {
flag = _arr[_i];
if (__in(flag, seenFlags)) {
throw ParserError("Invalid regular expression: flag " + __strnum(quote(flag)) + " occurred more than once", parser, index);
} else if (flag !== "g" && flag !== "i" && flag !== "m" && flag !== "y") {
throw ParserError("Invalid regular expression: unknown flag " + __strnum(quote(flag)), parser, index);
}
seenFlags.push(flag);
}
return parser.Regexp(index, text, flags);
})(_ref)));
}()));
function CustomConstantLiteral(parser, index) {
var name, value;
name = Name(parser, index);
if (!name) {
return;
}
value = parser.getConst(name.value);
if (!value) {
return;
}
return Box(name.index, parser.Const(index, value.value));
}
function NullOrVoidLiteral(parser, index) {
var constant;
constant = CustomConstantLiteral(parser, index);
if (!constant) {
return;
}
if (constant.value.value != null) {
return;
}
return constant;
}
ConstantLiteral = cache(oneOf(CustomConstantLiteral, NumberLiteral, StringLiteral, RegexLiteral));
Literal = cache(oneOf(ThisOrShorthandLiteral, ArgumentsLiteral, ConstantLiteral));
MaybeNotToken = cache(maybe(word("not")));
MaybeQuestionMarkChar = cache(maybe(character('"?"', 63)));
GeneratorBody = makeAlterStack.generic(Boolean)("inGenerator", true)(Body);
GeneratorBodyNoEnd = makeAlterStack.generic(Boolean)("inGenerator", true)(BodyNoEnd);
LessThanChar = character('"<"', 60);
LessThan = withSpace(LessThanChar);
GreaterThanChar = character('">"', 62);
GreaterThan = withSpace(GreaterThanChar);
FunctionGlyph = cache(sequential(Space, MinusChar, GreaterThanChar));
_FunctionBody = oneOf.generic(Node)(
sequential(FunctionGlyph, [
"this",
oneOf(Statement, Nothing)
]),
Body
);
FunctionBody = makeAlterStack.generic(Boolean)("inGenerator", false)(_FunctionBody);
GeneratorFunctionBody = makeAlterStack.generic(Boolean)("inGenerator", true)(_FunctionBody);
IdentifierOrSimpleAccessStart = oneOf(
Identifier,
(_ref = sequential(
["parent", ThisOrShorthandLiteralPeriod],
["child", IdentifierNameConstOrNumberLiteral]
), mutate(function (_p, parser, index) {
var child, parent;
parent = _p.parent;
child = _p.child;
return parser.Access(index, parent, child);
})(_ref)),
(_ref = sequential(
["parent", ThisOrShorthandLiteral],
DoubleColonChar,
["child", IdentifierNameConstOrNumberLiteral]
), mutate(function (_p, parser, index) {
var child, parent;
parent = _p.parent;
child = _p.child;
return parser.Access(
index,
parser.Access(index, parent, parser.Const(index, "prototype")),
child
);
})(_ref)),
(_ref = sequential(
["parent", ThisOrShorthandLiteral],
["isProto", maybe(DoubleColonChar)],
OpenSquareBracketChar,
["child", Expression],
CloseSquareBracket
), mutate(function (_p, parser, index) {
var child, isProto, parent;
parent = _p.parent;
isProto = _p.isProto;
child = _p.child;
return parser.Access(
index,
isProto
? parser.Access(index, parent, parser.Const(index, "prototype"))
: parent,
child
);
})(_ref))
);
PeriodOrDoubleColonChar = cache(oneOf(Period, DoubleColonChar));
_ref = oneOf(
sequential(
["type", PeriodOrDoubleColonChar],
["child", IdentifierNameConstOrNumberLiteral]
),
sequential(
["type", maybe(DoubleColonChar)],
OpenSquareBracketChar,
["child", Expression],
CloseSquareBracket
)
);
IdentifierOrSimpleAccessPart = mutate(function (_p, parser, childIndex) {
var child, isProto, type;
type = _p.type;
child = _p.child;
isProto = type === "::";
return function (parent, parser, index) {
return parser.Access(
index,
isProto
? parser.Access(index, parent, parser.Const(childIndex, "prototype"))
: parent,
child
);
};
})(_ref);
IdentifierOrSimpleAccess = cache((_ref = sequential(
["head", IdentifierOrSimpleAccessStart],
["tail", zeroOrMore(IdentifierOrSimpleAccessPart)]
), mutate(function (parts, parser, index) {
var _arr, _i, _len, acc, creator;
acc = parts.head;
for (_arr = __toArray(parts.tail), _i = 0, _len = _arr.length; _i < _len; ++_i) {
creator = _arr[_i];
acc = creator(acc, parser, index);
}
return acc;
})(_ref)));
IdentifierOrAccess = cache(function (parser, index) {
var node, value;
node = InvocationOrAccess(parser, index);
if (!node) {
return;
}
value = node.value;
if (value instanceof IdentNode || value instanceof AccessNode) {
return node;
}
});
inFunctionTypeParams = makeAlterStack.generic(Boolean)("inFunctionTypeParams", true);
notInFunctionTypeParams = makeAlterStack.generic(Boolean)("inFunctionTypeParams", false);
TypeReference = function (parser, index) {
return TypeReference(parser, index);
};
ArrayType = cache((_ref = sequential(
OpenSquareBracket,
["this", maybe(TypeReference)],
CloseSquareBracket
), mutate(function (subtype, parser, index) {
var arrayIdent;
arrayIdent = parser.Ident(index, "Array");
if (subtype) {
return parser.TypeGeneric(index, arrayIdent, [subtype]);
} else {
return arrayIdent;
}
})(_ref)));
ObjectTypePair = sequential(
[
"key",
function (parser, index) {
return ConstObjectKey(parser, index);
}
],
Colon,
["value", TypeReference]
);
ObjectType = cache((_ref = sequential(
OpenCurlyBrace,
[
"this",
maybe(
separatedList(ObjectTypePair, CommaOrNewline),
function () {
return [];
}
)
],
MaybeComma,
CloseCurlyBrace
), mutate(function (pairs, parser, index) {
var _arr, _i, _len, key, keys, keyValue;
if (pairs.length === 0) {
return parser.Ident(index, "Object");
} else {
keys = [];
for (_arr = __toArray(pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
key = _arr[_i].key;
if (!key.isConst()) {
throw ParserError("Expected a constant key, got " + __typeof(key), parser, key.index);
} else {
keyValue = String(key.constValue());
if (__in(keyValue, keys)) {
throw ParserError("Duplicate object key: " + __strnum(quote(keyValue)), parser, key.index);
}
keys.push(keyValue);
}
}
return parser.TypeObject(index, pairs);
}
})(_ref)));
_ref = sequential(
oneOf(
sequential(
OpenParenthesis,
separatedList(TypeReference, CommaOrNewline),
CloseParenthesis
),
inFunctionTypeParams(TypeReference),
Nothing
),
FunctionGlyph,
["this", maybe(TypeReference)]
);
FunctionType = mutate(function (returnType, parser, index) {
var functionIdent;
functionIdent = parser.Ident(index, "Function");
if (returnType) {
return parser.TypeGeneric(index, functionIdent, [returnType]);
} else {
return functionIdent;
}
})(_ref);
NonUnionType = oneOf(
function (parser, index) {
if (!parser.inFunctionTypeParams.peek()) {
return FunctionType(parser, index);
}
},
sequential(
OpenParenthesis,
[
"this",
notInFunctionTypeParams(function (parser, index) {
return TypeReference(parser, index);
})
],
CloseParenthesis
),
ArrayType,
ObjectType,
NullOrVoidLiteral,
(_ref = sequential(
["base", IdentifierOrSimpleAccess],
[
"args",
maybe(
sequential(
character('"<"', 60),
SHORT_CIRCUIT,
[
"this",
separatedList(
function (parser, index) {
return TypeReference(parser, index);
},
Comma
)
],
Space,
character('">"', 62)
),
function () {
return [];
}
)
]
), mutate(function (_p, parser, index) {
var args, base;
base = _p.base;
args = _p.args;
if (!args.length) {
return base;
} else {
return parser.TypeGeneric(index, base, args);
}
})(_ref))
);
Pipe = cache(withSpace(PipeChar));
TypeReference = cache((_ref = separatedList(NonUnionType, Pipe), mutate(function (types, parser, index) {
var _arr, i, type;
types = types.slice();
for (_arr = __toArray(types), i = _arr.length; i--; ) {
type = _arr[i];
if (type instanceof TypeUnionNode) {
types.splice.apply(types, [i, 1].concat(__toArray(type.types)));
}
}
if (types.length === 1) {
return types[0];
} else {
return parser.TypeUnion(index, types);
}
})(_ref)));
MaybeAsType = maybe(sequential(word("as"), SHORT_CIRCUIT, ["this", TypeReference]));
BracketedObjectKey = cache(sequential(
OpenSquareBracket,
["this", ExpressionOrAssignment],
CloseSquareBracket
));
ConstObjectKey = oneOf(
StringLiteral,
mutate(function (node, parser, index) {
return parser.Const(index, String(node.constValue()));
})(NumberLiteral),
IdentifierNameConst
);
ObjectKey = cache(oneOf(BracketedObjectKey, ConstObjectKey));
ObjectKeyColon = cache(sequential(
["this", ObjectKey],
Colon,
except(EqualChar),
function (parser, index) {
if (parser.options.noindent) {
if (EmptyLine(parser, index)) {
return;
} else if (parser.options.embedded && (EmbeddedClose(parser, index) || EmbeddedCloseWrite(parser, index))) {
return;
}
}
return Box(index);
}
));
function mutateFunction(node, parser, index) {
var mutateFunctionMacro;
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
mutateFunctionMacro = parser.getMacroByLabel("mutateFunction");
if (!mutateFunctionMacro) {
return node;
} else {
return mutateFunctionMacro.func(
{ op: "", node: node },
parser,
index
);
}
}
function validateSpreadParameters(params, parser) {
var _arr, _i, _len, param, spreadCount;
spreadCount = 0;
for (_arr = __toArray(params), _i = 0, _len = _arr.length; _i < _len; ++_i) {
param = _arr[_i];
if (param instanceof ParamNode && param.spread) {
++spreadCount;
if (spreadCount > 1) {
throw ParserError("Cannot have more than one spread parameter", parser, parser.indexFromPosition(param.line, param.column));
}
}
}
return params;
}
function removeTrailingNothings(array) {
var last;
if (!__isArray(array)) {
throw TypeError("Expected array to be an Array, got " + __typeof(array));
}
while (array.length) {
last = array[array.length - 1];
if (!(last instanceof NothingNode)) {
break;
}
array.pop();
}
return array;
}
IdentifierOrThisAccess = oneOf(Identifier, (_ref = sequential(
["parent", ThisOrShorthandLiteralPeriod],
["child", IdentifierNameConst]
), mutate(function (_p, parser, index) {
var child, parent;
parent = _p.parent;
child = _p.child;
return parser.Access(index, parent, child);
})(_ref)));
_ref = sequential(
["isMutable", bool(maybe(word("mutable")))],
["spread", bool(MaybeSpreadToken)],
["ident", IdentifierOrThisAccess],
["asType", MaybeAsType],
[
"defaultValue",
maybe(sequential(EqualSign, ["this", Expression]))
]
);
IdentifierParameter = mutate(function (_p, parser, index) {
var asType, defaultValue, ident, isMutable, spread;
isMutable = _p.isMutable;
spread = _p.spread;
ident = _p.ident;
asType = _p.asType;
defaultValue = _p.defaultValue;
if (spread && defaultValue) {
throw ParserError("Cannot specify a default value for a spread parameter", parser, index);
}
return parser.Param(
index,
ident,
defaultValue,
spread,
isMutable,
asType
);
})(_ref);
Parameter = function (parser, index) {
return Parameter(parser, index);
};
_ref = sequential(
OpenSquareBracket,
EmptyLines,
[
"this",
function (parser, index) {
return Parameters(parser, index);
}
],
EmptyLines,
CloseSquareBracket
);
ArrayParameter = mutate(function (params, parser, index) {
return parser.Array(index, params);
})(_ref);
ParamDualObjectKey = sequential(
["key", ObjectKeyColon],
["value", Parameter]
);
_ref = sequential(
["this", IdentifierParameter],
NotColon
);
ParamSingularObjectKey = mutate(function (param, parser, index) {
var ident, key;
ident = param.ident;
if (ident instanceof IdentNode) {
key = parser.Const(index, ident.name);
} else if (ident instanceof AccessNode) {
key = ident.child;
} else {
throw Error("Unknown object key type: " + __strnum(param.type));
}
return { key: key, value: param };
})(_ref);
KvpParameter = maybe(oneOf(ParamDualObjectKey, ParamSingularObjectKey));
_ref = sequential(
OpenCurlyBrace,
EmptyLines,
[
"this",
separatedList(KvpParameter, CommaOrNewline)
],
EmptyLines,
CloseCurlyBrace
);
ObjectParameter = mutate(function (params, parser, index) {
return parser.object(index, (function () {
var _arr, _arr2, _i, _len, param;
for (_arr = [], _arr2 = __toArray(params), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
param = _arr2[_i];
if (param) {
_arr.push(param);
}
}
return _arr;
}()));
})(_ref);
Parameter = oneOf(IdentifierParameter, ArrayParameter, ObjectParameter);
ParameterOrNothing = oneOf(Parameter, Nothing);
_ref = separatedList(ParameterOrNothing, CommaOrNewline);
Parameters = mutate(function (params, parser, index) {
return validateSpreadParameters(removeTrailingNothings(params), parser);
})(_ref);
_ref = sequential(
OpenParenthesis,
SHORT_CIRCUIT,
EmptyLines,
["this", Parameters],
EmptyLines,
CloseParenthesis
);
ParameterSequence = mutate((function () {
function checkParam(param, parser, names) {
var _arr, _i, _len, child, element, ident, name, pair;
if (!(param instanceof Node)) {
throw TypeError("Expected param to be a " + __name(Node) + ", got " + __typeof(param));
}
if (!__isArray(names)) {
throw TypeError("Expected names to be an Array, got " + __typeof(names));
}
if (param instanceof ParamNode) {
ident = param.ident;
if (ident instanceof IdentNode) {
name = ident.name;
} else if (ident instanceof AccessNode) {
child = ident.child;
if (!child.isConstType("string")) {
throw Error("Expected constant access");
}
name = child.constValue();
} else {
throw Error("Unknown param ident type: " + __typeof(param));
}
if (__in(name, names)) {
throw ParserError("Duplicate parameter name: " + __strnum(quote(name)), parser, parser.indexFromPosition(ident.line, ident.column));
} else {
names.push(name);
}
} else if (param instanceof ArrayNode) {
for (_arr = __toArray(param.elements), _i = 0, _len = _arr.length; _i < _len; ++_i) {
element = _arr[_i];
checkParam(element, parser, names);
}
} else if (param instanceof ObjectNode) {
for (_arr = __toArray(param.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
pair = _arr[_i];
checkParam(pair.value, parser, names);
}
} else if (!param instanceof NothingNode) {
throw Error("Unknown param type: " + __typeof(param));
}
}
return function (params, parser, index) {
var _arr, _i, _len, names, param;
names = [];
for (_arr = __toArray(params), _i = 0, _len = _arr.length; _i < _len; ++_i) {
param = _arr[_i];
checkParam(param, parser, names);
}
return params;
};
}()))(_ref);
FunctionDeclaration = (function () {
var _ref, asTypeRule, FunctionFlag, FunctionFlags, GenericDefinitionPart, paramsRule;
FunctionFlag = oneOf(ExclamationPointChar, AtSignChar, AsterixChar, CaretChar);
_ref = zeroOrMore(FunctionFlag);
FunctionFlags = mutate(function (codes, parser, index) {
var _arr, _i, _len, c, flags, uniqueChars;
flags = { autoReturn: true, bound: false, generator: false, curry: false };
uniqueChars = [];
for (_arr = __toArray(codes), _i = 0, _len = _arr.length; _i < _len; ++_i) {
c = _arr[_i];
if (__in(c, uniqueChars)) {
throw ParserError("Function flag " + __strnum(quote(fromCharCode(c))) + " specified more than once", parser, index);
} else {
uniqueChars.push(c);
switch (c) {
case 33:
flags.autoReturn = false;
break;
case 64:
flags.bound = true;
break;
case 42:
flags.generator = true;
break;
case 94:
flags.curry = true;
break;
default: throw Error("Unknown function flag: " + __strnum(quote(fromCharCode(c))));
}
}
}
if (!flags.autoReturn && flags.generator) {
throw ParserError("A function cannot be both non-returning (!) and a generator (*)", parser, index);
}
return flags;
})(_ref);
GenericDefinitionPart = maybe(
sequential(
LessThanChar,
[
"this",
separatedList(Identifier, Comma)
],
GreaterThan
),
function () {
return [];
}
);
paramsRule = maybe(ParameterSequence, function () {
return [];
});
asTypeRule = inFunctionTypeParams(MaybeAsType);
function getBodyRule(generator) {
if (generator) {
return GeneratorFunctionBody;
} else {
return FunctionBody;
}
}
return function (parser, index) {
var _arr, _i, asType, body, flags, flagsValue, func, generic, param, params, result, scope;
generic = GenericDefinitionPart(parser, index);
scope = parser.pushScope(true);
params = paramsRule(parser, generic.index);
for (_arr = __toArray(params.value), _i = _arr.length; _i--; ) {
param = _arr[_i];
addParamToScope(scope, param);
}
flags = FunctionFlags(parser, params.index);
flagsValue = flags.value;
asType = asTypeRule(parser, flags.index);
body = getBodyRule(flags.value.generator)(parser, asType.index);
if (!body) {
parser.popScope();
return;
}
func = parser.Function(
index,
params.value,
body.value,
flagsValue.autoReturn,
flagsValue.bound,
flagsValue.curry,
asType.value,
flagsValue.generator,
generic.value
);
result = mutateFunction(func, parser, index);
parser.popScope();
return Box(body.index, result);
};
}());
FunctionLiteral = cache(sequential(Space, HashSignChar, ["this", FunctionDeclaration]));
preventUnclosedObjectLiteral = makeAlterStack.generic(Boolean)("preventUnclosedObjectLiteral", true);
ArrayLiteral = cache(preventUnclosedObjectLiteral((_ref = sequential(
OpenSquareBracket,
Space,
[
"this",
concat(
maybe(
sequential(
[
"this",
separatedList(SpreadOrExpression, Comma)
],
MaybeComma
),
function () {
return [];
}
),
maybe(
retainIndent(sequential(
SomeEmptyLines,
MaybeAdvance,
[
"this",
maybe(
sequential(CheckIndent, [
"this",
separatedList(SpreadOrExpression, CommaOrSomeEmptyLinesWithCheckIndent)
]),
function () {
return [];
}
)
],
EmptyLines,
MaybeCommaOrNewline
)),
function () {
return [];
}
)
)
],
CloseSquareBracket
), mutate(function (items, parser, index) {
return parser.Array(index, items);
})(_ref))));
SetLiteral = cache((_ref = sequential(PercentSign, check(OpenSquareBracketChar), SHORT_CIRCUIT, ["this", ArrayLiteral]), mutate(function (value, parser, index) {
var constructSet;
constructSet = parser.getMacroByLabel("constructSet");
if (!constructSet) {
throw Error("Cannot use literal set until the construct-set macro has been defined");
}
return constructSet.func(
{ op: "", node: value },
parser,
index
);
})(_ref)));
NoNewlineIfNoIndent = cache(function (parser, index) {
if (parser.options.noindent) {
return NoSpaceNewline(parser, index);
} else {
return Box(index);
}
});
DualObjectKey = sequential(
["key", ObjectKeyColon],
NoNewlineIfNoIndent,
["value", Expression]
);
GetSetToken = cache(oneOf(word("get"), word("set")));
PropertyDualObjectKey = cache(sequential(
[
"property",
oneOf(word("property"), GetSetToken)
],
Space,
["key", ObjectKeyColon],
NoNewlineIfNoIndent,
SHORT_CIRCUIT,
["value", Expression]
));
PropertyOrDualObjectKey = cache(oneOf(PropertyDualObjectKey, DualObjectKey));
MethodDeclaration = sequential(
["property", maybe(GetSetToken)],
["key", ObjectKey],
NotColon,
["value", FunctionDeclaration]
);
PropertyOrDualObjectKeyOrMethodDeclaration = oneOf(PropertyOrDualObjectKey, MethodDeclaration);
UnclosedObjectLiteral = cache((_ref = separatedList(PropertyOrDualObjectKey, Comma), mutate(function (pairs, parser, index) {
return parser.object(index, pairs);
})(_ref)));
SingularObjectKey = oneOf(
(_ref = sequential(
["this", IdentifierOrAccess],
NotColon
), mutate(function (ident, parser, index) {
var key;
if (ident instanceof AccessNode) {
key = ident.child;
} else if (ident instanceof IdentNode) {
key = parser.Const(index, ident.name);
} else {
throw ParserError("Unknown ident type: " + __typeof(ident), parser, index);
}
return { key: key, value: ident };
})(_ref)),
(_ref = sequential(
["this", ConstantLiteral],
NotColon
), mutate(function (node, parser, index) {
var key;
if (node.isConst() && !node.isConstType("string")) {
key = parser.Const(index, String(node.value));
} else {
key = node;
}
return { key: key, value: node };
})(_ref)),
(_ref = sequential(
["this", ThisLiteral],
NotColon
), mutate(function (node, parser, index) {
return {
key: parser.Const(index, "this"),
value: node
};
})(_ref)),
(_ref = sequential(
["this", ArgumentsLiteral],
NotColon
), mutate(function (node, parser, index) {
return {
key: parser.Const(index, "arguments"),
value: node
};
})(_ref)),
(_ref = sequential(
["this", BracketedObjectKey],
NotColon
), mutate(function (node, parser, index) {
return { key: node, value: node };
})(_ref))
);
KeyValuePair = cache(oneOf(
PropertyOrDualObjectKeyOrMethodDeclaration,
(_ref = sequential(
Space,
["flag", maybe(PlusOrMinusChar)],
["key", SingularObjectKey]
), mutate(function (_p, parser, index) {
var flag, key;
flag = _p.flag;
key = _p.key;
if (flag) {
return {
key: key.key,
value: parser.Const(index, flag === 43)
};
} else {
return key;
}
})(_ref)),
(_ref = sequential(
Space,
["bool", PlusOrMinusChar],
["key", IdentifierNameConst]
), mutate(function (_p, parser, index) {
var bool, key;
bool = _p.bool;
key = _p.key;
return {
key: key,
value: parser.Const(index, bool === 43)
};
})(_ref))
));
ObjectLiteral = cache((_ref = sequential(
OpenCurlyBrace,
Space,
[
"prototype",
maybe(sequential(
word("extends"),
["this", preventUnclosedObjectLiteral(Logic)],
Space,
oneOf(Comma, check(Newline), check(CloseCurlyBrace))
))
],
[
"pairs",
concat(
maybe(
sequential(
[
"this",
separatedList(KeyValuePair, Comma)
],
MaybeComma
),
function () {
return [];
}
),
maybe(
retainIndent(sequential(
SomeEmptyLines,
MaybeAdvance,
[
"this",
maybe(
sequential(CheckIndent, [
"this",
separatedList(KeyValuePair, CommaOrSomeEmptyLinesWithCheckIndent)
]),
function () {
return [];
}
)
],
PopIndent
)),
function () {
return [];
}
)
)
],
EmptyLines,
MaybeCommaOrNewline,
EmptyLines,
CloseCurlyBrace
), mutate(function (x, parser, index) {
return parser.object(index, x.pairs, x.prototype);
})(_ref)));
MapLiteral = cache((_ref = sequential(
PercentSign,
OpenCurlyBraceChar,
SHORT_CIRCUIT,
Space,
[
"this",
concat(
maybe(
sequential(
[
"this",
separatedList(DualObjectKey, Comma)
],
MaybeComma
),
function () {
return [];
}
),
maybe(
retainIndent(sequential(
SomeEmptyLines,
MaybeAdvance,
[
"this",
maybe(
sequential(CheckIndent, [
"this",
separatedList(DualObjectKey, CommaOrSomeEmptyLinesWithCheckIndent)
]),
function () {
return [];
}
)
],
PopIndent
)),
function () {
return [];
}
)
)
],
EmptyLines,
MaybeCommaOrNewline,
EmptyLines,
CloseCurlyBrace
), mutate(function (pairs, parser, index) {
var constructMap;
constructMap = parser.macros.getByLabel("constructMap");
if (!constructMap) {
throw Error("Cannot use literal map until the construct-map macro has been defined");
}
return constructMap.func(
{
op: "",
node: parser.object(index, pairs)
},
parser,
index
);
})(_ref)));
function Assignment(parser, index) {
var _arr, _i, left, op, operator, right, rule;
left = IdentifierOrAccess(parser, index);
if (!left) {
return;
}
for (_arr = __toArray(parser.assignOperators()), _i = _arr.length; _i--; ) {
operator = _arr[_i];
rule = operator.rule;
op = rule(parser, left.index);
if (!op) {
continue;
}
right = ExpressionOrAssignmentOrBody(parser, op.index);
if (!right) {
continue;
}
return Box(right.index, operator.func(
{ left: left.value, op: op.value, right: right.value },
parser,
index
));
}
}
CustomOperatorCloseParenthesis = (function () {
function handleUnaryOperator(operator, parser, index) {
var close, node, op, result, scope;
op = operator.rule(parser, index);
if (!op) {
return;
}
close = CloseParenthesis(parser, op.index);
if (!close) {
return;
}
node = parser.Ident(index, "x");
scope = parser.pushScope(true);
scope.add(node, false, Type.any);
result = mutateFunction(
parser.Function(
index,
[parser.Param(index, node)],
operator.func(
{ op: op.value, node: node },
parser,
index
),
true
),
parser,
index
);
parser.popScope();
return Box(close.index, result);
}
function handleBinaryOperator(operator, parser, index) {
var close, invert, inverted, left, op, result, right, scope;
inverted = false;
if (operator.invertible) {
invert = MaybeNotToken(parser, index);
if (invert.value) {
inverted = true;
}
index = invert.index;
}
op = operator.rule(parser, index);
if (!op) {
return;
}
close = CloseParenthesis(parser, op.index);
if (!close) {
return;
}
left = parser.Ident(index, "x");
right = parser.Ident(index, "y");
scope = parser.pushScope(true);
scope.add(left, false, Type.any);
scope.add(right, false, Type.any);
result = mutateFunction(
parser.Function(
index,
[
parser.Param(index, left),
parser.Param(index, right)
],
operator.func(
{ left: left, inverted: inverted, op: op.value, right: right },
parser,
index
),
true,
false,
true
),
parser,
index
);
parser.popScope();
return Box(close.index, result);
}
return function (parser, index) {
var _arr, _i, _ref, operator;
for (_arr = __toArray(parser.allBinaryOperators()), _i = _arr.length; _i--; ) {
operator = _arr[_i];
if ((_ref = handleBinaryOperator(operator, parser, index)) != null) {
return _ref;
}
}
for (_arr = __toArray(parser.prefixUnaryOperators()), _i = _arr.length; _i--; ) {
operator = _arr[_i];
if ((_ref = handleUnaryOperator(operator, parser, index)) != null) {
return _ref;
}
}
for (_arr = __toArray(parser.postfixUnaryOperators()), _i = _arr.length; _i--; ) {
operator = _arr[_i];
if ((_ref = handleUnaryOperator(operator, parser, index)) != null) {
return _ref;
}
}
};
}());
function CustomBinaryOperator(parser, index) {
var _arr, _i, currentIndex, invert, inverted, op, operator;
for (_arr = __toArray(parser.allBinaryOperators()), _i = _arr.length; _i--; ) {
operator = _arr[_i];
inverted = false;
currentIndex = index;
if (operator.invertible) {
invert = MaybeNotToken(parser, index);
if (invert.value) {
inverted = true;
}
currentIndex = invert.index;
}
op = operator.rule(parser, currentIndex);
if (!op) {
continue;
}
return Box(op.index, { op: op.value, operator: operator, inverted: inverted });
}
}
Parenthetical = cache(sequential(OpenParenthesis, [
"this",
oneOf.generic(Node)(
sequential(
["this", AssignmentAsExpression],
CloseParenthesis
),
(_ref = sequential(
["left", Expression],
["operator", maybe(CustomBinaryOperator)],
CloseParenthesis
), mutate(function (_p, parser, index) {
var left, operator, result, right, scope;
left = _p.left;
operator = _p.operator;
if (!operator) {
return left;
}
scope = parser.pushScope(true);
right = parser.makeTmp(index, "x");
result = mutateFunction(
parser.Function(
index,
[parser.Param(index, right)],
operator.operator.func(
{ left: left.rescope(scope), inverted: operator.inverted, op: operator.op, right: right },
parser,
index
),
true
),
parser,
index
);
parser.popScope();
return result;
})(_ref)),
CustomOperatorCloseParenthesis,
(_ref = sequential(
["operator", CustomBinaryOperator],
["right", Expression],
CloseParenthesis
), mutate(function (_p, parser, index) {
var _p2, inverted, left, op, operator, result, right, scope;
right = _p.right;
_p2 = _p.operator;
op = _p2.op;
operator = _p2.operator;
inverted = _p2.inverted;
scope = parser.pushScope(true);
left = parser.makeTmp(index, "x");
result = mutateFunction(
parser.Function(
index,
[parser.Param(index, left)],
operator.func(
{ left: left, inverted: inverted, op: op, right: right.rescope(scope) },
parser,
index
),
true
),
parser,
index
);
parser.popScope();
return result;
})(_ref)),
(_ref = sequential(
[
"this",
oneOrMore(function (parser, index) {
return InvocationOrAccessPart(parser, index);
})
],
CloseParenthesis
), mutate(function (tail, parser, index) {
var left, result, scope;
scope = parser.pushScope(true);
left = parser.makeTmp(index, "o");
result = mutateFunction(
parser.Function(
index,
[parser.Param(index, left)],
convertInvocationOrAccess(
false,
{ type: "normal", existential: false, node: left },
tail,
parser,
index
).rescope(scope),
true,
false
),
parser,
index
);
parser.popScope();
return result;
})(_ref))
)
]));
CurrentArrayLength = cache(function (parser, index) {
var asterix;
if (parser.asterixAsArrayLength.peek()) {
asterix = AsterixChar(parser, index);
if (asterix) {
return Box(asterix.index, parser.Ident(index, "__currentArrayLength"));
}
}
});
IndentedUnclosedObjectLiteralInner = cache((_ref = separatedList(PropertyOrDualObjectKey, CommaOrSomeEmptyLinesWithCheckIndent), mutate(function (pairs, parser, index) {
return parser.object(index, pairs);
})(_ref)));
UnclosedObjectLiteralsAllowed = cache(function (parser, index) {
if (!parser.preventUnclosedObjectLiteral.peek()) {
return Box(index);
}
});
IndentedUnclosedObjectLiteral = cache(sequential(
UnclosedObjectLiteralsAllowed,
IndentationRequired,
Space,
Newline,
EmptyLines,
[
"this",
retainIndent(sequential(
Advance,
CheckIndent,
["this", IndentedUnclosedObjectLiteralInner],
PopIndent
))
]
));
UnclosedArrayLiteralElement = sequential(AsterixChar, Space, [
"this",
oneOf(
retainIndent(sequential(PushFakeIndent(2), [
"this",
oneOf(
IndentedUnclosedObjectLiteralInner,
function (parser, index) {
return IndentedUnclosedArrayLiteralInner(parser, index);
},
SpreadOrExpression
)
])),
SpreadOrExpression
)
]);
IndentedUnclosedArrayLiteralInner = cache((_ref = separatedList(UnclosedArrayLiteralElement, sequential(MaybeComma, SomeEmptyLinesWithCheckIndent)), mutate(function (items, parser, index) {
return parser.Array(index, items);
})(_ref)));
IndentedUnclosedArrayLiteral = cache(sequential(
UnclosedObjectLiteralsAllowed,
IndentationRequired,
Space,
Newline,
EmptyLines,
[
"this",
retainIndent(sequential(
Advance,
CheckIndent,
["this", IndentedUnclosedArrayLiteralInner],
PopIndent
))
]
));
inAst = makeAlterStack.generic(Boolean)("inAst", true);
inEvilAst = makeAlterStack.generic(Boolean)("inEvilAst", true);
AstExpression = sequential(
word("ASTE"),
SHORT_CIRCUIT,
function (parser, index) {
if (!parser.inMacro.peek()) {
throw ParserError("Can only use ASTE inside of a macro", parser, index);
} else if (parser.inAst.peek()) {
throw ParserError("Can only use ASTE inside of another AST", parser, index);
} else {
return Box(index);
}
},
[
"this",
(function () {
var evilRule, rule;
rule = inAst(ExpressionOrAssignment);
evilRule = inEvilAst(rule);
return function (parser, index) {
var isEvil;
isEvil = ExclamationPointChar(parser, index);
if (isEvil) {
return evilRule(parser, isEvil.index);
} else {
return rule(parser, index);
}
};
}())
]
);
AstStatement = sequential(
word("AST"),
SHORT_CIRCUIT,
function (parser, index) {
if (!parser.inMacro.peek()) {
throw ParserError("Can only use AST inside of a macro", parser, index);
} else if (parser.inAst.peek()) {
throw ParserError("Can only use AST inside of another AST", parser, index);
} else {
return Box(index);
}
},
[
"this",
(function () {
var evilRule, rule;
rule = inAst(oneOf(Body, Statement));
evilRule = inEvilAst(rule);
return function (parser, index) {
var isEvil;
isEvil = ExclamationPointChar(parser, index);
if (isEvil) {
return evilRule(parser, isEvil.index);
} else {
return rule(parser, index);
}
};
}())
]
);
Ast = cache((_ref = oneOf(AstExpression, AstStatement), mutate(function (node, parser, index) {
var position;
position = parser.getPosition(index);
return MacroContext.constifyObject(node, position.line, position.column, parser.scope.peek());
})(_ref)));
PrimaryExpression = cache(oneOf.generic(Node)(
UnclosedObjectLiteral,
Literal,
ArrayLiteral,
ObjectLiteral,
SetLiteral,
MapLiteral,
Ast,
Parenthetical,
FunctionLiteral,
UseMacro,
Identifier,
CurrentArrayLength,
IndentedUnclosedObjectLiteral,
IndentedUnclosedArrayLiteral
));
convertInvocationOrAccess = (function () {
var linkTypes;
linkTypes = {
access: (function () {
var indexTypes;
indexTypes = {
multi: function (parser, index, child) {
return function (parent) {
var result, setParent, tmp, tmpIds;
setParent = parent;
tmpIds = [];
if (parent.cacheable) {
tmp = parser.makeTmp(index, "ref", parent.type(parser));
tmpIds.push(tmp.id);
setParent = parser.Assign(index, tmp, "=", parent.doWrap(parser));
parent = tmp;
}
result = parser.Array(index, (function () {
var _arr, _arr2, _len, element, i;
for (_arr = [], _arr2 = __toArray(child.elements), i = 0, _len = _arr2.length; i < _len; ++i) {
element = _arr2[i];
_arr.push(parser.Access(
index,
i === 0 ? setParent : parent,
element
));
}
return _arr;
}()));
if (tmpIds.length) {
return parser.TmpWrapper(index, result, tmpIds);
} else {
return result;
}
};
}
};
return function (parser, index, head, link, linkIndex, links) {
var bindAccess, child, existentialOp, makeAccess, result, setChild, setHead, tmp, tmpIds;
if (link.bind) {
bindAccess = function (parent, child) {
return parser.Call(
index,
parser.Ident(index, "__bind"),
[parent, child]
);
};
} else {
bindAccess = function (parent, child) {
return parser.Access(index, parent, child);
};
}
if (link.owns) {
tmpIds = [];
setHead = head;
if (head.cacheable) {
tmp = parser.makeTmp(index, "ref", head.type(parser));
tmpIds.push(tmp.id);
setHead = parser.Assign(index, tmp, "=", head.doWrap(parser));
head = tmp;
}
child = link.child;
setChild = child;
if (child.cacheable) {
tmp = parser.makeTmp(index, "ref", child.type(parser));
tmpIds.push(tmp.id);
setChild = parser.Assign(index, tmp, "=", child.doWrap(parser));
child = tmp;
}
result = parser.If(
index,
(function () {
var existentialOp, ownershipOp;
ownershipOp = parser.getMacroByLabel("ownership");
if (!ownershipOp) {
throw Error("Cannot use ownership access until the ownership operator has been defined");
}
if (link.existential) {
existentialOp = parser.getMacroByLabel("existential");
if (!existentialOp) {
throw Error("Cannot use existential access until the existential operator has been defined");
}
return parser.Binary(
index,
existentialOp.func(
{ op: "", node: setHead },
parser,
index
),
"&&",
ownershipOp.func(
{ left: head, op: "", right: setChild },
parser,
index
)
);
} else {
return ownershipOp.func(
{ left: setHead, op: "", right: setChild },
parser,
index
);
}
}()),
convertCallChain(
parser,
index,
bindAccess(head, child),
__num(linkIndex) + 1,
links
)
);
if (tmpIds.length) {
return parser.TmpWrapper(index, result, tmpIds);
} else {
return result;
}
} else {
switch (link.type) {
case "access":
makeAccess = function (parent) {
return bindAccess(parent, link.child);
};
break;
case "accessIndex":
if (!__owns.call(indexTypes, link.child.type)) {
throw Error("Unknown index type: " + __strnum(link.child.type));
}
makeAccess = indexTypes[link.child.type](parser, index, link.child);
break;
default: throw Error("Unknown link type: " + __strnum(link.type));
}
if (link.existential) {
tmpIds = [];
setHead = head;
if (head.cacheable) {
tmp = parser.makeTmp(index, "ref", head.type(parser));
tmpIds.push(tmp.id);
setHead = parser.Assign(index, tmp, "=", head.doWrap(parser));
head = tmp;
}
existentialOp = parser.getMacroByLabel("existential");
if (!existentialOp) {
throw Error("Cannot use existential access until the existential operator has been defined");
}
result = parser.If(
index,
existentialOp.func(
{ op: "", node: setHead },
parser,
index
),
convertCallChain(
parser,
index,
makeAccess(head),
__num(linkIndex) + 1,
links
)
);
if (tmpIds.length) {
return parser.TmpWrapper(index, result, tmpIds);
} else {
return result;
}
} else {
return convertCallChain(
parser,
index,
makeAccess(head),
__num(linkIndex) + 1,
links
);
}
}
};
}()),
call: function (parser, index, head, link, linkIndex, links) {
var child, parent, result, setChild, setHead, setParent, tmp, tmpIds;
if (!link.existential) {
return convertCallChain(
parser,
index,
parser.Call(
index,
head,
link.args,
link.isNew,
link.isApply
),
__num(linkIndex) + 1,
links
);
} else {
tmpIds = [];
setHead = head;
if (head instanceof AccessNode && !link.isApply && !link.isNew) {
parent = head.parent;
child = head.child;
setParent = parent;
setChild = child;
if (parent.cacheable) {
tmp = parser.makeTmp(index, "ref", parent.type(parser));
tmpIds.push(tmp.id);
setParent = parser.Assign(index, tmp, "=", parent.doWrap(parser));
parent = tmp;
}
if (child.cacheable) {
tmp = parser.makeTmp(index, "ref", child.type(parser));
tmpIds.push(tmp.id);
setChild = parser.Assign(index, tmp, "=", child.doWrap(parser));
child = tmp;
}
if (parent !== setParent || child !== setChild) {
setHead = parser.Access(index, setParent, setChild);
head = parser.Access(index, parent, child);
}
} else if (head.cacheable) {
tmp = parser.makeTmp(index, "ref", head.type(parser));
tmpIds.push(tmp.id);
setHead = parser.Assign(index, tmp, "=", head.doWrap(parser));
head = tmp;
}
result = parser.If(
index,
parser.Binary(
index,
parser.Unary(index, "typeof", setHead),
"===",
parser.Const(index, "function")
),
convertCallChain(
parser,
index,
parser.Call(
index,
head,
link.args,
link.isNew,
link.isApply
),
__num(linkIndex) + 1,
links
)
);
if (tmpIds.length) {
return parser.TmpWrapper(index, result, tmpIds);
} else {
return result;
}
}
}
};
linkTypes.accessIndex = linkTypes.access;
function convertCallChain(parser, index, head, linkIndex, links) {
var link;
if (!__lt(linkIndex, links.length)) {
return head;
} else {
link = links[linkIndex];
if (!__owns.call(linkTypes, link.type)) {
throw Error("Unknown call-chain link: " + __strnum(link.type));
}
return linkTypes[link.type](
parser,
index,
head,
link,
linkIndex,
links
);
}
}
return function (isNew, head, tail, parser, index) {
var _arr, _i, _len, _ref, links, part;
if (tail.length === 0 && !isNew && head.type === "normal") {
return head.node;
}
links = [];
if (head.type === "thisAccess") {
links.push({ type: "access", child: head.child, existential: head.existential });
}
for (_arr = __toArray(tail), _i = 0, _len = _arr.length; _i < _len; ++_i) {
part = _arr[_i];
switch (part.type) {
case "protoAccess":
case "protoAccessIndex":
links.push({
type: "access",
child: parser.Const(index, "prototype"),
existential: part.existential
});
links.push(((_ref = __import({}, part)).type = part.type === "protoAccess" ? "access" : "accessIndex", _ref));
break;
case "access":
case "accessIndex":
links.push(part);
break;
case "call":
if (isNew && part.isApply) {
throw ParserError("Cannot call with both new and @ at the same time", parser, index);
}
links.push(((_ref = __import({}, part)).isNew = isNew, _ref));
isNew = false;
break;
case "generic":
links.push({
type: "access",
child: parser.Const(index, "generic"),
existential: false
});
links.push({ type: "call", args: part.args, existential: false });
break;
default: throw Error("Unknown link type: " + __strnum(part.type));
}
}
if (isNew) {
links.push({
type: "call",
args: [],
existential: false,
isNew: true,
isApply: false
});
}
return convertCallChain(
parser,
index,
head.node,
0,
links
);
};
}());
InvocationOrAccessPart = cache(oneOf(
(_ref = sequential(
LessThanChar,
[
"this",
separatedList(
function (parser, index) {
return BasicInvocationOrAccess(parser, index);
},
Comma
)
],
GreaterThan
), mutate(function (args) {
return { type: "generic", args: args };
})(_ref)),
(_ref = sequential(
["existential", MaybeQuestionMarkChar],
["owns", MaybeExclamationPointChar],
["bind", MaybeAtSignChar],
EmptyLines,
Space,
["type", PeriodOrDoubleColonChar],
["child", IdentifierNameConstOrNumberLiteral]
), mutate(function (x) {
return {
type: x.type === "::" ? "protoAccess" : "access",
child: x.child,
existential: x.existential,
owns: x.owns,
bind: x.bind
};
})(_ref)),
(_ref = sequential(
["existential", MaybeQuestionMarkChar],
["owns", MaybeExclamationPointChar],
["bind", MaybeAtSignChar],
["type", maybe(DoubleColonChar)],
OpenSquareBracketChar,
[
"child",
(_ref2 = separatedList(
makeAlterStack.generic(Boolean)("asterixAsArrayLength", true)(Expression),
CommaOrNewline
), mutate(function (nodes) {
if (__num(nodes.length) > 1) {
return { type: "multi", elements: nodes };
} else {
return { type: "single", node: nodes[0] };
}
})(_ref2))
],
CloseSquareBracket
), mutate(function (x, parser, index) {
if (x.child.type === "single") {
return {
type: x.type === "::" ? "protoAccess" : "access",
child: x.child.node,
existential: x.existential,
owns: x.owns,
bind: x.bind
};
} else {
if (x.owns) {
throw ParserError("Cannot use ! when using a multiple or slicing index", parser, index);
} else if (x.bind) {
throw ParserError("Cannot use @ when using a multiple or slicing index", parser, index);
}
return {
type: x.type === "::" ? "protoAccessIndex" : "accessIndex",
child: x.child,
existential: x.existential
};
}
})(_ref)),
(_ref = sequential(
["existential", bool(MaybeQuestionMarkChar)],
["isApply", bool(MaybeAtSignChar)],
["args", InvocationArguments]
), mutate(function (x) {
return {
type: "call",
args: x.args,
existential: x.existential,
isNew: false,
isApply: x.isApply
};
})(_ref))
));
_ref = sequential(
["isNew", bool(maybe(word("new")))],
[
"head",
oneOf(
(_ref2 = sequential(
["node", ThisShorthandLiteral],
["existential", MaybeQuestionMarkChar],
["owns", MaybeExclamationPointChar],
["bind", MaybeAtSignChar],
["child", IdentifierNameConstOrNumberLiteral]
), mutate(function (x, parser, index) {
return __import({ type: "thisAccess" }, x);
})(_ref2)),
mutate(function (node) {
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
return { type: "normal", node: node };
})(PrimaryExpression)
)
],
["tail", zeroOrMore(InvocationOrAccessPart)]
);
BasicInvocationOrAccess = mutate(function (_p, parser, index) {
var head, isNew, tail;
isNew = _p.isNew;
head = _p.head;
tail = _p.tail;
return convertInvocationOrAccess(
isNew,
__import({}, head),
tail,
parser,
index
);
})(_ref);
SuperInvocation = cache((_ref = sequential(
word("super"),
SHORT_CIRCUIT,
[
"child",
maybe(oneOf(
sequential(EmptyLines, Space, Period, ["this", IdentifierNameConstOrNumberLiteral]),
sequential(
OpenSquareBracketChar,
["this", Expression],
CloseSquareBracket
)
))
],
["args", InvocationArguments]
), mutate(function (_p, parser, index) {
var args, child;
child = _p.child;
args = _p.args;
return parser.Super(index, child, args);
})(_ref)));
Eval = cache((_ref = sequential(word("eval"), SHORT_CIRCUIT, ["this", InvocationArguments]), mutate(function (args, parser, index) {
if (args.length !== 1) {
throw ParserError("Expected only one argument to eval, got " + __strnum(args.length), parser, index);
}
return parser.Eval(index, args[0]);
})(_ref)));
InvocationOrAccess = cache(oneOf(
function (parser, index) {
var args, dollar, inAst;
inAst = parser.inAst;
if (!inAst.peek()) {
return;
}
dollar = DollarSign(parser, Space(parser, index).index);
if (!dollar) {
return;
}
inAst.push(false);
try {
args = InvocationArguments(parser, dollar.index);
if (!args) {
return;
}
return Box(args.index, parser.Call(
index,
parser.Ident(index, "$"),
args.value
));
} finally {
inAst.pop();
}
},
BasicInvocationOrAccess,
SuperInvocation,
Eval
));
PostfixUnaryOperation = cache(function (parser, index) {
var _arr, _i, found, node, op, operator, rule;
node = InvocationOrAccess(parser, index);
if (!node) {
return;
}
found = true;
while (found) {
found = false;
for (_arr = __toArray(parser.postfixUnaryOperators()), _i = _arr.length; _i--; ) {
operator = _arr[_i];
rule = operator.rule;
op = rule(parser, node.index);
if (!op) {
continue;
}
node = Box(op.index, operator.func(
{ op: op.value, node: node.value },
parser,
index
));
found = true;
break;
}
}
return node;
});
PrefixUnaryOperation = cache(function (parser, index) {
var _arr, _i, node, op, operator, rule;
for (_arr = __toArray(parser.prefixUnaryOperators()), _i = _arr.length; _i--; ) {
operator = _arr[_i];
rule = operator.rule;
op = rule(parser, index);
if (!op) {
continue;
}
node = PrefixUnaryOperation(parser, op.index);
if (!node) {
continue;
}
return Box(node.index, operator.func(
{ op: op.value, node: node.value },
parser,
index
));
}
return PostfixUnaryOperation(parser, index);
});
BinaryOperationByPrecedence = (function () {
var precedenceCache;
precedenceCache = [];
return function (precedence) {
return precedenceCache[precedence] || (precedenceCache[precedence] = cache(function (parser, index) {
var _arr, _i, _i2, _len, currentIndex, head, invert, inverted, j, left, nextRule, node, op, operator, operators, part, result, right, rule, tail;
operators = parser.binaryOperators(precedence);
if (!operators) {
return PrefixUnaryOperation(parser, index);
}
nextRule = BinaryOperationByPrecedence(+precedence + 1);
head = nextRule(parser, index);
if (!head) {
return;
}
for (_arr = __toArray(operators), _i = _arr.length; _i--; ) {
operator = _arr[_i];
rule = operator.rule;
tail = [];
currentIndex = head.index;
while (true) {
inverted = false;
if (operator.invertible) {
invert = MaybeNotToken(parser, currentIndex);
if (invert.value) {
inverted = true;
}
currentIndex = invert.index;
}
op = rule(parser, currentIndex);
if (!op) {
break;
}
node = nextRule(parser, op.index);
if (!node) {
break;
}
currentIndex = node.index;
tail.push({ inverted: inverted, op: op.value, node: node.value });
if (operator.maximum && tail.length >= __num(operator.maximum)) {
break;
}
}
if (tail.length) {
if (!operator.rightToLeft) {
left = head.value;
for (_i2 = 0, _len = tail.length; _i2 < _len; ++_i2) {
part = tail[_i2];
left = operator.func(
{ left: left, inverted: part.inverted, op: part.op, right: part.node },
parser,
index
);
}
result = left;
} else {
right = tail[tail.length - 1].node;
for (j = tail.length; j--; ) {
part = tail[j];
right = operator.func(
{
left: j === 0 ? head.value : tail[j - 1].node,
inverted: part.inverted,
op: part.op,
right: right
},
parser,
index
);
}
result = right;
}
return Box(currentIndex, result);
}
}
return head;
}));
};
}());
Logic = cache(BinaryOperationByPrecedence(0));
ExpressionAsStatement = cache(oneOf(UseMacro, Logic));
Expression = cache(inExpression(ExpressionAsStatement));
LicenseComment = cache(sequential(
SpaceChars,
[
"this",
function (parser, index) {
var _len, ch, currentIndex, i, indent, l, len, line, lines, result, source;
source = parser.source;
if (source.charCodeAt(index) !== 47 || source.charCodeAt(+index + 1) !== 42 || source.charCodeAt(+index + 2) !== 33) {
return;
}
line = [47, 42, 33];
lines = [line];
len = source.length;
currentIndex = +index + 3;
for (; ; ++currentIndex) {
if (currentIndex >= len) {
throw ParserError("Multi-line license comment never ends", parser, index);
}
ch = source.charCodeAt(currentIndex);
if (ch === 42 && source.charCodeAt(currentIndex + 1) === 47) {
line.push(42, 47);
result = [];
for (i = 0, _len = lines.length; i < _len; ++i) {
l = lines[i];
if (i > 0) {
result.push("\n");
}
processCharCodes(l, result);
}
return Box(currentIndex + 2, parser.Comment(index, result.join("")));
} else if (ch === 13 || ch === 10 || ch === 8232 || ch === 8233) {
if (ch === 13 && data.charCodeAt(currentIndex + 1) === 10) {
++currentIndex;
}
lines.push(line = []);
indent = StringIndent(parser, currentIndex + 1);
if (!indent) {
throw ParserError("Improper indent in multi-line license comment", parser, currentIndex + 1);
}
currentIndex = indent.index - 1;
} else {
line.push(ch);
}
}
}
],
Space
));
_ref = sequential(
[
"type",
oneOf(
Identifier,
StringLiteral,
(_ref2 = sequential(
OpenParenthesis,
EmptyLines,
[
"this",
function (parser, index) {
return MacroSyntaxParameters(parser, index);
}
],
EmptyLines,
MaybeCommaOrNewline,
CloseParenthesis
), mutate(function (value, parser, index) {
return parser.SyntaxSequence(index, value);
})(_ref2)),
(_ref2 = sequential(
OpenParenthesis,
EmptyLines,
[
"this",
function (parser, index) {
return MacroSyntaxChoiceParameters(parser, index);
}
],
EmptyLines,
CloseParenthesis
), mutate(function (value, parser, index) {
return parser.SyntaxChoice(index, value);
})(_ref2))
)
],
[
"multiplier",
maybe(oneOf(symbol("?"), symbol("*"), symbol("+")))
]
);
MacroSyntaxParameterType = mutate(function (_p, parser, index) {
var multiplier, type;
type = _p.type;
multiplier = _p.multiplier;
if (multiplier) {
return parser.SyntaxMany(index, type, multiplier);
} else {
return type;
}
})(_ref);
MacroSyntaxParameter = oneOf(StringLiteral, (_ref = sequential(
[
"ident",
oneOf(ThisOrShorthandLiteral, Identifier)
],
[
"type",
maybe(sequential(word("as"), ["this", MacroSyntaxParameterType]))
]
), mutate(function (_p, parser, index) {
var ident, type;
ident = _p.ident;
type = _p.type;
return parser.SyntaxParam(index, ident, type);
})(_ref)));
MacroSyntaxParameters = separatedList(MacroSyntaxParameter, Comma);
MacroSyntaxChoiceParameters = separatedList(MacroSyntaxParameterType, Pipe);
MacroOptions = maybe(
(_ref = sequential(word("with"), ["this", UnclosedObjectLiteral]), mutate(function (object, parser, index) {
object = object.reduce(parser);
if (!object.isLiteral()) {
throw ParserError("Macro options must be a literal object without any logic, invocation, or anything else", parser, index);
}
return object.literalValue();
})(_ref)),
function () {
return {};
}
);
function addMacroSyntaxParametersToScope(params, scope) {
var _arr, _i, _len, ident, param;
for (_arr = __toArray(params), _i = 0, _len = _arr.length; _i < _len; ++_i) {
param = _arr[_i];
if (param instanceof SyntaxParamNode) {
ident = param.ident;
if (ident instanceof IdentNode) {
scope.add(ident, true, Type.any);
}
}
}
}
MacroSyntax = sequential(
CheckIndent,
word("syntax"),
SHORT_CIRCUIT,
function (parser, index) {
var body, options, params, scope;
scope = parser.pushScope(true);
params = MacroSyntaxParameters(parser, index);
if (!params) {
throw SHORT_CIRCUIT;
}
options = MacroOptions(parser, params.index);
parser.startMacroSyntax(index, params.value, options.value);
addMacroSyntaxParametersToScope(params, scope);
scope.add(
parser.Ident(index, "macroName"),
true,
Type.string
);
body = FunctionBody(parser, options.index);
if (!body) {
throw SHORT_CIRCUIT;
}
parser.macroSyntax(
index,
"syntax",
params.value,
options.value,
body.value
);
parser.popScope();
return Box(body.index);
},
Space,
CheckStop
);
MacroBody = oneOf(
sequential(
function (parser, index) {
if (parser.options.noindent) {
return Colon(parser, index);
} else {
return Box(index);
}
},
Space,
Newline,
EmptyLines,
retainIndent(sequential(
function (parser, index) {
if (parser.options.noindent) {
return MaybeAdvance(parser, index);
} else {
return Advance(parser, index);
}
},
separatedList(MacroSyntax, SomeEmptyLines),
PopIndent
)),
End
),
function (parser, index) {
var _arr, _i, body, options, param, params, scope;
scope = parser.pushScope(true);
params = ParameterSequence(parser, index);
if (!params) {
throw SHORT_CIRCUIT;
}
for (_arr = __toArray(params.value), _i = _arr.length; _i--; ) {
param = _arr[_i];
addParamToScope(scope, param, true);
}
options = MacroOptions(parser, params.index);
body = FunctionBody(parser, options.index);
if (!body) {
throw SHORT_CIRCUIT;
}
parser.macroSyntax(
index,
"call",
params.value,
options.value,
body.value
);
parser.popScope();
return Box(body.index, parser.Nothing(index));
}
);
inMacro = makeAlterStack.generic(Boolean)("inMacro", true);
_DefineMacro = sequential(word("macro"), [
"this",
inMacro(function (parser, index) {
var body, names;
names = MacroNames(parser, index);
if (!names) {
return;
}
parser.enterMacro(index, names.value);
body = MacroBody(parser, names.index);
parser.exitMacro();
return Box(body.index, parser.Nothing(index));
})
]);
DefineSyntax = (function () {
var topRule;
topRule = sequential(
word("define"),
word("syntax"),
SHORT_CIRCUIT,
["name", Identifier],
EqualSign,
["value", MacroSyntaxParameters]
);
return inMacro(function (parser, index) {
var body, top;
top = topRule(parser, index);
if (!top) {
return;
}
body = FunctionBody(parser, top.index);
parser.defineSyntax(index, top.value.name.name, top.value.value, body != null ? body.value : void 0);
return Box(
body ? body.index : top.index,
parser.Nothing(index)
);
});
}());
_ref = sequential(
word("define"),
word("helper"),
SHORT_CIRCUIT,
["name", Identifier],
[
"value",
oneOf(
sequential(EqualSign, ["this", Expression]),
FunctionDeclaration
)
]
);
DefineHelper = mutate(function (_p, parser, index) {
var name, value;
name = _p.name;
value = _p.value;
parser.defineHelper(index, name, value);
return parser.Nothing(index);
})(_ref);
DefineOperator = (function () {
var mainRule;
mainRule = sequential(
word("define"),
word("operator"),
SHORT_CIRCUIT,
[
"type",
oneOf(word("binary"), word("assign"), word("unary"))
],
[
"ops",
separatedList(NameOrSymbol, Comma)
],
["options", MacroOptions]
);
return inMacro(function (parser, index) {
var _ref, body, ops, options, ret, scope, type, x;
x = mainRule(parser, index);
if (!x) {
return;
}
type = (_ref = x.value).type;
ops = _ref.ops;
options = _ref.options;
scope = parser.pushScope(true);
switch (type) {
case "binary":
case "assign":
scope.add(
parser.Ident(index, "left"),
true,
Type.any
);
scope.add(
parser.Ident(index, "op"),
true,
Type.string
);
scope.add(
parser.Ident(index, "right"),
true,
Type.any
);
break;
case "unary":
scope.add(
parser.Ident(index, "op"),
true,
Type.string
);
scope.add(
parser.Ident(index, "node"),
true,
Type.any
);
break;
}
body = FunctionBody(parser, x.index);
if (!body) {
throw SHORT_CIRCUIT;
}
switch (type) {
case "binary":
ret = parser.defineBinaryOperator(index, ops, options, body.value);
break;
case "assign":
ret = parser.defineAssignOperator(index, ops, options, body.value);
break;
case "unary":
ret = parser.defineUnaryOperator(index, ops, options, body.value);
break;
default: throw Error();
}
parser.popScope();
return Box(body.index, parser.Nothing(index));
});
}());
DefineMacro = cache(oneOf.generic(NothingNode)(_DefineMacro, DefineSyntax, DefineHelper, DefineOperator));
_ref = sequential(
word("const"),
SHORT_CIRCUIT,
["name", Name],
EqualSign,
["value", Expression]
);
DefineConstLiteral = mutate(function (_p, parser, index) {
var name, value;
name = _p.name;
value = _p.value;
value = parser.macroExpandAll(value.reduce(parser));
if (!value.isConst()) {
throw ParserError("const value must be a constant.", this, index);
}
parser.defineConst(index, name, value.constValue());
return parser.Nothing(index);
})(_ref);
Statement = cache(sequential(
[
"this",
inStatement(oneOf.generic(Node)(
LicenseComment,
DefineMacro,
DefineConstLiteral,
Assignment,
ExpressionAsStatement
))
],
Space
));
function unprettyText(text) {
if (typeof text !== "string") {
throw TypeError("Expected text to be a String, got " + __typeof(text));
}
return text.replace(/\s+/g, " ");
}
function EmbeddedReadLiteralText(parser, index) {
var c, codes, currentIndex, len, source, text;
source = parser.source;
len = source.length;
currentIndex = index;
codes = [];
for (; currentIndex < len; ++currentIndex) {
if (EmbeddedOpen(parser, currentIndex) || EmbeddedOpenWrite(parser, currentIndex) || EmbeddedOpenComment(parser, currentIndex)) {
break;
}
c = source.charCodeAt(currentIndex);
if (c === 13 && source.charCodeAt(currentIndex + 1) === 10) {
c = 10;
++currentIndex;
}
codes.push(c);
}
if (currentIndex === index) {
return;
}
text = codesToString(codes);
if (parser.options.embeddedUnpretty) {
text = unprettyText(text);
}
return Box(currentIndex, parser.EmbedWrite(
index,
parser.Const(index, text),
false
));
}
makeEmbeddedRule = (function () {
var rules;
function make(text) {
var _arr, codes, i, len;
if (typeof text !== "string") {
throw TypeError("Expected text to be a String, got " + __typeof(text));
}
len = text.length;
for (_arr = [], i = 0; i < len; ++i) {
_arr.push(text.charCodeAt(i));
}
codes = _arr;
return function (parser, index) {
var i, source;
source = parser.source;
for (i = 0; i < len; ++i) {
if (source.charCodeAt(__num(index) + i) !== codes[i]) {
return;
}
}
return Box(+index + len, text);
};
}
rules = __create(null);
function getEmbeddedRule(text) {
return rules[text] || (rules[text] = make(text));
}
return function (key, defaultValue) {
if (typeof key !== "string") {
throw TypeError("Expected key to be a String, got " + __typeof(key));
}
return function (parser, index) {
var text;
text = parser.options[key];
if (typeof text !== "string") {
text = defaultValue;
}
return getEmbeddedRule(text)(parser, index);
};
};
}());
EmbeddedOpenComment = cache(makeEmbeddedRule("embeddedOpenComment", "<%--"));
EmbeddedCloseComment = makeEmbeddedRule("embeddedCloseComment", "--%>");
function EmbeddedComment(parser, index) {
var any, close, currentIndex, len, open;
open = EmbeddedOpenComment(parser, index);
if (!open) {
return;
}
currentIndex = open.index;
len = parser.source.length;
while (currentIndex < len) {
close = EmbeddedCloseComment(parser, currentIndex);
if (close) {
currentIndex = close.index;
break;
}
any = AnyChar(parser, currentIndex);
if (!any) {
break;
}
if (currentIndex === any.index) {
throw Error("Infinite loop detected");
}
currentIndex = any.index;
}
return Box(currentIndex, parser.Nothing(index));
}
EmbeddedOpen = cache(makeEmbeddedRule("embeddedOpen", "<%"));
EmbeddedClose = cache(sequential(EmptyLines, Space, oneOf(Eof, makeEmbeddedRule("embeddedClose", "%>"))));
EmbeddedOpenWrite = cache(makeEmbeddedRule("embeddedOpenWrite", "<%="));
EmbeddedCloseWrite = cache(sequential(EmptyLines, Space, oneOf(Eof, makeEmbeddedRule("embeddedCloseWrite", "%>"))));
ColonEmbeddedClose = cache(sequential(Colon, EmbeddedClose));
ColonEmbeddedCloseWrite = cache(sequential(Colon, EmbeddedCloseWrite));
NotEmbeddedOpenComment = cache(except(EmbeddedOpenComment));
NotEmbeddedOpenWrite = cache(except(EmbeddedOpenWrite));
disallowEmbeddedText = makeAlterStack.generic(Boolean)("allowEmbeddedText", false);
EmbeddedWriteExpression = disallowEmbeddedText((_ref = sequential(
NotEmbeddedOpenComment,
EmbeddedOpenWrite,
["this", Expression],
EmbeddedCloseWrite
), mutate(function (node, parser, index) {
return parser.EmbedWrite(index, node, true);
})(_ref)));
EmbeddedLiteralTextInnerPart = oneOf(EmbeddedComment, EmbeddedWriteExpression, EmbeddedReadLiteralText);
EmbeddedLiteralText = cache((_ref = sequential(
function (parser, index) {
if (parser.options.embedded && parser.allowEmbeddedText.peek() && index < parser.source.length) {
return Box(index);
}
},
EmbeddedClose,
["this", zeroOrMore(EmbeddedLiteralTextInnerPart)],
oneOf(Eof, sequential(NotEmbeddedOpenComment, NotEmbeddedOpenWrite, EmbeddedOpen))
), mutate(function (nodes, parser, index) {
return parser.Block(index, nodes);
})(_ref)));
Semicolon = cache(withSpace(SemicolonChar));
Semicolons = cache(zeroOrMore(Semicolon, true));
Line = cache((function () {
var SemicolonsStatement;
SemicolonsStatement = sequential(Semicolons, ["this", Statement]);
return function (parser, index) {
var currentIndex, endSemis, indent, needSemicolon, parts, ret;
indent = CheckIndent(parser, index);
if (!indent) {
return;
}
currentIndex = index;
parts = [];
needSemicolon = false;
while (true) {
ret = EmbeddedLiteralText(parser, currentIndex);
if (ret) {
needSemicolon = false;
parts.push(ret.value);
currentIndex = ret.index;
} else {
ret = needSemicolon ? SemicolonsStatement(parser, currentIndex) : Statement(parser, currentIndex);
if (ret) {
needSemicolon = true;
parts.push(ret.value);
currentIndex = ret.index;
} else {
break;
}
}
}
if (parts.length === 0) {
return;
}
endSemis = Semicolons(parser, currentIndex);
if (endSemis) {
currentIndex = endSemis.index;
}
return Box(currentIndex, parts);
};
}()));
function _BlockMutator(lines, parser, index) {
var _arr, _arr2, _len, _len2, i, item, j, nodes, part;
nodes = [];
for (_arr = __toArray(lines), i = 0, _len = _arr.length; i < _len; ++i) {
item = _arr[i];
for (_arr2 = __toArray(item), j = 0, _len2 = _arr2.length; j < _len2; ++j) {
part = _arr2[j];
if (!(part instanceof Node)) {
throw TypeError("Expected lines[" + i + "][" + j + "] to be a Node, got " + __typeof(part));
} else if (part instanceof BlockNode && item.label == null) {
nodes.push.apply(nodes, __toArray(part.nodes));
} else if (!(part instanceof NothingNode)) {
nodes.push(part);
}
}
}
switch (nodes.length) {
case 0: return parser.Nothing(index);
case 1: return nodes[0];
default:
return parser.Block(index, nodes);
}
}
RootInnerP = __promise(function (parser, index) {
var _e, _send, _state, _step, _throw, currentIndex, head, item, result, separator;
_state = 0;
function _close() {
_state = 9;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
parser.clearCache();
head = Line(parser, index);
_state = !head ? 9 : 1;
break;
case 1:
result = [head.value];
currentIndex = head.index;
++_state;
case 2: ++_state;
case 3:
parser.clearCache();
_state = !parser.options.sync ? 4 : 5;
break;
case 4:
++_state;
return { done: false, value: __defer.fulfilled(void 0) };
case 5:
separator = SomeEmptyLines(parser, currentIndex);
_state = !separator ? 8 : 6;
break;
case 6:
item = Line(parser, separator.index);
_state = !item ? 8 : 7;
break;
case 7:
currentIndex = item.index;
result.push(item.value);
_state = 2;
break;
case 8:
parser.clearCache();
++_state;
return {
done: true,
value: Box(currentIndex, _BlockMutator(result, parser, index))
};
case 9:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
_Block = mutate(_BlockMutator, separatedList(Line, SomeEmptyLines));
Block = oneOf(
sequential(CheckIndent, [
"this",
oneOf.generic(Node)(IndentedUnclosedObjectLiteralInner, IndentedUnclosedArrayLiteralInner)
]),
_Block
);
EmbeddedBlock = sequential(
NotEmbeddedOpenWrite,
NotEmbeddedOpenComment,
EmbeddedOpen,
["this", _Block],
EmbeddedClose
);
EmbeddedLiteralTextInnerPartWithBlock = oneOf(EmbeddedLiteralTextInnerPart, EmbeddedBlock);
EmbeddedRootInnerP = __promise(function (parser, index) {
var _e, _send, _state, _step, _throw, currentIndex, item, nodes;
_state = 0;
function _close() {
_state = 7;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
nodes = [];
currentIndex = index;
++_state;
case 1: ++_state;
case 2:
parser.clearCache();
_state = !parser.options.sync ? 3 : 4;
break;
case 3:
++_state;
return { done: false, value: __defer.fulfilled(void 0) };
case 4:
item = EmbeddedLiteralTextInnerPartWithBlock(parser, currentIndex);
_state = !item ? 6 : 5;
break;
case 5:
nodes.push(item.value);
if (currentIndex === item.index) {
throw Error("Infinite loop detected");
}
currentIndex = item.index;
_state = 1;
break;
case 6:
parser.clearCache();
++_state;
return {
done: true,
value: Box(currentIndex, parser.Block(index, nodes))
};
case 7:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
EndNoIndent = sequential(EmptyLines, Space, maybe(Semicolons), word("end"));
BodyWithIndent = retainIndent(sequential(
Space,
Newline,
EmptyLines,
Advance,
["this", Block],
PopIndent
));
BodyNoIndentNoEnd = sequential(
function (parser, index) {
if (ColonNewline(parser, index) || parser.options.embedded && (ColonEmbeddedClose(parser, index) || ColonEmbeddedCloseWrite(parser, index))) {
return Box(index);
}
},
Colon,
EmptyLines,
[
"this",
function (parser, index) {
var indent;
indent = parser.indent;
indent.push(+indent.peek() + 1);
try {
return Block(parser, index);
} finally {
indent.pop();
}
}
]
);
BodyNoIndent = sequential(
["this", BodyNoIndentNoEnd],
EndNoIndent
);
Body = cache(function (parser, index) {
var ret, scope;
scope = parser.pushScope(true);
if (parser.options.noindent) {
ret = BodyNoIndent(parser, index);
} else {
ret = BodyWithIndent(parser, index);
}
parser.popScope();
return ret;
});
BodyNoEnd = cache(function (parser, index) {
var ret, scope;
scope = parser.pushScope(true);
if (parser.options.noindent) {
ret = BodyNoIndentNoEnd(parser, index);
} else {
ret = BodyWithIndent(parser, index);
}
parser.popScope();
return ret;
});
BOM = maybe(character('"\ufeff"', 65279));
Shebang = maybe(sequential(HashSignChar, ExclamationPointChar, zeroOrMore(anyExcept(Newline))));
RootP = __promise(function (parser) {
var _e, _send, _state, _step, _throw, bom, empty, emptyAgain, endSpace, root, shebang;
_state = 0;
function _close() {
_state = 8;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (!(parser instanceof Parser)) {
throw TypeError("Expected parser to be a " + __name(Parser) + ", got " + __typeof(parser));
}
bom = BOM(parser, 0);
shebang = Shebang(parser, bom.index);
empty = EmptyLines(parser, shebang.index);
_state = Eof(parser, empty.index) ? 1 : 2;
break;
case 1:
_state = 8;
return {
done: true,
value: Box(empty.index, parser.Root(empty.index, parser.options.filename, parser.Nothing(empty.index)))
};
case 2:
parser.clearCache();
_state = parser.options.sync ? 3 : 4;
break;
case 3:
root = RootInnerP.sync(parser, empty.index);
_state = 6;
break;
case 4:
++_state;
return {
done: false,
value: RootInnerP(parser, empty.index)
};
case 5:
root = _received;
++_state;
case 6:
parser.clearCache();
_state = !root ? 8 : 7;
break;
case 7:
emptyAgain = EmptyLines(parser, root.index);
endSpace = Space(parser, emptyAgain.index);
parser.clearCache();
++_state;
return {
done: true,
value: Box(endSpace.index, parser.Root(empty.index, parser.options.filename, root.value))
};
case 8:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
EmbeddedRootP = __promise(function (parser) {
var _e, _send, _state, _step, _throw, bom, root, shebang;
_state = 0;
function _close() {
_state = 6;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (!(parser instanceof Parser)) {
throw TypeError("Expected parser to be a " + __name(Parser) + ", got " + __typeof(parser));
}
bom = BOM(parser, 0);
shebang = Shebang(parser, bom.index);
parser.clearCache();
_state = parser.options.sync ? 1 : 2;
break;
case 1:
root = EmbeddedRootInnerP.sync(parser, shebang.index);
_state = 4;
break;
case 2:
++_state;
return {
done: false,
value: EmbeddedRootInnerP(parser, shebang.index)
};
case 3:
root = _received;
++_state;
case 4:
parser.clearCache();
_state = !root ? 6 : 5;
break;
case 5:
++_state;
return {
done: true,
value: Box(root.index, parser.Root(
0,
parser.options.filename,
root.value,
true,
parser.inGenerator.peek()
))
};
case 6:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
EmbeddedRootGeneratorP = __promise(function (parser) {
var _e, _send, _state, _step, _throw, result;
_state = 0;
function _close() {
_state = 5;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (!(parser instanceof Parser)) {
throw TypeError("Expected parser to be a " + __name(Parser) + ", got " + __typeof(parser));
}
parser.inGenerator.push(true);
_state = parser.options.sync ? 1 : 2;
break;
case 1:
result = EmbeddedRootP.sync(parser);
_state = 4;
break;
case 2:
++_state;
return { done: false, value: EmbeddedRootP(parser) };
case 3:
result = _received;
++_state;
case 4:
parser.inGenerator.pop();
++_state;
return { done: true, value: result };
case 5:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
AnyObjectLiteral = cache(oneOf(UnclosedObjectLiteral, ObjectLiteral, IndentedUnclosedObjectLiteral));
AnyArrayLiteral = cache(oneOf(ArrayLiteral, IndentedUnclosedArrayLiteral));
DedentedBody = cache(withSpace(oneOf(
sequential(Newline, EmptyLines, ["this", Block]),
sequential(
function (parser, index) {
if (parser.options.embedded) {
return Box(index);
}
},
check(EmbeddedClose),
EmptyLines,
["this", Block]
),
Nothing
)));
Stack = __genericFunc(1, function (T) {
var _instanceof_T;
_instanceof_T = __getInstanceof(T);
return (function () {
var _Stack_prototype;
function Stack(initial) {
var _this;
_this = this instanceof Stack ? this : __create(_Stack_prototype);
if (!_instanceof_T(initial)) {
throw TypeError("Expected initial to be a " + __name(T) + ", got " + __typeof(initial));
}
_this.initial = initial;
_this.data = [];
return _this;
}
_Stack_prototype = Stack.prototype;
Stack.displayName = "Stack<" + (T != null ? __name(T) : "") + ">";
_Stack_prototype.count = function () {
return this.data.length;
};
_Stack_prototype.push = function (value) {
if (!_instanceof_T(value)) {
throw TypeError("Expected value to be a " + __name(T) + ", got " + __typeof(value));
}
this.data.push(value);
};
_Stack_prototype.pop = function () {
var data;
data = this.data;
if (data.length === 0) {
throw Error("Cannot pop");
}
return data.pop();
};
_Stack_prototype.canPop = function () {
return __num(this.data.length) > 0;
};
_Stack_prototype.peek = function () {
var data, len;
data = this.data;
len = data.length;
if (len === 0) {
return this.initial;
} else {
return data[__num(len) - 1];
}
};
return Stack;
}());
});
function makeMacroHolder() {
return MacroHolder(
{
Logic: preventUnclosedObjectLiteral(Logic),
Expression: Expression,
Assignment: Assignment,
ExpressionOrAssignment: ExpressionOrAssignment,
ExpressionOrAssignmentOrBody: ExpressionOrAssignmentOrBody,
FunctionDeclaration: FunctionDeclaration,
Statement: Statement,
Body: Body,
BodyNoEnd: BodyNoEnd,
GeneratorBody: GeneratorBody,
GeneratorBodyNoEnd: GeneratorBodyNoEnd,
End: End,
Identifier: Identifier,
SimpleAssignable: IdentifierOrSimpleAccess,
Parameter: Parameter,
InvocationArguments: InvocationArguments,
ObjectLiteral: AnyObjectLiteral,
ArrayLiteral: AnyArrayLiteral,
DedentedBody: DedentedBody,
ObjectKey: ObjectKey,
Type: TypeReference,
NoSpace: NoSpace,
ColonEqual: ColonEqual
},
macroName,
wordOrSymbol,
oneOf,
sequential
);
}
Parser = (function () {
var _Parser_prototype, ASSIGN_OPERATOR, BINARY_OPERATOR, DEFINE_SYNTAX, deserializeParams, deserializeParamType, macroDeserializers, macroSyntaxConstLiterals, macroSyntaxTypes, UNARY_OPERATOR;
function Parser(source, macros, options) {
var _this;
_this = this instanceof Parser ? this : __create(_Parser_prototype);
if (source == null) {
source = "";
} else if (typeof source !== "string") {
throw TypeError("Expected source to be a String, got " + __typeof(source));
}
_this.source = source;
if (macros == null) {
macros = makeMacroHolder();
} else if (!(macros instanceof MacroHolder)) {
throw TypeError("Expected macros to be a " + __name(MacroHolder) + ", got " + __typeof(macros));
}
_this.macros = macros;
if (options == null) {
options = {};
} else if (typeof options !== "object" || options === null) {
throw TypeError("Expected options to be an Object, got " + __typeof(options));
}
_this.options = options;
_this.indent = Stack.generic(Number)(0);
_this.position = Stack.generic(String)("statement");
_this.inAst = Stack.generic(Boolean)(false);
_this.inGenerator = Stack.generic(Boolean)(false);
_this.inFunctionTypeParams = Stack.generic(Boolean)(false);
_this.preventUnclosedObjectLiteral = Stack.generic(Boolean)(false);
_this.allowEmbeddedText = Stack.generic(Boolean)(true);
_this.inMacro = Stack.generic(Boolean)(false);
_this.inAst = Stack.generic(Boolean)(false);
_this.inEvilAst = Stack.generic(Boolean)(false);
_this.asterixAsArrayLength = Stack.generic(Boolean)(false);
_this.scope = Stack.generic(Scope)(Scope(null, true));
_this.failureMessages = [];
_this.failureIndex = -1;
_this.calculateLineInfo();
_this.cache = [];
_this.currentTmpId = -1;
return _this;
}
_Parser_prototype = Parser.prototype;
Parser.displayName = "Parser";
_Parser_prototype.buildError = function (message, node) {
var index;
if (typeof message !== "string") {
throw TypeError("Expected message to be a String, got " + __typeof(message));
}
if (typeof node !== "number" && !(node instanceof Node)) {
throw TypeError("Expected node to be one of Number or " + __name(Node) + ", got " + __typeof(node));
}
if (typeof node === "number") {
index = node;
} else {
index = this.indexFromPosition(node.line, node.column);
}
return MacroError(message, this, index);
};
_Parser_prototype.makeTmp = function (index, name, type) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (type == null) {
type = Type.any;
} else if (!(type instanceof Type)) {
throw TypeError("Expected type to be a " + __name(Type) + ", got " + __typeof(type));
}
return this.Tmp(index, this.currentTmpId = __num(this.currentTmpId) + 1, name, type);
};
_Parser_prototype.calculateLineInfo = function () {
var index, lineInfo, match, newlineRegex, source;
newlineRegex = /(?:\r\n?|[\n\u2028\u2029])/g;
source = this.source;
lineInfo = this.lineInfo = [];
index = 0;
lineInfo.push(0);
while (true) {
match = newlineRegex.exec(source);
if (!match) {
break;
}
index = __num(match.index) + __num(match[0].length);
lineInfo.push(index);
}
};
_Parser_prototype.indexFromPosition = function (line, column) {
var lineInfo;
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
lineInfo = this.lineInfo[line - 1];
if (lineInfo != null) {
return __num(lineInfo) + column - 1;
} else {
return 0;
}
};
_Parser_prototype.getPosition = function (index) {
var current, i, left, lineInfo, right;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
lineInfo = this.lineInfo;
left = 0;
right = lineInfo.length;
while (left !== right) {
i = Math.floor((left + right) / 2);
current = lineInfo[i];
if (current > index) {
right = i;
} else if (current < index) {
if (left === i) {
break;
}
left = i;
} else {
left = i;
break;
}
}
return { line: left + 1, column: index - __num(lineInfo[left]) + 1 };
};
_Parser_prototype.getLine = function (index) {
if (index == null) {
index = this.index;
} else if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
return this.getPosition(index).line;
};
_Parser_prototype.fail = function (message, index) {
if (typeof message !== "string") {
throw TypeError("Expected message to be a String, got " + __typeof(message));
}
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
if (index > __num(this.failureIndex)) {
this.failureMessages = [];
this.failureIndex = index;
}
if (index >= __num(this.failureIndex)) {
this.failureMessages.push(message);
}
};
function buildExpected(messages) {
var errors;
errors = unique(messages).sort(function (a, b) {
return __cmp(a.toLowerCase(), b.toLowerCase());
});
switch (errors.length) {
case 0: return "End of input";
case 1: return errors[0];
case 2: return __strnum(errors[0]) + " or " + __strnum(errors[1]);
default:
return __strnum(__slice.call(errors, 0, -1).join(", ")) + ", or " + __strnum(errors[__num(errors.length) - 1]);
}
}
_Parser_prototype.getFailure = function (index) {
var lastToken, source;
if (index == null) {
index = this.failureIndex;
} else if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
source = this.source;
if (index < __num(source.length)) {
lastToken = JSON.stringify(source.substring(index, index + 20));
} else {
lastToken = "end-of-input";
}
return ParserError("Expected " + __strnum(buildExpected(this.failureMessages)) + ", but " + __str(lastToken) + " found", this, index);
};
_Parser_prototype.pushScope = function (isTop, parent) {
var scope;
if (isTop == null) {
isTop = false;
} else if (typeof isTop !== "boolean") {
throw TypeError("Expected isTop to be a Boolean, got " + __typeof(isTop));
}
if (parent == null) {
parent = null;
} else if (!(parent instanceof Scope)) {
throw TypeError("Expected parent to be one of " + (__name(Scope) + " or null") + ", got " + __typeof(parent));
}
scope = (parent || this.scope.peek()).clone(isTop);
this.scope.push(scope);
return scope;
};
_Parser_prototype.popScope = function () {
this.scope.pop();
};
_Parser_prototype.getPackageVersion = function () {
var _ref;
if ((_ref = this._packageVersion) == null) {
return this._packageVersion = getPackageVersion(this.options.filename);
} else {
return _ref;
}
};
_Parser_prototype.hasMacroOrOperator = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
return this.macros.hasMacroOrOperator(name);
};
_Parser_prototype.assignOperators = function () {
return this.macros.assignOperators;
};
_Parser_prototype.allBinaryOperators = function () {
return this.macros.allBinaryOperators();
};
_Parser_prototype.binaryOperators = function (precedence) {
return this.macros.binaryOperators[precedence];
};
_Parser_prototype.prefixUnaryOperators = function () {
return this.macros.prefixUnaryOperators;
};
_Parser_prototype.postfixUnaryOperators = function () {
return this.macros.postfixUnaryOperators;
};
_Parser_prototype.getMacroByName = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
return this.macros.getByName(name);
};
_Parser_prototype.getMacroByLabel = function (label) {
if (typeof label !== "string") {
throw TypeError("Expected label to be a String, got " + __typeof(label));
}
return this.macros.getByLabel(label);
};
_Parser_prototype.enterMacro = function (index, names) {
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
if (!names) {
throw Error("Must provide a macro name");
}
if (this.currentMacro) {
throw ParserError("Attempting to define a macro " + __strnum(quote(String(names))) + " inside a macro " + __strnum(quote(String(this.currentMacro))), this, index);
}
this.currentMacro = names;
};
_Parser_prototype.exitMacro = function () {
if (!this.currentMacro) {
throw Error("Attempting to exit a macro when not in one");
}
this.currentMacro = null;
};
_Parser_prototype.defineHelper = function (i, name, value) {
var _ref, dependencies, helper, node, translator, type;
if (!(name instanceof IdentNode)) {
throw TypeError("Expected name to be a " + __name(IdentNode) + ", got " + __typeof(name));
}
if (!(value instanceof Node)) {
throw TypeError("Expected value to be a " + __name(Node) + ", got " + __typeof(value));
}
translator = require("./jstranslator");
node = this.macroExpandAll(value).reduce(this);
type = node.type(this);
helper = (_ref = translator.defineHelper(this.macros, name, node, type)).helper;
dependencies = _ref.dependencies;
if (this.options.serializeMacros) {
this.macros.addSerializedHelper(name.name, helper, type, dependencies);
}
};
macroSyntaxConstLiterals = {
",": Comma,
";": Semicolon,
":": Colon,
":=": ColonEqual,
"": Nothing,
"\n": SomeEmptyLinesWithCheckIndent,
"<": LessThan,
">": GreaterThan,
"(": OpenParenthesis,
")": CloseParenthesis,
"[": OpenSquareBracket,
"]": CloseSquareBracket,
"{": OpenCurlyBrace,
"}": CloseCurlyBrace,
end: End
};
function reduceObject(o, obj) {
var _arr, _arr2, _i, _len, item, k, result, v;
if (__isArray(obj)) {
for (_arr = [], _arr2 = __toArray(obj), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
item = _arr2[_i];
_arr.push(reduceObject(o, item));
}
return _arr;
} else if (obj instanceof Node) {
return obj.reduce(o);
} else if (typeof obj === "object" && obj !== null) {
result = {};
for (k in obj) {
if (__owns.call(obj, k)) {
v = obj[k];
result[k] = reduceObject(o, v);
}
}
return result;
} else {
return obj;
}
}
function makeMacroRoot(index, params, body) {
return this.Root(index, void 0, this.Return(
index,
this.Function(
index,
[
params,
this.Param(
index,
this.Ident(index, "__wrap"),
void 0,
false,
true,
void 0
),
this.Param(
index,
this.Ident(index, "__node"),
void 0,
false,
true,
void 0
)
],
body,
true,
false
),
false
));
}
function serializeParamType(asType) {
if (asType instanceof IdentNode) {
return ["ident", asType.name];
} else if (asType instanceof SyntaxSequenceNode) {
return ["sequence"].concat(__toArray(fixArray(serializeParams(asType.params))));
} else if (asType instanceof SyntaxChoiceNode) {
return ["choice"].concat((function () {
var _arr, _arr2, _i, _len, choice;
for (_arr = [], _arr2 = __toArray(asType.choices), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
choice = _arr2[_i];
_arr.push(serializeParamType(choice));
}
return _arr;
}()));
} else if (asType.isConst()) {
return ["const", asType.constValue()];
} else if (asType instanceof SyntaxManyNode) {
return ["many", asType.multiplier].concat(__toArray(serializeParamType(asType.inner)));
} else {
throw Error("Unknown param type: " + __typeof(asType));
}
}
function serializeParams(params) {
return simplifyArray((function () {
var _arr, _arr2, _i, _len, ident, param, value;
for (_arr = [], _arr2 = __toArray(params), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
param = _arr2[_i];
if (param.isConst()) {
_arr.push(["const", param.constValue()]);
} else if (param instanceof SyntaxParamNode) {
ident = param.ident;
if (ident instanceof IdentNode) {
value = ["ident", ident.name];
} else if (ident instanceof ThisNode) {
value = ["this"];
} else {
throw Error();
}
if (param.asType) {
value.push.apply(value, __toArray(serializeParamType(param.asType)));
}
_arr.push(value);
} else {
throw Error();
}
}
return _arr;
}()));
}
deserializeParamType = (function () {
var deserializeParamTypeByType;
deserializeParamTypeByType = {
ident: function (scope, name) {
return IdentNode(0, 0, scope, name);
},
sequence: function (scope) {
var items;
items = __slice.call(arguments, 1);
return SyntaxSequenceNode(0, 0, scope, deserializeParams(items, scope));
},
choice: function (scope) {
var choices;
choices = __slice.call(arguments, 1);
return SyntaxChoiceNode(0, 0, scope, (function () {
var _arr, _i, _len, choice;
for (_arr = [], _i = 0, _len = choices.length; _i < _len; ++_i) {
choice = choices[_i];
_arr.push(deserializeParamType(choice, scope));
}
return _arr;
}()));
},
"const": function (scope, value) {
return ConstNode(0, 0, scope, value);
},
many: function (scope, multiplier) {
var inner;
inner = __slice.call(arguments, 2);
return SyntaxManyNode(
0,
0,
scope,
deserializeParamType(inner, scope),
multiplier
);
}
};
return function (asType, scope) {
var type;
if (asType == null) {
asType = [];
} else if (!__isArray(asType)) {
throw TypeError("Expected asType to be an Array, got " + __typeof(asType));
}
if (asType.length === 0) {
return;
} else {
type = asType[0];
if (__owns.call(deserializeParamTypeByType, type)) {
return deserializeParamTypeByType[type].apply(deserializeParamTypeByType, [scope].concat(__toArray(__slice.call(asType, 1))));
} else {
throw Error("Unknown as-type: " + String(type));
}
}
};
}());
deserializeParams = (function () {
var deserializeParamByType;
deserializeParamByType = {
"const": function (scope, value) {
return ConstNode(0, 0, scope, value);
},
ident: function (scope, name) {
var asType;
asType = __slice.call(arguments, 2);
return SyntaxParamNode(
0,
0,
scope,
IdentNode(0, 0, scope, name),
deserializeParamType(asType, scope)
);
},
"this": function (scope) {
var asType;
asType = __slice.call(arguments, 1);
return SyntaxParamNode(
0,
0,
scope,
ThisNode(0, 0, scope),
deserializeParamType(asType, scope)
);
}
};
return function (params, scope) {
var _arr, _arr2, _i, _len, param, type;
if (!(scope instanceof Scope)) {
throw TypeError("Expected scope to be a " + __name(Scope) + ", got " + __typeof(scope));
}
for (_arr = [], _arr2 = __toArray(fixArray(params)), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
param = _arr2[_i];
type = param[0];
if (__owns.call(deserializeParamByType, type)) {
_arr.push(deserializeParamByType[type].apply(deserializeParamByType, [scope].concat(__toArray(__slice.call(param, 1)))));
} else {
throw Error("Unknown param type: " + String(type));
}
}
return _arr;
};
}());
function calcParam(param) {
var _this, calced, macros, multiplier, name, string;
_this = this;
if (param instanceof IdentNode) {
name = param.name;
macros = this.macros;
if (macros.hasSyntax(name)) {
return macros.getSyntax(name);
} else {
return function (parser, index) {
return macros.getSyntax(name).call(this, parser, index);
};
}
} else if (param instanceof SyntaxSequenceNode) {
return handleParams.call(this, param.params);
} else if (param instanceof SyntaxChoiceNode) {
return oneOf.apply(void 0, (function () {
var _arr, _arr2, _i, _len, choice;
for (_arr = [], _arr2 = __toArray(param.choices), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
choice = _arr2[_i];
_arr.push(calcParam.call(_this, choice));
}
return _arr;
}()));
} else if (param.isConst()) {
string = param.constValue();
if (typeof string !== "string") {
this.error("Expected a constant string parameter, got " + __typeof(string));
}
return __owns.call(macroSyntaxConstLiterals, string) && macroSyntaxConstLiterals[string] || wordOrSymbol(string);
} else if (param instanceof SyntaxManyNode) {
multiplier = param.multiplier;
calced = calcParam.call(this, param.inner);
switch (multiplier) {
case "*": return zeroOrMore(calced);
case "+": return oneOrMore(calced);
case "?":
return oneOf(calced, Nothing);
default: throw Error("Unknown syntax multiplier: " + __strnum(multiplier));
}
} else {
return this.error("Unexpected type: " + __typeof(param));
}
}
function handleParams(params) {
var _arr, _i, _len, _ref, ident, key, param, sequence, string, type;
sequence = [];
for (_arr = __toArray(params), _i = 0, _len = _arr.length; _i < _len; ++_i) {
param = _arr[_i];
if (param.isConst()) {
string = param.constValue();
if (typeof string !== "string") {
this.error("Expected a constant string parameter, got " + __typeof(string));
}
sequence.push(__owns.call(macroSyntaxConstLiterals, string) && macroSyntaxConstLiterals[string] || wordOrSymbol(string));
} else if (param instanceof SyntaxParamNode) {
ident = param.ident;
if (ident instanceof IdentNode) {
key = ident.name;
} else if (ident instanceof ThisNode) {
key = "this";
} else {
throw Error("Don't know how to handle ident type: " + __typeof(ident));
}
if ((_ref = param.asType) != null) {
type = _ref;
} else {
type = IdentNode(0, 0, param.scope, "Expression");
}
sequence.push([
key,
calcParam.call(this, type)
]);
} else {
this.error("Unexpected parameter type: " + __typeof(param));
}
}
return sequential.apply(void 0, __toArray(sequence));
}
function simplifyArray(operators) {
if (!__isArray(operators)) {
throw TypeError("Expected operators to be an Array, got " + __typeof(operators));
}
if (operators.length === 0) {
return;
} else if (operators.length === 1 && !__isArray(operators[0])) {
return operators[0];
} else {
return operators;
}
}
function simplifyObject(options) {
var k, v;
if (typeof options !== "object" || options === null) {
throw TypeError("Expected options to be an Object, got " + __typeof(options));
}
for (k in options) {
if (__owns.call(options, k)) {
v = options[k];
return options;
}
}
return;
}
function getCompilationOptions(stateOptions) {
if (typeof stateOptions !== "object" || stateOptions === null) {
throw TypeError("Expected stateOptions to be an Object, got " + __typeof(stateOptions));
}
if (stateOptions.serializeMacros) {
return { minify: true };
} else {
return {};
}
}
macroSyntaxTypes = {
syntax: function (index, params, body, options, stateOptions, translator) {
var _this, compilation, funcParam, handler, macroDataIdent, macroFullDataIdent, macroNameIdent, rawFunc, scope, serialization, state, translated;
_this = this;
macroFullDataIdent = this.Ident(index, "macroFullData");
funcParam = this.Param(
index,
macroFullDataIdent,
void 0,
false,
false,
void 0
);
macroNameIdent = this.Ident(index, "macroName");
scope = this.scope.peek();
scope.add(macroNameIdent, false, Type.string);
macroDataIdent = this.Ident(index, "macroData");
scope.add(macroDataIdent, false, Type.object);
body = this.Block(index, [
this.Var(index, macroNameIdent, false),
this.Assign(index, macroNameIdent, "=", this.Access(index, macroFullDataIdent, this.Const(index, "macroName"))),
this.Var(index, macroDataIdent, false),
this.Assign(index, macroDataIdent, "=", this.Access(index, macroFullDataIdent, this.Const(index, "macroData")))
].concat(
(function () {
var _arr, _arr2, _i, _len, param;
for (_arr = [], _arr2 = __toArray(params), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
param = _arr2[_i];
if (param instanceof SyntaxParamNode) {
scope.add(param.ident, true, Type.any);
_arr.push(_this.Block(index, [
_this.Var(index, param.ident, true),
_this.Assign(index, param.ident, "=", _this.Access(index, macroDataIdent, _this.Const(index, param.ident.name)))
]));
}
}
return _arr;
}()),
[body]
));
rawFunc = makeMacroRoot.call(this, index, funcParam, body);
translated = translator(this.macroExpandAll(rawFunc).reduce(this), this.macros, { "return": true });
compilation = translated.node.toString(getCompilationOptions(stateOptions));
if (stateOptions.serializeMacros) {
serialization = compilation;
}
handler = Function(compilation)();
if (typeof handler !== "function") {
throw Error("Error creating function for macro: " + String(this.currentMacro));
}
state = this;
return {
handler: function (args) {
var rest;
rest = __slice.call(arguments, 1);
return handler.apply(this, [reduceObject(state, args)].concat(__toArray(rest))).reduce(state);
},
rule: handleParams.call(this, params),
serialization: serialization != null
? {
type: "syntax",
code: serialization,
options: simplifyObject(options),
params: serializeParams(params),
names: simplifyArray(this.currentMacro)
}
: void 0
};
},
defineSyntax: function (index, params, body, options, stateOptions, translator) {
var _this, handler, serialization, state;
_this = this;
state = this;
if (body != null) {
handler = (function () {
var compilation, funcParam, handler, macroDataIdent, rawFunc, scope, translated;
macroDataIdent = _this.Ident(index, "macroData");
funcParam = _this.Param(
index,
macroDataIdent,
void 0,
false,
false,
void 0
);
scope = _this.scope.peek();
body = _this.Block(index, (function () {
var _arr, _arr2, _i, _len, param;
for (_arr = [], _arr2 = __toArray(params), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
param = _arr2[_i];
if (param instanceof SyntaxParamNode) {
scope.add(param.ident, true, Type.any);
_arr.push(_this.Block(index, [
_this.Var(index, param.ident, true),
_this.Assign(index, param.ident, "=", _this.Access(index, macroDataIdent, _this.Const(index, param.ident.name)))
]));
}
}
return _arr;
}()).concat([body]));
rawFunc = makeMacroRoot.call(_this, index, funcParam, body);
translated = translator(_this.macroExpandAll(rawFunc).reduce(state), _this.macros, { "return": true });
compilation = translated.node.toString(getCompilationOptions(stateOptions));
if (stateOptions.serializeMacros) {
serialization = compilation;
}
handler = Function(compilation)();
if (typeof handler !== "function") {
throw Error("Error creating function for syntax: " + __strnum(options.name));
}
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return reduceObject(state, handler.apply(this, [reduceObject(state, args)].concat(__toArray(rest))));
};
}());
} else {
handler = function (args) {
var rest;
rest = __slice.call(arguments, 1);
return reduceObject(state, args);
};
}
return {
handler: handler,
rule: handleParams.call(this, params),
serialization: stateOptions.serializeMacros ? { type: "defineSyntax", code: serialization, options: simplifyObject(options), params: serializeParams(params) } : void 0
};
},
call: function (index, params, body, options, stateOptions, translator) {
var _this, compilation, funcParam, handler, macroDataIdent, macroFullDataIdent, macroNameIdent, rawFunc, scope, serialization, state, translated;
_this = this;
macroFullDataIdent = this.Ident(index, "macroFullData");
funcParam = this.Param(
index,
macroFullDataIdent,
void 0,
false,
false,
void 0
);
scope = this.scope.peek();
macroNameIdent = this.Ident(index, "macroName");
scope.add(macroNameIdent, false, Type.string);
macroDataIdent = this.Ident(index, "macroData");
scope.add(macroDataIdent, false, Type.object);
body = this.Block(index, [
this.Var(index, macroNameIdent, false),
this.Assign(index, macroNameIdent, "=", this.Access(index, macroFullDataIdent, this.Const(index, "macroName"))),
this.Var(index, macroDataIdent, false),
this.Assign(index, macroDataIdent, "=", this.Access(index, macroFullDataIdent, this.Const(index, "macroData")))
].concat(
(function () {
var _arr, _arr2, _len, i, param;
for (_arr = [], _arr2 = __toArray(params), i = 0, _len = _arr2.length; i < _len; ++i) {
param = _arr2[i];
if (param instanceof ParamNode) {
scope.add(param.ident, true, Type.any);
_arr.push(_this.Block(index, [
_this.Var(index, param.ident, true),
_this.Assign(index, param.ident, "=", _this.Access(index, macroDataIdent, _this.Const(index, i)))
]));
}
}
return _arr;
}()),
[body]
));
rawFunc = makeMacroRoot.call(this, index, funcParam, body);
translated = translator(this.macroExpandAll(rawFunc).reduce(this), this.macros, { "return": true });
compilation = translated.node.toString(getCompilationOptions(stateOptions));
if (stateOptions.serializeMacros) {
serialization = compilation;
}
handler = Function(compilation)();
if (typeof handler !== "function") {
throw Error("Error creating function for macro: " + __strnum(this.currentMacro));
}
state = this;
handler = (function (inner) {
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest))).reduce(state);
};
}(handler));
return {
handler: handler,
rule: InvocationArguments,
serialization: serialization != null ? { type: "call", code: serialization, options: simplifyObject(options), names: simplifyArray(this.currentMacro) } : void 0
};
},
binaryOperator: function (index, operators, body, options, stateOptions, translator) {
var _this, compilation, funcParam, handler, macroDataIdent, rawFunc, scope, serialization, state, translated;
_this = this;
macroDataIdent = this.Ident(index, "macroData");
funcParam = this.Param(
index,
macroDataIdent,
void 0,
false,
false,
void 0
);
scope = this.scope.peek();
body = this.Block(index, (function () {
var _arr, _arr2, _i, _len, ident, name;
for (_arr = [], _arr2 = ["left", "op", "right"], _i = 0, _len = _arr2.length; _i < _len; ++_i) {
name = _arr2[_i];
ident = _this.Ident(index, name);
scope.add(ident, true, Type.any);
_arr.push(_this.Block(index, [
_this.Var(index, ident, true),
_this.Assign(index, ident, "=", _this.Access(index, macroDataIdent, _this.Const(index, name)))
]));
}
return _arr;
}()).concat([body]));
rawFunc = makeMacroRoot.call(this, index, funcParam, body);
translated = translator(this.macroExpandAll(rawFunc).reduce(this), this.macros, { "return": true });
compilation = translated.node.toString(getCompilationOptions(stateOptions));
if (stateOptions.serializeMacros) {
serialization = compilation;
}
handler = Function(compilation)();
if (typeof handler !== "function") {
throw Error("Error creating function for binary operator " + __strnum(operators.join(", ")));
}
state = this;
if (options.invertible) {
handler = (function (inner) {
return function (args) {
var rest, result;
rest = __slice.call(arguments, 1);
result = inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest)));
if (args.inverted) {
return UnaryNode(
result.line,
result.column,
result.scope,
"!",
result
).reduce(state);
} else {
return result.reduce(state);
}
};
}(handler));
} else {
handler = (function (inner) {
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest))).reduce(state);
};
}(handler));
}
return {
handler: handler,
rule: void 0,
serialization: serialization != null ? { type: "binaryOperator", code: serialization, operators: simplifyArray(operators), options: simplifyObject(options) } : void 0
};
},
assignOperator: function (index, operators, body, options, stateOptions, translator) {
var _this, compilation, funcParam, handler, macroDataIdent, rawFunc, scope, serialization, state, translated;
_this = this;
macroDataIdent = this.Ident(index, "macroData");
funcParam = this.Param(
index,
macroDataIdent,
void 0,
false,
false,
void 0
);
scope = this.scope.peek();
body = this.Block(index, (function () {
var _arr, _arr2, _i, _len, ident, name;
for (_arr = [], _arr2 = ["left", "op", "right"], _i = 0, _len = _arr2.length; _i < _len; ++_i) {
name = _arr2[_i];
ident = _this.Ident(index, name);
scope.add(ident, true, Type.any);
_arr.push(_this.Block(index, [
_this.Var(index, ident, true),
_this.Assign(index, ident, "=", _this.Access(index, macroDataIdent, _this.Const(index, name)))
]));
}
return _arr;
}()).concat([body]));
rawFunc = makeMacroRoot.call(this, index, funcParam, body);
translated = translator(this.macroExpandAll(rawFunc).reduce(this), this.macros, { "return": true });
compilation = translated.node.toString(getCompilationOptions(stateOptions));
if (stateOptions.serializeMacros) {
serialization = compilation;
}
handler = Function(compilation)();
if (typeof handler !== "function") {
throw Error("Error creating function for assign operator " + __strnum(operators.join(", ")));
}
state = this;
handler = (function (inner) {
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest))).reduce(state);
};
}(handler));
return {
handler: handler,
rule: void 0,
serialization: serialization != null ? { type: "assignOperator", code: serialization, operators: simplifyArray(operators), options: simplifyObject(options) } : void 0
};
},
unaryOperator: function (index, operators, body, options, stateOptions, translator) {
var _this, compilation, funcParam, handler, macroDataIdent, rawFunc, scope, serialization, state, translated;
_this = this;
macroDataIdent = this.Ident(index, "macroData");
funcParam = this.Param(
index,
macroDataIdent,
void 0,
false,
false,
void 0
);
scope = this.scope.peek();
body = this.Block(index, (function () {
var _arr, _arr2, _i, _len, ident, name;
for (_arr = [], _arr2 = ["op", "node"], _i = 0, _len = _arr2.length; _i < _len; ++_i) {
name = _arr2[_i];
ident = _this.Ident(index, name);
scope.add(ident, true, Type.any);
_arr.push(_this.Block(index, [
_this.Var(index, ident, true),
_this.Assign(index, ident, "=", _this.Access(index, macroDataIdent, _this.Const(index, name)))
]));
}
return _arr;
}()).concat([body]));
rawFunc = makeMacroRoot.call(this, index, funcParam, body);
translated = translator(this.macroExpandAll(rawFunc).reduce(this), this.macros, { "return": true });
compilation = translated.node.toString(getCompilationOptions(stateOptions));
if (stateOptions.serializeMacros) {
serialization = compilation;
}
handler = Function(compilation)();
if (typeof handler !== "function") {
throw Error("Error creating function for unary operator " + __strnum(operators.join(", ")));
}
state = this;
handler = (function (inner) {
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest))).reduce(state);
};
}(handler));
return {
handler: handler,
rule: void 0,
serialization: serialization != null ? { type: "unaryOperator", code: serialization, operators: simplifyArray(operators), options: simplifyObject(options) } : void 0
};
}
};
function fixArray(operators) {
if (operators == null) {
return [];
} else if (__isArray(operators)) {
return operators;
} else {
return [operators];
}
}
macroDeserializers = {
syntax: function (_p) {
var _this, code, handler, id, names, options, params, state;
_this = this;
code = _p.code;
params = _p.params;
names = _p.names;
options = _p.options;
if (options == null) {
options = {};
}
id = _p.id;
names = fixArray(names);
handler = Function(code)();
if (typeof handler !== "function") {
throw Error("Error deserializing function for macro " + __strnum(name));
}
state = this;
handler = (function (inner) {
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest))).reduce(state);
};
}(handler));
this.enterMacro(0, names);
handleMacroSyntax.call(
this,
0,
"syntax",
handler,
handleParams.call(this, deserializeParams(params, this.scope.peek())),
null,
options,
id
);
return this.exitMacro();
},
call: function (_p) {
var _this, code, handler, id, names, options, state;
_this = this;
code = _p.code;
names = _p.names;
options = _p.options;
if (options == null) {
options = {};
}
id = _p.id;
names = fixArray(names);
handler = Function(code)();
if (typeof handler !== "function") {
throw Error("Error deserializing function for macro " + __strnum(name));
}
state = this;
handler = (function (inner) {
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest))).reduce(state);
};
}(handler));
this.enterMacro(0, names);
handleMacroSyntax.call(
this,
0,
"call",
handler,
InvocationArguments,
null,
options,
id
);
return this.exitMacro();
},
defineSyntax: function (_p) {
var _this, code, handler, id, options, params, state;
_this = this;
code = _p.code;
params = _p.params;
options = _p.options;
if (options == null) {
options = {};
}
id = _p.id;
if (this.macros.hasSyntax(options.name)) {
throw Error("Cannot override already-defined syntax: " + __strnum(options.name));
}
state = this;
if (code != null) {
handler = Function(code)();
if (typeof handler !== "function") {
throw Error("Error deserializing function for macro syntax " + __strnum(options.name));
}
handler = (function (inner) {
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return reduceObject(state, inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest))));
};
}(handler));
} else {
handler = function (args) {
return reduceObject(state, args);
};
}
this.enterMacro(0, DEFINE_SYNTAX);
handleMacroSyntax.call(
this,
0,
"defineSyntax",
handler,
handleParams.call(this, deserializeParams(params, this.scope.peek())),
null,
options,
id
);
return this.exitMacro();
},
binaryOperator: function (_p) {
var _this, code, handler, id, operators, options, state;
_this = this;
code = _p.code;
operators = _p.operators;
options = _p.options;
if (options == null) {
options = {};
}
id = _p.id;
operators = fixArray(operators);
handler = Function(code)();
if (typeof handler !== "function") {
throw Error("Error deserializing function for binary operator " + __strnum(operators.join(", ")));
}
state = this;
if (options.invertible) {
handler = (function (inner) {
return function (args) {
var rest, result;
rest = __slice.call(arguments, 1);
result = inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest)));
if (args.inverted) {
return UnaryNode(
result.line,
result.column,
result.scope,
"!",
result
).reduce(state);
} else {
return result.reduce(state);
}
};
}(handler));
} else {
handler = (function (inner) {
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest))).reduce(state);
};
}(handler));
}
this.enterMacro(0, BINARY_OPERATOR);
handleMacroSyntax.call(
this,
0,
"binaryOperator",
handler,
void 0,
operators,
options,
id
);
return this.exitMacro();
},
assignOperator: function (_p) {
var _this, code, handler, id, operators, options, state;
_this = this;
code = _p.code;
operators = _p.operators;
options = _p.options;
if (options == null) {
options = {};
}
id = _p.id;
operators = fixArray(operators);
handler = Function(code)();
if (typeof handler !== "function") {
throw Error("Error deserializing function for assign operator " + __strnum(operators.join(", ")));
}
state = this;
handler = (function (inner) {
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest))).reduce(state);
};
}(handler));
this.enterMacro(0, ASSIGN_OPERATOR);
handleMacroSyntax.call(
this,
0,
"assignOperator",
handler,
void 0,
operators,
options,
id
);
return this.exitMacro();
},
unaryOperator: function (_p) {
var _this, code, handler, id, operators, options, state;
_this = this;
code = _p.code;
operators = _p.operators;
options = _p.options;
if (options == null) {
options = {};
}
id = _p.id;
operators = fixArray(operators);
handler = Function(code)();
if (typeof handler !== "function") {
throw Error("Error deserializing function for unary operator " + __strnum(operators.join(", ")));
}
state = this;
handler = (function (inner) {
return function (args) {
var rest;
rest = __slice.call(arguments, 1);
return inner.apply(this, [reduceObject(state, args)].concat(__toArray(rest))).reduce(state);
};
}(handler));
this.enterMacro(0, UNARY_OPERATOR);
handleMacroSyntax.call(
this,
0,
"unaryOperator",
handler,
void 0,
operators,
options,
id
);
this.exitMacro();
}
};
function removeNoops(obj) {
var _arr, _arr2, _i, _len, item, k, result, v;
if (__isArray(obj)) {
for (_arr = [], _arr2 = __toArray(obj), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
item = _arr2[_i];
if (item instanceof NothingNode) {
_arr.push(void 0);
} else {
_arr.push(removeNoops(item));
}
}
return _arr;
} else if (obj instanceof Node) {
return obj;
} else if (typeof obj === "object" && obj !== null && !(obj instanceof RegExp)) {
result = {};
for (k in obj) {
if (__owns.call(obj, k)) {
v = obj[k];
if (!(v instanceof NothingNode)) {
result[k] = removeNoops(v);
}
}
}
return result;
} else {
return obj;
}
}
_Parser_prototype.startMacroSyntax = function (index, params, options) {
var _arr, _i, _len, _ref, m, macroId, macros, rule;
if (!__isArray(params)) {
throw TypeError("Expected params to be an Array, got " + __typeof(params));
}
if (options == null) {
options = {};
}
if (!this.currentMacro) {
throw Error("Attempting to specify a macro syntax when not in a macro");
}
rule = handleParams.call(this, params);
macros = this.macros;
function mutator(data, parser, index) {
if (parser.inAst.peek() || !parser.expandingMacros) {
return parser.MacroAccess(
index,
macroId,
parser.getLine(index),
removeNoops(data),
parser.position.peek(),
parser.inGenerator.peek(),
parser.inEvilAst.peek()
);
} else {
throw Error("Cannot use macro until fully defined");
}
}
for (_arr = __toArray(macros.getOrAddByNames(this.currentMacro)), _i = 0, _len = _arr.length; _i < _len; ++_i) {
m = _arr[_i];
m.data.push((_ref = sequential(
["macroName", m.token],
["macroData", rule]
), mutate(mutator)(_ref)));
}
macroId = macros.addMacro(mutator, void 0, options.type != null && __owns.call(Type, _ref = options.type) ? Type[_ref] : void 0);
this.pendingMacroId = macroId;
return params;
};
function handleMacroSyntax(index, type, handler, rule, params, options, macroId) {
var _this, macros;
_this = this;
if (typeof handler !== "function") {
throw TypeError("Expected handler to be a Function, got " + __typeof(handler));
}
macros = this.macros;
function mutator(data, parser, index) {
var line, macroContext, pos, result, scope, tmps, walker;
if (parser.inAst.peek() || !parser.expandingMacros) {
return parser.MacroAccess(
index,
macroId,
parser.getLine(index),
removeNoops(data),
parser.position.peek(),
parser.inGenerator.peek(),
parser.inEvilAst.peek()
);
} else {
scope = parser.pushScope(false);
macroContext = MacroContext(
parser,
index,
parser.position.peek(),
parser.inGenerator.peek(),
parser.inEvilAst.peek()
);
if (type === "assignOperator" && macroContext.isIdent(data.left)) {
if (!macroContext.hasVariable(data.left)) {
throw parser.buildError("Trying to assign with " + __strnum(data.op) + " to unknown variable '" + __strnum(macroContext.name(data.left)) + "'", data.left);
} else if (!macroContext.isVariableMutable(data.left) && !parser.inEvilAst.peek()) {
throw parser.buildError("Trying to assign with " + __strnum(data.op) + " to immutable variable '" + __strnum(macroContext.name(data.left)) + "'", data.left);
}
}
try {
result = handler.call(
macroContext,
removeNoops(data),
__bind(macroContext, "wrap"),
__bind(macroContext, "node")
);
} catch (e) {
if (e instanceof ReferenceError) {
throw e;
} else if (e instanceof MacroError) {
pos = parser.getPosition(index);
e.setPosition(pos.line, pos.column);
throw e;
} else {
throw MacroError(e, parser, index);
}
}
parser.popScope();
if (result instanceof Node) {
line = parser.getLine(index);
walker = function (node) {
if (node instanceof MacroAccessNode) {
node.callLine = line;
}
return node.walk(walker);
};
result = walker(result.reduce(_this));
tmps = macroContext.getTmps();
if (tmps.unsaved.length) {
return parser.TmpWrapper(index, result, tmps.unsaved);
} else {
return result;
}
} else {
return result;
}
}
}
return macroId = (function () {
var _arr, _i, _len, _ref, id, m;
switch (_this.currentMacro) {
case BINARY_OPERATOR:
return macros.addBinaryOperator(params, mutator, options, macroId);
case ASSIGN_OPERATOR:
return macros.addAssignOperator(params, mutator, options, macroId);
case UNARY_OPERATOR:
return macros.addUnaryOperator(params, mutator, options, macroId);
case DEFINE_SYNTAX:
if (!rule) {
throw Error("Expected rule to exist");
}
macros.addSyntax(options.name, mutate(mutator)(rule));
return macros.addMacro(mutator, macroId, options.type != null && __owns.call(Type, _ref = options.type) ? Type[_ref] : void 0);
default:
if (!rule) {
throw Error("Expected rule to exist");
}
for (_arr = __toArray(macros.getOrAddByNames(_this.currentMacro)), _i = 0, _len = _arr.length; _i < _len; ++_i) {
m = _arr[_i];
if (_this.pendingMacroId != null) {
m.data.pop();
}
m.data.push(cache((_ref = sequential(
["macroName", m.token],
["macroData", rule]
), mutate(mutator)(_ref))));
}
if (_this.pendingMacroId != null) {
if (macroId != null) {
throw Error("Cannot provide the macro id if there is a pending macro id");
}
id = _this.pendingMacroId;
_this.pendingMacroId = null;
macros.replaceMacro(id, mutator, options.type != null && __owns.call(Type, _ref = options.type) ? Type[_ref] : void 0);
return id;
} else {
return macros.addMacro(mutator, macroId, options.type != null && __owns.call(Type, _ref = options.type) ? Type[_ref] : void 0);
}
}
}());
}
_Parser_prototype.macroSyntax = function (index, type, params, options, body) {
var _ref, handler, macroId, rule, serialization;
if (!__isArray(params)) {
throw TypeError("Expected params to be an Array, got " + __typeof(params));
}
if (!__owns.call(macroSyntaxTypes, type)) {
throw Error("Unknown macro-syntax type: " + __strnum(type));
}
if (!this.currentMacro) {
this.error("Attempting to specify a macro syntax when not in a macro");
}
handler = (_ref = macroSyntaxTypes[type].call(
this,
index,
params,
body,
options,
this.options,
require("./jstranslator")
)).handler;
rule = _ref.rule;
serialization = _ref.serialization;
macroId = handleMacroSyntax.call(
this,
index,
type,
handler,
rule,
params,
options
);
if (serialization != null) {
serialization.id = macroId;
this.macros.addMacroSerialization(serialization);
}
};
BINARY_OPERATOR = {};
_Parser_prototype.defineBinaryOperator = function (index, operators, options, body) {
var _i;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
if (!__isArray(operators)) {
throw TypeError("Expected operators to be an Array, got " + __typeof(operators));
} else {
for (_i = operators.length; _i--; ) {
if (typeof operators[_i] !== "string") {
throw TypeError("Expected " + ("operators[" + _i + "]") + " to be a String, got " + __typeof(operators[_i]));
}
}
}
if (typeof options !== "object" || options === null) {
throw TypeError("Expected options to be an Object, got " + __typeof(options));
}
if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
this.enterMacro(index, BINARY_OPERATOR);
this.macroSyntax(
index,
"binaryOperator",
operators,
options,
body
);
return this.exitMacro();
};
ASSIGN_OPERATOR = {};
_Parser_prototype.defineAssignOperator = function (index, operators, options, body) {
var _i;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
if (!__isArray(operators)) {
throw TypeError("Expected operators to be an Array, got " + __typeof(operators));
} else {
for (_i = operators.length; _i--; ) {
if (typeof operators[_i] !== "string") {
throw TypeError("Expected " + ("operators[" + _i + "]") + " to be a String, got " + __typeof(operators[_i]));
}
}
}
if (typeof options !== "object" || options === null) {
throw TypeError("Expected options to be an Object, got " + __typeof(options));
}
if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
this.enterMacro(index, ASSIGN_OPERATOR);
this.macroSyntax(
index,
"assignOperator",
operators,
options,
body
);
return this.exitMacro();
};
UNARY_OPERATOR = {};
_Parser_prototype.defineUnaryOperator = function (index, operators, options, body) {
var _i;
if (typeof index !== "number") {
throw TypeError("Expected index to be a Number, got " + __typeof(index));
}
if (!__isArray(operators)) {
throw TypeError("Expected operators to be an Array, got " + __typeof(operators));
} else {
for (_i = operators.length; _i--; ) {
if (typeof operators[_i] !== "string") {
throw TypeError("Expected " + ("operators[" + _i + "]") + " to be a String, got " + __typeof(operators[_i]));
}
}
}
if (typeof options !== "object" || options === null) {
throw TypeError("Expected options to be an Object, got " + __typeof(options));
}
if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
this.enterMacro(index, UNARY_OPERATOR);
this.macroSyntax(
index,
"unaryOperator",
operators,
options,
body
);
return this.exitMacro();
};
DEFINE_SYNTAX = {};
_Parser_prototype.defineSyntax = function (index, name, params, body) {
this.enterMacro(index, DEFINE_SYNTAX);
this.macroSyntax(
index,
"defineSyntax",
params,
{ name: name },
body
);
return this.exitMacro();
};
_Parser_prototype.defineConst = function (index, name, value) {
var scope;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (value != null && typeof value !== "number" && typeof value !== "string" && typeof value !== "boolean") {
throw TypeError("Expected value to be one of Number or String or Boolean or undefined or null, got " + __typeof(value));
}
scope = this.scope.peek();
if (scope === this.scope.initial) {
this.macros.addConst(name, value);
if (this.options.serializeMacros) {
this.macros.addSerializedConst(name);
}
}
scope.addConst(name, value);
};
_Parser_prototype.getConst = function (name) {
var _ref, consts, scope;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
scope = this.scope.peek();
if ((_ref = scope.constValue(name)) != null) {
return _ref;
}
consts = this.macros.consts;
if (__owns.call(consts, name)) {
return { value: consts[name] };
}
};
_Parser_prototype.deserializeMacros = function (data) {
var _arr, _i, _len, _ref, deserializer, item, type;
for (type in macroDeserializers) {
if (__owns.call(macroDeserializers, type)) {
deserializer = macroDeserializers[type];
for (_arr = __toArray((_ref = __owns.call(data, type) ? data[type] : void 0) != null ? _ref : []), _i = 0, _len = _arr.length; _i < _len; ++_i) {
item = _arr[_i];
deserializer.call(this, item);
}
}
}
};
_Parser_prototype.macroExpand1 = function (node) {
var _i, _len, n, nodes, oldExpandingMacros, result;
if (node._macroExpanded != null) {
return node._macroExpanded;
} else if (node instanceof MacroAccessNode) {
nodes = [];
while (node instanceof MacroAccessNode) {
nodes.push(node);
this.position.push(node.position);
this.inGenerator.push(node.inGenerator);
this.inEvilAst.push(node.inEvilAst);
this.scope.push(node.scope);
oldExpandingMacros = this.expandingMacros;
this.expandingMacros = true;
result = void 0;
try {
result = this.macros.getById(node.id)(node.data, this, this.indexFromPosition(node.line, node.column));
} catch (e) {
if (e instanceof MacroError) {
e.setPosition(node.callLine, 0);
}
throw e;
} finally {
this.scope.pop();
this.position.pop();
this.inGenerator.pop();
this.inEvilAst.pop();
this.expandingMacros = oldExpandingMacros;
}
node = result;
}
for (_i = 0, _len = nodes.length; _i < _len; ++_i) {
n = nodes[_i];
n._macroExpanded = node;
}
return node;
} else {
return node._macroExpanded = node;
}
};
_Parser_prototype.macroExpandAllAsync = function (node, callback) {
var _this, startTime;
_this = this;
startTime = new Date().getTime();
function walker(node, callback) {
var _once, _once2, expanded;
if (__num(new Date().getTime()) - __num(startTime) > 5) {
return setImmediate(function () {
startTime = new Date().getTime();
return walker(node, callback);
});
}
if (node._macroExpandAlled != null) {
return callback(null, node._macroExpandAlled);
} else if (!(node instanceof MacroAccessNode)) {
return node.walkAsync(walker, (_once = false, function (_e, walked) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, walked._macroExpandAlled = walked._macroExpanded = node._macroExpandAlled = node._macroExpanded = walked);
}));
} else {
try {
expanded = _this.macroExpand1(node);
} catch (e) {
return callback(e);
}
if (!(expanded instanceof Node)) {
return callback(null, node._macroExpandAlled = node._macroExpanded = expanded);
}
return walker(expanded, (_once2 = false, function (_e, walked) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, expanded._macroExpandAlled = expanded._macroExpanded = walked._macroExpandAlled = walked._macroExpanded = node._macroExpandAlled = node._macroExpanded = walked);
}));
}
}
return walker(node, callback);
};
_Parser_prototype.macroExpandAll = function (node) {
var _this;
_this = this;
function walker(node) {
var expanded, walked;
if (node._macroExpandAlled != null) {
return node._macroExpandAlled;
} else if (!(node instanceof MacroAccessNode)) {
walked = node.walk(walker);
return walked._macroExpandAlled = walked._macroExpanded = node._macroExpandAlled = node._macroExpanded = walked;
} else {
expanded = _this.macroExpand1(node);
if (!(expanded instanceof Node)) {
return node._macroExpandAlled = node._macroExpanded = expanded;
}
walked = walker(expanded);
return expanded._macroExpandAlled = expanded._macroExpanded = walked._macroExpandAlled = walked._macroExpanded = node._macroExpandAlled = node._macroExpanded = walked;
}
}
return walker(node);
};
_Parser_prototype.macroExpandAllPromise = function (node) {
var defer;
if (this.options.sync) {
return __defer.fulfilled(this.macroExpandAll(node));
} else {
defer = __defer();
this.macroExpandAllAsync(node, function (err, result) {
if (err) {
return defer.reject(err);
} else {
return defer.fulfill(result);
}
});
return defer.promise;
}
};
_Parser_prototype.clearCache = function () {
this.cache = [];
};
Parser.addNodeFactory = function (name, type) {
Parser.prototype[name] = function (index) {
var args, pos;
args = __slice.call(arguments, 1);
pos = this.getPosition(index);
return type.apply(void 0, [pos.line, pos.column, this.scope.peek()].concat(__toArray(args)));
};
};
return Parser;
}());
parse = __promise(function (source, macros, options) {
var _e, _send, _state, _step, _throw, e, endExpandTime, endParseTime, endReduceTime, expanded, parser, reduced, result, rootRule, startTime;
_state = 0;
function _close() {
_state = 9;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (typeof source !== "string") {
throw TypeError("Expected source to be a String, got " + __typeof(source));
}
if (macros == null) {
macros = null;
} else if (!(macros instanceof MacroHolder)) {
throw TypeError("Expected macros to be one of " + (__name(MacroHolder) + " or null") + ", got " + __typeof(macros));
}
if (options == null) {
options = {};
} else if (typeof options !== "object" || options === null) {
throw TypeError("Expected options to be an Object, got " + __typeof(options));
}
parser = Parser(
source,
macros != null ? macros.clone() : void 0,
options
);
if (options.embeddedGenerator) {
rootRule = EmbeddedRootGeneratorP;
} else if (options.embedded) {
rootRule = EmbeddedRootP;
} else {
rootRule = RootP;
}
startTime = new Date().getTime();
result = void 0;
++_state;
case 1:
_state = options.sync ? 2 : 3;
break;
case 2:
result = rootRule.sync(parser);
_state = 5;
break;
case 3:
++_state;
return { done: false, value: rootRule(parser) };
case 4:
result = _received;
++_state;
case 5:
_state = 7;
break;
case 6:
if (!(e === SHORT_CIRCUIT)) {
throw e;
}
++_state;
case 7:
parser.clearCache();
endParseTime = new Date().getTime();
if (typeof options.progress === "function") {
options.progress("parse", __num(endParseTime) - __num(startTime));
}
if (!result || __num(result.index) < source.length) {
throw parser.getFailure(result != null ? result.index : void 0);
}
++_state;
return { done: false, value: parser.macroExpandAllPromise(result.value) };
case 8:
expanded = _received;
endExpandTime = new Date().getTime();
if (typeof options.progress === "function") {
options.progress("macroExpand", __num(endExpandTime) - __num(endParseTime));
}
reduced = expanded.reduce(parser);
endReduceTime = new Date().getTime();
if (typeof options.progress === "function") {
options.progress("reduce", __num(endReduceTime) - __num(endExpandTime));
}
++_state;
return {
done: true,
value: {
result: reduced,
macros: parser.macros,
parseTime: __num(endParseTime) - __num(startTime),
macroExpandTime: __num(endExpandTime) - __num(endParseTime),
reduceTime: __num(endReduceTime) - __num(endExpandTime),
time: __num(endReduceTime) - __num(startTime)
}
};
case 9:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
if (_state === 1 || _state === 2 || _state === 3 || _state === 4 || _state === 5) {
e = _e;
_state = 6;
} else {
_close();
throw _e;
}
}
function _send(_received) {
while (true) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
module.exports = (parse.ParserError = ParserError, parse.MacroError = MacroError, parse.Node = Node, parse.MacroHolder = MacroHolder, parse.unusedCaches = unusedCaches, parse.deserializePrelude = function (data) {
var parsed, parser;
if (typeof data === "string") {
parsed = JSON.parse(data);
} else {
parsed = data;
}
parser = Parser();
parser.macros.deserialize(parsed, parser, {});
return {
result: NothingNode(0, 0, parser.scope.peek()),
macros: parser.macros
};
}, parse.getReservedWords = function (macros, options) {
if (options == null) {
options = {};
}
return unique(__toArray(getReservedIdents(options)).concat(__toArray(macros != null && typeof macros.getMacroAndOperatorNames === "function" && macros.getMacroAndOperatorNames() || [])));
}, parse);
for (_arr = [
"Access",
"AccessMulti",
"Args",
"Array",
"Assign",
"Binary",
"Block",
"Break",
"Call",
"Comment",
"Const",
"Continue",
"Debugger",
"Def",
"EmbedWrite",
"Eval",
"For",
"ForIn",
"Function",
"Ident",
"If",
"MacroAccess",
"Nothing",
"Object",
"Param",
"Regexp",
"Return",
"Root",
"Spread",
"Super",
"Switch",
"SyntaxChoice",
"SyntaxMany",
"SyntaxParam",
"SyntaxSequence",
"This",
"Throw",
"Tmp",
"TmpWrapper",
"TryCatch",
"TryFinally",
"TypeFunction",
"TypeGeneric",
"TypeObject",
"TypeUnion",
"Unary",
"Var",
"Yield"
], _i = 0, _len = _arr.length; _i < _len; ++_i) {
nodeType = _arr[_i];
Parser.addNodeFactory(nodeType, Node[nodeType]);
}
Parser.prototype.string = Node.string;
Parser.prototype.arrayParam = Parser.prototype.array;
Parser.prototype.object = Node.object;
Parser.prototype.objectParam = Node.objectParam;
}.call(this, typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : this));
return module.exports;
};
require['./parser-utils'] = function () {
var module = { exports: this };
var exports = this;
(function () {
"use strict";
var __async, __isArray, __num, __once, __owns, __slice, __toArray, __typeof, nodeToType, Type;
__async = function (limit, length, hasResult, onValue, onComplete) {
var broken, completed, index, result, slotsUsed, sync;
if (typeof limit !== "number") {
throw TypeError("Expected limit to be a Number, got " + __typeof(limit));
}
if (typeof length !== "number") {
throw TypeError("Expected length to be a Number, got " + __typeof(length));
}
if (hasResult == null) {
hasResult = false;
} else if (typeof hasResult !== "boolean") {
throw TypeError("Expected hasResult to be a Boolean, got " + __typeof(hasResult));
}
if (typeof onValue !== "function") {
throw TypeError("Expected onValue to be a Function, got " + __typeof(onValue));
}
if (typeof onComplete !== "function") {
throw TypeError("Expected onComplete to be a Function, got " + __typeof(onComplete));
}
if (hasResult) {
result = [];
} else {
result = null;
}
if (length <= 0) {
return onComplete(null, result);
}
if (limit < 1 || limit !== limit) {
limit = 1/0;
}
broken = null;
slotsUsed = 0;
sync = false;
completed = false;
function onValueCallback(err, value) {
if (completed) {
return;
}
--slotsUsed;
if (err != null && broken == null) {
broken = err;
}
if (hasResult && broken == null && arguments.length > 1) {
result.push(value);
}
if (!sync) {
next();
}
}
index = -1;
function next() {
while (!completed && broken == null && slotsUsed < limit && ++index < length) {
++slotsUsed;
sync = true;
onValue(index, __once(onValueCallback));
sync = false;
}
if (!completed && (broken != null || slotsUsed === 0)) {
completed = true;
if (broken != null) {
onComplete(broken);
} else {
onComplete(null, result);
}
}
}
next();
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__once = (function () {
function replacement() {
throw Error("Attempted to call function more than once");
}
function doNothing() {}
return function (func, silentFail) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
if (silentFail == null) {
silentFail = false;
} else if (typeof silentFail !== "boolean") {
throw TypeError("Expected silentFail to be a Boolean, got " + __typeof(silentFail));
}
return function () {
var f;
f = func;
func = silentFail ? doNothing : replacement;
return f.apply(this, arguments);
};
};
}());
__owns = Object.prototype.hasOwnProperty;
__slice = Array.prototype.slice;
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
Type = require("./types");
nodeToType = (function () {
var identToType;
identToType = {
Boolean: Type.boolean,
String: Type.string,
Number: Type.number,
Array: Type.array,
Object: Type.object,
Function: Type["function"],
RegExp: Type.regexp,
Date: Type.date,
Error: Type.error,
RangeError: Type.error,
ReferenceError: Type.error,
SyntaxError: Type.error,
TypeError: Type.error,
URIError: Type.error
};
return function (node) {
var _arr, _arr2, _i, _len, _ref, arg, args, basetype, current, data, key, Node, type, value;
Node = require("./parser-nodes");
if (!(node instanceof Node)) {
throw TypeError("Expected a Node, got " + __typeof(node));
}
if (node instanceof Node.Ident) {
return (__owns.call(identToType, _ref = node.name) ? identToType[_ref] : void 0) || Type.any;
} else if (node instanceof Node.Const) {
if (node.value === null) {
return Type["null"];
} else if (node.value === void 0) {
return Type["undefined"];
} else {
return Type.any;
}
} else if (node instanceof Node.TypeGeneric) {
basetype = nodeToType(node.basetype);
for (_arr = [], _arr2 = __toArray(node.args), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
arg = _arr2[_i];
_arr.push(nodeToType(arg));
}
args = _arr;
if (basetype === Type.array || basetype === Type["function"]) {
return Type.generic.apply(Type, [basetype.base].concat(__toArray(args)));
} else if (basetype !== Type.any) {
return Type.generic.apply(Type, [basetype].concat(__toArray(args)));
} else {
return Type.any;
}
} else if (node instanceof Node.TypeUnion) {
current = Type.none;
for (_arr = __toArray(node.types), _i = _arr.length; _i--; ) {
type = _arr[_i];
current = current.union(nodeToType(type));
}
return current;
} else if (node instanceof Node.TypeObject) {
data = {};
for (_arr = __toArray(node.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
key = (_ref = _arr[_i]).key;
value = _ref.value;
if (key instanceof Node.Const) {
data[key.value] = nodeToType(value);
}
}
return Type.makeObject(data);
} else {
return Type.any;
}
};
}());
function map(array, func, arg) {
var _arr, _i, _len, changed, item, newItem, result;
result = [];
changed = false;
for (_arr = __toArray(array), _i = 0, _len = _arr.length; _i < _len; ++_i) {
item = _arr[_i];
newItem = func(item, arg);
result.push(newItem);
if (item !== newItem) {
changed = true;
}
}
if (changed) {
return result;
} else {
return array;
}
}
function mapAsync(array, func) {
var _i, args, callback, changed;
_i = arguments.length - 1;
if (_i > 2) {
args = __slice.call(arguments, 2, _i);
} else {
_i = 2;
args = [];
}
callback = arguments[_i];
changed = false;
return __async(
1,
__num(array.length),
true,
function (_i2, next) {
var _once, item;
item = array[_i2];
return func.apply(void 0, [item].concat(__toArray(args), [
(_once = false, function (_e, newItem) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return next(_e);
}
if (item !== newItem) {
changed = true;
}
return next(null, newItem);
})
]));
},
function (err, result) {
if (typeof err !== "undefined" && err !== null) {
return callback(err);
} else {
return callback(null, changed ? result : array);
}
}
);
}
function addParamToScope(scope, param, forceMutable) {
var _arr, _i, _ref, element, Node, pair;
Node = require("./parser-nodes");
if (param instanceof Node.Param) {
if ((_ref = param.ident) instanceof Node.Ident || _ref instanceof Node.Tmp) {
scope.add(param.ident, forceMutable || param.isMutable, param.asType ? nodeToType(param.asType) : param.spread ? Type.array : Type.any);
} else if (param.ident instanceof Node.Access) {
if (!(param.ident.child instanceof Node.Const) || typeof param.ident.child.value !== "string") {
throw Error("Expected constant access: " + __typeof(param.ident.child));
}
scope.add(
Node.Ident(param.line, param.column, param.scope, param.ident.child.value),
forceMutable || param.isMutable,
param.asType ? nodeToType(param.asType) : param.spread ? Type.array : Type.any
);
} else {
throw Error("Unknown param ident: " + __typeof(param.ident));
}
} else if (param instanceof Node.Array) {
for (_arr = __toArray(param.elements), _i = _arr.length; _i--; ) {
element = _arr[_i];
addParamToScope(scope, element, forceMutable);
}
} else if (param instanceof Node.Object) {
for (_arr = __toArray(param.pairs), _i = _arr.length; _i--; ) {
pair = _arr[_i];
addParamToScope(scope, pair.value, forceMutable);
}
} else if (!(param instanceof Node.Nothing)) {
throw Error("Unknown param node type: " + __typeof(param));
}
}
exports.nodeToType = nodeToType;
exports.map = map;
exports.mapAsync = mapAsync;
exports.addParamToScope = addParamToScope;
}.call(this));
return module.exports;
};
require['./parser-scope'] = function () {
var module = { exports: this };
var exports = this;
(function () {
"use strict";
var __create, __import, __isArray, __name, __owns, __slice, __toArray, __typeof, _ref, IdentNode, Node, Scope, ScopeDestroyedError, TmpNode, Type;
__create = typeof Object.create === "function" ? Object.create
: function (x) {
function F() {}
F.prototype = x;
return new F();
};
__import = function (dest, source) {
var k;
for (k in source) {
if (__owns.call(source, k)) {
dest[k] = source[k];
}
}
return dest;
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__name = function (func) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
return func.displayName || func.name || "";
};
__owns = Object.prototype.hasOwnProperty;
__slice = Array.prototype.slice;
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
Type = require("./types");
Node = require("./parser-nodes");
IdentNode = Node.Ident;
TmpNode = Node.Tmp;
ScopeDestroyedError = (function (Error) {
var _Error_prototype, _ScopeDestroyedError_prototype;
function ScopeDestroyedError(message) {
var _this, err;
_this = this instanceof ScopeDestroyedError ? this : __create(_ScopeDestroyedError_prototype);
if (message == null) {
message = "Scope already destroyed";
} else if (typeof message !== "string") {
throw TypeError("Expected message to be a String, got " + __typeof(message));
}
_this.message = message;
err = Error.call(_this, _this.message);
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(_this, ScopeDestroyedError);
} else if ("stack" in err) {
_this.stack = err.stack;
}
return _this;
}
_Error_prototype = Error.prototype;
_ScopeDestroyedError_prototype = ScopeDestroyedError.prototype = __create(_Error_prototype);
_ScopeDestroyedError_prototype.constructor = ScopeDestroyedError;
ScopeDestroyedError.displayName = "ScopeDestroyedError";
if (typeof Error.extended === "function") {
Error.extended(ScopeDestroyedError);
}
_ScopeDestroyedError_prototype.name = "ScopeDestroyedError";
return ScopeDestroyedError;
}(Error));
Scope = (function () {
var _Scope_prototype;
function Scope(parent, isTop) {
var _this;
_this = this instanceof Scope ? this : __create(_Scope_prototype);
if (parent == null) {
parent = null;
} else if (!(parent instanceof Scope)) {
throw TypeError("Expected parent to be one of " + (__name(Scope) + " or null") + ", got " + __typeof(parent));
}
_this.parent = parent;
if (isTop == null) {
isTop = false;
} else if (typeof isTop !== "boolean") {
throw TypeError("Expected isTop to be a Boolean, got " + __typeof(isTop));
}
_this.isTop = isTop;
if (!parent && !isTop) {
throw Error("Must either provide a parent or is-top = true");
}
_this.destroyed = false;
_this.children = [];
_this.variables = {};
_this.consts = {};
_this.tmps = {};
if (!isTop) {
parent.children.push(_this);
}
return _this;
}
_Scope_prototype = Scope.prototype;
Scope.displayName = "Scope";
_Scope_prototype._allVariables = function () {
var _arr, _i, _len, child, obj;
obj = __import({}, this.variables);
for (_arr = __toArray(this.children), _i = 0, _len = _arr.length; _i < _len; ++_i) {
child = _arr[_i];
__import(obj, child._allVariables());
}
return obj;
};
_Scope_prototype._allTmps = function () {
var _arr, _i, _len, child, obj;
obj = __import({}, this.tmps);
for (_arr = __toArray(this.children), _i = 0, _len = _arr.length; _i < _len; ++_i) {
child = _arr[_i];
__import(obj, child._allTmps());
}
return obj;
};
_Scope_prototype._allConsts = function () {
var _arr, _i, _len, child, obj;
obj = __import({}, this.consts);
for (_arr = __toArray(this.children), _i = 0, _len = _arr.length; _i < _len; ++_i) {
child = _arr[_i];
__import(obj, child._allConsts());
}
return obj;
};
function isEmpty(obj) {
var k;
for (k in obj) {
if (__owns.call(obj, k)) {
return false;
}
}
return true;
}
_Scope_prototype.inspect = function () {
var consts, inspect, text, tmps, variables;
if (!this.isTop) {
return this.top().inspect();
}
inspect = require("util").inspect;
variables = this._allVariables();
tmps = this._allTmps();
consts = this._allConsts();
text = [];
text.push("Scope(");
if (!isEmpty(variables) || !isEmpty(tmps) || !isEmpty(consts)) {
text.push(inspect(variables));
}
if (!isEmpty(tmps) || !isEmpty(consts)) {
text.push(", ");
text.push(inspect(tmps));
}
if (!isEmpty(consts)) {
text.push(", ");
text.push(inspect(consts));
}
text.push(")");
if (this.parent) {
text.push(" -> ");
text.push(this.parent.inspect());
}
return text.join("");
};
_Scope_prototype.destroy = function () {
var _arr, _i, child, index, parentChildren;
if (this.destroyed) {
throw ScopeDestroyedError();
}
for (_arr = __toArray(this.children), _i = _arr.length; _i--; ) {
child = _arr[_i];
child.destroy();
}
if (!this.isTop) {
parentChildren = this.parent.children;
index = parentChildren.lastIndexOf(this);
if (index === -1) {
throw Error("Not found in parents' children");
}
parentChildren.splice(index, 1);
}
};
_Scope_prototype.clone = function (isTop) {
if (isTop == null) {
isTop = false;
} else if (typeof isTop !== "boolean") {
throw TypeError("Expected isTop to be a Boolean, got " + __typeof(isTop));
}
if (this.destroyed) {
throw ScopeDestroyedError();
}
return Scope(this, isTop);
};
_Scope_prototype.reparent = function (parent) {
var index, oldParent, oldParentChildren;
if (parent == null) {
parent = null;
} else if (!(parent instanceof Scope)) {
throw TypeError("Expected parent to be one of " + (__name(Scope) + " or null") + ", got " + __typeof(parent));
}
if (this.destroyed) {
throw ScopeDestroyedError();
}
if (!parent && !this.isTop) {
throw Error("Must either provide a parent or is-top = true");
}
oldParent = this.parent;
if (parent === oldParent) {
return;
}
if (parent === this) {
throw Error("Cannot parent to self");
}
if (parent && parent.parent === this) {
throw Error("Trying to become your own grandpa");
}
this.parent = parent;
if (!this.isTop) {
oldParentChildren = oldParent.children;
index = oldParentChildren.lastIndexOf(this);
if (index === -1) {
throw Error("Not found in old parents' children");
}
oldParentChildren.splice(index, 1);
parent.children.push(this);
}
};
_Scope_prototype.top = function () {
if (this.destroyed) {
throw ScopeDestroyedError();
}
if (this.isTop) {
return this;
} else {
return this.parent.top();
}
};
_Scope_prototype.add = function (ident, isMutable, type) {
if (!(ident instanceof IdentNode) && !(ident instanceof TmpNode)) {
throw TypeError("Expected ident to be one of " + (__name(IdentNode) + " or " + __name(TmpNode)) + ", got " + __typeof(ident));
}
if (isMutable == null) {
isMutable = false;
} else if (typeof isMutable !== "boolean") {
throw TypeError("Expected isMutable to be a Boolean, got " + __typeof(isMutable));
}
if (!(type instanceof Type)) {
throw TypeError("Expected type to be a " + __name(Type) + ", got " + __typeof(type));
}
if (this.destroyed) {
throw ScopeDestroyedError();
}
if (ident instanceof TmpNode) {
this.tmps[ident.id] = { isMutable: isMutable, type: type };
} else {
this.variables[ident.name] = { isMutable: isMutable, type: type };
}
};
_Scope_prototype.addConst = function (name, value) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (value != null && typeof value !== "number" && typeof value !== "string" && typeof value !== "boolean") {
throw TypeError("Expected value to be one of Number or String or Boolean or null or undefined, got " + __typeof(value));
}
this.consts[name] = value;
};
function getIdent(scope, name) {
var _arr, _i, _len, _ref, child, variables;
variables = scope.variables;
if (__owns.call(variables, name)) {
return variables[name];
} else {
for (_arr = __toArray(scope.children), _i = 0, _len = _arr.length; _i < _len; ++_i) {
child = _arr[_i];
if ((_ref = getIdent(child, name)) != null) {
return _ref;
}
}
}
}
function getTmp(scope, id) {
var _arr, _i, _len, _ref, child, tmps;
tmps = scope.tmps;
if (__owns.call(tmps, id)) {
return tmps[id];
} else {
for (_arr = __toArray(scope.children), _i = 0, _len = _arr.length; _i < _len; ++_i) {
child = _arr[_i];
if ((_ref = getTmp(child, id)) != null) {
return _ref;
}
}
}
}
function get(scope, ident) {
var _ref, _ref2, current, isTmp, layers;
current = scope;
isTmp = ident instanceof TmpNode;
layers = 0;
while (current) {
++layers;
if (layers > 1000) {
throw Error("Infinite loop detected");
}
current = current.top();
if (isTmp) {
if ((_ref = getTmp(current, ident.id)) != null) {
return _ref;
}
} else if ((_ref2 = getIdent(current, ident.name)) != null) {
return _ref2;
}
current = current.parent;
}
}
_Scope_prototype.has = function (ident) {
if (!(ident instanceof IdentNode) && !(ident instanceof TmpNode)) {
throw TypeError("Expected ident to be one of " + (__name(IdentNode) + " or " + __name(TmpNode)) + ", got " + __typeof(ident));
}
if (this.destroyed) {
throw ScopeDestroyedError();
}
return get(this, ident) != null;
};
_Scope_prototype.isMutable = function (ident) {
var _ref;
if (!(ident instanceof IdentNode) && !(ident instanceof TmpNode)) {
throw TypeError("Expected ident to be one of " + (__name(IdentNode) + " or " + __name(TmpNode)) + ", got " + __typeof(ident));
}
if (this.destroyed) {
throw ScopeDestroyedError();
}
return ((_ref = get(this, ident)) != null ? _ref.isMutable : void 0) || false;
};
_Scope_prototype.type = function (ident) {
var _ref;
if (!(ident instanceof IdentNode) && !(ident instanceof TmpNode)) {
throw TypeError("Expected ident to be one of " + (__name(IdentNode) + " or " + __name(TmpNode)) + ", got " + __typeof(ident));
}
if (this.destroyed) {
throw ScopeDestroyedError();
}
return ((_ref = get(this, ident)) != null ? _ref.type : void 0) || Type.any;
};
function getConst(scope, name) {
var _arr, _i, _len, _ref, child, consts;
consts = scope.consts;
if (__owns.call(consts, name)) {
return { value: consts[name] };
} else {
for (_arr = __toArray(scope.children), _i = 0, _len = _arr.length; _i < _len; ++_i) {
child = _arr[_i];
if ((_ref = getConst(child, name)) != null) {
return _ref;
}
}
}
}
_Scope_prototype.constValue = function (name) {
var _ref, current, layers;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (this.destroyed) {
throw ScopeDestroyedError();
}
current = this;
layers = 0;
while (current) {
++layers;
if (layers > 1000) {
throw Error("Infinite loop detected");
}
current = current.top();
if ((_ref = getConst(current, name)) != null) {
return _ref;
}
current = current.parent;
}
};
return Scope;
}());
module.exports = Scope;
(_ref = module.exports).ScopeDestroyedError = ScopeDestroyedError;
}.call(this));
return module.exports;
};
require['./parser-nodes'] = function () {
var module = { exports: this };
var exports = this;
(function (GLOBAL) {
"use strict";
var __async, __create, __curry, __in, __isArray, __keys, __name, __num, __once, __owns, __slice, __strnum, __toArray, __typeof, _ref, AccessMultiNode, AccessNode, ArgsNode, ArrayNode, AssignNode, BinaryNode, BlockNode, BreakNode, CallNode, CommentNode, ConstNode, ContinueNode, DebuggerNode, DefNode, EmbedWriteNode, EvalNode, ForInNode, ForNode, FunctionNode, IdentNode, IfNode, inspect, MacroAccessNode, mapAsync, Node, nodeToType, NothingNode, ObjectNode, ParamNode, quote, RegexpNode, ReturnNode, RootNode, SpreadNode, SuperNode, SwitchNode, SyntaxChoiceNode, SyntaxManyNode, SyntaxParamNode, SyntaxSequenceNode, ThisNode, ThrowNode, TmpNode, TmpWrapperNode, TryCatchNode, TryFinallyNode, Type, TypeFunctionNode, TypeGenericNode, TypeObjectNode, TypeUnionNode, UnaryNode, VarNode, YieldNode;
__async = function (limit, length, hasResult, onValue, onComplete) {
var broken, completed, index, result, slotsUsed, sync;
if (typeof limit !== "number") {
throw TypeError("Expected limit to be a Number, got " + __typeof(limit));
}
if (typeof length !== "number") {
throw TypeError("Expected length to be a Number, got " + __typeof(length));
}
if (hasResult == null) {
hasResult = false;
} else if (typeof hasResult !== "boolean") {
throw TypeError("Expected hasResult to be a Boolean, got " + __typeof(hasResult));
}
if (typeof onValue !== "function") {
throw TypeError("Expected onValue to be a Function, got " + __typeof(onValue));
}
if (typeof onComplete !== "function") {
throw TypeError("Expected onComplete to be a Function, got " + __typeof(onComplete));
}
if (hasResult) {
result = [];
} else {
result = null;
}
if (length <= 0) {
return onComplete(null, result);
}
if (limit < 1 || limit !== limit) {
limit = 1/0;
}
broken = null;
slotsUsed = 0;
sync = false;
completed = false;
function onValueCallback(err, value) {
if (completed) {
return;
}
--slotsUsed;
if (err != null && broken == null) {
broken = err;
}
if (hasResult && broken == null && arguments.length > 1) {
result.push(value);
}
if (!sync) {
next();
}
}
index = -1;
function next() {
while (!completed && broken == null && slotsUsed < limit && ++index < length) {
++slotsUsed;
sync = true;
onValue(index, __once(onValueCallback));
sync = false;
}
if (!completed && (broken != null || slotsUsed === 0)) {
completed = true;
if (broken != null) {
onComplete(broken);
} else {
onComplete(null, result);
}
}
}
next();
};
__create = typeof Object.create === "function" ? Object.create
: function (x) {
function F() {}
F.prototype = x;
return new F();
};
__curry = function (numArgs, f) {
var currier;
if (typeof numArgs !== "number") {
throw TypeError("Expected numArgs to be a Number, got " + __typeof(numArgs));
}
if (typeof f !== "function") {
throw TypeError("Expected f to be a Function, got " + __typeof(f));
}
if (numArgs > 1) {
currier = function (args) {
var ret;
if (__num(args.length) >= numArgs) {
return f.apply(this, args);
} else {
ret = function () {
if (arguments.length === 0) {
return ret;
} else {
return currier.call(this, args.concat(__slice.call(arguments)));
}
};
return ret;
}
};
return currier([]);
} else {
return f;
}
};
__in = typeof Array.prototype.indexOf === "function"
? (function () {
var indexOf;
indexOf = Array.prototype.indexOf;
return function (child, parent) {
return indexOf.call(parent, child) !== -1;
};
}())
: function (child, parent) {
var i, len;
len = +parent.length;
i = -1;
while (++i < len) {
if (child === parent[i] && i in parent) {
return true;
}
}
return false;
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__keys = typeof Object.keys === "function" ? Object.keys
: function (x) {
var key, keys;
keys = [];
for (key in x) {
if (__owns.call(x, key)) {
keys.push(key);
}
}
return keys;
};
__name = function (func) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
return func.displayName || func.name || "";
};
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__once = (function () {
function replacement() {
throw Error("Attempted to call function more than once");
}
function doNothing() {}
return function (func, silentFail) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
if (silentFail == null) {
silentFail = false;
} else if (typeof silentFail !== "boolean") {
throw TypeError("Expected silentFail to be a Boolean, got " + __typeof(silentFail));
}
return function () {
var f;
f = func;
func = silentFail ? doNothing : replacement;
return f.apply(this, arguments);
};
};
}());
__owns = Object.prototype.hasOwnProperty;
__slice = Array.prototype.slice;
__strnum = function (strnum) {
var type;
type = typeof strnum;
if (type === "string") {
return strnum;
} else if (type === "number") {
return String(strnum);
} else {
throw TypeError("Expected a string or number, got " + __typeof(strnum));
}
};
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
Type = require("./types");
nodeToType = (_ref = require("./parser-utils")).nodeToType;
map = _ref.map;
mapAsync = _ref.mapAsync;
quote = require("./utils").quote;
if ((_ref = require("util")) != null) {
inspect = _ref.inspect;
}
function map(array, func, arg) {
var _arr, _i, _len, changed, item, newItem, result;
result = [];
changed = false;
for (_arr = __toArray(array), _i = 0, _len = _arr.length; _i < _len; ++_i) {
item = _arr[_i];
newItem = func(item, arg);
result.push(newItem);
if (item !== newItem) {
changed = true;
}
}
if (changed) {
return result;
} else {
return array;
}
}
Node = (function () {
var _Node_prototype;
function Node() {
var _this;
_this = this instanceof Node ? this : __create(_Node_prototype);
throw Error("Node should not be instantiated directly");
}
_Node_prototype = Node.prototype;
Node.displayName = "Node";
_Node_prototype.type = function () {
return Type.any;
};
_Node_prototype.walk = function (f) {
return this;
};
_Node_prototype.walkAsync = function (f, callback) {
return callback(null, this);
};
_Node_prototype.cacheable = true;
_Node_prototype.withLabel = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return BlockNode(
this.line,
this.column,
this.scope,
[this],
label
);
};
_Node_prototype._reduce = function (parser) {
return this.walk(function (node) {
return node.reduce(parser);
});
};
_Node_prototype.reduce = function (parser) {
var reduced;
if (this._reduced != null) {
return this._reduced;
} else {
reduced = this._reduce(parser);
if (reduced === this) {
return this._reduced = this;
} else {
return this._reduced = reduced.reduce(parser);
}
}
};
_Node_prototype.isConst = function () {
return false;
};
_Node_prototype.constValue = function () {
throw Error("Not a const: " + __typeof(this));
};
_Node_prototype.isConstType = function () {
return false;
};
_Node_prototype.isConstValue = function () {
return false;
};
_Node_prototype.isLiteral = function () {
return this.isConst();
};
_Node_prototype.literalValue = function () {
return this.constValue();
};
_Node_prototype.isNoop = function (o) {
return this.reduce(o)._isNoop(o);
};
_Node_prototype._isNoop = function (o) {
return false;
};
_Node_prototype.isStatement = function () {
return false;
};
_Node_prototype.rescope = function (newScope) {
var oldScope;
if (this.scope === newScope) {
return this;
}
oldScope = this.scope;
this.scope = newScope;
function walker(node) {
var nodeScope, parent;
nodeScope = node.scope;
if (nodeScope === newScope) {
return node;
} else if (nodeScope === oldScope) {
return node.rescope(newScope);
} else {
parent = nodeScope.parent;
if (parent === oldScope) {
nodeScope.reparent(newScope);
}
return node.walk(walker);
}
}
return this.walk(walker);
};
_Node_prototype.doWrap = function (parser) {
var innerScope, result;
if (this.isStatement()) {
innerScope = parser.pushScope(true, this.scope);
result = CallNode(
this.line,
this.column,
this.scope,
FunctionNode(
this.line,
this.column,
this.scope,
[],
this.rescope(innerScope),
true,
true
),
[]
);
parser.popScope();
return result;
} else {
return this;
}
};
return Node;
}());
function inspectHelper(depth, name, line, column) {
var _arr, _i, _len, arg, args, d, found, hasLarge, parts;
args = __slice.call(arguments, 4);
if (depth != null) {
d = __num(depth) - 1;
} else {
d = null;
}
found = false;
for (_i = args.length; _i--; ) {
arg = args[_i];
if (!arg || arg instanceof NothingNode || __isArray(arg) && arg.length === 0) {
args.pop();
} else {
break;
}
}
for (_arr = [], _i = 0, _len = args.length; _i < _len; ++_i) {
arg = args[_i];
_arr.push(inspect(arg, null, d));
}
parts = _arr;
hasLarge = (function () {
var _i, _len, part;
for (_i = 0, _len = parts.length; _i < _len; ++_i) {
part = parts[_i];
if (parts.length > 50 || part.indexOf("\n") !== -1) {
return true;
}
}
return false;
}());
if (hasLarge) {
parts = (function () {
var _arr, _i, _len, part;
for (_arr = [], _i = 0, _len = parts.length; _i < _len; ++_i) {
part = parts[_i];
_arr.push(" " + __strnum(part.split("\n").join("\n ")));
}
return _arr;
}());
return __strnum(name) + "(\n" + __strnum(parts.join(",\n")) + ")";
} else {
return __strnum(name) + "(" + __strnum(parts.join(", ")) + ")";
}
}
Node.Access = AccessNode = (function (Node) {
var _AccessNode_prototype, _Node_prototype;
function AccessNode(line, column, scope, parent, child) {
var _this;
_this = this instanceof AccessNode ? this : __create(_AccessNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(parent instanceof Node)) {
throw TypeError("Expected parent to be a " + __name(Node) + ", got " + __typeof(parent));
}
if (!(child instanceof Node)) {
throw TypeError("Expected child to be a " + __name(Node) + ", got " + __typeof(child));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.parent = parent;
_this.child = child;
return _this;
}
_Node_prototype = Node.prototype;
_AccessNode_prototype = AccessNode.prototype = __create(_Node_prototype);
_AccessNode_prototype.constructor = AccessNode;
AccessNode.displayName = "AccessNode";
if (typeof Node.extended === "function") {
Node.extended(AccessNode);
}
AccessNode.cappedName = "Access";
AccessNode.argNames = ["parent", "child"];
_AccessNode_prototype.type = function (o) {
var _ref, _this;
_this = this;
if ((_ref = this._type) == null) {
return this._type = (function () {
var child, childType, childValue, isString, parentType;
parentType = _this.parent.type(o);
isString = parentType.isSubsetOf(Type.string);
if (isString || parentType.isSubsetOf(Type.arrayLike)) {
child = o.macroExpand1(_this.child).reduce(o);
if (child.isConst()) {
childValue = child.constValue();
if (childValue === "length") {
return Type.number;
} else if (typeof childValue === "number") {
if (__num(childValue) >= 0 && __num(childValue) % 1 === 0) {
if (isString) {
return Type.string.union(Type["undefined"]);
} else if (parentType.subtype) {
return parentType.subtype.union(Type["undefined"]);
} else {
return Type.any;
}
} else {
return Type["undefined"];
}
}
} else {
childType = child.type(o);
if (childType.isSubsetOf(Type.number)) {
if (isString) {
return Type.string.union(Type["undefined"]);
} else if (parentType.subtype) {
return parentType.subtype.union(Type["undefined"]);
} else {
return Type.any;
}
}
}
} else if (parentType.isSubsetOf(Type.object) && typeof parentType.value === "function") {
child = o.macroExpand1(_this.child).reduce(o);
if (child.isConst()) {
return parentType.value(String(child.constValue()));
}
}
return Type.any;
}());
} else {
return _ref;
}
};
_AccessNode_prototype._reduce = function (o) {
var _ref, args, cachedParent, child, cValue, end, hasEnd, hasStep, inclusive, parent, pValue, start, step, value;
parent = this.parent.reduce(o).doWrap(o);
cachedParent = null;
function replaceLengthIdent(node) {
var nodeParent;
if (node instanceof IdentNode && node.name === "__currentArrayLength") {
if (parent.cacheable && cachedParent == null) {
cachedParent = o.makeTmp(
o.indexFromPosition(node.line, node.column),
"ref",
parent.type(o)
);
cachedParent.scope = node.scope;
}
return AccessNode(
node.line,
node.column,
node.scope,
cachedParent != null ? cachedParent : parent,
ConstNode(node.line, node.column, node.scope, "length")
);
} else if (node instanceof AccessNode) {
nodeParent = replaceLengthIdent(node.parent);
if (nodeParent !== node.parent) {
return AccessNode(
node.line,
node.column,
node.scope,
nodeParent,
node.child
).walk(replaceLengthIdent);
} else {
return node.walk(replaceLengthIdent);
}
} else {
return node.walk(replaceLengthIdent);
}
}
child = replaceLengthIdent(this.child.reduce(o).doWrap(o));
if (cachedParent != null) {
return TmpWrapperNode(
this.line,
this.column,
this.scope,
AccessNode(
this.line,
this.column,
this.scope,
AssignNode(
this.line,
this.column,
this.scope,
cachedParent,
"=",
parent
),
child
),
[cachedParent.id]
);
}
if (parent.isConst() && child.isConst()) {
pValue = parent.constValue();
cValue = child.constValue();
if (cValue in Object(pValue)) {
value = pValue[cValue];
if (value === null || value instanceof RegExp || (_ref = typeof value) === "string" || _ref === "number" || _ref === "boolean" || _ref === "undefined") {
return ConstNode(this.line, this.column, this.scope, value);
}
}
}
if (child instanceof CallNode && child.func instanceof IdentNode && child.func.name === "__range") {
start = (_ref = child.args)[0];
end = _ref[1];
step = _ref[2];
inclusive = _ref[3];
hasStep = !step.isConst() || step.constValue() !== 1;
if (!hasStep) {
if (inclusive.isConst()) {
if (inclusive.constValue()) {
end = end.isConst() && typeof end.constValue() === "number" ? ConstNode(end.line, end.column, end.scope, __num(end.constValue()) + 1 || 1/0)
: BinaryNode(
end.line,
end.column,
end.scope,
BinaryNode(
end.line,
end.column,
end.scope,
end,
"+",
ConstNode(inclusive.line, inclusive.column, inclusive.scope, 1)
),
"||",
ConstNode(end.line, end.column, end.scope, 1/0)
);
}
} else {
end = IfNode(
end.line,
end.column,
end.scope,
inclusive,
BinaryNode(
end.line,
end.column,
end.scope,
BinaryNode(
end.line,
end.column,
end.scope,
end,
"+",
ConstNode(inclusive.line, inclusive.column, inclusive.scope, 1)
),
"||",
ConstNode(end.line, end.column, end.scope, 1/0)
),
end
);
}
}
args = [parent];
hasEnd = !end.isConst() || (_ref = end.constValue()) !== void 0 && _ref !== 1/0;
if (!start.isConst() || start.constValue() !== 0 || hasEnd || hasStep) {
args.push(start);
}
if (hasEnd || hasStep) {
args.push(end);
}
if (hasStep) {
args.push(step);
if (!inclusive.isConst() || inclusive.constValue()) {
args.push(inclusive);
}
}
return CallNode(
this.line,
this.column,
this.scope,
IdentNode(this.line, this.column, this.scope, hasStep ? "__sliceStep" : "__slice"),
args,
false,
!hasStep
).reduce(o);
} else if (parent !== this.parent || child !== this.child) {
return AccessNode(
this.line,
this.column,
this.scope,
parent,
child
);
} else {
return this;
}
};
_AccessNode_prototype._isNoop = function (o) {
var _ref;
if ((_ref = this.__isNoop) == null) {
return this.__isNoop = this.parent.isNoop(o) && this.child.isNoop(o);
} else {
return _ref;
}
};
_AccessNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"AccessNode",
this.line,
this.column,
this.parent,
this.child
);
};
_AccessNode_prototype.walk = function (f) {
var child, parent;
parent = f(this.parent);
child = f(this.child);
if (parent !== this.parent || child !== this.child) {
return AccessNode(
this.line,
this.column,
this.scope,
parent,
child
);
} else {
return this;
}
};
_AccessNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.parent, (_once = false, function (_e, parent) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return f(_this.child, (_once2 = false, function (_e2, child) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return callback(null, parent !== _this.parent || child !== _this.child
? AccessNode(
_this.line,
_this.column,
_this.scope,
parent,
child
)
: _this);
}));
}));
};
return AccessNode;
}(Node));
Node.AccessMulti = AccessMultiNode = (function (Node) {
var _AccessMultiNode_prototype, _Node_prototype;
function AccessMultiNode(line, column, scope, parent, elements) {
var _i, _this;
_this = this instanceof AccessMultiNode ? this : __create(_AccessMultiNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(parent instanceof Node)) {
throw TypeError("Expected parent to be a " + __name(Node) + ", got " + __typeof(parent));
}
if (!__isArray(elements)) {
throw TypeError("Expected elements to be an Array, got " + __typeof(elements));
} else {
for (_i = elements.length; _i--; ) {
if (!(elements[_i] instanceof Node)) {
throw TypeError("Expected " + ("elements[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(elements[_i]));
}
}
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.parent = parent;
_this.elements = elements;
return _this;
}
_Node_prototype = Node.prototype;
_AccessMultiNode_prototype = AccessMultiNode.prototype = __create(_Node_prototype);
_AccessMultiNode_prototype.constructor = AccessMultiNode;
AccessMultiNode.displayName = "AccessMultiNode";
if (typeof Node.extended === "function") {
Node.extended(AccessMultiNode);
}
AccessMultiNode.cappedName = "AccessMulti";
AccessMultiNode.argNames = ["parent", "elements"];
_AccessMultiNode_prototype.type = function () {
return Type.array;
};
_AccessMultiNode_prototype._reduce = function (o) {
var _this, parent, result, setParent, tmp, tmpIds;
_this = this;
parent = this.parent.reduce(o);
setParent = parent;
tmpIds = [];
if (parent.cacheable) {
tmp = o.makeTmp(
o.indexFromPosition(this.line, this.column),
"ref",
parent.type(o)
);
tmp.scope = this.scope;
tmpIds.push(tmp.id);
setParent = AssignNode(
this.line,
this.column,
this.scope,
tmp,
"=",
parent.doWrap(o)
);
parent = tmp;
}
result = ArrayNode(this.line, this.column, this.scope, (function () {
var _arr, _arr2, _len, element, j;
for (_arr = [], _arr2 = __toArray(_this.elements), j = 0, _len = _arr2.length; j < _len; ++j) {
element = _arr2[j];
_arr.push(AccessNode(
_this.line,
_this.column,
_this.scope,
j === 0 ? setParent : parent,
element.reduce(o)
));
}
return _arr;
}()));
if (tmpIds.length) {
return TmpWrapperNode(
this.line,
this.column,
this.scope,
result,
tmpIds
);
} else {
return result;
}
};
_AccessMultiNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"AccessMultiNode",
this.line,
this.column,
this.parent,
this.elements
);
};
_AccessMultiNode_prototype.walk = function (f) {
var elements, parent;
parent = f(this.parent);
elements = map(this.elements, f);
if (parent !== this.parent || elements !== this.elements) {
return AccessMultiNode(
this.line,
this.column,
this.scope,
parent,
elements
);
} else {
return this;
}
};
_AccessMultiNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.parent, (_once = false, function (_e, parent) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return mapAsync(_this.elements, f, (_once2 = false, function (_e2, elements) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return callback(null, parent !== _this.parent || elements !== _this.elements
? AccessMultiNode(
_this.line,
_this.column,
_this.scope,
parent,
elements
)
: _this);
}));
}));
};
return AccessMultiNode;
}(Node));
Node.Args = ArgsNode = (function (Node) {
var _ArgsNode_prototype, _Node_prototype;
function ArgsNode(line, column, scope) {
var _this;
_this = this instanceof ArgsNode ? this : __create(_ArgsNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
return _this;
}
_Node_prototype = Node.prototype;
_ArgsNode_prototype = ArgsNode.prototype = __create(_Node_prototype);
_ArgsNode_prototype.constructor = ArgsNode;
ArgsNode.displayName = "ArgsNode";
if (typeof Node.extended === "function") {
Node.extended(ArgsNode);
}
ArgsNode.cappedName = "Args";
ArgsNode.argNames = [];
_ArgsNode_prototype.type = function () {
return Type.args;
};
_ArgsNode_prototype.cacheable = false;
_ArgsNode_prototype._isNoop = function () {
return true;
};
_ArgsNode_prototype.inspect = function (depth) {
return inspectHelper(depth, "ArgsNode", this.line, this.column);
};
return ArgsNode;
}(Node));
Node.Array = ArrayNode = (function (Node) {
var _ArrayNode_prototype, _Node_prototype;
function ArrayNode(line, column, scope, elements) {
var _i, _this;
_this = this instanceof ArrayNode ? this : __create(_ArrayNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!__isArray(elements)) {
throw TypeError("Expected elements to be an Array, got " + __typeof(elements));
} else {
for (_i = elements.length; _i--; ) {
if (!(elements[_i] instanceof Node)) {
throw TypeError("Expected " + ("elements[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(elements[_i]));
}
}
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.elements = elements;
return _this;
}
_Node_prototype = Node.prototype;
_ArrayNode_prototype = ArrayNode.prototype = __create(_Node_prototype);
_ArrayNode_prototype.constructor = ArrayNode;
ArrayNode.displayName = "ArrayNode";
if (typeof Node.extended === "function") {
Node.extended(ArrayNode);
}
ArrayNode.cappedName = "Array";
ArrayNode.argNames = ["elements"];
_ArrayNode_prototype.type = function () {
return Type.array;
};
_ArrayNode_prototype._reduce = function (o) {
var elements;
elements = map(this.elements, function (x) {
return x.reduce(o).doWrap(o);
});
if (elements !== this.elements) {
return ArrayNode(this.line, this.column, this.scope, elements);
} else {
return this;
}
};
_ArrayNode_prototype._isNoop = function (o) {
var _ref, _this;
_this = this;
if ((_ref = this.__isNoop) == null) {
return this.__isNoop = (function () {
var _arr, _i, _len, element;
for (_arr = __toArray(_this.elements), _i = 0, _len = _arr.length; _i < _len; ++_i) {
element = _arr[_i];
if (!element.isNoop(o)) {
return false;
}
}
return true;
}());
} else {
return _ref;
}
};
_ArrayNode_prototype.isLiteral = function () {
var _ref, _this;
_this = this;
if ((_ref = this._isLiteral) == null) {
return this._isLiteral = (function () {
var _arr, _i, _len, element;
for (_arr = __toArray(_this.elements), _i = 0, _len = _arr.length; _i < _len; ++_i) {
element = _arr[_i];
if (!element.isLiteral()) {
return false;
}
}
return true;
}());
} else {
return _ref;
}
};
_ArrayNode_prototype.literalValue = function () {
var _arr, _arr2, _i, _len, element;
for (_arr = [], _arr2 = __toArray(this.elements), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
element = _arr2[_i];
_arr.push(element.literalValue());
}
return _arr;
};
_ArrayNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"ArrayNode",
this.line,
this.column,
this.elements
);
};
_ArrayNode_prototype.walk = function (f) {
var elements;
elements = map(this.elements, f);
if (elements !== this.elements) {
return ArrayNode(this.line, this.column, this.scope, elements);
} else {
return this;
}
};
_ArrayNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return mapAsync(this.elements, f, (_once = false, function (_e, elements) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, elements !== _this.elements ? ArrayNode(_this.line, _this.column, _this.scope, elements) : _this);
}));
};
return ArrayNode;
}(Node));
Node.Assign = AssignNode = (function (Node) {
var _AssignNode_prototype, _Node_prototype;
function AssignNode(line, column, scope, left, op, right) {
var _this;
_this = this instanceof AssignNode ? this : __create(_AssignNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(left instanceof Node)) {
throw TypeError("Expected left to be a " + __name(Node) + ", got " + __typeof(left));
}
if (typeof op !== "string") {
throw TypeError("Expected op to be a String, got " + __typeof(op));
}
if (!(right instanceof Node)) {
throw TypeError("Expected right to be a " + __name(Node) + ", got " + __typeof(right));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.left = left;
_this.op = op;
_this.right = right;
return _this;
}
_Node_prototype = Node.prototype;
_AssignNode_prototype = AssignNode.prototype = __create(_Node_prototype);
_AssignNode_prototype.constructor = AssignNode;
AssignNode.displayName = "AssignNode";
if (typeof Node.extended === "function") {
Node.extended(AssignNode);
}
AssignNode.cappedName = "Assign";
AssignNode.argNames = ["left", "op", "right"];
_AssignNode_prototype.type = (function () {
var ops;
ops = {
"=": function (left, right) {
return right;
},
"+=": function (left, right) {
if (left.isSubsetOf(Type.numeric) && right.isSubsetOf(Type.numeric)) {
return Type.number;
} else if (left.overlaps(Type.numeric) && right.overlaps(Type.numeric)) {
return Type.stringOrNumber;
} else {
return Type.string;
}
},
"-=": Type.number,
"*=": Type.number,
"/=": Type.number,
"%=": Type.number,
"<<=": Type.number,
">>=": Type.number,
">>>=": Type.number,
"&=": Type.number,
"^=": Type.number,
"|=": Type.number
};
return function (o) {
var _ref, _this;
_this = this;
if ((_ref = this._type) == null) {
return this._type = (function () {
var _ref, type;
if (__owns.call(ops, _ref = _this.op)) {
type = ops[_ref];
}
if (!type) {
return Type.any;
} else if (typeof type === "function") {
return type(_this.left.type(o), _this.right.type(o));
} else {
return type;
}
}());
} else {
return _ref;
}
};
}());
_AssignNode_prototype._reduce = function (o) {
var left, right;
left = this.left.reduce(o);
right = this.right.reduce(o).doWrap(o);
if (left !== this.left || right !== this.right) {
return AssignNode(
this.line,
this.column,
this.scope,
left,
this.op,
right
);
} else {
return this;
}
};
_AssignNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"AssignNode",
this.line,
this.column,
this.left,
this.op,
this.right
);
};
_AssignNode_prototype.walk = function (f) {
var left, right;
left = f(this.left);
right = f(this.right);
if (left !== this.left || right !== this.right) {
return AssignNode(
this.line,
this.column,
this.scope,
left,
this.op,
right
);
} else {
return this;
}
};
_AssignNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.left, (_once = false, function (_e, left) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return f(_this.right, (_once2 = false, function (_e2, right) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return callback(null, left !== _this.left || right !== _this.right
? AssignNode(
_this.line,
_this.column,
_this.scope,
left,
_this.op,
right
)
: _this);
}));
}));
};
return AssignNode;
}(Node));
Node.Binary = BinaryNode = (function (Node) {
var _BinaryNode_prototype, _Node_prototype;
function BinaryNode(line, column, scope, left, op, right) {
var _this;
_this = this instanceof BinaryNode ? this : __create(_BinaryNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(left instanceof Node)) {
throw TypeError("Expected left to be a " + __name(Node) + ", got " + __typeof(left));
}
if (typeof op !== "string") {
throw TypeError("Expected op to be a String, got " + __typeof(op));
}
if (!(right instanceof Node)) {
throw TypeError("Expected right to be a " + __name(Node) + ", got " + __typeof(right));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.left = left;
_this.op = op;
_this.right = right;
return _this;
}
_Node_prototype = Node.prototype;
_BinaryNode_prototype = BinaryNode.prototype = __create(_Node_prototype);
_BinaryNode_prototype.constructor = BinaryNode;
BinaryNode.displayName = "BinaryNode";
if (typeof Node.extended === "function") {
Node.extended(BinaryNode);
}
BinaryNode.cappedName = "Binary";
BinaryNode.argNames = ["left", "op", "right"];
_BinaryNode_prototype.type = (function () {
var ops;
ops = {
"*": Type.number,
"/": Type.number,
"%": Type.number,
"+": function (left, right) {
if (left.isSubsetOf(Type.numeric) && right.isSubsetOf(Type.numeric)) {
return Type.number;
} else if (left.overlaps(Type.numeric) && right.overlaps(Type.numeric)) {
return Type.stringOrNumber;
} else {
return Type.string;
}
},
"-": Type.number,
"<<": Type.number,
">>": Type.number,
">>>": Type.number,
"<": Type.boolean,
"<=": Type.boolean,
">": Type.boolean,
">=": Type.boolean,
"in": Type.boolean,
"instanceof": Type.boolean,
"==": Type.boolean,
"!=": Type.boolean,
"===": Type.boolean,
"!==": Type.boolean,
"&": Type.number,
"^": Type.number,
"|": Type.number,
"&&": function (left, right) {
return left.intersect(Type.potentiallyFalsy).union(right);
},
"||": function (left, right) {
return left.intersect(Type.potentiallyTruthy).union(right);
}
};
return function (o) {
var _ref, _this;
_this = this;
if ((_ref = this._type) == null) {
return this._type = (function () {
var _ref, type;
if (__owns.call(ops, _ref = _this.op)) {
type = ops[_ref];
}
if (!type) {
return Type.any;
} else if (typeof type === "function") {
return type(_this.left.type(o), _this.right.type(o));
} else {
return type;
}
}());
} else {
return _ref;
}
};
}());
_BinaryNode_prototype._reduce = (function () {
var constOps, leftConstOps, nonConstOps, rightConstOps;
constOps = {
"*": __curry(2, function (x, y) {
return x * y;
}),
"/": __curry(2, function (x, y) {
return x / y;
}),
"%": __curry(2, function (x, y) {
return x % y;
}),
"+": (function () {
function isJSNumeric(x) {
var _ref;
return x === null || (_ref = typeof x) === "number" || _ref === "boolean" || _ref === "undefined";
}
return function (left, right) {
if (isJSNumeric(left) && isJSNumeric(right)) {
return left - -right;
} else {
return "" + left + right;
}
};
}()),
"-": __curry(2, function (x, y) {
return x - y;
}),
"<<": __curry(2, function (x, y) {
return x << y;
}),
">>": __curry(2, function (x, y) {
return x >> y;
}),
">>>": __curry(2, function (x, y) {
return x >>> y;
}),
"<": __curry(2, function (x, y) {
return x < y;
}),
"<=": __curry(2, function (x, y) {
return x <= y;
}),
">": __curry(2, function (x, y) {
return x > y;
}),
">=": __curry(2, function (x, y) {
return x >= y;
}),
"==": __curry(2, function (x, y) {
return x == y;
}),
"!=": __curry(2, function (x, y) {
return x != y;
}),
"===": __curry(2, function (x, y) {
return x === y;
}),
"!==": __curry(2, function (x, y) {
return x !== y;
}),
"&": __curry(2, function (x, y) {
return x & y;
}),
"^": __curry(2, function (x, y) {
return x ^ y;
}),
"|": __curry(2, function (x, y) {
return x | y;
}),
"&&": __curry(2, function (x, y) {
return x && y;
}),
"||": __curry(2, function (x, y) {
return x || y;
})
};
function leftConstNan(x, y) {
var _ref;
if ((_ref = x.constValue()) !== _ref) {
return BlockNode(this.line, this.column, this.scope, [y, x]);
}
}
leftConstOps = {
"*": function (x, y) {
var _ref;
if (x.constValue() === 1) {
return UnaryNode(
this.line,
this.column,
this.scope,
"+",
y
);
} else if (x.constValue() === -1) {
return UnaryNode(
this.line,
this.column,
this.scope,
"-",
y
);
} else if ((_ref = x.constValue()) !== _ref) {
return BlockNode(this.line, this.column, this.scope, [y, x]);
}
},
"/": leftConstNan,
"%": leftConstNan,
"+": function (x, y, o) {
var _ref;
if (x.constValue() === 0 && y.type(o).isSubsetOf(Type.number)) {
return UnaryNode(
this.line,
this.column,
this.scope,
"+",
y
);
} else if (x.constValue() === "" && y.type(o).isSubsetOf(Type.string)) {
return y;
} else if (typeof x.constValue() === "string" && y instanceof BinaryNode && y.op === "+" && y.left.isConst() && typeof y.left.constValue() === "string") {
return BinaryNode(
this.line,
this.column,
this.scope,
ConstNode(x.line, x.column, this.scope, __strnum(x.constValue()) + __strnum(y.left.constValue())),
"+",
y.right
);
} else if ((_ref = x.constValue()) !== _ref) {
return BlockNode(this.line, this.column, this.scope, [y, x]);
}
},
"-": function (x, y) {
var _ref;
if (x.constValue() === 0) {
return UnaryNode(
this.line,
this.column,
this.scope,
"-",
y
);
} else if ((_ref = x.constValue()) !== _ref) {
return BlockNode(this.line, this.column, this.scope, [y, x]);
}
},
"<<": leftConstNan,
">>": leftConstNan,
">>>": leftConstNan,
"&": leftConstNan,
"|": leftConstNan,
"^": leftConstNan,
"&&": function (x, y) {
if (x.constValue()) {
return y;
} else {
return x;
}
},
"||": function (x, y) {
if (x.constValue()) {
return x;
} else {
return y;
}
}
};
function rightConstNan(x, y) {
var _ref;
if ((_ref = y.constValue()) !== _ref) {
return BlockNode(this.line, this.column, this.scope, [x, y]);
}
}
rightConstOps = {
"*": function (x, y) {
var _ref;
if (y.constValue() === 1) {
return UnaryNode(
this.line,
this.column,
this.scope,
"+",
x
);
} else if (y.constValue() === -1) {
return UnaryNode(
this.line,
this.column,
this.scope,
"-",
x
);
} else if ((_ref = y.constValue()) !== _ref) {
return BlockNode(this.line, this.column, this.scope, [x, y]);
}
},
"/": function (x, y) {
var _ref;
if (y.constValue() === 1) {
return UnaryNode(
this.line,
this.column,
this.scope,
"+",
x
);
} else if (y.constValue() === -1) {
return UnaryNode(
this.line,
this.column,
this.scope,
"-",
x
);
} else if ((_ref = y.constValue()) !== _ref) {
return BlockNode(this.line, this.column, this.scope, [x, y]);
}
},
"%": rightConstNan,
"+": function (x, y, o) {
var _ref;
if (y.constValue() === 0 && x.type(o).isSubsetOf(Type.number)) {
return UnaryNode(
this.line,
this.column,
this.scope,
"+",
x
);
} else if (typeof y.constValue() === "number" && __num(y.constValue()) < 0 && x.type(o).isSubsetOf(Type.number)) {
return BinaryNode(
this.line,
this.column,
this.scope,
x,
"-",
ConstNode(y.line, y.column, this.scope, -__num(y.constValue()))
);
} else if (y.constValue() === "" && x.type(o).isSubsetOf(Type.string)) {
return x;
} else if (typeof y.constValue() === "string" && x instanceof BinaryNode && x.op === "+" && x.right.isConst() && typeof x.right.constValue() === "string") {
return BinaryNode(
this.line,
this.column,
this.scope,
x.left,
"+",
ConstNode(x.right.line, x.right.column, this.scope, __strnum(x.right.constValue()) + __strnum(y.constValue()))
);
} else if ((_ref = y.constValue()) !== _ref) {
return BlockNode(this.line, this.column, this.scope, [x, y]);
}
},
"-": function (x, y, o) {
var _ref;
if (y.constValue() === 0) {
return UnaryNode(
this.line,
this.column,
this.scope,
"+",
x
);
} else if (typeof y.constValue() === "number" && __num(y.constValue()) < 0 && x.type(o).isSubsetOf(Type.number)) {
return BinaryNode(
this.line,
this.column,
this.scope,
x,
"+",
ConstNode(y.line, y.column, this.scope, -__num(y.constValue()))
);
} else if ((_ref = y.constValue()) !== _ref) {
return BlockNode(this.line, this.column, this.scope, [x, y]);
}
},
"<<": rightConstNan,
">>": rightConstNan,
">>>": rightConstNan,
"&": rightConstNan,
"|": rightConstNan,
"^": rightConstNan
};
nonConstOps = {
"&&": function (x, y, o) {
var truthy, xRightType, xType;
xType = x.type(o);
if (xType.isSubsetOf(Type.alwaysTruthy)) {
return BlockNode(this.line, this.column, this.scope, [x, y]);
} else if (xType.isSubsetOf(Type.alwaysFalsy)) {
return x;
} else if (x instanceof BinaryNode && x.op === "&&") {
if (x.right.isConst()) {
truthy = !!x.right.constValue();
} else {
xRightType = x.right.type(o);
if (xRightType.isSubsetOf(Type.alwaysTruthy)) {
truthy = true;
} else if (xRightType.isSubsetOf(Type.alwaysFalsy)) {
truthy = false;
} else {
truthy = null;
}
}
if (truthy === true) {
return BinaryNode(
this.line,
this.column,
this.scope,
x.left,
"&&",
BlockNode(x.right.line, x.right.column, this.scope, [x.right, y])
);
} else if (truthy === false) {
return x;
}
}
},
"||": function (x, y, o) {
var test, truthy, whenTrue, xRightType, xType;
xType = x.type(o);
if (xType.isSubsetOf(Type.alwaysTruthy)) {
return x;
} else if (xType.isSubsetOf(Type.alwaysFalsy)) {
return BlockNode(this.line, this.column, this.scope, [x, y]);
} else if (x instanceof BinaryNode && x.op === "||") {
if (x.right.isConst()) {
truthy = !!x.right.constValue();
} else {
xRightType = x.right.type(o);
if (xRightType.isSubsetOf(Type.alwaysTruthy)) {
truthy = true;
} else if (xRightType.isSubsetOf(Type.alwaysFalsy)) {
truthy = false;
} else {
truthy = null;
}
}
if (truthy === true) {
return x;
} else if (truthy === false) {
return BinaryNode(
this.line,
this.column,
this.scope,
x.left,
"||",
BlockNode(x.right.line, x.right.column, this.scope, [x.right, y])
);
}
} else if (x instanceof IfNode && x.whenFalse.isConst() && !x.whenFalse.constValue()) {
test = x.test;
whenTrue = x.whenTrue;
while (whenTrue instanceof IfNode && whenTrue.whenFalse.isConst() && !whenTrue.whenFalse.constValue()) {
test = BinaryNode(
x.line,
x.column,
x.scope,
test,
"&&",
whenTrue.test
);
whenTrue = whenTrue.whenTrue;
}
return BinaryNode(
this.line,
this.column,
this.scope,
BinaryNode(
x.line,
x.column,
x.scope,
test,
"&&",
whenTrue
),
"||",
y
);
}
}
};
return function (o) {
var _ref, left, op, right;
left = this.left.reduce(o).doWrap(o);
right = this.right.reduce(o).doWrap(o);
op = this.op;
if (left.isConst()) {
if (right.isConst() && __owns.call(constOps, op)) {
return ConstNode(this.line, this.column, this.scope, constOps[op](left.constValue(), right.constValue()));
}
if (__owns.call(leftConstOps, op) && (_ref = leftConstOps[op].call(this, left, right, o)) != null) {
return _ref;
}
}
if (right.isConst() && __owns.call(rightConstOps, op) && (_ref = rightConstOps[op].call(this, left, right, o)) != null) {
return _ref;
}
if (__owns.call(nonConstOps, op) && (_ref = nonConstOps[op].call(this, left, right, o)) != null) {
return _ref;
}
if (left !== this.left || right !== this.right) {
return BinaryNode(
this.line,
this.column,
this.scope,
left,
op,
right
);
} else {
return this;
}
};
}());
_BinaryNode_prototype._isNoop = function (o) {
var _ref;
if ((_ref = this.__isNoop) == null) {
return this.__isNoop = this.left.isNoop(o) && this.right.isNoop(o);
} else {
return _ref;
}
};
_BinaryNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"BinaryNode",
this.line,
this.column,
this.left,
this.op,
this.right
);
};
_BinaryNode_prototype.walk = function (f) {
var left, right;
left = f(this.left);
right = f(this.right);
if (left !== this.left || right !== this.right) {
return BinaryNode(
this.line,
this.column,
this.scope,
left,
this.op,
right
);
} else {
return this;
}
};
_BinaryNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.left, (_once = false, function (_e, left) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return f(_this.right, (_once2 = false, function (_e2, right) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return callback(null, left !== _this.left || right !== _this.right
? BinaryNode(
_this.line,
_this.column,
_this.scope,
left,
_this.op,
right
)
: _this);
}));
}));
};
return BinaryNode;
}(Node));
Node.Block = BlockNode = (function (Node) {
var _BlockNode_prototype, _Node_prototype;
function BlockNode(line, column, scope, nodes, label) {
var _i, _this;
_this = this instanceof BlockNode ? this : __create(_BlockNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!__isArray(nodes)) {
throw TypeError("Expected nodes to be an Array, got " + __typeof(nodes));
} else {
for (_i = nodes.length; _i--; ) {
if (!(nodes[_i] instanceof Node)) {
throw TypeError("Expected " + ("nodes[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(nodes[_i]));
}
}
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.nodes = nodes;
_this.label = label;
return _this;
}
_Node_prototype = Node.prototype;
_BlockNode_prototype = BlockNode.prototype = __create(_Node_prototype);
_BlockNode_prototype.constructor = BlockNode;
BlockNode.displayName = "BlockNode";
if (typeof Node.extended === "function") {
Node.extended(BlockNode);
}
BlockNode.cappedName = "Block";
BlockNode.argNames = ["nodes", "label"];
_BlockNode_prototype.type = function (o) {
var nodes;
nodes = this.nodes;
if (nodes.length === 0) {
return Type["undefined"];
} else {
return nodes[__num(nodes.length) - 1].type(o);
}
};
_BlockNode_prototype.withLabel = function (label, o) {
var _ref, _this;
_this = this;
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
if (this.label == null) {
if (this.nodes.length === 1) {
return this.nodes[0].withLabel(label, o);
} else if (__num(this.nodes.length) > 1 && (_ref = this.nodes)[__num(_ref.length) - 1] instanceof ForInNode && (function () {
var _arr, _end, _i, _len, node;
for (_arr = __toArray(_this.nodes), _i = 0, _len = _arr.length, _end = -1, _end += _len, _end > _len && (_end = _len); _i < _end; ++_i) {
node = _arr[_i];
if (!(node instanceof AssignNode) && !(node instanceof VarNode)) {
return false;
}
}
return true;
}())) {
return BlockNode(this.line, this.column, this.scope, __slice.call(this.nodes, 0, -1).concat([(_ref = this.nodes)[__num(_ref.length) - 1].withLabel(label, o)]));
}
}
return BlockNode(
this.line,
this.column,
this.scope,
this.nodes,
label
);
};
_BlockNode_prototype._reduce = function (o) {
var _arr, body, changed, i, label, len, node, reduced;
changed = false;
body = [];
for (_arr = __toArray(this.nodes), i = 0, len = _arr.length; i < len; ++i) {
node = _arr[i];
reduced = node.reduce(o);
if (reduced instanceof BlockNode && reduced.label == null) {
body.push.apply(body, __toArray(reduced.nodes));
changed = true;
} else if (reduced instanceof NothingNode) {
changed = true;
} else if (reduced instanceof BreakNode || reduced instanceof ContinueNode || reduced instanceof ThrowNode || reduced instanceof ReturnNode) {
body.push(reduced);
if (reduced !== node || i < len - 1) {
changed = true;
}
break;
} else {
body.push(reduced);
if (reduced !== node) {
changed = true;
}
}
}
if (this.label != null) {
label = this.label.reduce(o);
} else {
label = this.label;
}
if (body.length === 0) {
return NothingNode(this.line, this.column, this.scope);
} else if (label == null && body.length === 1) {
return body[0];
} else if (changed || label !== this.label) {
return BlockNode(
this.line,
this.column,
this.scope,
body,
label
);
} else {
return this;
}
};
_BlockNode_prototype.isStatement = function () {
var _this;
_this = this;
return (function () {
var _arr, _i, node;
for (_arr = __toArray(_this.nodes), _i = _arr.length; _i--; ) {
node = _arr[_i];
if (node.isStatement()) {
return true;
}
}
return false;
}());
};
_BlockNode_prototype._isNoop = function (o) {
var _ref, _this;
_this = this;
if ((_ref = this.__isNoop) == null) {
return this.__isNoop = (function () {
var _arr, _i, node;
for (_arr = __toArray(_this.nodes), _i = _arr.length; _i--; ) {
node = _arr[_i];
if (!node.isNoop(o)) {
return false;
}
}
return true;
}());
} else {
return _ref;
}
};
_BlockNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"BlockNode",
this.line,
this.column,
this.nodes,
this.label
);
};
_BlockNode_prototype.walk = function (f) {
var label, nodes;
nodes = map(this.nodes, f);
if (this.label instanceof Node) {
label = f(this.label);
} else {
label = this.label;
}
if (nodes !== this.nodes || label !== this.label) {
return BlockNode(
this.line,
this.column,
this.scope,
nodes,
label
);
} else {
return this;
}
};
_BlockNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return mapAsync(this.nodes, f, (_once = false, function (_e, nodes) {
var _f;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
if (_this.label instanceof Node) {
_f = function (next) {
var _once2;
return f(_this.label, (_once2 = false, function (_e2, label) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return next(label);
}));
};
} else {
_f = function (next) {
return next(_this.label);
};
}
return _f(function (label) {
return callback(null, nodes !== _this.nodes || label !== _this.label
? BlockNode(
_this.line,
_this.column,
_this.scope,
nodes,
label
)
: _this);
});
}));
};
return BlockNode;
}(Node));
Node.Break = BreakNode = (function (Node) {
var _BreakNode_prototype, _Node_prototype;
function BreakNode(line, column, scope, label) {
var _this;
_this = this instanceof BreakNode ? this : __create(_BreakNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.label = label;
return _this;
}
_Node_prototype = Node.prototype;
_BreakNode_prototype = BreakNode.prototype = __create(_Node_prototype);
_BreakNode_prototype.constructor = BreakNode;
BreakNode.displayName = "BreakNode";
if (typeof Node.extended === "function") {
Node.extended(BreakNode);
}
BreakNode.cappedName = "Break";
BreakNode.argNames = ["label"];
_BreakNode_prototype.type = function () {
return Type["undefined"];
};
_BreakNode_prototype.isStatement = function () {
return true;
};
_BreakNode_prototype.withLabel = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return BreakNode(this.line, this.column, this.scope, label);
};
_BreakNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"BreakNode",
this.line,
this.column,
this.label
);
};
_BreakNode_prototype.walk = function (f) {
var label;
if (this.label instanceof Node) {
label = f(this.label);
} else {
label = this.label;
}
if (label !== this.label) {
return BreakNode(this.line, this.column, this.scope, label);
} else {
return this;
}
};
_BreakNode_prototype.walkAsync = function (f, callback) {
var _f, _this;
_this = this;
if (this.label instanceof Node) {
_f = function (next) {
var _once;
return f(_this.label, (_once = false, function (_e, label) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return next(label);
}));
};
} else {
_f = function (next) {
return next(_this.label);
};
}
return _f(function (label) {
return callback(null, label !== _this.label ? BreakNode(_this.line, _this.column, _this.scope, label) : _this);
});
};
return BreakNode;
}(Node));
Node.Call = CallNode = (function (Node) {
var _CallNode_prototype, _Node_prototype;
function CallNode(line, column, scope, func, args, isNew, isApply) {
var _i, _this;
_this = this instanceof CallNode ? this : __create(_CallNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(func instanceof Node)) {
throw TypeError("Expected func to be a " + __name(Node) + ", got " + __typeof(func));
}
if (!__isArray(args)) {
throw TypeError("Expected args to be an Array, got " + __typeof(args));
} else {
for (_i = args.length; _i--; ) {
if (!(args[_i] instanceof Node)) {
throw TypeError("Expected " + ("args[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(args[_i]));
}
}
}
if (isNew == null) {
isNew = false;
} else if (typeof isNew !== "boolean") {
throw TypeError("Expected isNew to be a Boolean, got " + __typeof(isNew));
}
if (isApply == null) {
isApply = false;
} else if (typeof isApply !== "boolean") {
throw TypeError("Expected isApply to be a Boolean, got " + __typeof(isApply));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.func = func;
_this.args = args;
_this.isNew = isNew;
_this.isApply = isApply;
return _this;
}
_Node_prototype = Node.prototype;
_CallNode_prototype = CallNode.prototype = __create(_Node_prototype);
_CallNode_prototype.constructor = CallNode;
CallNode.displayName = "CallNode";
if (typeof Node.extended === "function") {
Node.extended(CallNode);
}
CallNode.cappedName = "Call";
CallNode.argNames = ["func", "args", "isNew", "isApply"];
_CallNode_prototype.type = (function () {
var PRIMORDIAL_FUNCTIONS, PRIMORDIAL_METHODS, PRIMORDIAL_SUBFUNCTIONS;
PRIMORDIAL_FUNCTIONS = {
Object: Type.object,
String: Type.string,
Number: Type.number,
Boolean: Type.boolean,
Function: Type["function"],
Array: Type.array,
Date: Type.string,
RegExp: Type.regexp,
Error: Type.error,
RangeError: Type.error,
ReferenceError: Type.error,
SyntaxError: Type.error,
TypeError: Type.error,
URIError: Type.error,
escape: Type.string,
unescape: Type.string,
parseInt: Type.number,
parseFloat: Type.number,
isNaN: Type.boolean,
isFinite: Type.boolean,
decodeURI: Type.string,
decodeURIComponent: Type.string,
encodeURI: Type.string,
encodeURIComponent: Type.string
};
PRIMORDIAL_SUBFUNCTIONS = {
Object: {
getPrototypeOf: Type.object,
getOwnPropertyDescriptor: Type.object,
getOwnPropertyNames: Type.string.array(),
create: Type.object,
defineProperty: Type.object,
defineProperties: Type.object,
seal: Type.object,
freeze: Type.object,
preventExtensions: Type.object,
isSealed: Type.boolean,
isFrozen: Type.boolean,
isExtensible: Type.boolean,
keys: Type.string.array()
},
String: { fromCharCode: Type.string },
Number: { isFinite: Type.boolean, isNaN: Type.boolean },
Array: { isArray: Type.boolean },
Math: {
abs: Type.number,
acos: Type.number,
asin: Type.number,
atan: Type.number,
atan2: Type.number,
ceil: Type.number,
cos: Type.number,
exp: Type.number,
floor: Type.number,
log: Type.number,
max: Type.number,
min: Type.number,
pow: Type.number,
random: Type.number,
round: Type.number,
sin: Type.number,
sqrt: Type.number,
tan: Type.number
},
JSON: { stringify: Type.string.union(Type["undefined"]), parse: Type.string.union(Type.number).union(Type.boolean).union(Type["null"]).union(Type.array).union(Type.object) },
Date: { UTC: Type.number, now: Type.number }
};
PRIMORDIAL_METHODS = {
String: {
toString: Type.string,
valueOf: Type.string,
charAt: Type.string,
charCodeAt: Type.number,
concat: Type.string,
indexOf: Type.number,
lastIndexOf: Type.number,
localeCompare: Type.number,
match: Type.array.union(Type["null"]),
replace: Type.string,
search: Type.number,
slice: Type.string,
split: Type.string.array(),
substring: Type.string,
toLowerCase: Type.string,
toLocaleLowerCase: Type.string,
toUpperCase: Type.string,
toLocaleUpperCase: Type.string,
trim: Type.string
},
Boolean: { toString: Type.string, valueOf: Type.boolean },
Number: {
toString: Type.string,
valueOf: Type.number,
toLocaleString: Type.string,
toFixed: Type.string,
toExponential: Type.string,
toPrecision: Type.string
},
Date: {
toString: Type.string,
toDateString: Type.string,
toTimeString: Type.string,
toLocaleString: Type.string,
toLocaleDateString: Type.string,
toLocaleTimeString: Type.string,
valueOf: Type.number,
getTime: Type.number,
getFullYear: Type.number,
getUTCFullYear: Type.number,
getMonth: Type.number,
getUTCMonth: Type.number,
getDate: Type.number,
getUTCDate: Type.number,
getDay: Type.number,
getUTCDay: Type.number,
getHours: Type.number,
getUTCHours: Type.number,
getMinutes: Type.number,
getUTCMinutes: Type.number,
getSeconds: Type.number,
getUTCSeconds: Type.number,
getMilliseconds: Type.number,
getUTCMilliseconds: Type.number,
getTimezoneOffset: Type.number,
setTime: Type.number,
setMilliseconds: Type.number,
setUTCMilliseconds: Type.number,
setSeconds: Type.number,
setUTCSeconds: Type.number,
setMinutes: Type.number,
setUTCMinutes: Type.number,
setHours: Type.number,
setUTCHours: Type.number,
setDate: Type.number,
setUTCDate: Type.number,
setMonth: Type.number,
setUTCMonth: Type.number,
setFullYear: Type.number,
setUTCFullYear: Type.number,
toUTCString: Type.string,
toISOString: Type.string,
toJSON: Type.string
},
RegExp: { exec: Type.array.union(Type["null"]), test: Type.boolean, toString: Type.string },
Error: { toString: Type.string }
};
return function (o) {
var _ref, _this;
_this = this;
if ((_ref = this._type) == null) {
return this._type = (function () {
var _ref, _ref2, _ref3, _ref4, child, func, funcType, name, parent, parentType;
func = _this.func;
funcType = func.type(o);
if (funcType.isSubsetOf(Type["function"])) {
return funcType.args[0];
} else if (func instanceof IdentNode) {
name = func.name;
if (__owns.call(PRIMORDIAL_FUNCTIONS, name)) {
return PRIMORDIAL_FUNCTIONS[name];
} else if (o != null ? o.macros.hasHelper(name) : void 0) {
funcType = o.macros.helperType(name);
if (funcType.isSubsetOf(Type["function"])) {
return funcType.args[0];
}
}
} else if (func instanceof AccessNode) {
parent = func.parent;
child = func.child;
if (child instanceof ConstNode) {
if ((_ref = child.value) === "call" || _ref === "apply") {
parentType = parent.type(o);
if (parentType.isSubsetOf(Type["function"])) {
return parentType.args[0];
}
} else if (parent instanceof IdentNode && __owns.call(PRIMORDIAL_SUBFUNCTIONS, _ref = parent.name) && __owns.call(_ref2 = PRIMORDIAL_SUBFUNCTIONS[_ref], _ref3 = child.value) && (_ref4 = _ref2[_ref3]) != null) {
return _ref4;
}
}
}
return Type.any;
}());
} else {
return _ref;
}
};
}());
_CallNode_prototype._reduce = (function () {
var PURE_PRIMORDIAL_FUNCTIONS, PURE_PRIMORDIAL_SUBFUNCTIONS;
PURE_PRIMORDIAL_FUNCTIONS = {
escape: true,
unescape: true,
parseInt: true,
parseFloat: true,
isNaN: true,
isFinite: true,
decodeURI: true,
decodeURIComponent: true,
encodeURI: true,
encodeURIComponent: true,
String: true,
Boolean: true,
Number: true,
RegExp: true
};
PURE_PRIMORDIAL_SUBFUNCTIONS = {
String: { fromCharCode: true },
Number: { isFinite: true, isNaN: true },
Math: {
abs: true,
acos: true,
asin: true,
atan: true,
atan2: true,
ceil: true,
cos: true,
exp: true,
floor: true,
log: true,
max: true,
min: true,
pow: true,
round: true,
sin: true,
sqrt: true,
tan: true
},
JSON: { parse: true, stringify: true }
};
return function (o) {
var _arr, _i, _len, _ref, _ref2, _ref3, allConst, arg, args, child, constArgs, cValue, func, parent, pValue, value;
func = this.func.reduce(o).doWrap(o);
args = map(this.args, function (node) {
return node.reduce(o).doWrap(o);
});
if (!this.isNew && !this.isApply) {
constArgs = [];
allConst = true;
for (_arr = __toArray(args), _i = 0, _len = _arr.length; _i < _len; ++_i) {
arg = _arr[_i];
if (arg.isConst()) {
constArgs.push(arg.constValue());
} else {
allConst = false;
break;
}
}
if (allConst) {
if (func instanceof IdentNode) {
if (__owns.call(PURE_PRIMORDIAL_FUNCTIONS, func.name)) {
try {
value = GLOBAL[func.name].apply(void 0, __toArray(constArgs));
return ConstNode(this.line, this.column, this.scope, value);
} catch (e) {}
}
} else if (func instanceof AccessNode && func.child.isConst()) {
parent = func.parent;
child = func.child;
cValue = child.constValue();
if (parent.isConst()) {
pValue = parent.constValue();
if (typeof pValue[cValue] === "function") {
try {
value = pValue[cValue].apply(pValue, __toArray(constArgs));
return ConstNode(this.line, this.column, this.scope, value);
} catch (e) {}
}
} else if (parent instanceof IdentNode && (__owns.call(PURE_PRIMORDIAL_SUBFUNCTIONS, _ref = parent.name) && __owns.call(_ref2 = PURE_PRIMORDIAL_SUBFUNCTIONS[_ref], _ref3 = child.value) ? _ref2[_ref3] : void 0)) {
try {
value = (_ref = GLOBAL[parent.name])[cValue].apply(_ref, __toArray(constArgs));
return ConstNode(this.line, this.column, this.scope, value);
} catch (e) {}
}
}
}
}
if (func !== this.func || args !== this.args) {
return CallNode(
this.line,
this.column,
this.scope,
func,
args,
this.isNew,
this.isApply
);
} else {
return this;
}
};
}());
_CallNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"CallNode",
this.line,
this.column,
this.func,
this.args,
this.isNew,
this.isApply
);
};
_CallNode_prototype.walk = function (f) {
var args, func;
func = f(this.func);
args = map(this.args, f);
if (func !== this.func || args !== this.args) {
return CallNode(
this.line,
this.column,
this.scope,
func,
args,
this.isNew,
this.isApply
);
} else {
return this;
}
};
_CallNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.func, (_once = false, function (_e, func) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return mapAsync(_this.args, f, (_once2 = false, function (_e2, args) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return callback(null, func !== _this.func || args !== _this.args
? CallNode(
_this.line,
_this.column,
_this.scope,
func,
args,
_this.isNew,
_this.isApply
)
: _this);
}));
}));
};
return CallNode;
}(Node));
Node.Comment = CommentNode = (function (Node) {
var _CommentNode_prototype, _Node_prototype;
function CommentNode(line, column, scope, text) {
var _this;
_this = this instanceof CommentNode ? this : __create(_CommentNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (typeof text !== "string") {
throw TypeError("Expected text to be a String, got " + __typeof(text));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.text = text;
return _this;
}
_Node_prototype = Node.prototype;
_CommentNode_prototype = CommentNode.prototype = __create(_Node_prototype);
_CommentNode_prototype.constructor = CommentNode;
CommentNode.displayName = "CommentNode";
if (typeof Node.extended === "function") {
Node.extended(CommentNode);
}
CommentNode.cappedName = "Comment";
CommentNode.argNames = ["text"];
_CommentNode_prototype.type = function () {
return Type["undefined"];
};
_CommentNode_prototype.cacheable = false;
_CommentNode_prototype.isCount = function () {
return true;
};
_CommentNode_prototype.constValue = function () {
return;
};
_CommentNode_prototype._isNoop = function () {
return true;
};
_CommentNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"CommentNode",
this.line,
this.column,
this.text
);
};
_CommentNode_prototype.walk = function (f) {
return this;
};
_CommentNode_prototype.walkAsync = function (f, callback) {
return callback(null, this);
};
return CommentNode;
}(Node));
Node.Const = ConstNode = (function (Node) {
var _ConstNode_prototype, _Node_prototype;
function ConstNode(line, column, scope, value) {
var _this;
_this = this instanceof ConstNode ? this : __create(_ConstNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (value != null && typeof value !== "number" && typeof value !== "string" && typeof value !== "boolean") {
throw TypeError("Expected value to be one of Number or String or Boolean or undefined or null, got " + __typeof(value));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.value = value;
return _this;
}
_Node_prototype = Node.prototype;
_ConstNode_prototype = ConstNode.prototype = __create(_Node_prototype);
_ConstNode_prototype.constructor = ConstNode;
ConstNode.displayName = "ConstNode";
if (typeof Node.extended === "function") {
Node.extended(ConstNode);
}
ConstNode.cappedName = "Const";
ConstNode.argNames = ["value"];
_ConstNode_prototype.type = function () {
var value;
value = this.value;
if (value === null) {
return Type["null"];
} else {
switch (typeof value) {
case "number": return Type.number;
case "string": return Type.string;
case "boolean": return Type.boolean;
case "undefined": return Type["undefined"];
default: throw Error("Unknown type for " + String(value));
}
}
};
_ConstNode_prototype.cacheable = false;
_ConstNode_prototype.isConst = function () {
return true;
};
_ConstNode_prototype.constValue = function () {
return this.value;
};
_ConstNode_prototype.isConstType = function (type) {
return type === typeof this.value;
};
_ConstNode_prototype.isConstValue = function (value) {
return value === this.value;
};
_ConstNode_prototype._isNoop = function () {
return true;
};
_ConstNode_prototype.inspect = function (depth) {
return "ConstNode(" + __strnum(inspect(this.value, null, depth != null ? __num(depth) - 1 : null)) + ")";
};
_ConstNode_prototype.walk = function (f) {
return this;
};
_ConstNode_prototype.walkAsync = function (f, callback) {
return callback(null, this);
};
return ConstNode;
}(Node));
Node.Continue = ContinueNode = (function (Node) {
var _ContinueNode_prototype, _Node_prototype;
function ContinueNode(line, column, scope, label) {
var _this;
_this = this instanceof ContinueNode ? this : __create(_ContinueNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.label = label;
return _this;
}
_Node_prototype = Node.prototype;
_ContinueNode_prototype = ContinueNode.prototype = __create(_Node_prototype);
_ContinueNode_prototype.constructor = ContinueNode;
ContinueNode.displayName = "ContinueNode";
if (typeof Node.extended === "function") {
Node.extended(ContinueNode);
}
ContinueNode.cappedName = "Continue";
ContinueNode.argNames = ["label"];
_ContinueNode_prototype.type = function () {
return Type["undefined"];
};
_ContinueNode_prototype.isStatement = function () {
return true;
};
_ContinueNode_prototype.withLabel = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return ContinueNode(this.line, this.column, this.scope, label);
};
_ContinueNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"ContinueNode",
this.line,
this.column,
this.label
);
};
_ContinueNode_prototype.walk = function (f) {
var label;
if (this.label instanceof Node) {
label = f(this.label);
} else {
label = this.label;
}
if (label !== this.label) {
return ContinueNode(this.line, this.column, this.scope, label);
} else {
return this;
}
};
_ContinueNode_prototype.walkAsync = function (f, callback) {
var _f, _this;
_this = this;
if (this.label instanceof Node) {
_f = function (next) {
var _once;
return f(_this.label, (_once = false, function (_e, label) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return next(label);
}));
};
} else {
_f = function (next) {
return next(_this.label);
};
}
return _f(function (label) {
return callback(null, label !== _this.label ? ContinueNode(_this.line, _this.column, _this.scope, label) : _this);
});
};
return ContinueNode;
}(Node));
Node.Debugger = DebuggerNode = (function (Node) {
var _DebuggerNode_prototype, _Node_prototype;
function DebuggerNode(line, column, scope) {
var _this;
_this = this instanceof DebuggerNode ? this : __create(_DebuggerNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
return _this;
}
_Node_prototype = Node.prototype;
_DebuggerNode_prototype = DebuggerNode.prototype = __create(_Node_prototype);
_DebuggerNode_prototype.constructor = DebuggerNode;
DebuggerNode.displayName = "DebuggerNode";
if (typeof Node.extended === "function") {
Node.extended(DebuggerNode);
}
DebuggerNode.cappedName = "Debugger";
DebuggerNode.argNames = [];
_DebuggerNode_prototype.type = function () {
return Type["undefined"];
};
_DebuggerNode_prototype.isStatement = function () {
return true;
};
_DebuggerNode_prototype.inspect = function (depth) {
return inspectHelper(depth, "DebuggerNode", this.line, this.column);
};
return DebuggerNode;
}(Node));
Node.Def = DefNode = (function (Node) {
var _DefNode_prototype, _Node_prototype;
function DefNode(line, column, scope, left, right) {
var _this;
_this = this instanceof DefNode ? this : __create(_DefNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(left instanceof Node)) {
throw TypeError("Expected left to be a " + __name(Node) + ", got " + __typeof(left));
}
if (right == null) {
right = void 0;
} else if (!(right instanceof Node)) {
throw TypeError("Expected right to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(right));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.left = left;
_this.right = right;
return _this;
}
_Node_prototype = Node.prototype;
_DefNode_prototype = DefNode.prototype = __create(_Node_prototype);
_DefNode_prototype.constructor = DefNode;
DefNode.displayName = "DefNode";
if (typeof Node.extended === "function") {
Node.extended(DefNode);
}
DefNode.cappedName = "Def";
DefNode.argNames = ["left", "right"];
_DefNode_prototype.type = function (o) {
if (this.right != null) {
return this.right.type(o);
} else {
return Type.any;
}
};
_DefNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"DefNode",
this.line,
this.column,
this.left,
this.right
);
};
_DefNode_prototype.walk = function (f) {
var left, right;
left = f(this.left);
if (this.right instanceof Node) {
right = f(this.right);
} else {
right = this.right;
}
if (left !== this.left || right !== this.right) {
return DefNode(
this.line,
this.column,
this.scope,
left,
right
);
} else {
return this;
}
};
_DefNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.left, (_once = false, function (_e, left) {
var _f;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
if (_this.right instanceof Node) {
_f = function (next) {
var _once2;
return f(_this.right, (_once2 = false, function (_e2, right) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return next(right);
}));
};
} else {
_f = function (next) {
return next(_this.right);
};
}
return _f(function (right) {
return callback(null, left !== _this.left || right !== _this.right
? DefNode(
_this.line,
_this.column,
_this.scope,
left,
right
)
: _this);
});
}));
};
return DefNode;
}(Node));
Node.EmbedWrite = EmbedWriteNode = (function (Node) {
var _EmbedWriteNode_prototype, _Node_prototype;
function EmbedWriteNode(line, column, scope, text, escape) {
var _this;
_this = this instanceof EmbedWriteNode ? this : __create(_EmbedWriteNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(text instanceof Node)) {
throw TypeError("Expected text to be a " + __name(Node) + ", got " + __typeof(text));
}
if (escape == null) {
escape = false;
} else if (typeof escape !== "boolean") {
throw TypeError("Expected escape to be a Boolean, got " + __typeof(escape));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.text = text;
_this.escape = escape;
return _this;
}
_Node_prototype = Node.prototype;
_EmbedWriteNode_prototype = EmbedWriteNode.prototype = __create(_Node_prototype);
_EmbedWriteNode_prototype.constructor = EmbedWriteNode;
EmbedWriteNode.displayName = "EmbedWriteNode";
if (typeof Node.extended === "function") {
Node.extended(EmbedWriteNode);
}
EmbedWriteNode.cappedName = "EmbedWrite";
EmbedWriteNode.argNames = ["text", "escape"];
_EmbedWriteNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"EmbedWriteNode",
this.line,
this.column,
this.text,
this.escape
);
};
_EmbedWriteNode_prototype.walk = function (f) {
var text;
text = f(this.text);
if (text !== this.text) {
return EmbedWriteNode(
this.line,
this.column,
this.scope,
text,
this.escape
);
} else {
return this;
}
};
_EmbedWriteNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.text, (_once = false, function (_e, text) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, text !== _this.text
? EmbedWriteNode(
_this.line,
_this.column,
_this.scope,
text,
_this.escape
)
: _this);
}));
};
return EmbedWriteNode;
}(Node));
Node.Eval = EvalNode = (function (Node) {
var _EvalNode_prototype, _Node_prototype, simplifiers;
function EvalNode(line, column, scope, code) {
var _this;
_this = this instanceof EvalNode ? this : __create(_EvalNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(code instanceof Node)) {
throw TypeError("Expected code to be a " + __name(Node) + ", got " + __typeof(code));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.code = code;
return _this;
}
_Node_prototype = Node.prototype;
_EvalNode_prototype = EvalNode.prototype = __create(_Node_prototype);
_EvalNode_prototype.constructor = EvalNode;
EvalNode.displayName = "EvalNode";
if (typeof Node.extended === "function") {
Node.extended(EvalNode);
}
EvalNode.cappedName = "Eval";
EvalNode.argNames = ["code"];
simplifiers = {
"true": function () {
return ConstNode(this.line, this.column, this.scope, true);
},
"false": function () {
return ConstNode(this.line, this.column, this.scope, false);
},
"void 0": function () {
return ConstNode(this.line, this.column, this.scope, void 0);
},
"null": function () {
return ConstNode(this.line, this.column, this.scope, null);
}
};
_EvalNode_prototype._reduce = function (o) {
var _ref, code, simplifier;
code = this.code.reduce(o).doWrap();
if (code.isConst() && code.isConstType("string")) {
if (__owns.call(simplifiers, _ref = code.constValue())) {
simplifier = simplifiers[_ref];
}
if (simplifier) {
return simplifier.call(this);
}
}
if (code !== this.code) {
return EvalNode(this.line, this.column, this.scope, code);
} else {
return this;
}
};
_EvalNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"EvalNode",
this.line,
this.column,
this.code
);
};
_EvalNode_prototype.walk = function (f) {
var code;
code = f(this.code);
if (code !== this.code) {
return EvalNode(this.line, this.column, this.scope, code);
} else {
return this;
}
};
_EvalNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.code, (_once = false, function (_e, code) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, code !== _this.code ? EvalNode(_this.line, _this.column, _this.scope, code) : _this);
}));
};
return EvalNode;
}(Node));
Node.For = ForNode = (function (Node) {
var _ForNode_prototype, _Node_prototype;
function ForNode(line, column, scope, init, test, step, body, label) {
var _this;
_this = this instanceof ForNode ? this : __create(_ForNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (init == null) {
init = NothingNode(0, 0, scope);
} else if (!(init instanceof Node)) {
throw TypeError("Expected init to be a " + __name(Node) + ", got " + __typeof(init));
}
if (test == null) {
test = ConstNode(0, 0, scope, true);
} else if (!(test instanceof Node)) {
throw TypeError("Expected test to be a " + __name(Node) + ", got " + __typeof(test));
}
if (step == null) {
step = NothingNode(0, 0, scope);
} else if (!(step instanceof Node)) {
throw TypeError("Expected step to be a " + __name(Node) + ", got " + __typeof(step));
}
if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.init = init;
_this.test = test;
_this.step = step;
_this.body = body;
_this.label = label;
return _this;
}
_Node_prototype = Node.prototype;
_ForNode_prototype = ForNode.prototype = __create(_Node_prototype);
_ForNode_prototype.constructor = ForNode;
ForNode.displayName = "ForNode";
if (typeof Node.extended === "function") {
Node.extended(ForNode);
}
ForNode.cappedName = "For";
ForNode.argNames = [
"init",
"test",
"step",
"body",
"label"
];
_ForNode_prototype.type = function () {
return Type["undefined"];
};
_ForNode_prototype.isStatement = function () {
return true;
};
_ForNode_prototype.withLabel = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return ForNode(
this.line,
this.column,
this.scope,
this.init,
this.test,
this.step,
this.body,
label
);
};
_ForNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"ForNode",
this.line,
this.column,
this.init,
this.test,
this.step,
this.body,
this.label
);
};
_ForNode_prototype.walk = function (f) {
var body, init, label, step, test;
init = f(this.init);
test = f(this.test);
step = f(this.step);
body = f(this.body);
if (this.label instanceof Node) {
label = f(this.label);
} else {
label = this.label;
}
if (init !== this.init || test !== this.test || step !== this.step || body !== this.body || label !== this.label) {
return ForNode(
this.line,
this.column,
this.scope,
init,
test,
step,
body,
label
);
} else {
return this;
}
};
_ForNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.init, (_once = false, function (_e, init) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return f(_this.test, (_once2 = false, function (_e2, test) {
var _once3;
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return f(_this.step, (_once3 = false, function (_e3, step) {
var _once4;
if (_once3) {
throw Error("Attempted to call function more than once");
} else {
_once3 = true;
}
if (_e3 != null) {
return callback(_e3);
}
return f(_this.body, (_once4 = false, function (_e4, body) {
var _f;
if (_once4) {
throw Error("Attempted to call function more than once");
} else {
_once4 = true;
}
if (_e4 != null) {
return callback(_e4);
}
if (_this.label instanceof Node) {
_f = function (next) {
var _once5;
return f(_this.label, (_once5 = false, function (_e5, label) {
if (_once5) {
throw Error("Attempted to call function more than once");
} else {
_once5 = true;
}
if (_e5 != null) {
return callback(_e5);
}
return next(label);
}));
};
} else {
_f = function (next) {
return next(_this.label);
};
}
return _f(function (label) {
return callback(null, init !== _this.init || test !== _this.test || step !== _this.step || body !== _this.body || label !== _this.label
? ForNode(
_this.line,
_this.column,
_this.scope,
init,
test,
step,
body,
label
)
: _this);
});
}));
}));
}));
}));
};
return ForNode;
}(Node));
Node.ForIn = ForInNode = (function (Node) {
var _ForInNode_prototype, _Node_prototype;
function ForInNode(line, column, scope, key, object, body, label) {
var _this;
_this = this instanceof ForInNode ? this : __create(_ForInNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(key instanceof Node)) {
throw TypeError("Expected key to be a " + __name(Node) + ", got " + __typeof(key));
}
if (!(object instanceof Node)) {
throw TypeError("Expected object to be a " + __name(Node) + ", got " + __typeof(object));
}
if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.key = key;
_this.object = object;
_this.body = body;
_this.label = label;
return _this;
}
_Node_prototype = Node.prototype;
_ForInNode_prototype = ForInNode.prototype = __create(_Node_prototype);
_ForInNode_prototype.constructor = ForInNode;
ForInNode.displayName = "ForInNode";
if (typeof Node.extended === "function") {
Node.extended(ForInNode);
}
ForInNode.cappedName = "ForIn";
ForInNode.argNames = ["key", "object", "body", "label"];
_ForInNode_prototype.type = function () {
return Type["undefined"];
};
_ForInNode_prototype.isStatement = function () {
return true;
};
_ForInNode_prototype.withLabel = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return ForInNode(
this.line,
this.column,
this.scope,
this.key,
this.object,
this.body,
label
);
};
_ForInNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"ForInNode",
this.line,
this.column,
this.key,
this.object,
this.body,
this.label
);
};
_ForInNode_prototype.walk = function (f) {
var body, key, label, object;
key = f(this.key);
object = f(this.object);
body = f(this.body);
if (this.label instanceof Node) {
label = f(this.label);
} else {
label = this.label;
}
if (key !== this.key || object !== this.object || body !== this.body || label !== this.label) {
return ForInNode(
this.line,
this.column,
this.scope,
key,
object,
body,
label
);
} else {
return this;
}
};
_ForInNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.key, (_once = false, function (_e, key) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return f(_this.object, (_once2 = false, function (_e2, object) {
var _once3;
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return f(_this.body, (_once3 = false, function (_e3, body) {
var _f;
if (_once3) {
throw Error("Attempted to call function more than once");
} else {
_once3 = true;
}
if (_e3 != null) {
return callback(_e3);
}
if (_this.label instanceof Node) {
_f = function (next) {
var _once4;
return f(_this.label, (_once4 = false, function (_e4, label) {
if (_once4) {
throw Error("Attempted to call function more than once");
} else {
_once4 = true;
}
if (_e4 != null) {
return callback(_e4);
}
return next(label);
}));
};
} else {
_f = function (next) {
return next(_this.label);
};
}
return _f(function (label) {
return callback(null, key !== _this.key || object !== _this.object || body !== _this.body || label !== _this.label
? ForInNode(
_this.line,
_this.column,
_this.scope,
key,
object,
body,
label
)
: _this);
});
}));
}));
}));
};
return ForInNode;
}(Node));
Node.Function = FunctionNode = (function (Node) {
var _FunctionNode_prototype, _Node_prototype;
function FunctionNode(line, column, scope, params, body, autoReturn, bound, curry, asType, generator, generic) {
var _i, _i2, _this;
_this = this instanceof FunctionNode ? this : __create(_FunctionNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!__isArray(params)) {
throw TypeError("Expected params to be an Array, got " + __typeof(params));
} else {
for (_i = params.length; _i--; ) {
if (!(params[_i] instanceof Node)) {
throw TypeError("Expected " + ("params[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(params[_i]));
}
}
}
if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (autoReturn == null) {
autoReturn = true;
} else if (typeof autoReturn !== "boolean") {
throw TypeError("Expected autoReturn to be a Boolean, got " + __typeof(autoReturn));
}
if (bound == null) {
bound = false;
} else if (!(bound instanceof Node) && typeof bound !== "boolean") {
throw TypeError("Expected bound to be one of " + (__name(Node) + " or Boolean") + ", got " + __typeof(bound));
}
if (curry == null) {
curry = false;
} else if (typeof curry !== "boolean") {
throw TypeError("Expected curry to be a Boolean, got " + __typeof(curry));
}
if (asType == null) {
asType = void 0;
} else if (!(asType instanceof Node)) {
throw TypeError("Expected asType to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(asType));
}
if (generator == null) {
generator = false;
} else if (typeof generator !== "boolean") {
throw TypeError("Expected generator to be a Boolean, got " + __typeof(generator));
}
if (generic == null) {
generic = [];
} else if (!__isArray(generic)) {
throw TypeError("Expected generic to be an Array, got " + __typeof(generic));
} else {
for (_i2 = generic.length; _i2--; ) {
if (!(generic[_i2] instanceof IdentNode)) {
throw TypeError("Expected " + ("generic[" + _i2 + "]") + " to be a " + __name(IdentNode) + ", got " + __typeof(generic[_i2]));
}
}
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.params = params;
_this.body = body;
_this.autoReturn = autoReturn;
_this.bound = bound;
_this.curry = curry;
_this.asType = asType;
_this.generator = generator;
_this.generic = generic;
return _this;
}
_Node_prototype = Node.prototype;
_FunctionNode_prototype = FunctionNode.prototype = __create(_Node_prototype);
_FunctionNode_prototype.constructor = FunctionNode;
FunctionNode.displayName = "FunctionNode";
if (typeof Node.extended === "function") {
Node.extended(FunctionNode);
}
FunctionNode.cappedName = "Function";
FunctionNode.argNames = [
"params",
"body",
"autoReturn",
"bound",
"curry",
"asType",
"generator",
"generic"
];
_FunctionNode_prototype.type = function (o) {
var _ref, _this;
_this = this;
if ((_ref = this._type) == null) {
return this._type = (function () {
var returnType, walker;
if (_this.asType != null) {
return nodeToType(_this.asType)["function"]();
} else {
if (_this.autoReturn) {
returnType = _this.body.type(o);
} else {
returnType = Type["undefined"];
}
walker = function (node) {
var _ref;
if (node instanceof ReturnNode) {
returnType = returnType.union(node.type(o));
return node;
} else if (node instanceof FunctionNode) {
return node;
} else if (node instanceof MacroAccessNode) {
if ((_ref = node.data.macroName) === "return" || _ref === "return?") {
if (node.data.macroData.node) {
returnType = returnType.union(node.data.macroData.node.type(o));
} else {
returnType = returnType.union(Type["undefined"]);
}
}
return node.walk(walker);
} else {
return node.walk(walker);
}
};
walker(_this.body);
return returnType["function"]();
}
}());
} else {
return _ref;
}
};
_FunctionNode_prototype._isNoop = function (o) {
return true;
};
_FunctionNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"FunctionNode",
this.line,
this.column,
this.params,
this.body,
this.autoReturn,
this.bound,
this.curry,
this.asType,
this.generator,
this.generic
);
};
_FunctionNode_prototype.walk = function (f) {
var asType, body, bound, params;
params = map(this.params, f);
body = f(this.body);
if (this.bound instanceof Node) {
bound = f(this.bound);
} else {
bound = this.bound;
}
if (this.asType instanceof Node) {
asType = f(this.asType);
} else {
asType = this.asType;
}
if (params !== this.params || body !== this.body || bound !== this.bound || asType !== this.asType) {
return FunctionNode(
this.line,
this.column,
this.scope,
params,
body,
this.autoReturn,
bound,
this.curry,
asType,
this.generator,
this.generic
);
} else {
return this;
}
};
_FunctionNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return mapAsync(this.params, f, (_once = false, function (_e, params) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return f(_this.body, (_once2 = false, function (_e2, body) {
var _f;
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
if (_this.bound instanceof Node) {
_f = function (next) {
var _once3;
return f(_this.bound, (_once3 = false, function (_e3, bound) {
if (_once3) {
throw Error("Attempted to call function more than once");
} else {
_once3 = true;
}
if (_e3 != null) {
return callback(_e3);
}
return next(bound);
}));
};
} else {
_f = function (next) {
return next(_this.bound);
};
}
return _f(function (bound) {
var _f;
if (_this.asType instanceof Node) {
_f = function (next) {
var _once3;
return f(_this.asType, (_once3 = false, function (_e3, asType) {
if (_once3) {
throw Error("Attempted to call function more than once");
} else {
_once3 = true;
}
if (_e3 != null) {
return callback(_e3);
}
return next(asType);
}));
};
} else {
_f = function (next) {
return next(_this.asType);
};
}
return _f(function (asType) {
return callback(null, params !== _this.params || body !== _this.body || bound !== _this.bound || asType !== _this.asType
? FunctionNode(
_this.line,
_this.column,
_this.scope,
params,
body,
_this.autoReturn,
bound,
_this.curry,
asType,
_this.generator,
_this.generic
)
: _this);
});
});
}));
}));
};
return FunctionNode;
}(Node));
Node.Ident = IdentNode = (function (Node) {
var _IdentNode_prototype, _Node_prototype;
function IdentNode(line, column, scope, name) {
var _this;
_this = this instanceof IdentNode ? this : __create(_IdentNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.name = name;
return _this;
}
_Node_prototype = Node.prototype;
_IdentNode_prototype = IdentNode.prototype = __create(_Node_prototype);
_IdentNode_prototype.constructor = IdentNode;
IdentNode.displayName = "IdentNode";
if (typeof Node.extended === "function") {
Node.extended(IdentNode);
}
IdentNode.cappedName = "Ident";
IdentNode.argNames = ["name"];
_IdentNode_prototype.cacheable = false;
_IdentNode_prototype.type = function (o) {
if (this.name === "__currentArrayLength") {
return Type.number;
} else if (o) {
return this.scope.type(this);
} else {
return Type.any;
}
};
_IdentNode_prototype._isNoop = function (o) {
return true;
};
_IdentNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"IdentNode",
this.line,
this.column,
this.name
);
};
_IdentNode_prototype.walk = function (f) {
return this;
};
_IdentNode_prototype.walkAsync = function (f, callback) {
return callback(null, this);
};
return IdentNode;
}(Node));
Node.If = IfNode = (function (Node) {
var _IfNode_prototype, _Node_prototype;
function IfNode(line, column, scope, test, whenTrue, whenFalse, label) {
var _this;
_this = this instanceof IfNode ? this : __create(_IfNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(test instanceof Node)) {
throw TypeError("Expected test to be a " + __name(Node) + ", got " + __typeof(test));
}
if (!(whenTrue instanceof Node)) {
throw TypeError("Expected whenTrue to be a " + __name(Node) + ", got " + __typeof(whenTrue));
}
if (whenFalse == null) {
whenFalse = NothingNode(0, 0, scope);
} else if (!(whenFalse instanceof Node)) {
throw TypeError("Expected whenFalse to be a " + __name(Node) + ", got " + __typeof(whenFalse));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.test = test;
_this.whenTrue = whenTrue;
_this.whenFalse = whenFalse;
_this.label = label;
return _this;
}
_Node_prototype = Node.prototype;
_IfNode_prototype = IfNode.prototype = __create(_Node_prototype);
_IfNode_prototype.constructor = IfNode;
IfNode.displayName = "IfNode";
if (typeof Node.extended === "function") {
Node.extended(IfNode);
}
IfNode.cappedName = "If";
IfNode.argNames = ["test", "whenTrue", "whenFalse", "label"];
_IfNode_prototype.type = function (o) {
var _ref;
if ((_ref = this._type) == null) {
return this._type = this.whenTrue.type(o).union(this.whenFalse.type(o));
} else {
return _ref;
}
};
_IfNode_prototype.withLabel = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return IfNode(
this.line,
this.column,
this.scope,
this.test,
this.whenTrue,
this.whenFalse,
label
);
};
_IfNode_prototype._reduce = function (o) {
var label, test, testType, whenFalse, whenTrue;
test = this.test.reduce(o);
whenTrue = this.whenTrue.reduce(o);
whenFalse = this.whenFalse.reduce(o);
if (this.label != null) {
label = this.label.reduce(o);
} else {
label = this.label;
}
if (test.isConst()) {
return BlockNode(
this.line,
this.column,
this.scope,
[test.constValue() ? whenTrue : whenFalse],
label
).reduce(o);
} else {
testType = test.type(o);
if (testType.isSubsetOf(Type.alwaysTruthy)) {
return BlockNode(
this.line,
this.column,
this.scope,
[test, whenTrue],
label
).reduce(o);
} else if (testType.isSubsetOf(Type.alwaysFalsy)) {
return BlockNode(
this.line,
this.column,
this.scope,
[test, whenFalse],
label
).reduce(o);
} else if (test !== this.test || whenTrue !== this.whenTrue || whenFalse !== this.whenFalse || label !== this.label) {
return IfNode(
this.line,
this.column,
this.scope,
test,
whenTrue,
whenFalse,
label
);
} else {
return this;
}
}
};
_IfNode_prototype.isStatement = function () {
var _ref;
if ((_ref = this._isStatement) == null) {
return this._isStatement = this.whenTrue.isStatement() || this.whenFalse.isStatement();
} else {
return _ref;
}
};
_IfNode_prototype.doWrap = function (o) {
var whenFalse, whenTrue;
whenTrue = this.whenTrue.doWrap(o);
whenFalse = this.whenFalse.doWrap(o);
if (whenTrue !== this.whenTrue || whenFalse !== this.whenFalse) {
return IfNode(
this.line,
this.column,
this.scope,
this.test,
whenTrue,
whenFalse,
this.label
);
} else {
return this;
}
};
_IfNode_prototype._isNoop = function (o) {
var _ref;
if ((_ref = this.__isNoop) == null) {
return this.__isNoop = this.test.isNoop(o) && this.whenTrue.isNoop(o) && this.whenFalse.isNoop(o);
} else {
return _ref;
}
};
_IfNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"IfNode",
this.line,
this.column,
this.test,
this.whenTrue,
this.whenFalse,
this.label
);
};
_IfNode_prototype.walk = function (f) {
var label, test, whenFalse, whenTrue;
test = f(this.test);
whenTrue = f(this.whenTrue);
whenFalse = f(this.whenFalse);
if (this.label instanceof Node) {
label = f(this.label);
} else {
label = this.label;
}
if (test !== this.test || whenTrue !== this.whenTrue || whenFalse !== this.whenFalse || label !== this.label) {
return IfNode(
this.line,
this.column,
this.scope,
test,
whenTrue,
whenFalse,
label
);
} else {
return this;
}
};
_IfNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.test, (_once = false, function (_e, test) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return f(_this.whenTrue, (_once2 = false, function (_e2, whenTrue) {
var _once3;
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return f(_this.whenFalse, (_once3 = false, function (_e3, whenFalse) {
var _f;
if (_once3) {
throw Error("Attempted to call function more than once");
} else {
_once3 = true;
}
if (_e3 != null) {
return callback(_e3);
}
if (_this.label instanceof Node) {
_f = function (next) {
var _once4;
return f(_this.label, (_once4 = false, function (_e4, label) {
if (_once4) {
throw Error("Attempted to call function more than once");
} else {
_once4 = true;
}
if (_e4 != null) {
return callback(_e4);
}
return next(label);
}));
};
} else {
_f = function (next) {
return next(_this.label);
};
}
return _f(function (label) {
return callback(null, test !== _this.test || whenTrue !== _this.whenTrue || whenFalse !== _this.whenFalse || label !== _this.label
? IfNode(
_this.line,
_this.column,
_this.scope,
test,
whenTrue,
whenFalse,
label
)
: _this);
});
}));
}));
}));
};
return IfNode;
}(Node));
Node.MacroAccess = MacroAccessNode = (function (Node) {
var _MacroAccessNode_prototype, _Node_prototype;
function MacroAccessNode(line, column, scope, id, callLine, data, position, inGenerator, inEvilAst) {
var _this;
_this = this instanceof MacroAccessNode ? this : __create(_MacroAccessNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (typeof id !== "number") {
throw TypeError("Expected id to be a Number, got " + __typeof(id));
}
if (typeof callLine !== "number") {
throw TypeError("Expected callLine to be a Number, got " + __typeof(callLine));
}
if (typeof data !== "object" || data === null) {
throw TypeError("Expected data to be an Object, got " + __typeof(data));
}
if (typeof position !== "string") {
throw TypeError("Expected position to be a String, got " + __typeof(position));
}
if (inGenerator == null) {
inGenerator = false;
} else if (typeof inGenerator !== "boolean") {
throw TypeError("Expected inGenerator to be a Boolean, got " + __typeof(inGenerator));
}
if (inEvilAst == null) {
inEvilAst = false;
} else if (typeof inEvilAst !== "boolean") {
throw TypeError("Expected inEvilAst to be a Boolean, got " + __typeof(inEvilAst));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.id = id;
_this.callLine = callLine;
_this.data = data;
_this.position = position;
_this.inGenerator = inGenerator;
_this.inEvilAst = inEvilAst;
return _this;
}
_Node_prototype = Node.prototype;
_MacroAccessNode_prototype = MacroAccessNode.prototype = __create(_Node_prototype);
_MacroAccessNode_prototype.constructor = MacroAccessNode;
MacroAccessNode.displayName = "MacroAccessNode";
if (typeof Node.extended === "function") {
Node.extended(MacroAccessNode);
}
MacroAccessNode.cappedName = "MacroAccess";
MacroAccessNode.argNames = [
"id",
"callLine",
"data",
"position",
"inGenerator",
"inEvilAst"
];
_MacroAccessNode_prototype.type = function (o) {
var _ref, _this;
_this = this;
if ((_ref = this._type) == null) {
return this._type = (function () {
var type;
type = o.macros.getTypeById(_this.id);
if (type != null) {
if (typeof type === "string") {
return _this.data[type].type(o);
} else {
return type;
}
} else {
return o.macroExpand1(_this).type(o);
}
}());
} else {
return _ref;
}
};
_MacroAccessNode_prototype.withLabel = function (label, o) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return o.macroExpand1(this).withLabel(label, o);
};
_MacroAccessNode_prototype.walk = (function () {
function walkObject(obj, func) {
var changed, k, newV, result, v;
result = {};
changed = false;
for (k in obj) {
if (__owns.call(obj, k)) {
v = obj[k];
newV = walkItem(v, func);
if (newV !== v) {
changed = true;
}
result[k] = newV;
}
}
if (changed) {
return result;
} else {
return obj;
}
}
function walkItem(item, func) {
if (item instanceof Node) {
return func(item);
} else if (__isArray(item)) {
return map(item, function (x) {
return walkItem(x, func);
});
} else if (typeof item === "object" && item !== null) {
return walkObject(item, func);
} else {
return item;
}
}
return function (func) {
var data;
data = walkItem(this.data, func);
if (data !== this.data) {
return MacroAccessNode(
this.line,
this.column,
this.scope,
this.id,
this.callLine,
data,
this.position,
this.inGenerator,
this.inEvilAst
);
} else {
return this;
}
};
}());
_MacroAccessNode_prototype.walkAsync = (function () {
function walkObject(obj, func, callback) {
var _keys, changed, result;
changed = false;
result = {};
_keys = __keys(obj);
return __async(
1,
_keys.length,
false,
function (_i, next) {
var _once, k, v;
k = _keys[_i];
v = obj[k];
return walkItem(item, func, (_once = false, function (_e, newItem) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return next(_e);
}
if (item !== newItem) {
changed = true;
}
result[k] = newItem;
return next(null);
}));
},
function (err) {
if (typeof err !== "undefined" && err !== null) {
return callback(err);
} else {
return callback(null, changed ? result : obj);
}
}
);
}
function walkItem(item, func, callback) {
if (item instanceof Node) {
return func(item, callback);
} else if (__isArray(item)) {
return mapAsync(
item,
function (x, cb) {
return walkItem(x, func, cb);
},
callback
);
} else if (typeof item === "object" && item !== null) {
return walkObject(item, func, callback);
} else {
return callback(null, item);
}
}
return function (func, callback) {
var _once, _this;
_this = this;
return walkItem(this.data, func, (_once = false, function (_e, data) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, data !== _this.data
? MacroAccessNode(
_this.line,
_this.column,
_this.scope,
_this.id,
_this.callLine,
data,
_this.position,
_this.inGenerator,
_this.inEvilAst
)
: _this);
}));
};
}());
_MacroAccessNode_prototype._isNoop = function (o) {
return o.macroExpand1(this).isNoop(o);
};
_MacroAccessNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"MacroAccessNode",
this.line,
this.column,
this.id,
this.callLine,
this.data,
this.position,
this.inGenerator,
this.inEvilAst
);
};
return MacroAccessNode;
}(Node));
Node.Nothing = NothingNode = (function (Node) {
var _Node_prototype, _NothingNode_prototype;
function NothingNode(line, column, scope) {
var _this;
_this = this instanceof NothingNode ? this : __create(_NothingNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
return _this;
}
_Node_prototype = Node.prototype;
_NothingNode_prototype = NothingNode.prototype = __create(_Node_prototype);
_NothingNode_prototype.constructor = NothingNode;
NothingNode.displayName = "NothingNode";
if (typeof Node.extended === "function") {
Node.extended(NothingNode);
}
NothingNode.cappedName = "Nothing";
NothingNode.argNames = [];
_NothingNode_prototype.type = function () {
return Type["undefined"];
};
_NothingNode_prototype.cacheable = false;
_NothingNode_prototype.isConst = function () {
return true;
};
_NothingNode_prototype.constValue = function () {
return;
};
_NothingNode_prototype.isConstType = function (type) {
return type === "undefined";
};
_NothingNode_prototype.isConstValue = function (value) {
return value === void 0;
};
_NothingNode_prototype._isNoop = function () {
return true;
};
_NothingNode_prototype.inspect = function (depth) {
return inspectHelper(depth, "NothingNode", this.line, this.column);
};
return NothingNode;
}(Node));
Node.Object = ObjectNode = (function (Node) {
var _Node_prototype, _ObjectNode_prototype;
function ObjectNode(line, column, scope, pairs, prototype) {
var _i, _this;
_this = this instanceof ObjectNode ? this : __create(_ObjectNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!__isArray(pairs)) {
throw TypeError("Expected pairs to be an Array, got " + __typeof(pairs));
} else {
for (_i = pairs.length; _i--; ) {
if (typeof pairs[_i] !== "object" || pairs[_i] === null) {
throw TypeError("Expected " + ("pairs[" + _i + "]") + " to be an Object, got " + __typeof(pairs[_i]));
} else {
if (!(pairs[_i].key instanceof Node)) {
throw TypeError("Expected " + ("pairs[" + _i + "].key") + " to be a " + __name(Node) + ", got " + __typeof(pairs[_i].key));
}
if (!(pairs[_i].value instanceof Node)) {
throw TypeError("Expected " + ("pairs[" + _i + "].value") + " to be a " + __name(Node) + ", got " + __typeof(pairs[_i].value));
}
if (pairs[_i].property == null) {
pairs[_i].property = void 0;
} else if (typeof pairs[_i].property !== "string") {
throw TypeError("Expected " + ("pairs[" + _i + "].property") + " to be one of String or undefined, got " + __typeof(pairs[_i].property));
}
}
}
}
if (prototype == null) {
prototype = void 0;
} else if (!(prototype instanceof Node)) {
throw TypeError("Expected prototype to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(prototype));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.pairs = pairs;
_this.prototype = prototype;
return _this;
}
_Node_prototype = Node.prototype;
_ObjectNode_prototype = ObjectNode.prototype = __create(_Node_prototype);
_ObjectNode_prototype.constructor = ObjectNode;
ObjectNode.displayName = "ObjectNode";
if (typeof Node.extended === "function") {
Node.extended(ObjectNode);
}
ObjectNode.cappedName = "Object";
ObjectNode.argNames = ["pairs", "prototype"];
_ObjectNode_prototype.type = function (o) {
var _ref, _this;
_this = this;
if ((_ref = this._type) == null) {
return this._type = (function () {
var _arr, _i, _len, _ref, data, key, value;
data = {};
for (_arr = __toArray(_this.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
key = (_ref = _arr[_i]).key;
value = _ref.value;
if (key.isConst()) {
data[key.constValue()] = value.type(o);
}
}
return Type.makeObject(data);
}());
} else {
return _ref;
}
};
_ObjectNode_prototype.walk = (function () {
function walkPair(pair, func) {
var key, value;
key = func(pair.key);
value = func(pair.value);
if (key !== pair.key || value !== pair.value) {
return { key: key, value: value, property: pair.property };
} else {
return pair;
}
}
return function (func) {
var pairs, prototype;
pairs = map(this.pairs, walkPair, func);
if (this.prototype != null) {
prototype = func(this.prototype);
} else {
prototype = this.prototype;
}
if (pairs !== this.pairs || prototype !== this.prototype) {
return ObjectNode(
this.line,
this.column,
this.scope,
pairs,
prototype
);
} else {
return this;
}
};
}());
_ObjectNode_prototype.walkAsync = (function () {
function walkPair(pair, func, callback) {
var _once;
return func(pair.key, (_once = false, function (_e, key) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return func(pair.value, (_once2 = false, function (_e2, value) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return callback(null, key !== pair.key || value !== pair.value ? { key: key, value: value, property: pair.property } : pair);
}));
}));
}
return function (func, callback) {
var _once, _this;
_this = this;
return mapAsync(this.pairs, walkPair, func, (_once = false, function (_e, pairs) {
var _f;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
if (_this.prototype != null) {
_f = function (next) {
var _once2;
return func(_this.prototype, (_once2 = false, function (_e2, p) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return next(p);
}));
};
} else {
_f = function (next) {
return next(_this.prototype);
};
}
return _f(function (prototype) {
return callback(null, pairs !== _this.pairs || prototype !== _this.prototype
? ObjectNode(
_this.line,
_this.column,
_this.scope,
pairs,
prototype
)
: _this);
});
}));
};
}());
_ObjectNode_prototype._reduce = (function () {
function reducePair(pair, o) {
var key, value;
key = pair.key.reduce(o);
value = pair.value.reduce(o).doWrap(o);
if (key !== pair.key || value !== pair.value) {
return { key: key, value: value, property: pair.property };
} else {
return pair;
}
}
return function (o) {
var pairs, prototype;
pairs = map(this.pairs, reducePair, o);
if (this.prototype != null) {
prototype = this.prototype.reduce(o);
} else {
prototype = this.prototype;
}
if (pairs !== this.pairs || prototype !== this.prototype) {
return ObjectNode(
this.line,
this.column,
this.scope,
pairs,
prototype
);
} else {
return this;
}
};
}());
_ObjectNode_prototype._isNoop = function (o) {
var _ref, _this;
_this = this;
if ((_ref = this.__isNoop) == null) {
return this.__isNoop = (function () {
var _arr, _i, _len, _ref, key, value;
for (_arr = __toArray(_this.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
key = (_ref = _arr[_i]).key;
value = _ref.value;
if (!key.isNoop(o) || !value.isNoop(o)) {
return false;
}
}
return true;
}());
} else {
return _ref;
}
};
_ObjectNode_prototype.isLiteral = function () {
var _ref, _this;
_this = this;
if ((_ref = this._isLiteral) == null) {
return this._isLiteral = this.prototype == null && (function () {
var _arr, _i, _len, _ref, key, value;
for (_arr = __toArray(_this.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
key = (_ref = _arr[_i]).key;
value = _ref.value;
if (!key.isLiteral() || !value.isLiteral()) {
return false;
}
}
return true;
}());
} else {
return _ref;
}
};
_ObjectNode_prototype.literalValue = function () {
var _arr, _i, _len, _ref, key, result, value;
if (this.prototype != null) {
throw Error("Cannot convert object with prototype to a literal");
}
result = {};
for (_arr = __toArray(this.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
key = (_ref = _arr[_i]).key;
value = _ref.value;
result[key.literalValue()] = value.literalValue();
}
return result;
};
_ObjectNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"ObjectNode",
this.line,
this.column,
this.pairs,
this.prototype
);
};
return ObjectNode;
}(Node));
Node.object = function (index, pairs, prototype) {
var _arr, _i, _len, _ref, key, keyValue, knownKeys, lastPropertyPair, ParserError, property;
knownKeys = [];
lastPropertyPair = null;
for (_arr = __toArray(pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
key = (_ref = _arr[_i]).key;
property = _ref.property;
if (key instanceof ConstNode) {
keyValue = String(key.value);
if ((property === "get" || property === "set") && lastPropertyPair && lastPropertyPair.property !== property && lastPropertyPair.key === keyValue) {
lastPropertyPair = null;
continue;
} else if (__in(keyValue, knownKeys)) {
ParserError = require("./parser").ParserError;
throw ParserError("Duplicate key " + __strnum(quote(keyValue)) + " in object", this, this.indexFromPosition(key.line, key.column));
}
knownKeys.push(keyValue);
if (property === "get" || property === "set") {
lastPropertyPair = { key: keyValue, property: property };
} else {
lastPropertyPair = null;
}
} else {
lastPropertyPair = null;
}
}
return this.Object(index, pairs, prototype);
};
Node.objectParam = Node.object;
Node.Param = ParamNode = (function (Node) {
var _Node_prototype, _ParamNode_prototype;
function ParamNode(line, column, scope, ident, defaultValue, spread, isMutable, asType) {
var _this;
_this = this instanceof ParamNode ? this : __create(_ParamNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(ident instanceof Node)) {
throw TypeError("Expected ident to be a " + __name(Node) + ", got " + __typeof(ident));
}
if (defaultValue == null) {
defaultValue = void 0;
} else if (!(defaultValue instanceof Node)) {
throw TypeError("Expected defaultValue to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(defaultValue));
}
if (spread == null) {
spread = false;
} else if (typeof spread !== "boolean") {
throw TypeError("Expected spread to be a Boolean, got " + __typeof(spread));
}
if (isMutable == null) {
isMutable = false;
} else if (typeof isMutable !== "boolean") {
throw TypeError("Expected isMutable to be a Boolean, got " + __typeof(isMutable));
}
if (asType == null) {
asType = void 0;
} else if (!(asType instanceof Node)) {
throw TypeError("Expected asType to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(asType));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.ident = ident;
_this.defaultValue = defaultValue;
_this.spread = spread;
_this.isMutable = isMutable;
_this.asType = asType;
return _this;
}
_Node_prototype = Node.prototype;
_ParamNode_prototype = ParamNode.prototype = __create(_Node_prototype);
_ParamNode_prototype.constructor = ParamNode;
ParamNode.displayName = "ParamNode";
if (typeof Node.extended === "function") {
Node.extended(ParamNode);
}
ParamNode.cappedName = "Param";
ParamNode.argNames = [
"ident",
"defaultValue",
"spread",
"isMutable",
"asType"
];
_ParamNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"ParamNode",
this.line,
this.column,
this.ident,
this.defaultValue,
this.spread,
this.isMutable,
this.asType
);
};
_ParamNode_prototype.walk = function (f) {
var asType, defaultValue, ident;
ident = f(this.ident);
if (this.defaultValue instanceof Node) {
defaultValue = f(this.defaultValue);
} else {
defaultValue = this.defaultValue;
}
if (this.asType instanceof Node) {
asType = f(this.asType);
} else {
asType = this.asType;
}
if (ident !== this.ident || defaultValue !== this.defaultValue || asType !== this.asType) {
return ParamNode(
this.line,
this.column,
this.scope,
ident,
defaultValue,
this.spread,
this.isMutable,
asType
);
} else {
return this;
}
};
_ParamNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.ident, (_once = false, function (_e, ident) {
var _f;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
if (_this.defaultValue instanceof Node) {
_f = function (next) {
var _once2;
return f(_this.defaultValue, (_once2 = false, function (_e2, defaultValue) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return next(defaultValue);
}));
};
} else {
_f = function (next) {
return next(_this.defaultValue);
};
}
return _f(function (defaultValue) {
var _f;
if (_this.asType instanceof Node) {
_f = function (next) {
var _once2;
return f(_this.asType, (_once2 = false, function (_e2, asType) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return next(asType);
}));
};
} else {
_f = function (next) {
return next(_this.asType);
};
}
return _f(function (asType) {
return callback(null, ident !== _this.ident || defaultValue !== _this.defaultValue || asType !== _this.asType
? ParamNode(
_this.line,
_this.column,
_this.scope,
ident,
defaultValue,
_this.spread,
_this.isMutable,
asType
)
: _this);
});
});
}));
};
return ParamNode;
}(Node));
Node.Regexp = RegexpNode = (function (Node) {
var _Node_prototype, _RegexpNode_prototype;
function RegexpNode(line, column, scope, source, flags) {
var _this;
_this = this instanceof RegexpNode ? this : __create(_RegexpNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(source instanceof Node)) {
throw TypeError("Expected source to be a " + __name(Node) + ", got " + __typeof(source));
}
if (typeof flags !== "string") {
throw TypeError("Expected flags to be a String, got " + __typeof(flags));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.source = source;
_this.flags = flags;
return _this;
}
_Node_prototype = Node.prototype;
_RegexpNode_prototype = RegexpNode.prototype = __create(_Node_prototype);
_RegexpNode_prototype.constructor = RegexpNode;
RegexpNode.displayName = "RegexpNode";
if (typeof Node.extended === "function") {
Node.extended(RegexpNode);
}
RegexpNode.cappedName = "Regexp";
RegexpNode.argNames = ["source", "flags"];
_RegexpNode_prototype.type = function () {
return Type.regexp;
};
_RegexpNode_prototype._isNoop = function (o) {
return this.text.isNoop(o);
};
_RegexpNode_prototype._reduce = function (o) {
var source;
source = this.source.reduce(o).doWrap(o);
if (!source.isConst()) {
return CallNode(
this.line,
this.column,
this.scope,
IdentNode(this.line, this.column, this.scope, "RegExp"),
[
source,
ConstNode(this.line, this.column, this.scope, this.flags)
]
);
} else if (source !== this.source) {
return RegexpNode(
this.line,
this.column,
this.scope,
source,
this.flags
);
} else {
return this;
}
};
_RegexpNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"RegexpNode",
this.line,
this.column,
this.source,
this.flags
);
};
_RegexpNode_prototype.walk = function (f) {
var source;
source = f(this.source);
if (source !== this.source) {
return RegexpNode(
this.line,
this.column,
this.scope,
source,
this.flags
);
} else {
return this;
}
};
_RegexpNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.source, (_once = false, function (_e, source) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, source !== _this.source
? RegexpNode(
_this.line,
_this.column,
_this.scope,
source,
_this.flags
)
: _this);
}));
};
return RegexpNode;
}(Node));
Node.Return = ReturnNode = (function (Node) {
var _Node_prototype, _ReturnNode_prototype;
function ReturnNode(line, column, scope, node) {
var _this;
_this = this instanceof ReturnNode ? this : __create(_ReturnNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (node == null) {
node = ConstNode(line, column, scope, void 0);
} else if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.node = node;
return _this;
}
_Node_prototype = Node.prototype;
_ReturnNode_prototype = ReturnNode.prototype = __create(_Node_prototype);
_ReturnNode_prototype.constructor = ReturnNode;
ReturnNode.displayName = "ReturnNode";
if (typeof Node.extended === "function") {
Node.extended(ReturnNode);
}
ReturnNode.cappedName = "Return";
ReturnNode.argNames = ["node"];
_ReturnNode_prototype.type = function (o) {
return this.node.type(o);
};
_ReturnNode_prototype.isStatement = function () {
return true;
};
_ReturnNode_prototype._reduce = function (o) {
var node;
node = this.node.reduce(o).doWrap(o);
if (node !== this.node) {
return ReturnNode(this.line, this.column, this.scope, node);
} else {
return this;
}
};
_ReturnNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"ReturnNode",
this.line,
this.column,
this.node
);
};
_ReturnNode_prototype.walk = function (f) {
var node;
node = f(this.node);
if (node !== this.node) {
return ReturnNode(this.line, this.column, this.scope, node);
} else {
return this;
}
};
_ReturnNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.node, (_once = false, function (_e, node) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, node !== _this.node ? ReturnNode(_this.line, _this.column, _this.scope, node) : _this);
}));
};
return ReturnNode;
}(Node));
Node.Root = RootNode = (function (Node) {
var _Node_prototype, _RootNode_prototype;
function RootNode(line, column, scope, file, body, isEmbedded, isGenerator) {
var _this;
_this = this instanceof RootNode ? this : __create(_RootNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (file == null) {
file = void 0;
} else if (typeof file !== "string") {
throw TypeError("Expected file to be one of String or undefined, got " + __typeof(file));
}
if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (isEmbedded == null) {
isEmbedded = false;
} else if (typeof isEmbedded !== "boolean") {
throw TypeError("Expected isEmbedded to be a Boolean, got " + __typeof(isEmbedded));
}
if (isGenerator == null) {
isGenerator = false;
} else if (typeof isGenerator !== "boolean") {
throw TypeError("Expected isGenerator to be a Boolean, got " + __typeof(isGenerator));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.file = file;
_this.body = body;
_this.isEmbedded = isEmbedded;
_this.isGenerator = isGenerator;
return _this;
}
_Node_prototype = Node.prototype;
_RootNode_prototype = RootNode.prototype = __create(_Node_prototype);
_RootNode_prototype.constructor = RootNode;
RootNode.displayName = "RootNode";
if (typeof Node.extended === "function") {
Node.extended(RootNode);
}
RootNode.cappedName = "Root";
RootNode.argNames = ["file", "body", "isEmbedded", "isGenerator"];
_RootNode_prototype.isStatement = function () {
return true;
};
_RootNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"RootNode",
this.line,
this.column,
this.file,
this.body,
this.isEmbedded,
this.isGenerator
);
};
_RootNode_prototype.walk = function (f) {
var body;
body = f(this.body);
if (body !== this.body) {
return RootNode(
this.line,
this.column,
this.scope,
this.file,
body,
this.isEmbedded,
this.isGenerator
);
} else {
return this;
}
};
_RootNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.body, (_once = false, function (_e, body) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, body !== _this.body
? RootNode(
_this.line,
_this.column,
_this.scope,
_this.file,
body,
_this.isEmbedded,
_this.isGenerator
)
: _this);
}));
};
return RootNode;
}(Node));
Node.Spread = SpreadNode = (function (Node) {
var _Node_prototype, _SpreadNode_prototype;
function SpreadNode(line, column, scope, node) {
var _this;
_this = this instanceof SpreadNode ? this : __create(_SpreadNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.node = node;
return _this;
}
_Node_prototype = Node.prototype;
_SpreadNode_prototype = SpreadNode.prototype = __create(_Node_prototype);
_SpreadNode_prototype.constructor = SpreadNode;
SpreadNode.displayName = "SpreadNode";
if (typeof Node.extended === "function") {
Node.extended(SpreadNode);
}
SpreadNode.cappedName = "Spread";
SpreadNode.argNames = ["node"];
_SpreadNode_prototype._reduce = function (o) {
var node;
node = this.node.reduce(o).doWrap(o);
if (node !== this.node) {
return SpreadNode(this.line, this.column, this.scope, node);
} else {
return this;
}
};
_SpreadNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"SpreadNode",
this.line,
this.column,
this.node
);
};
_SpreadNode_prototype.walk = function (f) {
var node;
node = f(this.node);
if (node !== this.node) {
return SpreadNode(this.line, this.column, this.scope, node);
} else {
return this;
}
};
_SpreadNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.node, (_once = false, function (_e, node) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, node !== _this.node ? SpreadNode(_this.line, _this.column, _this.scope, node) : _this);
}));
};
return SpreadNode;
}(Node));
Node.string = function (index, parts) {
var _i, _i2, _len, concatOp, current, part;
if (!__isArray(parts)) {
throw TypeError("Expected parts to be an Array, got " + __typeof(parts));
} else {
for (_i = parts.length; _i--; ) {
if (!(parts[_i] instanceof Node)) {
throw TypeError("Expected " + ("parts[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(parts[_i]));
}
}
}
concatOp = this.getMacroByLabel("stringConcat");
if (!concatOp) {
throw Error("Cannot use string interpolation until the string-concat operator has been defined");
}
if (parts.length === 0) {
return this.Const(index, "");
} else if (parts.length === 1) {
return concatOp.func(
{
left: this.Const(index, ""),
op: "",
right: parts[0]
},
this,
index,
this.getLine(index)
);
} else {
current = parts[0];
for (_i2 = 1, _len = parts.length; _i2 < _len; ++_i2) {
part = parts[_i2];
current = concatOp.func(
{ left: current, op: "", right: part },
this,
index,
this.getLine(index)
);
}
return current;
}
};
Node.Super = SuperNode = (function (Node) {
var _Node_prototype, _SuperNode_prototype;
function SuperNode(line, column, scope, child, args) {
var _i, _this;
_this = this instanceof SuperNode ? this : __create(_SuperNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (child == null) {
child = void 0;
} else if (!(child instanceof Node)) {
throw TypeError("Expected child to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(child));
}
if (!__isArray(args)) {
throw TypeError("Expected args to be an Array, got " + __typeof(args));
} else {
for (_i = args.length; _i--; ) {
if (!(args[_i] instanceof Node)) {
throw TypeError("Expected " + ("args[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(args[_i]));
}
}
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.child = child;
_this.args = args;
return _this;
}
_Node_prototype = Node.prototype;
_SuperNode_prototype = SuperNode.prototype = __create(_Node_prototype);
_SuperNode_prototype.constructor = SuperNode;
SuperNode.displayName = "SuperNode";
if (typeof Node.extended === "function") {
Node.extended(SuperNode);
}
SuperNode.cappedName = "Super";
SuperNode.argNames = ["child", "args"];
_SuperNode_prototype._reduce = function (o) {
var args, child;
if (this.child != null) {
child = this.child.reduce(o).doWrap(o);
} else {
child = this.child;
}
args = map(
this.args,
function (node, o) {
return node.reduce(o).doWrap(o);
},
o
);
if (child !== this.child || args !== this.args) {
return SuperNode(
this.line,
this.column,
this.scope,
child,
args
);
} else {
return this;
}
};
_SuperNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"SuperNode",
this.line,
this.column,
this.child,
this.args
);
};
_SuperNode_prototype.walk = function (f) {
var args, child;
if (this.child instanceof Node) {
child = f(this.child);
} else {
child = this.child;
}
args = map(this.args, f);
if (child !== this.child || args !== this.args) {
return SuperNode(
this.line,
this.column,
this.scope,
child,
args
);
} else {
return this;
}
};
_SuperNode_prototype.walkAsync = function (f, callback) {
var _f, _this;
_this = this;
if (this.child instanceof Node) {
_f = function (next) {
var _once;
return f(_this.child, (_once = false, function (_e, child) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return next(child);
}));
};
} else {
_f = function (next) {
return next(_this.child);
};
}
return _f(function (child) {
var _once;
return mapAsync(_this.args, f, (_once = false, function (_e, args) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, child !== _this.child || args !== _this.args
? SuperNode(
_this.line,
_this.column,
_this.scope,
child,
args
)
: _this);
}));
});
};
return SuperNode;
}(Node));
Node.Switch = SwitchNode = (function (Node) {
var _Node_prototype, _SwitchNode_prototype;
function SwitchNode(line, column, scope, node, cases, defaultCase, label) {
var _this;
_this = this instanceof SwitchNode ? this : __create(_SwitchNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
if (!__isArray(cases)) {
throw TypeError("Expected cases to be an Array, got " + __typeof(cases));
}
if (defaultCase == null) {
defaultCase = void 0;
} else if (!(defaultCase instanceof Node)) {
throw TypeError("Expected defaultCase to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(defaultCase));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.node = node;
_this.cases = cases;
_this.defaultCase = defaultCase;
_this.label = label;
return _this;
}
_Node_prototype = Node.prototype;
_SwitchNode_prototype = SwitchNode.prototype = __create(_Node_prototype);
_SwitchNode_prototype.constructor = SwitchNode;
SwitchNode.displayName = "SwitchNode";
if (typeof Node.extended === "function") {
Node.extended(SwitchNode);
}
SwitchNode.cappedName = "Switch";
SwitchNode.argNames = ["node", "cases", "defaultCase", "label"];
_SwitchNode_prototype.type = function (o) {
var _ref, _this;
_this = this;
if ((_ref = this._type) == null) {
return this._type = (function () {
var _arr, _i, _len, case_, type;
if (_this.defaultCase != null) {
type = _this.defaultCase.type(o);
} else {
type = Type["undefined"];
}
for (_arr = __toArray(_this.cases), _i = 0, _len = _arr.length; _i < _len; ++_i) {
case_ = _arr[_i];
if (case_.fallthrough) {
type = type;
} else {
type = type.union(case_.body.type(o));
}
}
return type;
}());
} else {
return _ref;
}
};
_SwitchNode_prototype.withLabel = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return SwitchNode(
this.line,
this.column,
this.scope,
this.node,
this.cases,
this.defaultCase,
label
);
};
_SwitchNode_prototype.walk = function (f) {
var cases, defaultCase, label, node;
node = f(this.node);
cases = map(this.cases, function (case_) {
var caseBody, caseNode;
caseNode = f(case_.node);
caseBody = f(case_.body);
if (caseNode !== case_.node || caseBody !== case_.body) {
return { node: caseNode, body: caseBody, fallthrough: case_.fallthrough };
} else {
return case_;
}
});
if (this.defaultCase) {
defaultCase = f(this.defaultCase);
} else {
defaultCase = this.defaultCase;
}
if (this.label != null) {
label = f(this.label);
} else {
label = this.label;
}
if (node !== this.node || cases !== this.cases || defaultCase !== this.defaultCase || label !== this.label) {
return SwitchNode(
this.line,
this.column,
this.scope,
node,
cases,
defaultCase,
label
);
} else {
return this;
}
};
_SwitchNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.node, (_once = false, function (_e, node) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return mapAsync(
_this.cases,
function (case_, cb) {
var _once3;
return f(case_.node, (_once3 = false, function (_e2, caseNode) {
var _once4;
if (_once3) {
throw Error("Attempted to call function more than once");
} else {
_once3 = true;
}
if (_e2 != null) {
return cb(_e2);
}
return f(case_.body, (_once4 = false, function (_e3, caseBody) {
if (_once4) {
throw Error("Attempted to call function more than once");
} else {
_once4 = true;
}
if (_e3 != null) {
return cb(_e3);
}
return cb(null, caseNode !== case_.node || caseBody !== case_.body ? { node: caseNode, body: caseBody, fallthrough: case_.fallthrough } : case_);
}));
}));
},
(_once2 = false, function (_e2, cases) {
var _f;
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
if (_this.defaultCase != null) {
_f = function (next) {
var _once3;
return f(_this.defaultCase, (_once3 = false, function (_e3, x) {
if (_once3) {
throw Error("Attempted to call function more than once");
} else {
_once3 = true;
}
if (_e3 != null) {
return callback(_e3);
}
return next(x);
}));
};
} else {
_f = function (next) {
return next(_this.defaultCase);
};
}
return _f(function (defaultCase) {
var _f;
if (_this.label != null) {
_f = function (next) {
var _once3;
return f(_this.label, (_once3 = false, function (_e3, x) {
if (_once3) {
throw Error("Attempted to call function more than once");
} else {
_once3 = true;
}
if (_e3 != null) {
return callback(_e3);
}
return next(x);
}));
};
} else {
_f = function (next) {
return next(_this.label);
};
}
return _f(function (label) {
return callback(null, node !== _this.node || cases !== _this.cases || defaultCase !== _this.defaultCase || label !== _this.label
? SwitchNode(
_this.line,
_this.column,
_this.scope,
node,
cases,
defaultCase,
label
)
: _this);
});
});
})
);
}));
};
_SwitchNode_prototype.isStatement = function () {
return true;
};
_SwitchNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"SwitchNode",
this.line,
this.column,
this.node,
this.cases,
this.defaultCase,
this.label
);
};
return SwitchNode;
}(Node));
Node.SyntaxChoice = SyntaxChoiceNode = (function (Node) {
var _Node_prototype, _SyntaxChoiceNode_prototype;
function SyntaxChoiceNode(line, column, scope, choices) {
var _i, _this;
_this = this instanceof SyntaxChoiceNode ? this : __create(_SyntaxChoiceNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!__isArray(choices)) {
throw TypeError("Expected choices to be an Array, got " + __typeof(choices));
} else {
for (_i = choices.length; _i--; ) {
if (!(choices[_i] instanceof Node)) {
throw TypeError("Expected " + ("choices[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(choices[_i]));
}
}
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.choices = choices;
return _this;
}
_Node_prototype = Node.prototype;
_SyntaxChoiceNode_prototype = SyntaxChoiceNode.prototype = __create(_Node_prototype);
_SyntaxChoiceNode_prototype.constructor = SyntaxChoiceNode;
SyntaxChoiceNode.displayName = "SyntaxChoiceNode";
if (typeof Node.extended === "function") {
Node.extended(SyntaxChoiceNode);
}
SyntaxChoiceNode.cappedName = "SyntaxChoice";
SyntaxChoiceNode.argNames = ["choices"];
_SyntaxChoiceNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"SyntaxChoiceNode",
this.line,
this.column,
this.choices
);
};
_SyntaxChoiceNode_prototype.walk = function (f) {
var choices;
choices = map(this.choices, f);
if (choices !== this.choices) {
return SyntaxChoiceNode(this.line, this.column, this.scope, choices);
} else {
return this;
}
};
_SyntaxChoiceNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return mapAsync(this.choices, f, (_once = false, function (_e, choices) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, choices !== _this.choices ? SyntaxChoiceNode(_this.line, _this.column, _this.scope, choices) : _this);
}));
};
return SyntaxChoiceNode;
}(Node));
Node.SyntaxMany = SyntaxManyNode = (function (Node) {
var _Node_prototype, _SyntaxManyNode_prototype;
function SyntaxManyNode(line, column, scope, inner, multiplier) {
var _this;
_this = this instanceof SyntaxManyNode ? this : __create(_SyntaxManyNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(inner instanceof Node)) {
throw TypeError("Expected inner to be a " + __name(Node) + ", got " + __typeof(inner));
}
if (typeof multiplier !== "string") {
throw TypeError("Expected multiplier to be a String, got " + __typeof(multiplier));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.inner = inner;
_this.multiplier = multiplier;
return _this;
}
_Node_prototype = Node.prototype;
_SyntaxManyNode_prototype = SyntaxManyNode.prototype = __create(_Node_prototype);
_SyntaxManyNode_prototype.constructor = SyntaxManyNode;
SyntaxManyNode.displayName = "SyntaxManyNode";
if (typeof Node.extended === "function") {
Node.extended(SyntaxManyNode);
}
SyntaxManyNode.cappedName = "SyntaxMany";
SyntaxManyNode.argNames = ["inner", "multiplier"];
_SyntaxManyNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"SyntaxManyNode",
this.line,
this.column,
this.inner,
this.multiplier
);
};
_SyntaxManyNode_prototype.walk = function (f) {
var inner;
inner = f(this.inner);
if (inner !== this.inner) {
return SyntaxManyNode(
this.line,
this.column,
this.scope,
inner,
this.multiplier
);
} else {
return this;
}
};
_SyntaxManyNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.inner, (_once = false, function (_e, inner) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, inner !== _this.inner
? SyntaxManyNode(
_this.line,
_this.column,
_this.scope,
inner,
_this.multiplier
)
: _this);
}));
};
return SyntaxManyNode;
}(Node));
Node.SyntaxParam = SyntaxParamNode = (function (Node) {
var _Node_prototype, _SyntaxParamNode_prototype;
function SyntaxParamNode(line, column, scope, ident, asType) {
var _this;
_this = this instanceof SyntaxParamNode ? this : __create(_SyntaxParamNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(ident instanceof Node)) {
throw TypeError("Expected ident to be a " + __name(Node) + ", got " + __typeof(ident));
}
if (asType == null) {
asType = void 0;
} else if (!(asType instanceof Node)) {
throw TypeError("Expected asType to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(asType));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.ident = ident;
_this.asType = asType;
return _this;
}
_Node_prototype = Node.prototype;
_SyntaxParamNode_prototype = SyntaxParamNode.prototype = __create(_Node_prototype);
_SyntaxParamNode_prototype.constructor = SyntaxParamNode;
SyntaxParamNode.displayName = "SyntaxParamNode";
if (typeof Node.extended === "function") {
Node.extended(SyntaxParamNode);
}
SyntaxParamNode.cappedName = "SyntaxParam";
SyntaxParamNode.argNames = ["ident", "asType"];
_SyntaxParamNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"SyntaxParamNode",
this.line,
this.column,
this.ident,
this.asType
);
};
_SyntaxParamNode_prototype.walk = function (f) {
var asType, ident;
ident = f(this.ident);
if (this.asType instanceof Node) {
asType = f(this.asType);
} else {
asType = this.asType;
}
if (ident !== this.ident || asType !== this.asType) {
return SyntaxParamNode(
this.line,
this.column,
this.scope,
ident,
asType
);
} else {
return this;
}
};
_SyntaxParamNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.ident, (_once = false, function (_e, ident) {
var _f;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
if (_this.asType instanceof Node) {
_f = function (next) {
var _once2;
return f(_this.asType, (_once2 = false, function (_e2, asType) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return next(asType);
}));
};
} else {
_f = function (next) {
return next(_this.asType);
};
}
return _f(function (asType) {
return callback(null, ident !== _this.ident || asType !== _this.asType
? SyntaxParamNode(
_this.line,
_this.column,
_this.scope,
ident,
asType
)
: _this);
});
}));
};
return SyntaxParamNode;
}(Node));
Node.SyntaxSequence = SyntaxSequenceNode = (function (Node) {
var _Node_prototype, _SyntaxSequenceNode_prototype;
function SyntaxSequenceNode(line, column, scope, params) {
var _i, _this;
_this = this instanceof SyntaxSequenceNode ? this : __create(_SyntaxSequenceNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!__isArray(params)) {
throw TypeError("Expected params to be an Array, got " + __typeof(params));
} else {
for (_i = params.length; _i--; ) {
if (!(params[_i] instanceof Node)) {
throw TypeError("Expected " + ("params[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(params[_i]));
}
}
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.params = params;
return _this;
}
_Node_prototype = Node.prototype;
_SyntaxSequenceNode_prototype = SyntaxSequenceNode.prototype = __create(_Node_prototype);
_SyntaxSequenceNode_prototype.constructor = SyntaxSequenceNode;
SyntaxSequenceNode.displayName = "SyntaxSequenceNode";
if (typeof Node.extended === "function") {
Node.extended(SyntaxSequenceNode);
}
SyntaxSequenceNode.cappedName = "SyntaxSequence";
SyntaxSequenceNode.argNames = ["params"];
_SyntaxSequenceNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"SyntaxSequenceNode",
this.line,
this.column,
this.params
);
};
_SyntaxSequenceNode_prototype.walk = function (f) {
var params;
params = map(this.params, f);
if (params !== this.params) {
return SyntaxSequenceNode(this.line, this.column, this.scope, params);
} else {
return this;
}
};
_SyntaxSequenceNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return mapAsync(this.params, f, (_once = false, function (_e, params) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, params !== _this.params ? SyntaxSequenceNode(_this.line, _this.column, _this.scope, params) : _this);
}));
};
return SyntaxSequenceNode;
}(Node));
Node.This = ThisNode = (function (Node) {
var _Node_prototype, _ThisNode_prototype;
function ThisNode(line, column, scope) {
var _this;
_this = this instanceof ThisNode ? this : __create(_ThisNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
return _this;
}
_Node_prototype = Node.prototype;
_ThisNode_prototype = ThisNode.prototype = __create(_Node_prototype);
_ThisNode_prototype.constructor = ThisNode;
ThisNode.displayName = "ThisNode";
if (typeof Node.extended === "function") {
Node.extended(ThisNode);
}
ThisNode.cappedName = "This";
ThisNode.argNames = [];
_ThisNode_prototype.cacheable = false;
_ThisNode_prototype._isNoop = function () {
return true;
};
_ThisNode_prototype.inspect = function (depth) {
return inspectHelper(depth, "ThisNode", this.line, this.column);
};
return ThisNode;
}(Node));
Node.Throw = ThrowNode = (function (Node) {
var _Node_prototype, _ThrowNode_prototype;
function ThrowNode(line, column, scope, node) {
var _this;
_this = this instanceof ThrowNode ? this : __create(_ThrowNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.node = node;
return _this;
}
_Node_prototype = Node.prototype;
_ThrowNode_prototype = ThrowNode.prototype = __create(_Node_prototype);
_ThrowNode_prototype.constructor = ThrowNode;
ThrowNode.displayName = "ThrowNode";
if (typeof Node.extended === "function") {
Node.extended(ThrowNode);
}
ThrowNode.cappedName = "Throw";
ThrowNode.argNames = ["node"];
_ThrowNode_prototype.type = function () {
return Type.none;
};
_ThrowNode_prototype.isStatement = function () {
return true;
};
_ThrowNode_prototype._reduce = function (o) {
var node;
node = this.node.reduce(o).doWrap(o);
if (node !== this.node) {
return ThrowNode(this.line, this.column, this.scope, node);
} else {
return this;
}
};
_ThrowNode_prototype.doWrap = function (o) {
return CallNode(
this.line,
this.column,
this.scope,
IdentNode(this.line, this.column, this.scope, "__throw"),
[this.node]
);
};
_ThrowNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"ThrowNode",
this.line,
this.column,
this.node
);
};
_ThrowNode_prototype.walk = function (f) {
var node;
node = f(this.node);
if (node !== this.node) {
return ThrowNode(this.line, this.column, this.scope, node);
} else {
return this;
}
};
_ThrowNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.node, (_once = false, function (_e, node) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, node !== _this.node ? ThrowNode(_this.line, _this.column, _this.scope, node) : _this);
}));
};
return ThrowNode;
}(Node));
Node.Tmp = TmpNode = (function (Node) {
var _Node_prototype, _TmpNode_prototype;
function TmpNode(line, column, scope, id, name, _type) {
var _this;
_this = this instanceof TmpNode ? this : __create(_TmpNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (typeof id !== "number") {
throw TypeError("Expected id to be a Number, got " + __typeof(id));
}
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (_type == null) {
_type = Type.any;
} else if (!(_type instanceof Type)) {
throw TypeError("Expected _type to be a " + __name(Type) + ", got " + __typeof(_type));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.id = id;
_this.name = name;
_this._type = _type;
return _this;
}
_Node_prototype = Node.prototype;
_TmpNode_prototype = TmpNode.prototype = __create(_Node_prototype);
_TmpNode_prototype.constructor = TmpNode;
TmpNode.displayName = "TmpNode";
if (typeof Node.extended === "function") {
Node.extended(TmpNode);
}
TmpNode.cappedName = "Tmp";
TmpNode.argNames = ["id", "name", "_type"];
_TmpNode_prototype.cacheable = false;
_TmpNode_prototype.type = function () {
return this._type;
};
_TmpNode_prototype._isNoop = function () {
return true;
};
_TmpNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"TmpNode",
this.line,
this.column,
this.id,
this.name,
this._type
);
};
_TmpNode_prototype.walk = function (f) {
return this;
};
_TmpNode_prototype.walkAsync = function (f, callback) {
return callback(null, this);
};
return TmpNode;
}(Node));
Node.TmpWrapper = TmpWrapperNode = (function (Node) {
var _Node_prototype, _TmpWrapperNode_prototype;
function TmpWrapperNode(line, column, scope, node, tmps) {
var _this;
_this = this instanceof TmpWrapperNode ? this : __create(_TmpWrapperNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
if (!__isArray(tmps)) {
throw TypeError("Expected tmps to be an Array, got " + __typeof(tmps));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.node = node;
_this.tmps = tmps;
return _this;
}
_Node_prototype = Node.prototype;
_TmpWrapperNode_prototype = TmpWrapperNode.prototype = __create(_Node_prototype);
_TmpWrapperNode_prototype.constructor = TmpWrapperNode;
TmpWrapperNode.displayName = "TmpWrapperNode";
if (typeof Node.extended === "function") {
Node.extended(TmpWrapperNode);
}
TmpWrapperNode.cappedName = "TmpWrapper";
TmpWrapperNode.argNames = ["node", "tmps"];
_TmpWrapperNode_prototype.type = function (o) {
return this.node.type(o);
};
_TmpWrapperNode_prototype.withLabel = function (label, o) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return TmpWrapperNode(
this.line,
this.column,
this.scope,
this.node.withLabel(label, o),
this.tmps
);
};
_TmpWrapperNode_prototype._reduce = function (o) {
var node;
node = this.node.reduce(o);
if (this.tmps.length === 0) {
return node;
} else if (this.node !== node) {
return TmpWrapperNode(
this.line,
this.column,
this.scope,
node,
this.tmps
);
} else {
return this;
}
};
_TmpWrapperNode_prototype.isStatement = function () {
return this.node.isStatement();
};
_TmpWrapperNode_prototype._isNoop = function (o) {
return this.node.isNoop(o);
};
_TmpWrapperNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"TmpWrapperNode",
this.line,
this.column,
this.node,
this.tmps
);
};
_TmpWrapperNode_prototype.walk = function (f) {
var node;
node = f(this.node);
if (node !== this.node) {
return TmpWrapperNode(
this.line,
this.column,
this.scope,
node,
this.tmps
);
} else {
return this;
}
};
_TmpWrapperNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.node, (_once = false, function (_e, node) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, node !== _this.node
? TmpWrapperNode(
_this.line,
_this.column,
_this.scope,
node,
_this.tmps
)
: _this);
}));
};
return TmpWrapperNode;
}(Node));
Node.TryCatch = TryCatchNode = (function (Node) {
var _Node_prototype, _TryCatchNode_prototype;
function TryCatchNode(line, column, scope, tryBody, catchIdent, catchBody, label) {
var _this;
_this = this instanceof TryCatchNode ? this : __create(_TryCatchNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(tryBody instanceof Node)) {
throw TypeError("Expected tryBody to be a " + __name(Node) + ", got " + __typeof(tryBody));
}
if (!(catchIdent instanceof Node)) {
throw TypeError("Expected catchIdent to be a " + __name(Node) + ", got " + __typeof(catchIdent));
}
if (!(catchBody instanceof Node)) {
throw TypeError("Expected catchBody to be a " + __name(Node) + ", got " + __typeof(catchBody));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.tryBody = tryBody;
_this.catchIdent = catchIdent;
_this.catchBody = catchBody;
_this.label = label;
return _this;
}
_Node_prototype = Node.prototype;
_TryCatchNode_prototype = TryCatchNode.prototype = __create(_Node_prototype);
_TryCatchNode_prototype.constructor = TryCatchNode;
TryCatchNode.displayName = "TryCatchNode";
if (typeof Node.extended === "function") {
Node.extended(TryCatchNode);
}
TryCatchNode.cappedName = "TryCatch";
TryCatchNode.argNames = ["tryBody", "catchIdent", "catchBody", "label"];
_TryCatchNode_prototype.type = function (o) {
var _ref;
if ((_ref = this._type) == null) {
return this._type = this.tryBody.type(o).union(this.catchBody.type(o));
} else {
return _ref;
}
};
_TryCatchNode_prototype.isStatement = function () {
return true;
};
_TryCatchNode_prototype._isNoop = function (o) {
return this.tryBody.isNoop(o);
};
_TryCatchNode_prototype.withLabel = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return TryCatchNode(
this.line,
this.column,
this.scope,
this.tryBody,
this.catchIdent,
this.catchBody,
label
);
};
_TryCatchNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"TryCatchNode",
this.line,
this.column,
this.tryBody,
this.catchIdent,
this.catchBody,
this.label
);
};
_TryCatchNode_prototype.walk = function (f) {
var catchBody, catchIdent, label, tryBody;
tryBody = f(this.tryBody);
catchIdent = f(this.catchIdent);
catchBody = f(this.catchBody);
if (this.label instanceof Node) {
label = f(this.label);
} else {
label = this.label;
}
if (tryBody !== this.tryBody || catchIdent !== this.catchIdent || catchBody !== this.catchBody || label !== this.label) {
return TryCatchNode(
this.line,
this.column,
this.scope,
tryBody,
catchIdent,
catchBody,
label
);
} else {
return this;
}
};
_TryCatchNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.tryBody, (_once = false, function (_e, tryBody) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return f(_this.catchIdent, (_once2 = false, function (_e2, catchIdent) {
var _once3;
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return f(_this.catchBody, (_once3 = false, function (_e3, catchBody) {
var _f;
if (_once3) {
throw Error("Attempted to call function more than once");
} else {
_once3 = true;
}
if (_e3 != null) {
return callback(_e3);
}
if (_this.label instanceof Node) {
_f = function (next) {
var _once4;
return f(_this.label, (_once4 = false, function (_e4, label) {
if (_once4) {
throw Error("Attempted to call function more than once");
} else {
_once4 = true;
}
if (_e4 != null) {
return callback(_e4);
}
return next(label);
}));
};
} else {
_f = function (next) {
return next(_this.label);
};
}
return _f(function (label) {
return callback(null, tryBody !== _this.tryBody || catchIdent !== _this.catchIdent || catchBody !== _this.catchBody || label !== _this.label
? TryCatchNode(
_this.line,
_this.column,
_this.scope,
tryBody,
catchIdent,
catchBody,
label
)
: _this);
});
}));
}));
}));
};
return TryCatchNode;
}(Node));
Node.TryFinally = TryFinallyNode = (function (Node) {
var _Node_prototype, _TryFinallyNode_prototype;
function TryFinallyNode(line, column, scope, tryBody, finallyBody, label) {
var _this;
_this = this instanceof TryFinallyNode ? this : __create(_TryFinallyNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(tryBody instanceof Node)) {
throw TypeError("Expected tryBody to be a " + __name(Node) + ", got " + __typeof(tryBody));
}
if (!(finallyBody instanceof Node)) {
throw TypeError("Expected finallyBody to be a " + __name(Node) + ", got " + __typeof(finallyBody));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.tryBody = tryBody;
_this.finallyBody = finallyBody;
_this.label = label;
return _this;
}
_Node_prototype = Node.prototype;
_TryFinallyNode_prototype = TryFinallyNode.prototype = __create(_Node_prototype);
_TryFinallyNode_prototype.constructor = TryFinallyNode;
TryFinallyNode.displayName = "TryFinallyNode";
if (typeof Node.extended === "function") {
Node.extended(TryFinallyNode);
}
TryFinallyNode.cappedName = "TryFinally";
TryFinallyNode.argNames = ["tryBody", "finallyBody", "label"];
_TryFinallyNode_prototype.type = function (o) {
return this.tryBody.type(o);
};
_TryFinallyNode_prototype._reduce = function (o) {
var finallyBody, label, tryBody;
tryBody = this.tryBody.reduce(o);
finallyBody = this.finallyBody.reduce(o);
if (this.label != null) {
label = this.label.reduce(o);
} else {
label = this.label;
}
if (finallyBody instanceof NothingNode) {
return BlockNode(this.line, this.column, this.scopeIf([tryBody], label)).reduce(o);
} else if (tryBody instanceof NothingNode) {
return BlockNode(this.line, this.column, this.scopeIf([finallyBody], label)).reduce(o);
} else if (tryBody !== this.tryBody || finallyBody !== this.finallyBody || label !== this.label) {
return TryFinallyNode(
this.line,
this.column,
this.scope,
tryBody,
finallyBody,
label
);
} else {
return this;
}
};
_TryFinallyNode_prototype.isStatement = function () {
return true;
};
_TryFinallyNode_prototype._isNoop = function (o) {
var _ref;
if ((_ref = this.__isNoop) == null) {
return this.__isNoop = this.tryBody.isNoop(o) && this.finallyBody.isNoop();
} else {
return _ref;
}
};
_TryFinallyNode_prototype.withLabel = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return TryFinallyNode(
this.line,
this.column,
this.scope,
this.tryBody,
this.finallyBody,
label
);
};
_TryFinallyNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"TryFinallyNode",
this.line,
this.column,
this.tryBody,
this.finallyBody,
this.label
);
};
_TryFinallyNode_prototype.walk = function (f) {
var finallyBody, label, tryBody;
tryBody = f(this.tryBody);
finallyBody = f(this.finallyBody);
if (this.label instanceof Node) {
label = f(this.label);
} else {
label = this.label;
}
if (tryBody !== this.tryBody || finallyBody !== this.finallyBody || label !== this.label) {
return TryFinallyNode(
this.line,
this.column,
this.scope,
tryBody,
finallyBody,
label
);
} else {
return this;
}
};
_TryFinallyNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.tryBody, (_once = false, function (_e, tryBody) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return f(_this.finallyBody, (_once2 = false, function (_e2, finallyBody) {
var _f;
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
if (_this.label instanceof Node) {
_f = function (next) {
var _once3;
return f(_this.label, (_once3 = false, function (_e3, label) {
if (_once3) {
throw Error("Attempted to call function more than once");
} else {
_once3 = true;
}
if (_e3 != null) {
return callback(_e3);
}
return next(label);
}));
};
} else {
_f = function (next) {
return next(_this.label);
};
}
return _f(function (label) {
return callback(null, tryBody !== _this.tryBody || finallyBody !== _this.finallyBody || label !== _this.label
? TryFinallyNode(
_this.line,
_this.column,
_this.scope,
tryBody,
finallyBody,
label
)
: _this);
});
}));
}));
};
return TryFinallyNode;
}(Node));
Node.TypeFunction = TypeFunctionNode = (function (Node) {
var _Node_prototype, _TypeFunctionNode_prototype;
function TypeFunctionNode(line, column, scope, returnType) {
var _this;
_this = this instanceof TypeFunctionNode ? this : __create(_TypeFunctionNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(returnType instanceof Node)) {
throw TypeError("Expected returnType to be a " + __name(Node) + ", got " + __typeof(returnType));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.returnType = returnType;
return _this;
}
_Node_prototype = Node.prototype;
_TypeFunctionNode_prototype = TypeFunctionNode.prototype = __create(_Node_prototype);
_TypeFunctionNode_prototype.constructor = TypeFunctionNode;
TypeFunctionNode.displayName = "TypeFunctionNode";
if (typeof Node.extended === "function") {
Node.extended(TypeFunctionNode);
}
TypeFunctionNode.cappedName = "TypeFunction";
TypeFunctionNode.argNames = ["returnType"];
_TypeFunctionNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"TypeFunctionNode",
this.line,
this.column,
this.returnType
);
};
_TypeFunctionNode_prototype.walk = function (f) {
var returnType;
returnType = f(this.returnType);
if (returnType !== this.returnType) {
return TypeFunctionNode(this.line, this.column, this.scope, returnType);
} else {
return this;
}
};
_TypeFunctionNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.returnType, (_once = false, function (_e, returnType) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, returnType !== _this.returnType ? TypeFunctionNode(_this.line, _this.column, _this.scope, returnType) : _this);
}));
};
return TypeFunctionNode;
}(Node));
Node.TypeGeneric = TypeGenericNode = (function (Node) {
var _Node_prototype, _TypeGenericNode_prototype;
function TypeGenericNode(line, column, scope, basetype, args) {
var _i, _this;
_this = this instanceof TypeGenericNode ? this : __create(_TypeGenericNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(basetype instanceof Node)) {
throw TypeError("Expected basetype to be a " + __name(Node) + ", got " + __typeof(basetype));
}
if (!__isArray(args)) {
throw TypeError("Expected args to be an Array, got " + __typeof(args));
} else {
for (_i = args.length; _i--; ) {
if (!(args[_i] instanceof Node)) {
throw TypeError("Expected " + ("args[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(args[_i]));
}
}
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.basetype = basetype;
_this.args = args;
return _this;
}
_Node_prototype = Node.prototype;
_TypeGenericNode_prototype = TypeGenericNode.prototype = __create(_Node_prototype);
_TypeGenericNode_prototype.constructor = TypeGenericNode;
TypeGenericNode.displayName = "TypeGenericNode";
if (typeof Node.extended === "function") {
Node.extended(TypeGenericNode);
}
TypeGenericNode.cappedName = "TypeGeneric";
TypeGenericNode.argNames = ["basetype", "args"];
_TypeGenericNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"TypeGenericNode",
this.line,
this.column,
this.basetype,
this.args
);
};
_TypeGenericNode_prototype.walk = function (f) {
var args, basetype;
basetype = f(this.basetype);
args = map(this.args, f);
if (basetype !== this.basetype || args !== this.args) {
return TypeGenericNode(
this.line,
this.column,
this.scope,
basetype,
args
);
} else {
return this;
}
};
_TypeGenericNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.basetype, (_once = false, function (_e, basetype) {
var _once2;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return mapAsync(_this.args, f, (_once2 = false, function (_e2, args) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
if (_e2 != null) {
return callback(_e2);
}
return callback(null, basetype !== _this.basetype || args !== _this.args
? TypeGenericNode(
_this.line,
_this.column,
_this.scope,
basetype,
args
)
: _this);
}));
}));
};
return TypeGenericNode;
}(Node));
Node.TypeObject = TypeObjectNode = (function (Node) {
var _Node_prototype, _TypeObjectNode_prototype;
function TypeObjectNode(line, column, scope, pairs) {
var _this;
_this = this instanceof TypeObjectNode ? this : __create(_TypeObjectNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!__isArray(pairs)) {
throw TypeError("Expected pairs to be an Array, got " + __typeof(pairs));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.pairs = pairs;
return _this;
}
_Node_prototype = Node.prototype;
_TypeObjectNode_prototype = TypeObjectNode.prototype = __create(_Node_prototype);
_TypeObjectNode_prototype.constructor = TypeObjectNode;
TypeObjectNode.displayName = "TypeObjectNode";
if (typeof Node.extended === "function") {
Node.extended(TypeObjectNode);
}
TypeObjectNode.cappedName = "TypeObject";
TypeObjectNode.argNames = ["pairs"];
function reducePair(pair, o) {
var key, value;
key = pair.key.reduce(o);
value = pair.value.reduce(o);
if (key !== pair.key || value !== pair.value) {
return { key: key, value: value };
} else {
return pair;
}
}
_TypeObjectNode_prototype._reduce = function (o) {
var pairs;
pairs = map(this.pairs, reducePair, o);
if (pairs !== this.pairs) {
return TypeObjectNode(this.line, this.column, this.scope, pairs);
} else {
return this;
}
};
_TypeObjectNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"TypeObjectNode",
this.line,
this.column,
this.pairs
);
};
_TypeObjectNode_prototype.walk = function (f) {
return this;
};
_TypeObjectNode_prototype.walkAsync = function (f, callback) {
return callback(null, this);
};
return TypeObjectNode;
}(Node));
Node.TypeUnion = TypeUnionNode = (function (Node) {
var _Node_prototype, _TypeUnionNode_prototype;
function TypeUnionNode(line, column, scope, types) {
var _i, _this;
_this = this instanceof TypeUnionNode ? this : __create(_TypeUnionNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!__isArray(types)) {
throw TypeError("Expected types to be an Array, got " + __typeof(types));
} else {
for (_i = types.length; _i--; ) {
if (!(types[_i] instanceof Node)) {
throw TypeError("Expected " + ("types[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(types[_i]));
}
}
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.types = types;
return _this;
}
_Node_prototype = Node.prototype;
_TypeUnionNode_prototype = TypeUnionNode.prototype = __create(_Node_prototype);
_TypeUnionNode_prototype.constructor = TypeUnionNode;
TypeUnionNode.displayName = "TypeUnionNode";
if (typeof Node.extended === "function") {
Node.extended(TypeUnionNode);
}
TypeUnionNode.cappedName = "TypeUnion";
TypeUnionNode.argNames = ["types"];
_TypeUnionNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"TypeUnionNode",
this.line,
this.column,
this.types
);
};
_TypeUnionNode_prototype.walk = function (f) {
var types;
types = map(this.types, f);
if (types !== this.types) {
return TypeUnionNode(this.line, this.column, this.scope, types);
} else {
return this;
}
};
_TypeUnionNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return mapAsync(this.types, f, (_once = false, function (_e, types) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, types !== _this.types ? TypeUnionNode(_this.line, _this.column, _this.scope, types) : _this);
}));
};
return TypeUnionNode;
}(Node));
Node.Unary = UnaryNode = (function (Node) {
var _Node_prototype, _UnaryNode_prototype;
function UnaryNode(line, column, scope, op, node) {
var _this;
_this = this instanceof UnaryNode ? this : __create(_UnaryNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (typeof op !== "string") {
throw TypeError("Expected op to be a String, got " + __typeof(op));
}
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.op = op;
_this.node = node;
return _this;
}
_Node_prototype = Node.prototype;
_UnaryNode_prototype = UnaryNode.prototype = __create(_Node_prototype);
_UnaryNode_prototype.constructor = UnaryNode;
UnaryNode.displayName = "UnaryNode";
if (typeof Node.extended === "function") {
Node.extended(UnaryNode);
}
UnaryNode.cappedName = "Unary";
UnaryNode.argNames = ["op", "node"];
_UnaryNode_prototype.type = (function () {
var ops;
ops = {
"-": Type.number,
"+": Type.number,
"--": Type.number,
"++": Type.number,
"--post": Type.number,
"++post": Type.number,
"!": Type.boolean,
"~": Type.number,
"typeof": Type.string,
"delete": Type.boolean
};
return function () {
var _ref;
return (__owns.call(ops, _ref = this.op) ? ops[_ref] : void 0) || Type.any;
};
}());
_UnaryNode_prototype._reduce = (function () {
var constOps, nonconstOps;
constOps = {
"-": function (x) {
return -x;
},
"+": function (x) {
return +x;
},
"!": function (x) {
return !x;
},
"~": function (x) {
return ~x;
},
"typeof": function (x) {
return typeof x;
}
};
nonconstOps = {
"+": function (node, o) {
if (node.type(o).isSubsetOf(Type.number)) {
return node;
}
},
"-": function (node) {
var _ref;
if (node instanceof UnaryNode) {
if ((_ref = node.op) === "-" || _ref === "+") {
return UnaryNode(
this.line,
this.column,
this.scope,
node.op === "-" ? "+" : "-",
node.node
);
}
} else if (node instanceof BinaryNode) {
if ((_ref = node.op) === "-" || _ref === "+") {
return BinaryNode(
this.line,
this.column,
this.scope,
node.left,
node.op === "-" ? "+" : "-",
node.right
);
} else if ((_ref = node.op) === "*" || _ref === "/") {
return BinaryNode(
this.line,
this.column,
this.scope,
UnaryNode(
node.left.line,
node.left.column,
node.left.scope,
"-",
node.left
),
node.op,
node.right
);
}
}
},
"!": (function () {
var invertibleBinaryOps;
invertibleBinaryOps = {
"<": ">=",
"<=": ">",
">": "<=",
">=": "<",
"==": "!=",
"!=": "==",
"===": "!==",
"!==": "===",
"&&": function (x, y) {
return BinaryNode(
this.line,
this.column,
this.scope,
UnaryNode(
x.line,
x.column,
x.scope,
"!",
x
),
"||",
UnaryNode(
y.line,
y.column,
y.scope,
"!",
y
)
);
},
"||": function (x, y) {
return BinaryNode(
this.line,
this.column,
this.scope,
UnaryNode(
x.line,
x.column,
x.scope,
"!",
x
),
"&&",
UnaryNode(
y.line,
y.column,
y.scope,
"!",
y
)
);
}
};
return function (node, o) {
var invert;
if (node instanceof UnaryNode) {
if (node.op === "!" && node.node.type(o).isSubsetOf(Type.boolean)) {
return node.node;
}
} else if (node instanceof BinaryNode && __owns.call(invertibleBinaryOps, node.op)) {
invert = invertibleBinaryOps[node.op];
if (typeof invert === "function") {
return invert.call(this, node.left, node.right);
} else {
return BinaryNode(
this.line,
this.column,
this.scope,
node.left,
invert,
node.right
);
}
}
};
}()),
"typeof": (function () {
var objectType;
objectType = Type["null"].union(Type.object).union(Type.arrayLike).union(Type.regexp).union(Type.date).union(Type.error);
return function (node, o) {
var type;
if (node.isNoop(o)) {
type = node.type(o);
if (type.isSubsetOf(Type.number)) {
return ConstNode(this.line, this.column, this.scope, "number");
} else if (type.isSubsetOf(Type.string)) {
return ConstNode(this.line, this.column, this.scope, "string");
} else if (type.isSubsetOf(Type.boolean)) {
return ConstNode(this.line, this.column, this.scope, "boolean");
} else if (type.isSubsetOf(Type["undefined"])) {
return ConstNode(this.line, this.column, this.scope, "undefined");
} else if (type.isSubsetOf(Type["function"])) {
return ConstNode(this.line, this.column, this.scope, "function");
} else if (type.isSubsetOf(objectType)) {
return ConstNode(this.line, this.column, this.scope, "object");
}
}
};
}())
};
return function (o) {
var node, op, result;
node = this.node.reduce(o).doWrap(o);
op = this.op;
if (node.isConst() && __owns.call(constOps, op)) {
return ConstNode(this.line, this.column, this.scope, constOps[op](node.constValue()));
}
if (__owns.call(nonconstOps, op)) {
result = nonconstOps[op].call(this, node, o);
}
if (result != null) {
return result.reduce(o);
}
if (node !== this.node) {
return UnaryNode(
this.line,
this.column,
this.scope,
op,
node
);
} else {
return this;
}
};
}());
_UnaryNode_prototype._isNoop = function (o) {
var _ref, _ref2;
if ((_ref = this.__isNoop) == null) {
return this.__isNoop = (_ref2 = this.op) !== "++" && _ref2 !== "--" && _ref2 !== "++post" && _ref2 !== "--post" && _ref2 !== "delete" && this.node.isNoop(o);
} else {
return _ref;
}
};
_UnaryNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"UnaryNode",
this.line,
this.column,
this.op,
this.node
);
};
_UnaryNode_prototype.walk = function (f) {
var node;
node = f(this.node);
if (node !== this.node) {
return UnaryNode(
this.line,
this.column,
this.scope,
this.op,
node
);
} else {
return this;
}
};
_UnaryNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.node, (_once = false, function (_e, node) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, node !== _this.node
? UnaryNode(
_this.line,
_this.column,
_this.scope,
_this.op,
node
)
: _this);
}));
};
return UnaryNode;
}(Node));
Node.Var = VarNode = (function (Node) {
var _Node_prototype, _VarNode_prototype;
function VarNode(line, column, scope, ident, isMutable) {
var _this;
_this = this instanceof VarNode ? this : __create(_VarNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(ident instanceof IdentNode) && !(ident instanceof TmpNode)) {
throw TypeError("Expected ident to be one of " + (__name(IdentNode) + " or " + __name(TmpNode)) + ", got " + __typeof(ident));
}
if (isMutable == null) {
isMutable = false;
} else if (typeof isMutable !== "boolean") {
throw TypeError("Expected isMutable to be a Boolean, got " + __typeof(isMutable));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.ident = ident;
_this.isMutable = isMutable;
return _this;
}
_Node_prototype = Node.prototype;
_VarNode_prototype = VarNode.prototype = __create(_Node_prototype);
_VarNode_prototype.constructor = VarNode;
VarNode.displayName = "VarNode";
if (typeof Node.extended === "function") {
Node.extended(VarNode);
}
VarNode.cappedName = "Var";
VarNode.argNames = ["ident", "isMutable"];
_VarNode_prototype.type = function () {
return Type["undefined"];
};
_VarNode_prototype._reduce = function (o) {
var ident;
ident = this.ident.reduce(o);
if (ident !== this.ident) {
return VarNode(
this.line,
this.column,
this.scope,
ident,
this.isMutable
);
} else {
return this;
}
};
_VarNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"VarNode",
this.line,
this.column,
this.ident,
this.isMutable
);
};
_VarNode_prototype.walk = function (f) {
var ident;
ident = f(this.ident);
if (ident !== this.ident) {
return VarNode(
this.line,
this.column,
this.scope,
ident,
this.isMutable
);
} else {
return this;
}
};
_VarNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.ident, (_once = false, function (_e, ident) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, ident !== _this.ident
? VarNode(
_this.line,
_this.column,
_this.scope,
ident,
_this.isMutable
)
: _this);
}));
};
return VarNode;
}(Node));
Node.Yield = YieldNode = (function (Node) {
var _Node_prototype, _YieldNode_prototype;
function YieldNode(line, column, scope, node) {
var _this;
_this = this instanceof YieldNode ? this : __create(_YieldNode_prototype);
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
_this.line = line;
_this.column = column;
_this.scope = scope;
_this._reduced = void 0;
_this._macroExpanded = void 0;
_this._macroExpandAlled = void 0;
_this.node = node;
return _this;
}
_Node_prototype = Node.prototype;
_YieldNode_prototype = YieldNode.prototype = __create(_Node_prototype);
_YieldNode_prototype.constructor = YieldNode;
YieldNode.displayName = "YieldNode";
if (typeof Node.extended === "function") {
Node.extended(YieldNode);
}
YieldNode.cappedName = "Yield";
YieldNode.argNames = ["node"];
_YieldNode_prototype.type = function () {
return Type.any;
};
_YieldNode_prototype._reduce = function (o) {
var node;
node = this.node.reduce(o).doWrap(o);
if (node !== this.node) {
return YieldNode(this.line, this.column, this.scope, node);
} else {
return this;
}
};
_YieldNode_prototype.inspect = function (depth) {
return inspectHelper(
depth,
"YieldNode",
this.line,
this.column,
this.node
);
};
_YieldNode_prototype.walk = function (f) {
var node;
node = f(this.node);
if (node !== this.node) {
return YieldNode(this.line, this.column, this.scope, node);
} else {
return this;
}
};
_YieldNode_prototype.walkAsync = function (f, callback) {
var _once, _this;
_this = this;
return f(this.node, (_once = false, function (_e, node) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_e != null) {
return callback(_e);
}
return callback(null, node !== _this.node ? YieldNode(_this.line, _this.column, _this.scope, node) : _this);
}));
};
return YieldNode;
}(Node));
module.exports = Node;
}.call(this, typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : this));
return module.exports;
};
require['./parser-macroholder'] = function () {
var module = { exports: this };
var exports = this;
(function () {
"use strict";
var __create, __import, __isArray, __lt, __name, __num, __owns, __slice, __strnum, __toArray, __typeof, MacroHolder, Type;
__create = typeof Object.create === "function" ? Object.create
: function (x) {
function F() {}
F.prototype = x;
return new F();
};
__import = function (dest, source) {
var k;
for (k in source) {
if (__owns.call(source, k)) {
dest[k] = source[k];
}
}
return dest;
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__lt = function (x, y) {
var type;
type = typeof x;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof y) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof y);
} else {
return x < y;
}
};
__name = function (func) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
return func.displayName || func.name || "";
};
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__owns = Object.prototype.hasOwnProperty;
__slice = Array.prototype.slice;
__strnum = function (strnum) {
var type;
type = typeof strnum;
if (type === "string") {
return strnum;
} else if (type === "number") {
return String(strnum);
} else {
throw TypeError("Expected a string or number, got " + __typeof(strnum));
}
};
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
Type = require("./types");
MacroHolder = (function () {
var _MacroHolder_prototype;
function MacroHolder(syntaxes, macroName, wordOrSymbol, oneOf, sequential) {
var _this;
_this = this instanceof MacroHolder ? this : __create(_MacroHolder_prototype);
if (typeof syntaxes !== "object" || syntaxes === null) {
throw TypeError("Expected syntaxes to be an Object, got " + __typeof(syntaxes));
}
_this.syntaxes = syntaxes;
if (typeof macroName !== "function") {
throw TypeError("Expected macroName to be a Function, got " + __typeof(macroName));
}
_this.macroName = macroName;
if (typeof wordOrSymbol !== "function") {
throw TypeError("Expected wordOrSymbol to be a Function, got " + __typeof(wordOrSymbol));
}
_this.wordOrSymbol = wordOrSymbol;
if (typeof oneOf !== "function") {
throw TypeError("Expected oneOf to be a Function, got " + __typeof(oneOf));
}
_this.oneOf = oneOf;
if (typeof sequential !== "function") {
throw TypeError("Expected sequential to be a Function, got " + __typeof(sequential));
}
_this.sequential = sequential;
_this.byName = {};
_this.byId = [];
_this.byLabel = {};
_this.typeById = [];
_this.operatorNames = {};
_this.binaryOperators = [];
_this.assignOperators = [];
_this.prefixUnaryOperators = [];
_this.postfixUnaryOperators = [];
_this.consts = {};
_this.serialization = {};
_this.helpers = {};
return _this;
}
_MacroHolder_prototype = MacroHolder.prototype;
MacroHolder.displayName = "MacroHolder";
_MacroHolder_prototype.clone = function () {
var clone;
clone = MacroHolder(
this.syntaxes,
this.macroName,
this.wordOrSymbol,
this.oneOf,
this.sequential
);
clone.byName = __import({}, this.byName);
clone.byId = this.byId.slice();
clone.byLabel = __import({}, this.byLabel);
clone.typeById = this.typeById.slice();
clone.operatorNames = __import({}, this.operatorNames);
clone.binaryOperators = this.binaryOperators.slice();
clone.assignOperators = this.assignOperators.slice();
clone.prefixUnaryOperators = this.prefixUnaryOperators.slice();
clone.postfixUnaryOperators = this.postfixUnaryOperators.slice();
clone.consts = __import({}, this.consts);
clone.serialization = __import({}, this.serialization);
clone.helpers = __import({}, this.helpers);
clone.syntaxes = __import({}, this.syntaxes);
return clone;
};
_MacroHolder_prototype.getByName = function (name) {
var _ref;
if (__owns.call(_ref = this.byName, name)) {
return _ref[name];
}
};
_MacroHolder_prototype.getOrAddByName = function (name) {
var byName, m, token;
byName = this.byName;
if (__owns.call(byName, name)) {
return byName[name];
} else {
token = this.macroName(name);
m = function (parser, index) {
var _arr, _i, _len, _ref, item;
for (_arr = __toArray(m.data), _i = 0, _len = _arr.length; _i < _len; ++_i) {
item = _arr[_i];
if (_ref = item(parser, index)) {
return _ref;
}
}
};
m.token = token;
m.data = [];
return byName[name] = m;
}
};
_MacroHolder_prototype.getOrAddByNames = function (names) {
var _arr, _i, _i2, _len, name;
if (!__isArray(names)) {
throw TypeError("Expected names to be an Array, got " + __typeof(names));
} else {
for (_i = names.length; _i--; ) {
if (typeof names[_i] !== "string") {
throw TypeError("Expected " + ("names[" + _i + "]") + " to be a String, got " + __typeof(names[_i]));
}
}
}
for (_arr = [], _i2 = 0, _len = names.length; _i2 < _len; ++_i2) {
name = names[_i2];
_arr.push(this.getOrAddByName(name));
}
return _arr;
};
_MacroHolder_prototype.setTypeById = function (id, type) {
if (typeof id !== "number") {
throw TypeError("Expected id to be a Number, got " + __typeof(id));
}
if (!(type instanceof Type)) {
throw TypeError("Expected type to be a " + __name(Type) + ", got " + __typeof(type));
}
this.typeById[id] = type;
};
_MacroHolder_prototype.getTypeById = function (id) {
return this.typeById[id];
};
_MacroHolder_prototype.getById = function (id) {
var byId;
byId = this.byId;
if (__num(id) >= 0 && __lt(id, byId.length)) {
return byId[id];
}
};
_MacroHolder_prototype.addMacro = function (m, macroId, type) {
var byId;
if (macroId == null) {
macroId = void 0;
} else if (typeof macroId !== "number") {
throw TypeError("Expected macroId to be one of Number or undefined, got " + __typeof(macroId));
}
if (type == null) {
type = void 0;
} else if (!(type instanceof Type) && typeof type !== "string") {
throw TypeError("Expected type to be one of " + (__name(Type) + " or String or undefined") + ", got " + __typeof(type));
}
byId = this.byId;
if (macroId != null) {
if (__owns.call(byId, macroId)) {
throw Error("Cannot add macro #" + __strnum(macroId) + ", as it already exists");
}
byId[macroId] = m;
} else {
byId.push(m);
macroId = __num(byId.length) - 1;
}
if (type != null) {
this.typeById[macroId] = type;
}
return macroId;
};
_MacroHolder_prototype.replaceMacro = function (id, m, type) {
var byId;
if (type == null) {
type = void 0;
} else if (!(type instanceof Type)) {
throw TypeError("Expected type to be one of " + (__name(Type) + " or undefined") + ", got " + __typeof(type));
}
byId = this.byId;
byId[id] = m;
if (type != null) {
this.typeById[id] = type;
}
};
_MacroHolder_prototype.hasMacroOrOperator = function (name) {
return __owns.call(this.byName, name) || __owns.call(this.operatorNames, name);
};
_MacroHolder_prototype.getMacroAndOperatorNames = function () {
var _obj, name, names;
names = [];
_obj = this.byName;
for (name in _obj) {
if (__owns.call(_obj, name)) {
names.push(name);
}
}
_obj = this.operatorNames;
for (name in _obj) {
if (__owns.call(_obj, name)) {
names.push(name);
}
}
return names;
};
_MacroHolder_prototype.allBinaryOperators = function () {
var _ref, _this;
_this = this;
if ((_ref = this._allBinaryOperators) == null) {
return this._allBinaryOperators = (function () {
var _arr, _i, _len, array, result;
result = [];
for (_arr = __toArray(_this.binaryOperators), _i = 0, _len = _arr.length; _i < _len; ++_i) {
array = _arr[_i];
result.push.apply(result, __toArray(array));
}
return result;
}());
} else {
return _ref;
}
};
_MacroHolder_prototype.addBinaryOperator = function (operators, m, options, macroId) {
var _arr, _i, _ref, _this, binaryOperators, data, i, op, precedence;
_this = this;
for (_arr = __toArray(operators), _i = _arr.length; _i--; ) {
op = _arr[_i];
this.operatorNames[op] = true;
}
precedence = Number(options.precedence) || 0;
for (i = __num(this.binaryOperators.length); i <= precedence; ++i) {
this.binaryOperators[i] = [];
}
binaryOperators = this.binaryOperators[precedence];
data = {
rule: this.oneOf.apply(this, (function () {
var _arr, _arr2, _i, _len, op;
for (_arr = [], _arr2 = __toArray(operators), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
op = _arr2[_i];
_arr.push(_this.wordOrSymbol(op));
}
return _arr;
}())),
func: m,
rightToLeft: !!options.rightToLeft,
maximum: options.maximum || 0,
minimum: options.minimum || 0,
invertible: !!options.invertible
};
binaryOperators.push(data);
this._allBinaryOperators = null;
if (options.label) {
this.addByLabel(options.label, data);
}
return this.addMacro(m, macroId, (_ref = options.type) === "left" || _ref === "right" ? options.type
: options.type != null && __owns.call(Type, _ref = options.type) ? Type[_ref]
: void 0);
};
_MacroHolder_prototype.getByLabel = function (label) {
var _ref;
if (__owns.call(_ref = this.byLabel, label)) {
return _ref[label];
}
};
_MacroHolder_prototype.addByLabel = function (label, data) {
if (typeof label !== "string") {
throw TypeError("Expected label to be a String, got " + __typeof(label));
}
return this.byLabel[label] = data;
};
_MacroHolder_prototype.addAssignOperator = function (operators, m, options, macroId) {
var _arr, _i, _ref, _this, data, op;
_this = this;
for (_arr = __toArray(operators), _i = _arr.length; _i--; ) {
op = _arr[_i];
this.operatorNames[op] = true;
}
data = {
rule: this.oneOf.apply(this, (function () {
var _arr, _arr2, _i, _len, op;
for (_arr = [], _arr2 = __toArray(operators), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
op = _arr2[_i];
if (op === ":=") {
_arr.push(_this.syntaxes.ColonEqual);
} else {
_arr.push(_this.wordOrSymbol(op));
}
}
return _arr;
}())),
func: m
};
this.assignOperators.push(data);
if (options.label) {
this.addByLabel(options.label, data);
}
return this.addMacro(m, macroId, (_ref = options.type) === "left" || _ref === "right" ? options.type
: options.type != null && __owns.call(Type, _ref = options.type) ? Type[_ref]
: void 0);
};
_MacroHolder_prototype.addUnaryOperator = function (operators, m, options, macroId) {
var _arr, _i, _ref, _this, data, op, store;
_this = this;
for (_arr = __toArray(operators), _i = _arr.length; _i--; ) {
op = _arr[_i];
this.operatorNames[op] = true;
}
if (options.postfix) {
store = this.postfixUnaryOperators;
} else {
store = this.prefixUnaryOperators;
}
data = {
rule: this.oneOf.apply(this, (function () {
var _arr, _arr2, _i, _len, op, rule;
for (_arr = [], _arr2 = __toArray(operators), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
op = _arr2[_i];
rule = _this.wordOrSymbol(op);
if (!/[a-zA-Z]/.test(op)) {
if (options.postfix) {
_arr.push(_this.sequential(_this.syntaxes.NoSpace, ["this", rule]));
} else {
_arr.push(_this.sequential(
["this", rule],
_this.syntaxes.NoSpace
));
}
} else {
_arr.push(rule);
}
}
return _arr;
}())),
func: m,
standalone: __owns.call(!options, "standalone") || !!options.standalone
};
store.push(data);
if (options.label) {
this.addByLabel(options.label, data);
}
return this.addMacro(m, macroId, options.type === "node" ? options.type
: options.type != null && __owns.call(Type, _ref = options.type) ? Type[_ref]
: void 0);
};
_MacroHolder_prototype.addSerializedHelper = function (name, helper, type, dependencies) {
var _ref, _ref2, helpers;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if ((_ref = (_ref2 = this.serialization).helpers) != null) {
helpers = _ref;
} else {
helpers = _ref2.helpers = {};
}
helpers[name] = { helper: helper, type: type, dependencies: dependencies };
};
_MacroHolder_prototype.addConst = function (name, value) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (value != null && typeof value !== "number" && typeof value !== "string" && typeof value !== "boolean") {
throw TypeError("Expected value to be one of Number or String or Boolean or null or undefined, got " + __typeof(value));
}
this.consts[name] = value;
};
function serializeConstValue(value) {
switch (value) {
case 0:
return { type: value === 0 && 1 / value > 0 ? "+0" : "-0" };
case 1/0: return { type: "Infinity" };
case -1/0: return { type: "-Infinity" };
default:
if (value !== value) {
return { type: "NaN" };
} else if (value === void 0) {
return { type: "void" };
} else {
return value;
}
}
}
function deserializeConstValue(value) {
if (typeof value === "object" && value !== null && typeof value.type === "string") {
switch (value.type) {
case "+0": return 0;
case "-0": return -0;
case "Infinity": return 1/0;
case "-Infinity": return -1/0;
case "NaN": return 0/0;
case "void": return;
default: throw Error("Unknown value");
}
} else {
return value;
}
}
_MacroHolder_prototype.addSerializedConst = function (name) {
var _ref, _ref2, consts;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (!__owns.call(this.consts, name)) {
throw Error("Unknown const " + name);
}
if ((_ref = (_ref2 = this.serialization).consts) != null) {
consts = _ref;
} else {
consts = _ref2.consts = {};
}
consts[name] = serializeConstValue(this.consts[name]);
};
_MacroHolder_prototype.addMacroSerialization = function (serialization) {
var _ref, _ref2, _ref3, byType, obj;
if (typeof serialization !== "object" || serialization === null) {
throw TypeError("Expected serialization to be an Object, got " + __typeof(serialization));
} else if (typeof serialization.type !== "string") {
throw TypeError("Expected serialization.type to be a String, got " + __typeof(serialization.type));
}
obj = __import({}, serialization);
delete obj.type;
if ((_ref = (_ref2 = this.serialization)[_ref3 = serialization.type]) != null) {
byType = _ref;
} else {
byType = _ref2[_ref3] = [];
}
byType.push(obj);
};
_MacroHolder_prototype.addSyntax = function (name, value) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (typeof value !== "function") {
throw TypeError("Expected value to be a Function, got " + __typeof(value));
}
if (__owns.call(this.syntaxes, name)) {
throw Error("Cannot override already-defined syntax: " + name);
}
this.syntaxes[name] = value;
};
_MacroHolder_prototype.hasSyntax = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
return __owns.call(this.syntaxes, name);
};
_MacroHolder_prototype.getSyntax = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (__owns.call(this.syntaxes, name)) {
return this.syntaxes[name];
} else {
throw Error("Unknown syntax: " + name);
}
};
_MacroHolder_prototype.serialize = function (allowJS) {
var _arr, dep, helper, helpers, i, name, serialization;
if (allowJS == null) {
allowJS = false;
} else if (typeof allowJS !== "boolean") {
throw TypeError("Expected allowJS to be a Boolean, got " + __typeof(allowJS));
}
serialization = __import({}, this.serialization);
if (__owns.call(serialization, "helpers")) {
helpers = serialization.helpers;
}
if (helpers) {
for (name in helpers) {
if (__owns.call(helpers, name)) {
helper = helpers[name];
for (_arr = __toArray(helper.dependencies), i = _arr.length; i--; ) {
dep = _arr[i];
if (!__owns.call(helpers, dep)) {
helper.dependencies.splice(i, 1);
}
}
}
}
}
if (allowJS) {
return require("./jsutils").toJSSource(serialization);
} else {
return JSON.stringify(serialization);
}
};
_MacroHolder_prototype.deserialize = function (data, state) {
var _obj, _ref, ast, dependencies, helper, name, type, value;
ast = require("./jsast");
_obj = (_ref = __owns.call(data, "helpers") ? data.helpers : void 0) != null ? _ref : {};
for (name in _obj) {
if (__owns.call(_obj, name)) {
helper = (_ref = _obj[name]).helper;
type = _ref.type;
dependencies = _ref.dependencies;
this.addHelper(name, ast.fromJSON(helper), Type.fromJSON(type), dependencies);
}
}
_obj = (_ref = __owns.call(data, "consts") ? data.consts : void 0) != null ? _ref : {};
for (name in _obj) {
if (__owns.call(_obj, name)) {
value = _obj[name];
this.addConst(name, deserializeConstValue(value));
}
}
state.deserializeMacros(data);
};
_MacroHolder_prototype.addHelper = function (name, value, type, dependencies) {
var _i;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (!(type instanceof Type)) {
throw TypeError("Expected type to be a " + __name(Type) + ", got " + __typeof(type));
}
if (!__isArray(dependencies)) {
throw TypeError("Expected dependencies to be an Array, got " + __typeof(dependencies));
} else {
for (_i = dependencies.length; _i--; ) {
if (typeof dependencies[_i] !== "string") {
throw TypeError("Expected " + ("dependencies[" + _i + "]") + " to be a String, got " + __typeof(dependencies[_i]));
}
}
}
if (__owns.call(this.helpers, name)) {
throw Error("Trying to overwrite helper " + name);
}
return this.helpers[name] = { value: value, type: type, dependencies: dependencies };
};
_MacroHolder_prototype.hasHelper = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
return __owns.call(this.helpers, name);
};
_MacroHolder_prototype.getHelper = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (__owns.call(this.helpers, name)) {
return this.helpers[name].value;
} else {
throw Error("No such helper: " + name);
}
};
_MacroHolder_prototype.helperType = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (__owns.call(this.helpers, name)) {
return this.helpers[name].type;
} else {
throw Error("No such helper: " + name);
}
};
_MacroHolder_prototype.helperDependencies = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (__owns.call(this.helpers, name)) {
return this.helpers[name].dependencies;
} else {
throw Error("No such helper: " + name);
}
};
return MacroHolder;
}());
module.exports = MacroHolder;
}.call(this));
return module.exports;
};
require['./parser-macrocontext'] = function () {
var module = { exports: this };
var exports = this;
(function () {
"use strict";
var __create, __isArray, __name, __num, __owns, __slice, __strnum, __throw, __toArray, __typeof, _ref, AccessMultiNode, AccessNode, addParamToScope, ArgsNode, ArrayNode, AssignNode, BinaryNode, BlockNode, BreakNode, CallNode, CommentNode, ConstNode, ContinueNode, DebuggerNode, DefNode, EmbedWriteNode, EvalNode, ForInNode, ForNode, FunctionNode, IdentNode, IfNode, MacroAccessNode, MacroContext, map, Node, nodeToType, NothingNode, ObjectNode, ParamNode, RegexpNode, ReturnNode, RootNode, Scope, SpreadNode, SuperNode, SwitchNode, SyntaxChoiceNode, SyntaxManyNode, SyntaxParamNode, SyntaxSequenceNode, ThisNode, ThrowNode, TmpNode, TmpWrapperNode, TryCatchNode, TryFinallyNode, Type, TypeFunctionNode, TypeGenericNode, TypeObjectNode, TypeUnionNode, UnaryNode, VarNode, YieldNode;
__create = typeof Object.create === "function" ? Object.create
: function (x) {
function F() {}
F.prototype = x;
return new F();
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__name = function (func) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
return func.displayName || func.name || "";
};
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__owns = Object.prototype.hasOwnProperty;
__slice = Array.prototype.slice;
__strnum = function (strnum) {
var type;
type = typeof strnum;
if (type === "string") {
return strnum;
} else if (type === "number") {
return String(strnum);
} else {
throw TypeError("Expected a string or number, got " + __typeof(strnum));
}
};
__throw = function (err) {
throw err;
};
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
Node = require("./parser-nodes");
Type = require("./types");
Scope = require("./parser-scope");
nodeToType = (_ref = require("./parser-utils")).nodeToType;
addParamToScope = _ref.addParamToScope;
map = _ref.map;
AccessNode = Node.Access;
AccessMultiNode = Node.AccessMulti;
ArgsNode = Node.Args;
ArrayNode = Node.Array;
AssignNode = Node.Assign;
BinaryNode = Node.Binary;
BlockNode = Node.Block;
BreakNode = Node.Break;
CallNode = Node.Call;
CommentNode = Node.Comment;
ConstNode = Node.Const;
ContinueNode = Node.Continue;
DebuggerNode = Node.Debugger;
DefNode = Node.Def;
EmbedWriteNode = Node.EmbedWrite;
EvalNode = Node.Eval;
ForNode = Node.For;
ForInNode = Node.ForIn;
FunctionNode = Node.Function;
IdentNode = Node.Ident;
IfNode = Node.If;
MacroAccessNode = Node.MacroAccess;
NothingNode = Node.Nothing;
ObjectNode = Node.Object;
ParamNode = Node.Param;
RegexpNode = Node.Regexp;
ReturnNode = Node.Return;
RootNode = Node.Root;
SpreadNode = Node.Spread;
SuperNode = Node.Super;
SwitchNode = Node.Switch;
SyntaxChoiceNode = Node.SyntaxChoice;
SyntaxManyNode = Node.SyntaxMany;
SyntaxParamNode = Node.SyntaxParam;
SyntaxSequenceNode = Node.SyntaxSequence;
ThisNode = Node.This;
ThrowNode = Node.Throw;
TmpNode = Node.Tmp;
TmpWrapperNode = Node.TmpWrapper;
TryCatchNode = Node.TryCatch;
TryFinallyNode = Node.TryFinally;
TypeFunctionNode = Node.TypeFunction;
TypeGenericNode = Node.TypeGeneric;
TypeObjectNode = Node.TypeObject;
TypeUnionNode = Node.TypeUnion;
UnaryNode = Node.Unary;
VarNode = Node.Var;
YieldNode = Node.Yield;
function identity(x) {
return x;
}
function retThis() {
return this;
}
MacroContext = (function () {
var _MacroContext_prototype, mutators;
function MacroContext(parser, index, position, inGenerator, inEvilAst) {
var _this;
_this = this instanceof MacroContext ? this : __create(_MacroContext_prototype);
_this.parser = parser;
_this.index = index;
_this.position = position;
_this.inGenerator = inGenerator;
_this.inEvilAst = inEvilAst;
_this.unsavedTmps = [];
_this.savedTmps = [];
return _this;
}
_MacroContext_prototype = MacroContext.prototype;
MacroContext.displayName = "MacroContext";
_MacroContext_prototype.doWrap = function (node) {
if (node instanceof Node) {
return node.doWrap(this.parser);
} else {
return node;
}
};
_MacroContext_prototype.error = function (message, node) {
if (typeof message !== "string") {
throw TypeError("Expected message to be a String, got " + __typeof(message));
}
if (node == null) {
node = null;
} else if (!(node instanceof Node)) {
throw TypeError("Expected node to be one of " + (__name(Node) + " or null") + ", got " + __typeof(node));
}
throw this.parser.buildError(message, node || this.index);
};
_MacroContext_prototype.scope = function () {
return this.parser.scope.peek();
};
_MacroContext_prototype.line = function (node) {
if (node instanceof Node) {
return node.line;
} else {
return this.parser.getPosition(this.index).line;
}
};
_MacroContext_prototype.column = function (node) {
if (node instanceof Node) {
return node.column;
} else {
return this.parser.getPosition(this.index).column;
}
};
_MacroContext_prototype.file = function () {
return this.parser.options.filename || "";
};
_MacroContext_prototype.version = function () {
return this.parser.getPackageVersion();
};
_MacroContext_prototype["let"] = function (ident, isMutable, type) {
if (!(ident instanceof TmpNode) && !(ident instanceof IdentNode)) {
throw TypeError("Expected ident to be one of " + (__name(TmpNode) + " or " + __name(IdentNode)) + ", got " + __typeof(ident));
}
if (isMutable == null) {
isMutable = false;
} else if (typeof isMutable !== "boolean") {
throw TypeError("Expected isMutable to be a Boolean, got " + __typeof(isMutable));
}
if (type == null) {
type = Type.any;
} else if (!(type instanceof Type)) {
throw TypeError("Expected type to be a " + __name(Type) + ", got " + __typeof(type));
}
if (ident instanceof IdentNode && isMutable && type.isSubsetOf(Type.undefinedOrNull)) {
type = Type.any;
}
return this.scope().add(ident, isMutable, type);
};
_MacroContext_prototype.hasVariable = function (ident) {
if (!(ident instanceof TmpNode) && !(ident instanceof IdentNode)) {
throw TypeError("Expected ident to be one of " + (__name(TmpNode) + " or " + __name(IdentNode)) + ", got " + __typeof(ident));
}
return this.scope().has(ident);
};
_MacroContext_prototype.isVariableMutable = function (ident) {
if (!(ident instanceof TmpNode) && !(ident instanceof IdentNode)) {
throw TypeError("Expected ident to be one of " + (__name(TmpNode) + " or " + __name(IdentNode)) + ", got " + __typeof(ident));
}
return this.scope().isMutable(ident);
};
_MacroContext_prototype["var"] = function (ident, isMutable) {
if (!(ident instanceof IdentNode) && !(ident instanceof TmpNode)) {
throw TypeError("Expected ident to be one of " + (__name(IdentNode) + " or " + __name(TmpNode)) + ", got " + __typeof(ident));
}
if (isMutable == null) {
isMutable = false;
} else if (typeof isMutable !== "boolean") {
throw TypeError("Expected isMutable to be a Boolean, got " + __typeof(isMutable));
}
return this.parser.Var(this.index, ident, isMutable);
};
_MacroContext_prototype.def = function (key, value) {
if (key == null) {
key = NothingNode(0, 0, this.scope());
} else if (!(key instanceof Node)) {
throw TypeError("Expected key to be a " + __name(Node) + ", got " + __typeof(key));
}
if (value == null) {
value = void 0;
} else if (!(value instanceof Node)) {
throw TypeError("Expected value to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(value));
}
return this.parser.Def(this.index, key, this.doWrap(value));
};
_MacroContext_prototype.noop = function () {
return this.parser.Nothing(this.index);
};
_MacroContext_prototype.block = function (nodes, label) {
var _i;
if (!__isArray(nodes)) {
throw TypeError("Expected nodes to be an Array, got " + __typeof(nodes));
} else {
for (_i = nodes.length; _i--; ) {
if (!(nodes[_i] instanceof Node)) {
throw TypeError("Expected " + ("nodes[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(nodes[_i]));
}
}
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return this.parser.Block(this.index, nodes, label).reduce(this.parser);
};
_MacroContext_prototype["if"] = function (test, whenTrue, whenFalse, label) {
if (test == null) {
test = NothingNode(0, 0, this.scope());
} else if (!(test instanceof Node)) {
throw TypeError("Expected test to be a " + __name(Node) + ", got " + __typeof(test));
}
if (whenTrue == null) {
whenTrue = NothingNode(0, 0, this.scope());
} else if (!(whenTrue instanceof Node)) {
throw TypeError("Expected whenTrue to be a " + __name(Node) + ", got " + __typeof(whenTrue));
}
if (whenFalse == null) {
whenFalse = null;
} else if (!(whenFalse instanceof Node)) {
throw TypeError("Expected whenFalse to be one of " + (__name(Node) + " or null") + ", got " + __typeof(whenFalse));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return this.parser.If(
this.index,
this.doWrap(test),
whenTrue,
whenFalse,
label
).reduce(this.parser);
};
_MacroContext_prototype["switch"] = function (node, cases, defaultCase, label) {
var _this;
_this = this;
if (node == null) {
node = NothingNode(0, 0, this.scope());
} else if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
if (!__isArray(cases)) {
throw TypeError("Expected cases to be an Array, got " + __typeof(cases));
}
if (defaultCase == null) {
defaultCase = null;
} else if (!(defaultCase instanceof Node)) {
throw TypeError("Expected defaultCase to be one of " + (__name(Node) + " or null") + ", got " + __typeof(defaultCase));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return this.parser.Switch(
this.index,
this.doWrap(node),
(function () {
var _arr, _i, _len, case_;
for (_arr = [], _i = 0, _len = cases.length; _i < _len; ++_i) {
case_ = cases[_i];
_arr.push({ node: _this.doWrap(case_.node), body: case_.body, fallthrough: case_.fallthrough });
}
return _arr;
}()),
defaultCase,
label
).reduce(this.parser);
};
_MacroContext_prototype["for"] = function (init, test, step, body, label) {
if (init == null) {
init = null;
} else if (!(init instanceof Node)) {
throw TypeError("Expected init to be one of " + (__name(Node) + " or null") + ", got " + __typeof(init));
}
if (test == null) {
test = null;
} else if (!(test instanceof Node)) {
throw TypeError("Expected test to be one of " + (__name(Node) + " or null") + ", got " + __typeof(test));
}
if (step == null) {
step = null;
} else if (!(step instanceof Node)) {
throw TypeError("Expected step to be one of " + (__name(Node) + " or null") + ", got " + __typeof(step));
}
if (body == null) {
body = NothingNode(0, 0, this.scope());
} else if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return this.parser.For(
this.index,
this.doWrap(init),
this.doWrap(test),
this.doWrap(step),
body,
label
).reduce(this.parser);
};
_MacroContext_prototype.forIn = function (key, object, body, label) {
if (!(key instanceof IdentNode)) {
throw TypeError("Expected key to be a " + __name(IdentNode) + ", got " + __typeof(key));
}
if (object == null) {
object = NothingNode(0, 0);
} else if (!(object instanceof Node)) {
throw TypeError("Expected object to be a " + __name(Node) + ", got " + __typeof(object));
}
if (body == null) {
body = NothingNode(0, 0, this.scope());
} else if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return this.parser.ForIn(
this.index,
key,
this.doWrap(object),
body,
label
).reduce(this.parser);
};
_MacroContext_prototype.tryCatch = function (tryBody, catchIdent, catchBody, label) {
if (tryBody == null) {
tryBody = NothingNode(0, 0, this.scope());
} else if (!(tryBody instanceof Node)) {
throw TypeError("Expected tryBody to be a " + __name(Node) + ", got " + __typeof(tryBody));
}
if (catchIdent == null) {
catchIdent = NothingNode(0, 0, this.scope());
} else if (!(catchIdent instanceof Node)) {
throw TypeError("Expected catchIdent to be a " + __name(Node) + ", got " + __typeof(catchIdent));
}
if (catchBody == null) {
catchBody = NothingNode(0, 0, this.scope());
} else if (!(catchBody instanceof Node)) {
throw TypeError("Expected catchBody to be a " + __name(Node) + ", got " + __typeof(catchBody));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return this.parser.TryCatch(
this.index,
tryBody,
catchIdent,
catchBody,
label
).reduce(this.parser);
};
_MacroContext_prototype.tryFinally = function (tryBody, finallyBody, label) {
if (tryBody == null) {
tryBody = NothingNode(0, 0, this.scope());
} else if (!(tryBody instanceof Node)) {
throw TypeError("Expected tryBody to be a " + __name(Node) + ", got " + __typeof(tryBody));
}
if (finallyBody == null) {
finallyBody = NothingNode(0, 0, this.scope());
} else if (!(finallyBody instanceof Node)) {
throw TypeError("Expected finallyBody to be a " + __name(Node) + ", got " + __typeof(finallyBody));
}
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return this.parser.TryFinally(this.index, tryBody, finallyBody, label).reduce(this.parser);
};
_MacroContext_prototype.assign = function (left, op, right) {
if (left == null) {
left = NothingNode(0, 0, this.scope());
} else if (!(left instanceof Node)) {
throw TypeError("Expected left to be a " + __name(Node) + ", got " + __typeof(left));
}
if (typeof op !== "string") {
throw TypeError("Expected op to be a String, got " + __typeof(op));
}
if (right == null) {
right = NothingNode(0, 0, this.scope());
} else if (!(right instanceof Node)) {
throw TypeError("Expected right to be a " + __name(Node) + ", got " + __typeof(right));
}
return this.parser.Assign(this.index, left, op, this.doWrap(right)).reduce(this.parser);
};
_MacroContext_prototype.binary = function (left, op, right) {
if (left == null) {
left = NothingNode(0, 0, this.scope());
} else if (!(left instanceof Node)) {
throw TypeError("Expected left to be a " + __name(Node) + ", got " + __typeof(left));
}
if (typeof op !== "string") {
throw TypeError("Expected op to be a String, got " + __typeof(op));
}
if (right == null) {
right = NothingNode(0, 0, this.scope());
} else if (!(right instanceof Node)) {
throw TypeError("Expected right to be a " + __name(Node) + ", got " + __typeof(right));
}
return this.parser.Binary(this.index, this.doWrap(left), op, this.doWrap(right)).reduce(this.parser);
};
_MacroContext_prototype.binaryChain = function (op, nodes) {
var _i, _i2, _len, left, result, right;
if (typeof op !== "string") {
throw TypeError("Expected op to be a String, got " + __typeof(op));
}
if (!__isArray(nodes)) {
throw TypeError("Expected nodes to be an Array, got " + __typeof(nodes));
} else {
for (_i = nodes.length; _i--; ) {
if (!(nodes[_i] instanceof Node)) {
throw TypeError("Expected " + ("nodes[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(nodes[_i]));
}
}
}
if (nodes.length === 0) {
throw Error("Expected nodes to at least have a length of 1");
}
left = this.doWrap(nodes[0]);
for (_i2 = 1, _len = nodes.length; _i2 < _len; ++_i2) {
right = nodes[_i2];
left = this.parser.Binary(this.index, left, op, this.doWrap(right));
}
result = left;
return result.reduce(this.parser);
};
_MacroContext_prototype.unary = function (op, node) {
if (typeof op !== "string") {
throw TypeError("Expected op to be a String, got " + __typeof(op));
}
if (node == null) {
node = NothingNode(0, 0, this.scope());
} else if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
return this.parser.Unary(this.index, op, this.doWrap(node)).reduce(this.parser);
};
_MacroContext_prototype["throw"] = function (node) {
if (node == null) {
node = NothingNode(0, 0, this.scope());
} else if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
return this.parser.Throw(this.index, this.doWrap(node)).reduce(this.parser);
};
_MacroContext_prototype["return"] = function (node) {
if (node == null) {
node = void 0;
} else if (!(node instanceof Node)) {
throw TypeError("Expected node to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(node));
}
return this.parser.Return(this.index, this.doWrap(node)).reduce(this.parser);
};
_MacroContext_prototype["yield"] = function (node) {
if (node == null) {
node = NothingNode(0, 0, this.scope());
} else if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
return this.parser.Yield(this.index, this.doWrap(node)).reduce(this.parser);
};
_MacroContext_prototype["debugger"] = function () {
return this.parser.Debugger(this.index);
};
_MacroContext_prototype["break"] = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return this.parser.Break(this.index, label);
};
_MacroContext_prototype["continue"] = function (label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return this.parser.Continue(this.index, label);
};
_MacroContext_prototype.spread = function (node) {
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
return this.parser.Spread(this.index, node);
};
_MacroContext_prototype.real = function (node) {
node = this.macroExpand1(node);
if (node instanceof TmpWrapperNode) {
return node.node;
} else {
return node;
}
};
_MacroContext_prototype.rewrap = function (newNode, oldNode) {
oldNode = this.macroExpand1(oldNode);
if (oldNode instanceof TmpWrapperNode) {
if (newNode instanceof TmpWrapperNode) {
return TmpWrapperNode(
newNode.line,
newNode.column,
newNode.scope,
newNode,
oldNode.tmps.concat(newNode.tmps)
);
} else {
return TmpWrapperNode(
newNode.line,
newNode.column,
newNode.scope,
newNode,
oldNode.tmps.slice()
);
}
} else {
return newNode;
}
};
_MacroContext_prototype.eq = function (alpha, bravo) {
alpha = this.real(alpha);
bravo = this.real(bravo);
if (alpha instanceof ConstNode) {
return bravo instanceof ConstNode && alpha.value === bravo.value;
} else if (alpha instanceof IdentNode) {
return bravo instanceof IdentNode && alpha.name === bravo.name;
} else {
return false;
}
};
_MacroContext_prototype.isLabeledBlock = function (node) {
node = this.real(node);
if (node instanceof BlockNode || node instanceof IfNode || node instanceof SwitchNode || node instanceof ForNode || node instanceof ForInNode || node instanceof TryCatchNode || node instanceof TryFinallyNode) {
return node.label != null;
} else {
return false;
}
};
_MacroContext_prototype.isBreak = function (node) {
return this.real(node) instanceof BreakNode;
};
_MacroContext_prototype.isContinue = function (node) {
return this.real(node) instanceof ContinueNode;
};
_MacroContext_prototype.label = function (node) {
node = this.real(node);
if (node instanceof BreakNode || node instanceof ContinueNode || node instanceof BlockNode || node instanceof IfNode || node instanceof SwitchNode || node instanceof ForNode || node instanceof ForInNode || node instanceof TryCatchNode || node instanceof TryFinallyNode) {
return node.label;
} else {
return null;
}
};
_MacroContext_prototype.withLabel = function (node, label) {
if (label == null) {
label = null;
} else if (!(label instanceof IdentNode) && !(label instanceof TmpNode)) {
throw TypeError("Expected label to be one of " + (__name(IdentNode) + " or " + __name(TmpNode) + " or null") + ", got " + __typeof(label));
}
return node.withLabel(label, this.parser);
};
_MacroContext_prototype.macroExpand1 = function (node) {
var expanded;
if (node instanceof Node) {
expanded = this.parser.macroExpand1(node);
if (expanded instanceof Node) {
return expanded.reduce(this.parser);
} else {
return expanded;
}
} else {
return node;
}
};
_MacroContext_prototype.macroExpandAll = function (node) {
var expanded;
if (node instanceof Node) {
expanded = this.parser.macroExpandAll(node);
if (expanded instanceof Node) {
return expanded.reduce(this.parser);
} else {
return expanded;
}
} else {
return node;
}
};
_MacroContext_prototype.tmp = function (name, save, type) {
var tmp;
if (name == null) {
name = "ref";
} else if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (save == null) {
save = false;
} else if (typeof save !== "boolean") {
throw TypeError("Expected save to be a Boolean, got " + __typeof(save));
}
if (type == null) {
type = Type.any;
} else if (typeof type === "string") {
if (!((__owns.call(Type, type) ? Type[type] : void 0) instanceof Type)) {
throw Error(__strnum(type) + " is not a known type name");
}
type = __owns.call(Type, type) ? Type[type] : void 0;
} else if (!(type instanceof Type)) {
throw Error("Must provide a Type or a string for type, got " + __typeof(type));
}
tmp = this.parser.makeTmp(this.index, name, type);
(save ? this.savedTmps : this.unsavedTmps).push(tmp.id);
return tmp;
};
_MacroContext_prototype.getTmps = function () {
return { unsaved: this.unsavedTmps.slice(), saved: this.savedTmps.slice() };
};
_MacroContext_prototype.isConst = function (node) {
return node === void 0 || node instanceof Node && this.real(node).isConst();
};
_MacroContext_prototype.value = function (node) {
var expanded;
if (node === void 0) {
return;
} else if (node instanceof Node) {
expanded = this.real(node);
if (expanded.isConst()) {
return expanded.constValue();
}
}
};
_MacroContext_prototype["const"] = function (value) {
return this.parser.Const(this.index, value);
};
_MacroContext_prototype.isSpread = function (node) {
return this.real(node) instanceof SpreadNode;
};
_MacroContext_prototype.spreadSubnode = function (node) {
node = this.real(node);
if (node instanceof SpreadNode) {
return node.node;
}
};
_MacroContext_prototype.isNode = function (node) {
return node instanceof Node;
};
_MacroContext_prototype.isIdent = function (node) {
return this.real(node) instanceof IdentNode;
};
_MacroContext_prototype.isTmp = function (node) {
return this.real(node) instanceof TmpNode;
};
_MacroContext_prototype.isIdentOrTmp = function (node) {
var _ref;
return (_ref = this.real(node)) instanceof IdentNode || _ref instanceof TmpNode;
};
_MacroContext_prototype.name = function (node) {
node = this.real(node);
if (this.isIdent(node)) {
return node.name;
}
};
_MacroContext_prototype.ident = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (require("./jsutils").isAcceptableIdent(name, true)) {
return this.parser.Ident(this.index, name);
}
};
_MacroContext_prototype.isCall = function (node) {
return this.real(node) instanceof CallNode;
};
_MacroContext_prototype.callFunc = function (node) {
node = this.real(node);
if (node instanceof CallNode) {
return node.func;
}
};
_MacroContext_prototype.callArgs = function (node) {
node = this.real(node);
if (node instanceof CallNode) {
return node.args;
}
};
_MacroContext_prototype.isSuper = function (node) {
return this.real(node) instanceof SuperNode;
};
_MacroContext_prototype.superChild = function (node) {
node = this.real(node);
if (this.isSuper(node)) {
return node.child;
}
};
_MacroContext_prototype.superArgs = function (node) {
node = this.real(node);
if (this.isSuper(node)) {
return node.args;
}
};
_MacroContext_prototype.callIsNew = function (node) {
node = this.real(node);
if (node instanceof CallNode) {
return !!node.isNew;
} else {
return false;
}
};
_MacroContext_prototype.callIsApply = function (node) {
node = this.real(node);
if (node instanceof CallNode) {
return !!node.isApply;
} else {
return false;
}
};
_MacroContext_prototype.call = function (func, args, isNew, isApply) {
var _i, _this;
_this = this;
if (!(func instanceof Node)) {
throw TypeError("Expected func to be a " + __name(Node) + ", got " + __typeof(func));
}
if (args == null) {
args = [];
} else if (!__isArray(args)) {
throw TypeError("Expected args to be an Array, got " + __typeof(args));
} else {
for (_i = args.length; _i--; ) {
if (!(args[_i] instanceof Node)) {
throw TypeError("Expected " + ("args[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(args[_i]));
}
}
}
if (isNew == null) {
isNew = false;
} else if (typeof isNew !== "boolean") {
throw TypeError("Expected isNew to be a Boolean, got " + __typeof(isNew));
}
if (isApply == null) {
isApply = false;
} else if (typeof isApply !== "boolean") {
throw TypeError("Expected isApply to be a Boolean, got " + __typeof(isApply));
}
if (isNew && isApply) {
throw Error("Cannot specify both is-new and is-apply");
}
return CallNode(
func.line,
func.column,
this.scope(),
this.doWrap(func),
(function () {
var _arr, _i2, _len, arg;
for (_arr = [], _i2 = 0, _len = args.length; _i2 < _len; ++_i2) {
arg = args[_i2];
_arr.push(_this.doWrap(arg));
}
return _arr;
}()),
isNew,
isApply
).reduce(this.parser);
};
_MacroContext_prototype.func = function (params, body, autoReturn, bound, curry, asType, generator, generic) {
var _i, _this, func, scope;
_this = this;
if (!(body instanceof Node)) {
throw TypeError("Expected body to be a " + __name(Node) + ", got " + __typeof(body));
}
if (autoReturn == null) {
autoReturn = true;
} else if (typeof autoReturn !== "boolean") {
throw TypeError("Expected autoReturn to be a Boolean, got " + __typeof(autoReturn));
}
if (bound == null) {
bound = false;
} else if (!(bound instanceof Node) && typeof bound !== "boolean") {
throw TypeError("Expected bound to be one of " + (__name(Node) + " or Boolean") + ", got " + __typeof(bound));
}
if (curry == null) {
curry = false;
} else if (typeof curry !== "boolean") {
throw TypeError("Expected curry to be a Boolean, got " + __typeof(curry));
}
if (asType == null) {
asType = void 0;
} else if (!(asType instanceof Node)) {
throw TypeError("Expected asType to be one of " + (__name(Node) + " or undefined") + ", got " + __typeof(asType));
}
if (generator == null) {
generator = false;
} else if (typeof generator !== "boolean") {
throw TypeError("Expected generator to be a Boolean, got " + __typeof(generator));
}
if (generic == null) {
generic = [];
} else if (!__isArray(generic)) {
throw TypeError("Expected generic to be an Array, got " + __typeof(generic));
} else {
for (_i = generic.length; _i--; ) {
if (!(generic[_i] instanceof IdentNode)) {
throw TypeError("Expected " + ("generic[" + _i + "]") + " to be a " + __name(IdentNode) + ", got " + __typeof(generic[_i]));
}
}
}
scope = this.parser.pushScope(true);
params = (function () {
var _arr, _arr2, _i2, _len, p, param;
for (_arr = [], _arr2 = __toArray(params), _i2 = 0, _len = _arr2.length; _i2 < _len; ++_i2) {
param = _arr2[_i2];
p = param.rescope(scope);
addParamToScope(scope, p);
_arr.push(p);
}
return _arr;
}());
func = FunctionNode(
body.line,
body.column,
scope.parent,
params,
body.rescope(scope),
autoReturn,
bound,
curry,
asType,
generator,
generic
).reduce(this.parser);
this.parser.popScope();
return func;
};
_MacroContext_prototype.isFunc = function (node) {
return this.real(node) instanceof FunctionNode;
};
_MacroContext_prototype.funcBody = function (node) {
node = this.real(node);
if (this.isFunc(node)) {
return node.body;
}
};
_MacroContext_prototype.funcParams = function (node) {
node = this.real(node);
if (this.isFunc(node)) {
return node.params;
}
};
_MacroContext_prototype.funcIsAutoReturn = function (node) {
node = this.real(node);
if (this.isFunc(node)) {
return !!node.autoReturn;
}
};
_MacroContext_prototype.funcIsBound = function (node) {
node = this.real(node);
if (this.isFunc(node)) {
return !!node.bound && !(node.bound instanceof Node);
}
};
_MacroContext_prototype.funcIsCurried = function (node) {
node = this.real(node);
if (this.isFunc(node)) {
return !!node.curry;
}
};
_MacroContext_prototype.funcAsType = function (node) {
node = this.real(node);
if (this.isFunc(node)) {
return node.asType;
}
};
_MacroContext_prototype.funcIsGenerator = function (node) {
node = this.real(node);
if (this.isFunc(node)) {
return !!node.generator;
}
};
_MacroContext_prototype.funcGeneric = function (node) {
node = this.real(node);
if (this.isFunc(node)) {
return node.generic.slice();
} else {
return [];
}
};
_MacroContext_prototype.param = function (ident, defaultValue, spread, isMutable, asType) {
if (!(ident instanceof Node)) {
throw TypeError("Expected ident to be a " + __name(Node) + ", got " + __typeof(ident));
}
return ParamNode(
ident.line,
ident.column,
ident.scope,
ident,
defaultValue,
spread,
isMutable,
asType
).reduce(this.parser);
};
_MacroContext_prototype.isParam = function (node) {
return this.real(node) instanceof ParamNode;
};
_MacroContext_prototype.paramIdent = function (node) {
node = this.real(node);
if (this.isParam(node)) {
return node.ident;
}
};
_MacroContext_prototype.paramDefaultValue = function (node) {
node = this.real(node);
if (this.isParam(node)) {
return node.defaultValue;
}
};
_MacroContext_prototype.paramIsSpread = function (node) {
node = this.real(node);
if (this.isParam(node)) {
return !!node.spread;
}
};
_MacroContext_prototype.paramIsMutable = function (node) {
node = this.real(node);
if (this.isParam(node)) {
return !!node.isMutable;
}
};
_MacroContext_prototype.paramType = function (node) {
node = this.real(node);
if (this.isParam(node)) {
return node.asType;
}
};
_MacroContext_prototype.isArray = function (node) {
return this.real(node) instanceof ArrayNode;
};
_MacroContext_prototype.elements = function (node) {
node = this.real(node);
if (this.isArray(node)) {
return node.elements;
}
};
_MacroContext_prototype.arrayHasSpread = function (node) {
var _this;
_this = this;
node = this.real(node);
if (node instanceof ArrayNode) {
return (function () {
var _arr, _i, _len, element;
for (_arr = __toArray(node.elements), _i = 0, _len = _arr.length; _i < _len; ++_i) {
element = _arr[_i];
if (_this.real(element) instanceof SpreadNode) {
return true;
}
}
return false;
}());
} else {
return false;
}
};
_MacroContext_prototype.isObject = function (node) {
return this.real(node) instanceof ObjectNode;
};
_MacroContext_prototype.pairs = function (node) {
node = this.real(node);
if (this.isObject(node) || this.isTypeObject(node)) {
return node.pairs;
}
};
_MacroContext_prototype.isBlock = function (node) {
return this.real(node) instanceof BlockNode;
};
_MacroContext_prototype.nodes = function (node) {
node = this.real(node);
if (this.isBlock(node)) {
return node.nodes;
}
};
_MacroContext_prototype.array = function (elements) {
var _i, _this;
_this = this;
if (!__isArray(elements)) {
throw TypeError("Expected elements to be an Array, got " + __typeof(elements));
} else {
for (_i = elements.length; _i--; ) {
if (!(elements[_i] instanceof Node)) {
throw TypeError("Expected " + ("elements[" + _i + "]") + " to be a " + __name(Node) + ", got " + __typeof(elements[_i]));
}
}
}
return this.parser.Array(0, (function () {
var _arr, _i2, _len, element;
for (_arr = [], _i2 = 0, _len = elements.length; _i2 < _len; ++_i2) {
element = elements[_i2];
_arr.push(_this.doWrap(element));
}
return _arr;
}())).reduce(this.parser);
};
_MacroContext_prototype.object = function (pairs) {
var _i, _this;
_this = this;
if (!__isArray(pairs)) {
throw TypeError("Expected pairs to be an Array, got " + __typeof(pairs));
} else {
for (_i = pairs.length; _i--; ) {
if (typeof pairs[_i] !== "object" || pairs[_i] === null) {
throw TypeError("Expected " + ("pairs[" + _i + "]") + " to be an Object, got " + __typeof(pairs[_i]));
} else {
if (!(pairs[_i].key instanceof Node)) {
throw TypeError("Expected " + ("pairs[" + _i + "].key") + " to be a " + __name(Node) + ", got " + __typeof(pairs[_i].key));
}
if (!(pairs[_i].value instanceof Node)) {
throw TypeError("Expected " + ("pairs[" + _i + "].value") + " to be a " + __name(Node) + ", got " + __typeof(pairs[_i].value));
}
}
}
}
return this.parser.Object(0, (function () {
var _arr, _i2, _len, _ref, key, property, value;
for (_arr = [], _i2 = 0, _len = pairs.length; _i2 < _len; ++_i2) {
key = (_ref = pairs[_i2]).key;
value = _ref.value;
property = _ref.property;
_arr.push({ key: _this.doWrap(key), value: _this.doWrap(value)(property) });
}
return _arr;
}())).reduce(this.parser);
};
_MacroContext_prototype.type = function (node) {
if (typeof node === "string") {
return __owns.call(Type, node) && Type[node] || __throw(Error("Unknown type " + __strnum(node)));
} else if (node instanceof Node) {
return node.type(this.parser);
} else {
throw Error("Can only retrieve type from a String or Node, got " + __typeof(node));
}
};
_MacroContext_prototype.toType = nodeToType;
_MacroContext_prototype.isComplex = function (node) {
node = this.real(node);
return node != null && !(node instanceof ConstNode) && !(node instanceof IdentNode) && !(node instanceof TmpNode) && !(node instanceof ThisNode) && !(node instanceof ArgsNode) && (!(node instanceof BlockNode) || node.nodes.length !== 0);
};
_MacroContext_prototype.isNoop = function (node) {
node = this.real(node);
return node.isNoop(this.parser);
};
_MacroContext_prototype.isNothing = function (node) {
return this.real(node) instanceof NothingNode;
};
_MacroContext_prototype.isTypeArray = function (node) {
node = this.real(node);
return node instanceof TypeGenericNode && node.basetype instanceof IdentNode && node.basetype.name === "Array";
};
_MacroContext_prototype.subtype = function (node) {
node = this.real(node);
if (node instanceof TypeGenericNode && node.basetype instanceof IdentNode && node.basetype.name === "Array") {
return node.args[0];
}
};
_MacroContext_prototype.isTypeGeneric = function (node) {
return this.real(node) instanceof TypeGenericNode;
};
_MacroContext_prototype.basetype = function (node) {
node = this.real(node);
return node instanceof TypeGenericNode && node.basetype;
};
_MacroContext_prototype.typeArguments = function (node) {
node = this.real(node);
return node instanceof TypeGenericNode && node.args;
};
_MacroContext_prototype.isTypeObject = function (node) {
return this.real(node) instanceof TypeObjectNode;
};
_MacroContext_prototype.isTypeFunction = function (node) {
node = this.real(node);
return node instanceof TypeGenericNode && node.basetype instanceof IdentNode && node.basetype.name === "Function";
};
_MacroContext_prototype.returnType = function (node) {
node = this.real(node);
if (node instanceof TypeGenericNode && node.basetype instanceof IdentNode && node.basetype.name === "Function") {
return node.args[0];
}
};
_MacroContext_prototype.isTypeUnion = function (node) {
return this.real(node) instanceof TypeUnionNode;
};
_MacroContext_prototype.types = function (node) {
node = this.real(node);
return this.isTypeUnion(node) && node.types;
};
_MacroContext_prototype.isThis = function (node) {
return this.real(node) instanceof ThisNode;
};
_MacroContext_prototype.isArguments = function (node) {
node = this.real(node);
return node instanceof ArgsNode;
};
_MacroContext_prototype.isDef = function (node) {
return this.real(node) instanceof DefNode;
};
_MacroContext_prototype.isAssign = function (node) {
return this.real(node) instanceof AssignNode;
};
_MacroContext_prototype.isBinary = function (node) {
return this.real(node) instanceof BinaryNode;
};
_MacroContext_prototype.isUnary = function (node) {
return this.real(node) instanceof UnaryNode;
};
_MacroContext_prototype.op = function (node) {
node = this.real(node);
if (this.isAssign(node) || this.isBinary(node) || this.isUnary(node)) {
return node.op;
}
};
_MacroContext_prototype.left = function (node) {
node = this.real(node);
if (this.isDef(node) || this.isBinary(node)) {
return node.left;
}
};
_MacroContext_prototype.right = function (node) {
node = this.real(node);
if (this.isDef(node) || this.isBinary(node)) {
return node.right;
}
};
_MacroContext_prototype.unaryNode = function (node) {
node = this.real(node);
if (this.isUnary(node)) {
return node.node;
}
};
_MacroContext_prototype.isAccess = function (node) {
return this.real(node) instanceof AccessNode;
};
_MacroContext_prototype.parent = function (node) {
node = this.real(node);
if (node instanceof AccessNode) {
return node.parent;
}
};
_MacroContext_prototype.child = function (node) {
node = this.real(node);
if (node instanceof AccessNode) {
return node.child;
}
};
_MacroContext_prototype.isIf = function (node) {
return this.real(node) instanceof IfNode;
};
_MacroContext_prototype.test = function (node) {
node = this.real(node);
if (node instanceof IfNode) {
return node.test;
}
};
_MacroContext_prototype.whenTrue = function (node) {
node = this.real(node);
if (node instanceof IfNode) {
return node.whenTrue;
}
};
_MacroContext_prototype.whenFalse = function (node) {
node = this.real(node);
if (node instanceof IfNode) {
return node.whenFalse;
}
};
_MacroContext_prototype.cache = function (node, init, name, save) {
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
if (name == null) {
name = "ref";
} else if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (save == null) {
save = false;
} else if (typeof save !== "boolean") {
throw TypeError("Expected save to be a Boolean, got " + __typeof(save));
}
return this.maybeCache(
node,
function (setNode, node, cached) {
if (cached) {
init.push(setNode);
}
return node;
},
name,
save
);
};
_MacroContext_prototype.maybeCache = function (node, func, name, save) {
var tmp, type;
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
if (name == null) {
name = "ref";
} else if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (save == null) {
save = false;
} else if (typeof save !== "boolean") {
throw TypeError("Expected save to be a Boolean, got " + __typeof(save));
}
node = this.macroExpand1(node);
if (this.isComplex(node)) {
type = node.type(this.parser);
tmp = this.tmp(name, save, type);
this.scope().add(tmp, false, type);
return func(
this.parser.Block(this.index, [
this.parser.Var(this.index, tmp, false),
this.parser.Assign(this.index, tmp, "=", this.doWrap(node))
]),
tmp,
true
);
} else {
return func(node, node, false);
}
};
_MacroContext_prototype.maybeCacheAccess = function (node, func, parentName, childName, save) {
var _this;
_this = this;
if (!(node instanceof Node)) {
throw TypeError("Expected node to be a " + __name(Node) + ", got " + __typeof(node));
}
if (parentName == null) {
parentName = "ref";
} else if (typeof parentName !== "string") {
throw TypeError("Expected parentName to be a String, got " + __typeof(parentName));
}
if (childName == null) {
childName = "ref";
} else if (typeof childName !== "string") {
throw TypeError("Expected childName to be a String, got " + __typeof(childName));
}
if (save == null) {
save = false;
} else if (typeof save !== "boolean") {
throw TypeError("Expected save to be a Boolean, got " + __typeof(save));
}
node = this.macroExpand1(node);
if (this.isAccess(node)) {
return this.maybeCache(
this.parent(node),
function (setParent, parent, parentCached) {
return _this.maybeCache(
_this.child(node),
function (setChild, child, childCached) {
if (parentCached || childCached) {
return func(
_this.parser.Access(_this.index, setParent, setChild),
_this.parser.Access(_this.index, parent, child),
true
);
} else {
return func(node, node, false);
}
},
childName,
save
);
},
parentName,
save
);
} else {
return func(node, node, false);
}
};
_MacroContext_prototype.empty = function (node) {
var _this;
_this = this;
if (node == null) {
return true;
} else if (!(node instanceof Node)) {
return false;
} else if (node instanceof BlockNode) {
return (function () {
var _arr, _i, item;
for (_arr = __toArray(node.nodes), _i = _arr.length; _i--; ) {
item = _arr[_i];
if (!_this.empty(item)) {
return false;
}
}
return true;
}());
} else {
return node instanceof NothingNode;
}
};
function constifyObject(obj, line, column, scope) {
if (!(scope instanceof Scope)) {
throw TypeError("Expected scope to be a " + __name(Scope) + ", got " + __typeof(scope));
}
if (typeof obj !== "object" || obj === null || obj instanceof RegExp) {
return ConstNode(line, column, scope, obj);
} else if (__isArray(obj)) {
return ArrayNode(line, column, scope, (function () {
var _arr, _arr2, _i, _len, item;
for (_arr = [], _arr2 = __toArray(obj), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
item = _arr2[_i];
_arr.push(constifyObject(item, line, column, scope));
}
return _arr;
}()));
} else if (obj instanceof IdentNode && __num(obj.name.length) > 1 && obj.name.charCodeAt(0) === 36) {
return CallNode(
obj.line,
obj.column,
scope,
IdentNode(obj.line, obj.column, scope, "__wrap"),
[IdentNode(obj.line, obj.column, scope, obj.name.substring(1))]
);
} else if (obj instanceof CallNode && !obj.isNew && !obj.isApply && obj.func instanceof IdentNode && obj.func.name === "$") {
if (obj.args.length !== 1 || obj.args[0] instanceof SpreadNode) {
throw Error("Can only use $() in an AST if it has one argument.");
}
return CallNode(
obj.line,
obj.column,
scope,
IdentNode(obj.line, obj.column, scope, "__wrap"),
[obj.args[0]]
);
} else if (obj instanceof Node) {
if (obj.constructor === Node) {
throw Error("Cannot constify a raw node");
}
return CallNode(
obj.line,
obj.column,
scope,
IdentNode(obj.line, obj.column, scope, "__node"),
[
ConstNode(obj.line, obj.column, scope, obj.constructor.cappedName),
ConstNode(obj.line, obj.column, scope, obj.line),
ConstNode(obj.line, obj.column, scope, obj.column)
].concat((function () {
var _arr, _arr2, _i, _len, k;
for (_arr = [], _arr2 = __toArray(obj.constructor.argNames), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
k = _arr2[_i];
_arr.push(constifyObject(obj[k], obj.line, obj.column, scope));
}
return _arr;
}()))
);
} else {
return ObjectNode(line, column, scope, (function () {
var _arr, k, v;
_arr = [];
for (k in obj) {
if (__owns.call(obj, k)) {
v = obj[k];
_arr.push({
key: ConstNode(line, column, scope, k),
value: constifyObject(v, line, column, scope)
});
}
}
return _arr;
}()));
}
}
MacroContext.constifyObject = constifyObject;
function walk(node, func) {
var _ref;
if (typeof node !== "object" || node === null || node instanceof RegExp) {
return node;
}
if (!(node instanceof Node)) {
throw Error("Unexpected type to walk through: " + __typeof(node));
}
if (!(node instanceof BlockNode) && (_ref = func(node)) != null) {
return _ref;
}
return node.walk(function (x) {
return walk(x, func);
});
}
_MacroContext_prototype.wrap = function (value) {
var _ref;
if (__isArray(value)) {
return BlockNode(0, 0, this.scope(), value).reduce(this.parser);
} else if (value instanceof Node) {
return value;
} else if (value == null) {
return NothingNode(0, 0, this.scope());
} else if (value instanceof RegExp || (_ref = typeof value) === "string" || _ref === "boolean" || _ref === "number") {
return ConstNode(0, 0, this.scope(), value);
} else {
return value;
}
};
_MacroContext_prototype.node = function (type, line, column) {
var args;
args = __slice.call(arguments, 3);
if (type === "MacroAccess") {
return this.macro.apply(this, [line, column].concat(__toArray(args)));
} else {
return Node[type].apply(Node, [line, column, this.scope()].concat(__toArray(args))).reduce(this.parser);
}
};
_MacroContext_prototype.macro = function (line, column, id, callLine, data, position, inGenerator, inEvilAst) {
return Node.MacroAccess(
line,
column,
this.scope(),
id,
callLine,
data,
position,
inGenerator || this.parser.inGenerator.peek(),
inEvilAst
).reduce(this.parser);
};
_MacroContext_prototype.walk = function (node, func) {
if (node != null && !(node instanceof Node)) {
throw TypeError("Expected node to be one of " + (__name(Node) + " or undefined or null") + ", got " + __typeof(node));
}
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
if (node != null) {
return walk(node, func);
} else {
return node;
}
};
_MacroContext_prototype.hasFunc = function (node) {
var FOUND, walker;
if (this._hasFunc != null) {
return this._hasFunc;
} else {
FOUND = {};
walker = function (x) {
if (x instanceof FunctionNode) {
throw FOUND;
} else {
return x.walk(walker);
}
};
try {
walk(this.macroExpandAll(node), walker);
} catch (e) {
if (e !== FOUND) {
throw e;
}
return this._hasFunc = true;
}
return this._hasFunc = false;
}
};
_MacroContext_prototype.isStatement = function (node) {
node = this.macroExpand1(node);
return node instanceof Node && node.isStatement();
};
_MacroContext_prototype.isType = function (node, name) {
var type;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (__owns.call(Type, name)) {
type = Type[name];
}
if (type == null || !(type instanceof Type)) {
throw Error(name + " is not a known type name");
}
return node.type(this.parser).isSubsetOf(type);
};
_MacroContext_prototype.hasType = function (node, name) {
var type;
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
if (__owns.call(Type, name)) {
type = Type[name];
}
if (type == null || !(type instanceof Type)) {
throw Error(name + " is not a known type name");
}
return node.type(this.parser).overlaps(type);
};
mutators = {
Block: function (x, func) {
var lastNode, len, nodes;
nodes = x.nodes;
len = nodes.length;
if (len !== 0) {
lastNode = this.mutateLast(nodes[__num(len) - 1], func);
if (lastNode !== nodes[__num(len) - 1]) {
return BlockNode(
x.line,
x.column,
x.scope,
__toArray(__slice.call(nodes, 0, -1)).concat([lastNode]),
x.label
);
}
}
return x;
},
If: function (x, func) {
var whenFalse, whenTrue;
whenTrue = this.mutateLast(x.whenTrue, func);
whenFalse = this.mutateLast(x.whenFalse, func);
if (whenTrue !== x.whenTrue || whenFalse !== x.whenFalse) {
return IfNode(
x.line,
x.column,
x.scope,
x.test,
whenTrue,
whenFalse,
x.label
);
} else {
return x;
}
},
Switch: function (x, func) {
var _this, cases, defaultCase;
_this = this;
cases = map(x.cases, function (case_) {
var body;
if (case_.fallthrough) {
return case_;
} else {
body = _this.mutateLast(case_.body, func);
if (body !== case_.body) {
return { node: case_.node, body: body, fallthrough: case_.fallthrough };
} else {
return case_;
}
}
});
defaultCase = this.mutateLast(x.defaultCase || this.noop(), func);
if (cases !== x.cases || defaultCase !== x.defaultCase) {
return SwitchNode(
x.line,
x.column,
x.scope,
x.node,
cases,
defaultCase,
x.label
);
} else {
return x;
}
},
TmpWrapper: function (x, func) {
var node;
node = this.mutateLast(x.node, func);
if (node !== x.node) {
return TmpWrapperNode(
x.line,
x.column,
x.scope,
node,
x.tmps
);
} else {
return x;
}
},
MacroAccess: function (x, func) {
return this.mutateLast(this.macroExpand1(x), func);
},
TryCatch: function (x, func) {
var catchBody, tryBody;
tryBody = this.mutateLast(x.tryBody, func);
catchBody = this.mutateLast(x.catchBody, func);
if (tryBody !== x.tryBody || catchBody !== x.catchBody) {
return TryCatchNode(
x.line,
x.column,
x.scope,
tryBody,
x.catchIdent,
catchBody,
x.label
);
} else {
return x;
}
},
Break: identity,
Continue: identity,
Nothing: identity,
Return: identity,
Debugger: identity,
Throw: identity
};
_MacroContext_prototype.mutateLast = function (node, func, includeNoop) {
var _ref;
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
if (typeof node !== "object" || node === null || node instanceof RegExp) {
return node;
}
if (!(node instanceof Node)) {
throw Error("Unexpected type to mutate-last through: " + __typeof(node));
}
if (!__owns.call(mutators, node.constructor.cappedName) || includeNoop && node instanceof NothingNode) {
if ((_ref = func.call(this, node)) != null) {
return _ref;
} else {
return node;
}
} else {
return mutators[node.constructor.cappedName].call(this, node, func);
}
};
_MacroContext_prototype.canMutateLast = function (node) {
return node instanceof Node && __owns.call(mutators, node.constructor.cappedName);
};
return MacroContext;
}());
module.exports = MacroContext;
}.call(this));
return module.exports;
};
require['./jstranslator'] = function () {
var module = { exports: this };
var exports = this;
(function (GLOBAL) {
"use strict";
var __arrayToIter, __cmp, __create, __import, __indexOfIdentical, __isArray, __iter, __name, __num, __owns, __slice, __strnum, __throw, __toArray, __typeof, _ref, ast, AstNode, Cache, GeneratorBuilder, GeneratorState, generatorTranslate, MacroHolder, Map, ParserNode, Scope, translators, Type;
__arrayToIter = (function () {
var proto;
proto = {
iterator: function () {
return this;
},
next: function () {
var array, i;
i = __num(this.index) + 1;
array = this.array;
if (i >= __num(array.length)) {
return { done: true, value: void 0 };
} else {
this.index = i;
return { done: false, value: array[i] };
}
}
};
return function (array) {
var _o;
if (!__isArray(array)) {
throw TypeError("Expected array to be an Array, got " + __typeof(array));
}
_o = __create(proto);
_o.array = array;
_o.index = -1;
return _o;
};
}());
__cmp = function (left, right) {
var type;
if (left === right) {
return 0;
} else {
type = typeof left;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof right) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof right);
} else if (left < right) {
return -1;
} else {
return 1;
}
}
};
__create = typeof Object.create === "function" ? Object.create
: function (x) {
function F() {}
F.prototype = x;
return new F();
};
__import = function (dest, source) {
var k;
for (k in source) {
if (__owns.call(source, k)) {
dest[k] = source[k];
}
}
return dest;
};
__indexOfIdentical = function (array, item) {
var _arr, check, i, inf;
if (typeof item === "number") {
if (item !== item) {
for (_arr = __toArray(array), i = _arr.length; i--; ) {
check = _arr[i];
if (check !== check) {
return i;
}
}
return -1;
} else if (item === 0) {
inf = 1 / item;
for (_arr = __toArray(array), i = _arr.length; i--; ) {
check = _arr[i];
if (check === 0 && 1 / check === inf) {
return i;
}
}
return -1;
}
}
return array.indexOf(item);
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__iter = function (iterable) {
if (iterable == null) {
throw TypeError("Expected iterable to be an Object, got " + __typeof(iterable));
} else if (__isArray(iterable)) {
return __arrayToIter(iterable);
} else if (typeof iterable.iterator === "function") {
return iterable.iterator();
} else if (typeof iterable.next === "function") {
return iterable;
} else {
throw Error("Expected iterable to be an Array or an Object with an 'iterator' function or an Object with a 'next' function, got " + __typeof(iterable));
}
};
__name = function (func) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
return func.displayName || func.name || "";
};
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__owns = Object.prototype.hasOwnProperty;
__slice = Array.prototype.slice;
__strnum = function (strnum) {
var type;
type = typeof strnum;
if (type === "string") {
return strnum;
} else if (type === "number") {
return String(strnum);
} else {
throw TypeError("Expected a string or number, got " + __typeof(strnum));
}
};
__throw = function (err) {
throw err;
};
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
Map = typeof GLOBAL.Map === "function" ? GLOBAL.Map
: (Map = (function () {
var _Map_prototype;
function Map(iterable) {
var _item, _iter, _this, x;
_this = this instanceof Map ? this : __create(_Map_prototype);
_this._keys = [];
_this._values = [];
if (iterable != null) {
try {
for (_iter = __iter(iterable); ; ) {
_item = _iter.next();
if (_item.done) {
break;
}
x = _item.value;
_this.set(x[0], x[1]);
}
} finally {
try {
_iter.close();
} catch (_e) {}
}
}
return _this;
}
_Map_prototype = Map.prototype;
Map.displayName = "Map";
_Map_prototype.get = function (key) {
var index;
index = __indexOfIdentical(this._keys, key);
if (index === -1) {
return;
} else {
return this._values[index];
}
};
_Map_prototype.has = function (key) {
return __indexOfIdentical(this._keys, key) !== -1;
};
_Map_prototype.set = function (key, value) {
var index, keys;
keys = this._keys;
index = __indexOfIdentical(keys, key);
if (index === -1) {
index = keys.length;
keys[index] = key;
}
this._values[index] = value;
};
_Map_prototype["delete"] = function (key) {
var index, keys;
keys = this._keys;
index = __indexOfIdentical(keys, key);
if (index === -1) {
return false;
} else {
keys.splice(index, 1);
return this._values.splice(index, 1);
}
};
_Map_prototype.keys = function () {
var _arr, _e, _i, _send, _state, _step, _this, _throw, key;
_this = this;
_state = 0;
function _close() {
_state = 3;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
_arr = __toArray(_this._keys);
_i = _arr.length;
++_state;
case 1:
_state = _i-- ? 2 : 3;
break;
case 2:
key = _arr[_i];
_state = 1;
return { done: false, value: key };
case 3:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
};
_Map_prototype.values = function () {
var _arr, _e, _i, _send, _state, _step, _this, _throw, value;
_this = this;
_state = 0;
function _close() {
_state = 3;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
_arr = __toArray(_this._values);
_i = _arr.length;
++_state;
case 1:
_state = _i-- ? 2 : 3;
break;
case 2:
value = _arr[_i];
_state = 1;
return { done: false, value: value };
case 3:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
};
_Map_prototype.items = function () {
var _arr, _e, _send, _state, _step, _this, _throw, i, key, values;
_this = this;
_state = 0;
function _close() {
_state = 3;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
values = _this._values;
_arr = __toArray(_this._keys);
i = _arr.length;
++_state;
case 1:
_state = i-- ? 2 : 3;
break;
case 2:
key = _arr[i];
_state = 1;
return {
done: false,
value: [key, values[i]]
};
case 3:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
};
_Map_prototype.iterator = Map.prototype.items;
return Map;
}()));
ast = require("./jsast");
AstNode = ast.Node;
Type = require("./types");
ParserNode = (_ref = require("./parser")).Node;
MacroHolder = _ref.MacroHolder;
Cache = require("./utils").Cache;
function needsCaching(item) {
return !(item instanceof ast.Ident) && !(item instanceof ast.Const) && !(item instanceof ast.This) && !(item instanceof ast.Arguments);
}
Scope = (function () {
var _Scope_prototype, getId;
function Scope(options, macros, bound, usedTmps, helperNames, variables, tmps) {
var _this;
_this = this instanceof Scope ? this : __create(_Scope_prototype);
if (options == null) {
options = {};
}
_this.options = options;
if (!(macros instanceof MacroHolder)) {
throw TypeError("Expected macros to be a " + __name(MacroHolder) + ", got " + __typeof(macros));
}
_this.macros = macros;
if (bound == null) {
bound = false;
}
_this.bound = bound;
if (usedTmps == null) {
usedTmps = {};
}
_this.usedTmps = usedTmps;
if (helperNames == null) {
helperNames = {};
}
_this.helperNames = helperNames;
if (tmps == null) {
tmps = {};
}
_this.tmps = tmps;
_this.variables = variables ? __create(variables) : {};
_this.hasBound = false;
_this.usedThis = false;
_this.id = getId();
return _this;
}
_Scope_prototype = Scope.prototype;
Scope.displayName = "Scope";
getId = (function () {
var id;
id = -1;
return function () {
return ++id;
};
}());
_Scope_prototype.maybeCache = function (item, type, func) {
var ident, result;
if (!(item instanceof ast.Expression)) {
throw TypeError("Expected item to be an Expression, got " + __typeof(item));
}
if (type == null) {
type = Type.any;
} else if (!(type instanceof Type)) {
throw TypeError("Expected type to be a " + __name(Type) + ", got " + __typeof(type));
}
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
if (!needsCaching(item)) {
return func(item, item, false);
} else {
ident = this.reserveIdent(item.pos, "ref", type);
result = func(
ast.Assign(item.pos, ident, item),
ident,
true
);
this.releaseIdent(ident);
return result;
}
};
_Scope_prototype.maybeCacheAccess = function (item, func, parentName, childName, save) {
var _this;
_this = this;
if (!(item instanceof ast.Expression)) {
throw TypeError("Expected item to be an Expression, got " + __typeof(item));
}
if (parentName == null) {
parentName = "ref";
} else if (typeof parentName !== "string") {
throw TypeError("Expected parentName to be a String, got " + __typeof(parentName));
}
if (childName == null) {
childName = "ref";
} else if (typeof childName !== "string") {
throw TypeError("Expected childName to be a String, got " + __typeof(childName));
}
if (save == null) {
save = false;
} else if (typeof save !== "boolean") {
throw TypeError("Expected save to be a Boolean, got " + __typeof(save));
}
if (item instanceof ast.Binary && item.op === ".") {
return this.maybeCache(item.left, Type.any, function (setParent, parent, parentCached) {
return _this.maybeCache(item.right, Type.any, function (setChild, child, childCached) {
if (parentCached || childCached) {
return func(
ast.Access(item.pos, setParent, setChild),
ast.Access(item.pos, parent, child),
true
);
} else {
return func(item, item, false);
}
});
});
} else {
return func(item, item, false);
}
};
_Scope_prototype.reserveIdent = function (pos, namePart, type) {
var _this;
_this = this;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (namePart == null) {
namePart = "ref";
}
if (type == null) {
type = Type.any;
} else if (!(type instanceof Type)) {
throw TypeError("Expected type to be a " + __name(Type) + ", got " + __typeof(type));
}
return (function () {
var i, ident, name;
for (i = 1; ; ++i) {
if (i === 1) {
name = "_" + __strnum(namePart);
} else {
name = "_" + __strnum(namePart) + i;
}
if (!(name in _this.usedTmps)) {
_this.usedTmps[name] = true;
ident = ast.Ident(pos, name);
_this.addVariable(ident, type);
return ident;
}
}
}());
};
_Scope_prototype.reserveParam = function (pos) {
var _this;
_this = this;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
return (function () {
var i, name;
for (i = 1; ; ++i) {
if (i === 1) {
name = "_p";
} else {
name = "_p" + i;
}
if (!(name in _this.usedTmps)) {
_this.usedTmps[name] = true;
return ast.Ident(pos, name);
}
}
}());
};
_Scope_prototype.getTmp = function (pos, id, name, type) {
var tmp, tmps;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (type == null) {
type = Type.any;
} else if (!(type instanceof Type)) {
throw TypeError("Expected type to be a " + __name(Type) + ", got " + __typeof(type));
}
tmps = this.tmps;
if (id in tmps) {
tmp = tmps[id];
if (tmp instanceof ast.Ident) {
return tmp;
}
}
return tmps[id] = this.reserveIdent(pos, name || "tmp", type);
};
_Scope_prototype.releaseTmp = function (id) {
var _ref, _ref2;
if (__owns.call(this.tmps, id)) {
this.releaseIdent((_ref = (_ref2 = this.tmps)[id], delete _ref2[id], _ref));
}
};
_Scope_prototype.releaseTmps = function () {
var _obj, id;
_obj = this.tmps;
for (id in _obj) {
if (__owns.call(_obj, id)) {
this.releaseTmp(id);
}
}
this.tmps = {};
};
_Scope_prototype.releaseIdent = function (ident) {
if (!(ident instanceof ast.Ident)) {
throw TypeError("Expected ident to be an Ident, got " + __typeof(ident));
}
if (!__owns.call(this.usedTmps, ident.name)) {
throw Error("Trying to release a non-reserved ident: " + __strnum(ident.name));
}
delete this.usedTmps[ident.name];
};
_Scope_prototype.markAsParam = function (ident) {
if (!(ident instanceof ast.Ident)) {
throw TypeError("Expected ident to be an Ident, got " + __typeof(ident));
}
this.variables[ident.name].isParam = true;
};
_Scope_prototype.markAsFunction = function (ident) {
if (!(ident instanceof ast.Ident)) {
throw TypeError("Expected ident to be an Ident, got " + __typeof(ident));
}
this.variables[ident.name].isFunction = true;
};
_Scope_prototype.addHelper = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
this.helperNames[name] = true;
};
_Scope_prototype.fillHelperDependencies = function () {
var _arr, _else, _i, dep, helperNames, name, toAdd;
helperNames = this.helperNames;
toAdd = {};
while (true) {
for (name in helperNames) {
if (__owns.call(helperNames, name) && this.macros.hasHelper(name)) {
for (_arr = __toArray(this.macros.helperDependencies(name)), _i = _arr.length; _i--; ) {
dep = _arr[_i];
if (!__owns.call(helperNames, dep)) {
toAdd[dep] = true;
}
}
}
}
_else = true;
for (name in toAdd) {
if (__owns.call(toAdd, name)) {
_else = false;
this.addHelper(name);
}
}
if (_else) {
break;
}
helperNames = toAdd;
toAdd = {};
}
};
function lowerSorter(a, b) {
return __cmp(a.toLowerCase(), b.toLowerCase());
}
_Scope_prototype.getHelpers = function () {
var _arr, _obj, k, names;
_arr = [];
_obj = this.helperNames;
for (k in _obj) {
if (__owns.call(_obj, k)) {
_arr.push(k);
}
}
names = _arr;
return names.sort(lowerSorter);
};
_Scope_prototype.hasHelper = function (name) {
if (typeof name !== "string") {
throw TypeError("Expected name to be a String, got " + __typeof(name));
}
return __owns.call(this.helperNames, name);
};
_Scope_prototype.addVariable = function (ident, type, isMutable) {
if (!(ident instanceof ast.Ident)) {
throw TypeError("Expected ident to be an Ident, got " + __typeof(ident));
}
if (type == null) {
type = Type.any;
} else if (!(type instanceof Type)) {
throw TypeError("Expected type to be a " + __name(Type) + ", got " + __typeof(type));
}
if (isMutable == null) {
isMutable = false;
} else if (typeof isMutable !== "boolean") {
throw TypeError("Expected isMutable to be a Boolean, got " + __typeof(isMutable));
}
this.variables[ident.name] = { type: type, isMutable: isMutable };
};
_Scope_prototype.hasVariable = function (ident) {
if (!(ident instanceof ast.Ident)) {
throw TypeError("Expected ident to be an Ident, got " + __typeof(ident));
}
return ident.name in this.variables && typeof this.variables[ident.name] === "object" && this.variables[ident.name] !== null;
};
_Scope_prototype.hasOwnVariable = function (ident) {
if (!(ident instanceof ast.Ident)) {
throw TypeError("Expected ident to be an Ident, got " + __typeof(ident));
}
return __owns.call(this.variables, ident.name);
};
_Scope_prototype.isVariableMutable = function (ident) {
var _ref;
if (!(ident instanceof ast.Ident)) {
throw TypeError("Expected ident to be an Ident, got " + __typeof(ident));
}
if ((_ref = this.variables[ident.name]) != null) {
return _ref.isMutable;
}
};
_Scope_prototype.removeVariable = function (ident) {
if (!(ident instanceof ast.Ident)) {
throw TypeError("Expected ident to be an Ident, got " + __typeof(ident));
}
delete this.variables[ident.name];
};
_Scope_prototype.getVariables = function () {
var _arr, _obj, k, v, variables;
_arr = [];
_obj = this.variables;
for (k in _obj) {
if (__owns.call(_obj, k)) {
v = _obj[k];
if (!v.isParam && !v.isFunction) {
_arr.push(k);
}
}
}
variables = _arr;
return variables.sort(lowerSorter);
};
_Scope_prototype.clone = function (bound) {
if (bound) {
this.hasBound = true;
}
return Scope(
this.options,
this.macros,
bound,
__create(this.usedTmps),
this.helperNames,
this.variables,
__create(this.tmps)
);
};
return Scope;
}());
function wrapReturn(x) {
return x.mutateLast(function (n) {
return ast.Return(n.pos, n);
});
}
function identity(x) {
return x;
}
function makeAutoReturn(x) {
if (x) {
return wrapReturn;
} else {
return identity;
}
}
function makeHasGeneratorNode() {
var inLoopCache, inSwitchCache, normalCache, returnFreeCache;
inLoopCache = Cache.generic(ParserNode, Boolean)();
function hasInLoop(node) {
var _once;
return inLoopCache.getOrAdd(node, (_once = false, function (node) {
var FOUND, result;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
result = false;
if (node instanceof ParserNode.Yield || node instanceof ParserNode.Return) {
return true;
} else if (!(node instanceof ParserNode.Function)) {
FOUND = {};
try {
node.walk(function (n) {
if (hasInLoop(n)) {
throw FOUND;
}
return n;
});
} catch (e) {
if (e === FOUND) {
return true;
} else {
throw e;
}
}
}
return false;
}));
}
inSwitchCache = Cache.generic(ParserNode, Boolean)();
function hasInSwitch(node) {
var _once;
return inSwitchCache.getOrAdd(node, (_once = false, function (node) {
var _ref, FOUND;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (_ref = inLoopCache.get(node)) {
return _ref;
}
if (node instanceof ParserNode.Yield || node instanceof ParserNode.Return || node instanceof ParserNode.Continue) {
return true;
} else if (!(node instanceof ParserNode.Function)) {
FOUND = {};
try {
node.walk(function (n) {
if (n instanceof ParserNode.For || n instanceof ParserNode.ForIn) {
if (hasInLoop(n)) {
throw FOUND;
}
} else if (hasInSwitch(n)) {
throw FOUND;
}
return n;
});
} catch (e) {
if (e === FOUND) {
return true;
} else {
throw e;
}
}
}
return false;
}));
}
returnFreeCache = Cache.generic(ParserNode, Boolean)();
normalCache = Cache.generic(ParserNode, Boolean)();
function hasGeneratorNode(node, allowReturn) {
var _once;
if (!(node instanceof ParserNode)) {
throw TypeError("Expected node to be a " + __name(ParserNode) + ", got " + __typeof(node));
}
if (allowReturn == null) {
allowReturn = false;
} else if (typeof allowReturn !== "boolean") {
throw TypeError("Expected allowReturn to be a Boolean, got " + __typeof(allowReturn));
}
return (allowReturn ? returnFreeCache : normalCache).getOrAdd(node, (_once = false, function (node) {
var _ref, FOUND;
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
if (!allowReturn && (_ref = returnFreeCache.get(node))) {
return _ref;
}
if (_ref = inLoopCache.get(node)) {
return _ref;
}
if (_ref = inSwitchCache.get(node)) {
return _ref;
}
if (node instanceof ParserNode.Yield || node instanceof ParserNode.Continue || node instanceof ParserNode.Break || !allowReturn && node instanceof ParserNode.Return) {
return true;
} else if (!(node instanceof ParserNode.Function)) {
FOUND = {};
try {
node.walk(function (n) {
if (n instanceof ParserNode.For || n instanceof ParserNode.ForIn) {
if (hasInLoop(n)) {
throw FOUND;
}
} else if (n instanceof ParserNode.Switch) {
if (hasInSwitch(n)) {
throw FOUND;
}
} else if (hasGeneratorNode(n, allowReturn)) {
throw FOUND;
}
return n;
});
} catch (e) {
if (e === FOUND) {
return true;
} else {
throw e;
}
}
}
return false;
}));
}
return hasGeneratorNode;
}
function uid() {
return __strnum(Math.random().toString(36).slice(2)) + "-" + __strnum(new Date().getTime());
}
GeneratorState = (function () {
var _GeneratorState_prototype;
function GeneratorState(builder) {
var _this;
_this = this instanceof GeneratorState ? this : __create(_GeneratorState_prototype);
if (!(builder instanceof GeneratorBuilder)) {
throw TypeError("Expected builder to be a " + __name(GeneratorBuilder) + ", got " + __typeof(builder));
}
_this.builder = builder;
_this.nodes = [];
return _this;
}
_GeneratorState_prototype = GeneratorState.prototype;
GeneratorState.displayName = "GeneratorState";
_GeneratorState_prototype.hasGeneratorNode = function (node) {
return this.builder.hasGeneratorNode(node);
};
_GeneratorState_prototype.add = function (tNode) {
if (typeof tNode !== "function") {
throw TypeError("Expected tNode to be a Function, got " + __typeof(tNode));
}
this.nodes.push(tNode);
return this;
};
_GeneratorState_prototype.branch = function () {
var _ref, state;
state = GeneratorState(this.builder);
if (this.builder.currentCatch.length) {
(_ref = this.builder.currentCatch)[__num(_ref.length) - 1].push(state);
}
this.builder.statesOrder.push(state);
return state;
};
_GeneratorState_prototype.caseId = function () {
return this.builder.caseId(this.getRedirect());
};
_GeneratorState_prototype.makeGoto = function (pos, tState, includeBreak) {
var _this;
_this = this;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (typeof tState !== "function") {
throw TypeError("Expected tState to be a Function, got " + __typeof(tState));
}
if (includeBreak == null) {
includeBreak = false;
} else if (typeof includeBreak !== "boolean") {
throw TypeError("Expected includeBreak to be a Boolean, got " + __typeof(includeBreak));
}
return function () {
var assign, caseId, state;
state = tState();
if (state instanceof GeneratorState) {
caseId = ast.Const(pos, state.caseId());
} else if (state instanceof ast.Node) {
caseId = state;
} else {
throw Error("Expected a GeneratorState or Node, got " + __typeof(state));
}
if (caseId instanceof ast.Const && typeof caseId.value === "number" && caseId.value === __num(_this.caseId()) + 1) {
return ast.Unary(pos, "++", _this.builder.stateIdent);
} else {
assign = ast.Assign(pos, _this.builder.stateIdent, caseId);
if (includeBreak) {
return ast.Block(pos, [assign, ast.Break(pos)]);
} else {
return assign;
}
}
};
};
_GeneratorState_prototype["yield"] = function (pos, tNode) {
var branch;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (typeof tNode !== "function") {
throw TypeError("Expected tNode to be a Function, got " + __typeof(tNode));
}
branch = this.branch();
this.nodes.push(
this.makeGoto(
pos,
function () {
return branch;
},
false
),
function () {
return ast.Return(pos, ast.Obj(pos, [
ast.Obj.Pair(pos, "done", ast.Const(pos, false)),
ast.Obj.Pair(pos, "value", tNode())
]));
}
);
return branch;
};
_GeneratorState_prototype["return"] = function (pos, tNode) {
var _this;
_this = this;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (tNode == null) {
tNode = null;
} else if (typeof tNode !== "function") {
throw TypeError("Expected tNode to be one of Function or null, got " + __typeof(tNode));
}
if (tNode == null) {
this.goto(pos, function () {
return _this.builder.stop;
});
} else {
this.add(this.makeGoto(
pos,
function () {
return _this.builder.stop;
},
false
));
this.add(function () {
return ast.Return(pos, ast.Obj(pos, [
ast.Obj.Pair(pos, "done", ast.Const(pos, true)),
ast.Obj.Pair(pos, "value", tNode())
]));
});
}
};
_GeneratorState_prototype.getRedirect = function () {
return this.builder.getRedirect(this);
};
function getCaseId(pos, value) {
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (value instanceof GeneratorState) {
return ast.Const(pos, value.caseId());
} else if (value instanceof ast.Node) {
return value;
} else {
throw TypeError("Expected a GeneratorState or Node, got " + __typeof(value));
}
}
_GeneratorState_prototype.goto = function (pos, tState, preventRedirect) {
var nodes;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (typeof tState !== "function") {
throw TypeError("Expected tState to be a Function, got " + __typeof(tState));
}
if (preventRedirect == null) {
preventRedirect = false;
} else if (typeof preventRedirect !== "boolean") {
throw TypeError("Expected preventRedirect to be a Boolean, got " + __typeof(preventRedirect));
}
nodes = this.nodes;
if (nodes.length === 0 && !preventRedirect) {
this.builder.addRedirect(this, tState);
}
nodes.push(this.makeGoto(
pos,
function () {
return getCaseId(pos, tState());
},
true
));
};
_GeneratorState_prototype.noop = function (pos) {
var branch;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (this.nodes.length === 0) {
return this;
} else {
branch = this.branch();
this.goto(pos, function () {
return branch;
});
return branch;
}
};
_GeneratorState_prototype.gotoIf = function (pos, tTest, tWhenTrue, tWhenFalse) {
var _this;
_this = this;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (typeof tTest !== "function") {
throw TypeError("Expected tTest to be a Function, got " + __typeof(tTest));
}
if (typeof tWhenTrue !== "function") {
throw TypeError("Expected tWhenTrue to be a Function, got " + __typeof(tWhenTrue));
}
if (typeof tWhenFalse !== "function") {
throw TypeError("Expected tWhenFalse to be a Function, got " + __typeof(tWhenFalse));
}
this.goto(
pos,
function () {
return ast.IfExpression(
pos,
tTest(),
getCaseId(pos, tWhenTrue()),
getCaseId(pos, tWhenFalse())
);
},
true
);
};
_GeneratorState_prototype.pendingFinally = function (pos, tFinallyBody) {
var _this, ident, scope;
_this = this;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (typeof tFinallyBody !== "function") {
throw TypeError("Expected tFinallyBody to be a Function, got " + __typeof(tFinallyBody));
}
scope = this.builder.scope;
ident = scope.reserveIdent(pos, "finally", Type["undefined"]["function"]());
scope.markAsFunction(ident);
this.builder.finallies.push(function () {
return ast.Func(
pos,
ident,
[],
[],
tFinallyBody()
);
});
this.nodes.push(function () {
return ast.Call(
pos,
ast.Access(pos, _this.builder.pendingFinalliesIdent, "push"),
[ident]
);
});
return this;
};
_GeneratorState_prototype.runPendingFinally = function (pos) {
var _this;
_this = this;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
this.nodes.push(function () {
return ast.Call(pos, ast.Call(pos, ast.Access(pos, _this.builder.pendingFinalliesIdent, "pop")));
});
return this;
};
_GeneratorState_prototype.enterTryCatch = function (pos) {
var fresh;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
fresh = this.noop(pos);
this.builder.enterTryCatch(fresh);
return fresh;
};
_GeneratorState_prototype.exitTryCatch = function (pos, tIdent, tPostState) {
var fresh;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
if (typeof tIdent !== "function") {
throw TypeError("Expected tIdent to be a Function, got " + __typeof(tIdent));
}
if (typeof tPostState !== "function") {
throw TypeError("Expected tPostState to be a Function, got " + __typeof(tPostState));
}
this.goto(pos, tPostState);
fresh = this.noop(pos);
this.builder.exitTryCatch(fresh, tIdent);
return fresh;
};
return GeneratorState;
}());
GeneratorBuilder = (function () {
var _GeneratorBuilder_prototype;
function GeneratorBuilder(pos, scope, hasGeneratorNode) {
var _this, sendScope;
_this = this instanceof GeneratorBuilder ? this : __create(_GeneratorBuilder_prototype);
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
_this.pos = pos;
if (!(scope instanceof Scope)) {
throw TypeError("Expected scope to be a " + __name(Scope) + ", got " + __typeof(scope));
}
_this.scope = scope;
if (typeof hasGeneratorNode !== "function") {
throw TypeError("Expected hasGeneratorNode to be a Function, got " + __typeof(hasGeneratorNode));
}
_this.hasGeneratorNode = hasGeneratorNode;
_this.currentCatch = [];
_this.redirects = Map();
_this.start = GeneratorState(_this);
_this.stop = GeneratorState(_this).add(function () {
return ast.Return(pos, ast.Obj(pos, [
ast.Obj.Pair(pos, "done", ast.Const(pos, true)),
ast.Obj.Pair(pos, "value", ast.Const(pos, void 0))
]));
});
_this.statesOrder = [_this.start];
_this.stateIdent = typeof stateIdent !== "undefined" && stateIdent !== null ? stateIdent : scope.reserveIdent(pos, "state", Type.number);
_this.pendingFinalliesIdent = scope.reserveIdent(pos, "finallies", Type["undefined"]["function"]().array());
sendScope = scope.clone(false);
_this.receivedIdent = sendScope.reserveIdent(pos, "received", Type.any);
sendScope.markAsParam(_this.receivedIdent);
_this.finallies = [];
_this.catches = [];
return _this;
}
_GeneratorBuilder_prototype = GeneratorBuilder.prototype;
GeneratorBuilder.displayName = "GeneratorBuilder";
_GeneratorBuilder_prototype.addRedirect = function (fromState, toState) {
if (!(fromState instanceof GeneratorState)) {
throw TypeError("Expected fromState to be a " + __name(GeneratorState) + ", got " + __typeof(fromState));
}
if (typeof toState !== "function") {
throw TypeError("Expected toState to be a Function, got " + __typeof(toState));
}
this.redirects.set(fromState, toState);
};
_GeneratorBuilder_prototype.getRedirect = function (fromState) {
var redirect, redirectFunc;
if (!(fromState instanceof GeneratorState)) {
throw TypeError("Expected fromState to be a " + __name(GeneratorState) + ", got " + __typeof(fromState));
}
redirectFunc = this.redirects.get(fromState);
if (redirectFunc == null) {
return fromState;
} else if (redirectFunc instanceof GeneratorState) {
return redirectFunc;
} else if (typeof redirectFunc === "function") {
redirect = redirectFunc();
if (redirect instanceof GeneratorState) {
redirect = this.getRedirect(redirect);
} else {
throw Error("Expected a GeneratorState, got " + __typeof(redirectFunc));
}
this.redirects.set(fromState, redirect);
return redirect;
} else {
throw Error("Unknown value in redirects: " + __typeof(redirectFunc));
}
};
_GeneratorBuilder_prototype._calculateCaseIds = function () {
var _arr, _i, _len, caseIds, id, state;
id = -1;
caseIds = this.caseIds = Map();
for (_arr = __toArray(this.statesOrder), _i = 0, _len = _arr.length; _i < _len; ++_i) {
state = _arr[_i];
if (!this.redirects.has(state)) {
caseIds.set(state, ++id);
}
}
};
_GeneratorBuilder_prototype.caseId = function (state) {
var caseIds;
if (!(state instanceof GeneratorState)) {
throw TypeError("Expected state to be a " + __name(GeneratorState) + ", got " + __typeof(state));
}
caseIds = this.caseIds;
if (caseIds == null) {
throw Error("_calculate-case-ids must be called first");
}
if (!caseIds.has(state)) {
throw Error("case-ids does not contain state");
}
return caseIds.get(state);
};
_GeneratorBuilder_prototype.enterTryCatch = function (state) {
if (!(state instanceof GeneratorState)) {
throw TypeError("Expected state to be a " + __name(GeneratorState) + ", got " + __typeof(state));
}
this.currentCatch.push([state]);
};
_GeneratorBuilder_prototype.exitTryCatch = function (state, tIdent) {
var catchStates, index;
if (!(state instanceof GeneratorState)) {
throw TypeError("Expected state to be a " + __name(GeneratorState) + ", got " + __typeof(state));
}
if (typeof tIdent !== "function") {
throw TypeError("Expected tIdent to be a Function, got " + __typeof(tIdent));
}
if (this.currentCatch.length === 0) {
throw Error("Unable to exit-try-catch without first using enter-try-catch");
}
catchStates = this.currentCatch.pop();
index = catchStates.indexOf(state);
if (index !== -1) {
catchStates.splice(index, 1);
}
this.catches.push({ tryStates: catchStates, tIdent: tIdent, catchState: state });
};
_GeneratorBuilder_prototype.create = function () {
var _this, body, catches, close, err, f, innerScope, send, sendTryCatch, stateIdent, step, throwIdent;
_this = this;
if (this.currentCatch.length) {
throw Error("Cannot create a generator if there are stray catches");
}
this.statesOrder.push(this.stop);
this._calculateCaseIds();
body = [
ast.Assign(this.pos, this.stateIdent, ast.Const(this.pos, this.start.caseId()))
];
close = this.scope.reserveIdent(this.pos, "close", Type["undefined"]["function"]());
this.scope.markAsFunction(close);
if (this.finallies.length === 0) {
this.scope.removeVariable(this.pendingFinalliesIdent);
body.push(ast.Func(
this.pos,
close,
[],
[],
ast.Block(this.pos, [ast.Assign(this.pos, this.stateIdent, this.stop.caseId())])
));
} else {
body.push(ast.Assign(this.pos, this.pendingFinalliesIdent, ast.Arr(this.pos)));
body.push.apply(body, (function () {
var _arr, _arr2, _i, _len, f;
for (_arr = [], _arr2 = __toArray(_this.finallies), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
f = _arr2[_i];
_arr.push(f());
}
return _arr;
}()));
innerScope = this.scope.clone(false);
f = innerScope.reserveIdent(this.pos, "f", Type["undefined"]["function"]().union(Type["undefined"]));
body.push(ast.Func(
this.pos,
close,
[],
innerScope.getVariables(),
ast.Block(this.pos, [
ast.Assign(this.pos, this.stateIdent, this.stop.caseId()),
ast.Assign(this.pos, f, ast.Call(this.pos, ast.Access(this.pos, this.pendingFinalliesIdent, "pop"))),
ast.If(this.pos, f, ast.TryFinally(
this.pos,
ast.Call(this.pos, f),
ast.Call(this.pos, close)
))
])
));
}
err = this.scope.reserveIdent(this.pos, "e", Type.any);
catches = this.catches;
stateIdent = this.stateIdent;
step = this.scope.reserveIdent(this.pos, "step", Type["function"]);
send = this.scope.reserveIdent(this.pos, "send", Type["function"]);
throwIdent = this.scope.reserveIdent(this.pos, "throw", Type["function"]);
body.push(ast.Func(
this.pos,
step,
[this.receivedIdent],
[],
ast.While(this.pos, true, ast.Switch(
this.pos,
stateIdent,
(function () {
var _arr, _arr2, _arr3, _arr4, _i, _i2, _len, _len2, nodes, state, tNode;
for (_arr = [], _arr2 = __toArray(_this.statesOrder), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
state = _arr2[_i];
if (!_this.redirects.has(state)) {
for (_arr3 = [], _arr4 = __toArray(state.nodes), _i2 = 0, _len2 = _arr4.length; _i2 < _len2; ++_i2) {
tNode = _arr4[_i2];
_arr3.push(tNode());
}
nodes = _arr3;
if (nodes.length === 0) {
throw Error("Found state with no nodes in it");
}
_arr.push(ast.Switch.Case(
nodes[0].pos,
ast.Const(nodes[0].pos, state.caseId()),
ast.Block(nodes[0].pos, nodes)
));
}
}
return _arr;
}()),
ast.Throw(this.pos, ast.Call(
this.pos,
ast.Ident(this.pos, "Error"),
[ast.Binary(this.pos, "Unknown state: ", "+", stateIdent)]
))
))
));
body.push(ast.Func(
this.pos,
throwIdent,
[err],
[],
(function () {
var _arr, _f, _i, current;
current = ast.Block(_this.pos, [
ast.Call(_this.pos, close, []),
ast.Throw(_this.pos, err)
]);
for (_arr = __toArray(catches), _i = _arr.length, _f = function (catchInfo) {
var _this, errIdent;
_this = this;
errIdent = catchInfo.tIdent();
this.scope.addVariable(errIdent);
return current = ast.If(
this.pos,
ast.Or.apply(ast, [this.pos].concat((function () {
var _arr, _arr2, _i, _len, state;
for (_arr = [], _arr2 = __toArray(catchInfo.tryStates), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
state = _arr2[_i];
if (!_this.redirects.has(state)) {
_arr.push(ast.Binary(_this.pos, stateIdent, "===", ast.Const(_this.pos, state.caseId())));
}
}
return _arr;
}()))),
ast.Block(this.pos, [
ast.Assign(this.pos, errIdent, err),
ast.Assign(this.pos, stateIdent, ast.Const(this.pos, catchInfo.catchState.caseId()))
]),
current
);
}; _i--; ) {
_f.call(_this, _arr[_i]);
}
return current;
}())
));
sendTryCatch = ast.TryCatch(
this.pos,
ast.Return(this.pos, ast.Call(this.pos, step, [this.receivedIdent])),
err,
ast.Call(this.pos, throwIdent, [err])
);
body.push(ast.Func(
this.pos,
send,
[this.receivedIdent],
[],
catches.length ? ast.While(this.pos, true, sendTryCatch) : sendTryCatch
));
body.push(ast.Return(this.pos, ast.Obj(this.pos, [
ast.Obj.Pair(this.pos, "close", close),
ast.Obj.Pair(this.pos, "iterator", ast.Func(
this.pos,
null,
[],
[],
ast.Return(this.pos, ast.This(this.pos))
)),
ast.Obj.Pair(this.pos, "next", ast.Func(
this.pos,
null,
[],
[],
ast.Return(this.pos, ast.Call(this.pos, send, [ast.Const(this.pos, void 0)]))
)),
ast.Obj.Pair(this.pos, "send", send),
ast.Obj.Pair(this.pos, "throw", ast.Func(
this.pos,
null,
[err],
[],
ast.Block(this.pos, [
ast.Call(this.pos, throwIdent, [err]),
ast.Return(this.pos, ast.Call(this.pos, send, [ast.Const(this.pos, void 0)]))
])
))
])));
return ast.Block(this.pos, body);
};
return GeneratorBuilder;
}());
function flattenSpreadArray(elements) {
var _arr, _i, _len, changed, element, result;
result = [];
changed = false;
for (_arr = __toArray(elements), _i = 0, _len = _arr.length; _i < _len; ++_i) {
element = _arr[_i];
if (element instanceof ParserNode.Spread && element.node instanceof ParserNode.Array) {
result.push.apply(result, __toArray(element.node.elements));
changed = true;
} else {
result.push(element);
}
}
if (changed) {
return flattenSpreadArray(result);
} else {
return elements;
}
}
function makePos(line, column, file) {
var pos;
if (typeof line !== "number") {
throw TypeError("Expected line to be a Number, got " + __typeof(line));
}
if (typeof column !== "number") {
throw TypeError("Expected column to be a Number, got " + __typeof(column));
}
if (file == null) {
file = void 0;
} else if (typeof file !== "string") {
throw TypeError("Expected file to be one of String or undefined, got " + __typeof(file));
}
pos = { line: line, column: column };
if (file != null) {
pos.file = file;
}
return pos;
}
function getPos(node) {
if (!(node instanceof ParserNode)) {
throw TypeError("Expected node to be a " + __name(ParserNode) + ", got " + __typeof(node));
}
return makePos(node.line, node.column, node.file);
}
function doNothing() {}
generatorTranslate = (function () {
var expressions, statements;
function memoize(func) {
var _ref, result;
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
if (func.memoized) {
return func;
} else {
(_ref = function () {
if (func) {
result = func();
func = null;
}
return result;
}).memoized = true;
return _ref;
}
}
function same(value) {
var _ref;
(_ref = function () {
return value;
}).memoized = true;
return _ref;
}
function maybeMemoize(value) {
if (typeof value === "function") {
return memoize(value);
} else {
return same(value);
}
}
function handleAssign(assignTo, scope, state, tNode, cleanup) {
var nodeNeedsCaching, tAssignTo, tTmp;
if (!(state instanceof GeneratorState)) {
throw TypeError("Expected state to be a " + __name(GeneratorState) + ", got " + __typeof(state));
}
if (typeof tNode !== "function") {
throw TypeError("Expected tNode to be a Function, got " + __typeof(tNode));
}
if (cleanup == null) {
cleanup = doNothing;
} else if (typeof cleanup !== "function") {
throw TypeError("Expected cleanup to be a Function, got " + __typeof(cleanup));
}
if (typeof assignTo === "function") {
tAssignTo = memoize(assignTo);
return {
state: state.add(function () {
var node;
node = tNode();
return ast.Assign(node.pos, tAssignTo(), node);
}),
tNode: tAssignTo,
cleanup: cleanup
};
} else if (assignTo) {
tNode = memoize(tNode);
tTmp = memoize(function () {
return scope.reserveIdent(tNode().pos, "tmp", Type.any);
});
nodeNeedsCaching = memoize(function () {
return tNode() === state.builder.receivedIdent || needsCaching(tNode());
});
return {
state: state.add(function () {
var node;
node = tNode();
if (nodeNeedsCaching()) {
return ast.Assign(node.pos, tTmp(), node);
} else {
return node;
}
}),
tNode: function () {
if (nodeNeedsCaching()) {
return tTmp();
} else {
return tNode();
}
},
cleanup: function () {
cleanup();
if (nodeNeedsCaching()) {
return scope.releaseIdent(tTmp());
}
}
};
} else {
return { state: state, tNode: tNode, cleanup: cleanup };
}
}
function makeTTmp(assignTo, scope, pos, name, type) {
if (name == null) {
name = "tmp";
}
if (type == null) {
type = Type.any;
}
if (typeof assignTo === "function") {
return memoize(assignTo);
} else {
return same(scope.reserveIdent(pos, name, type));
}
}
function makeCleanup(assignTo, scope, tTmp) {
if (typeof tTmp !== "function") {
throw TypeError("Expected tTmp to be a Function, got " + __typeof(tTmp));
}
if (typeof assignTo === "function") {
return function () {
var tmp, value;
value = assignTo();
tmp = tTmp();
if (value === tmp) {
return scope.releaseIdent(tmp);
}
};
} else {
return function () {
return scope.releaseIdent(tTmp());
};
}
}
function generatorArrayTranslate(pos, elements, scope, state, assignTo) {
var _arr, _f, _len, i, tArrayStart, tTmp;
if (!(state instanceof GeneratorState)) {
throw TypeError("Expected state to be a " + __name(GeneratorState) + ", got " + __typeof(state));
}
tTmp = makeTTmp(
assignTo,
scope,
pos,
"arr",
Type.array
);
tArrayStart = null;
for (_arr = __toArray(elements), i = 0, _len = _arr.length, _f = function (element, i) {
var expr;
if (tArrayStart || state.hasGeneratorNode(element)) {
if (tArrayStart == null) {
tArrayStart = arrayTranslate(
pos,
__slice.call(elements, 0, i),
scope,
true,
false
);
state = state.add(function () {
return ast.Assign(pos, tTmp(), tArrayStart());
});
}
if (element instanceof ParserNode.Spread) {
expr = generatorTranslateExpression(element.node, scope, state, false);
return state = expr.state.add(function () {
var _ref, tmp;
tmp = tTmp();
scope.addHelper("__toArray");
return ast.Call(
getPos(element),
ast.Access(
getPos(element),
tmp,
ast.Const(getPos(element), "push"),
ast.Const(getPos(element), "apply")
),
[
tmp,
ast.Call(
getPos(element),
ast.Ident(getPos(element), "__toArray"),
[(_ref = expr.tNode(), expr.cleanup(), _ref)]
)
]
);
});
} else {
expr = generatorTranslateExpression(element, scope, state, false);
return state = expr.state.add(function () {
var _ref;
return ast.Call(
getPos(element),
ast.Access(getPos(element), tTmp(), ast.Const(getPos(element), "push")),
[(_ref = expr.tNode(), expr.cleanup(), _ref)]
);
});
}
}
}; i < _len; ++i) {
_f.call(this, _arr[i], i);
}
if (tArrayStart == null) {
return {
state: state,
tNode: arrayTranslate(
pos,
elements,
scope,
true,
false
),
cleanup: doNothing
};
} else {
return {
state: state,
tNode: tTmp,
cleanup: makeCleanup(assignTo, scope, tTmp)
};
}
}
expressions = {
Access: function (node, scope, state, assignTo) {
var gChild, gParent;
gParent = generatorTranslateExpression(node.parent, scope, state, true);
gChild = generatorTranslateExpression(node.child, scope, gParent.state, false);
return handleAssign(assignTo, scope, gChild.state, function () {
var _ref;
_ref = ast.Access(getPos(node), gParent.tNode(), gChild.tNode());
gParent.cleanup();
gChild.cleanup();
return _ref;
});
},
Array: function (node, scope, state, assignTo) {
return generatorArrayTranslate(
getPos(node),
node.elements,
scope,
state,
assignTo
);
},
Assign: function (node, scope, state, assignTo) {
var gChild, gLeft, gParent, gRight, left;
left = node.left;
if (left instanceof ParserNode.Access) {
gParent = generatorTranslateExpression(left.parent, scope, state, true);
gChild = generatorTranslateExpression(left.child, scope, gParent.state, true);
gLeft = {
state: gChild.state,
tNode: function () {
return ast.Access(getPos(left), gParent.tNode(), gChild.tNode());
},
cleanup: function () {
gParent.cleanup();
return gChild.cleanup();
}
};
} else {
gLeft = {
state: state,
tNode: translate(node.left, scope, "leftExpression"),
cleanup: doNothing
};
}
gRight = generatorTranslateExpression(node.right, scope, gLeft.state, gLeft.tNode);
return handleAssign(
assignTo,
scope,
gRight.state,
gRight.tNode,
function () {
gLeft.cleanup();
return gRight.cleanup();
}
);
},
Binary: (function () {
var lazyOps;
lazyOps = {
"&&": function (node, scope, state, assignTo) {
var gLeft, gRight, postBranch, tNode, whenTrueBranch;
gLeft = generatorTranslateExpression(node.left, scope, state, assignTo || true);
tNode = memoize(gLeft.tNode);
gLeft.state.gotoIf(
getPos(node),
tNode,
function () {
return whenTrueBranch;
},
function () {
return postBranch;
}
);
whenTrueBranch = gLeft.state.branch();
gRight = generatorTranslateExpression(node.right, scope, whenTrueBranch, tNode);
gRight.state.goto(getPos(node), function () {
return postBranch;
});
postBranch = gLeft.state.branch();
return {
tNode: tNode,
state: postBranch,
cleanup: function () {
gLeft.cleanup();
return gRight.cleanup();
}
};
},
"||": function (node, scope, state, assignTo) {
var gLeft, gRight, postBranch, tNode, whenFalseBranch;
gLeft = generatorTranslateExpression(node.left, scope, state, assignTo || true);
tNode = memoize(gLeft.tNode);
gLeft.state.gotoIf(
getPos(node),
tNode,
function () {
return postBranch;
},
function () {
return whenFalseBranch;
}
);
whenFalseBranch = gLeft.state.branch();
gRight = generatorTranslateExpression(node.right, scope, whenFalseBranch, tNode);
gRight.state.goto(getPos(node), function () {
return postBranch;
});
postBranch = gLeft.state.branch();
return {
tNode: tNode,
state: postBranch,
cleanup: function () {
gLeft.cleanup();
return gRight.cleanup();
}
};
}
};
return function (node, scope, state, assignTo) {
var gLeft, gRight;
if (__owns.call(lazyOps, node.op)) {
return lazyOps[node.op](node, scope, state, assignTo);
} else {
gLeft = generatorTranslateExpression(node.left, scope, state, true);
gRight = generatorTranslateExpression(node.right, scope, gLeft.state, false);
return handleAssign(assignTo, scope, gRight.state, function () {
var _ref;
return ast.Binary(
getPos(node),
gLeft.tNode(),
(gLeft.cleanup(), node.op),
(_ref = gRight.tNode(), gRight.cleanup(), _ref)
);
});
}
};
}()),
Block: function (node, scope, state, assignTo) {
var _arr, i, len, result, subnode;
for (_arr = __toArray(node.nodes), i = 0, len = _arr.length; i < len; ++i) {
subnode = _arr[i];
result = generatorTranslateExpression(subnode, scope, state, i === len - 1 && assignTo);
state = result.state;
if (i === len - 1) {
return result;
}
}
throw Error("Unreachable state");
},
Call: function (node, scope, state, assignTo) {
var args, gArgs, gFunc, gStart, isApply, isNew;
gFunc = generatorTranslateExpression(node.func, scope, state, true);
isApply = node.isApply;
isNew = node.isNew;
args = node.args;
if (isApply && (args.length === 0 || !(args[0] instanceof ParserNode.Spread))) {
if (args.length === 0) {
gStart = {
state: gFunc.state,
tNode: function () {
return ast.Const(getPos(node), void 0);
},
cleanup: doNothing
};
} else {
gStart = generatorTranslateExpression(args[0], scope, gFunc.state, true);
}
gArgs = generatorArrayTranslate(
getPos(node),
__slice.call(args, 1),
scope,
gStart.state
);
return handleAssign(assignTo, scope, gArgs.state, function () {
var args, func, start;
func = gFunc.tNode();
start = gStart.tNode();
args = gArgs.tNode();
gFunc.cleanup();
gStart.cleanup();
gArgs.cleanup();
if (args instanceof ast.Arr) {
return ast.Call(
getPos(node),
ast.Access(getPos(node), func, "call"),
[start].concat(__toArray(args.elements))
);
} else {
return ast.Call(
getPos(node),
ast.Access(getPos(node), func, "apply"),
[start, args]
);
}
});
} else {
gArgs = generatorArrayTranslate(getPos(node), args, scope, gFunc.state);
return handleAssign(assignTo, scope, gArgs.state, function () {
var args, func;
func = gFunc.tNode();
args = gArgs.tNode();
gFunc.cleanup();
gArgs.cleanup();
if (isApply) {
return ast.Call(
getPos(node),
ast.Access(getPos(node), func, "apply"),
[
ast.Access(getPos(node), args, ast.Const(getPos(node), 0)),
ast.Call(
getPos(node),
ast.Access(getPos(node), args, ast.Const(getPos(node), "slice")),
[ast.Const(getPos(node), 1)]
)
]
);
} else if (isNew) {
scope.addHelper("__new");
return ast.Call(
getPos(node),
ast.Access(
getPos(node),
ast.Ident(getPos(node), "__new"),
ast.Const(getPos(node), "apply")
),
[func, args]
);
} else if (args instanceof ast.Arr) {
return ast.Call(
getPos(node),
ast.Access(getPos(node), func, "call"),
[
func instanceof ast.Binary && func.op === "." ? func.left : ast.Const(getPos(node), void 0)
].concat(__toArray(args.elements))
);
} else {
return ast.Call(
getPos(node),
ast.Access(getPos(node), func, "apply"),
[
func instanceof ast.Binary && func.op === "." ? func.left : ast.Const(getPos(node), void 0),
args
]
);
}
});
}
},
EmbedWrite: function (node, scope, state, assignTo) {
var gText;
gText = generatorTranslateExpression(node.text, scope, state, false);
return handleAssign(
assignTo,
scope,
gText.state,
function () {
return ast.Call(
getPos(node),
ast.Ident(getPos(node), "write"),
[gText.tNode()].concat(node.escape
? [ast.Const(getPos(node), true)]
: [])
);
},
gText.cleanup
);
},
Eval: function (node, scope, state, assignTo) {
var gCode;
gCode = generatorTranslateExpression(node.code, scope, state, false);
return handleAssign(assignTo, scope, gCode.state, function () {
return ast.Eval(getPos(node), gCode.tNode(), gCode.cleanup);
});
},
If: function (node, scope, state, assignTo) {
var cleanup, gWhenFalse, gWhenTrue, postBranch, test, tTmp, tWhenFalse, tWhenTrue, whenFalseBranch, whenTrueBranch;
test = generatorTranslateExpression(node.test, scope, state, state.hasGeneratorNode(node.test));
state = test.state;
if (state.hasGeneratorNode(node.whenTrue) || state.hasGeneratorNode(node.whenFalse)) {
state.gotoIf(
getPos(node),
function () {
var _ref;
_ref = test.tNode();
test.cleanup();
return _ref;
},
function () {
return whenTrueBranch;
},
function () {
return whenFalseBranch;
}
);
tTmp = makeTTmp(assignTo, scope, getPos(node));
whenTrueBranch = state.branch();
gWhenTrue = generatorTranslateExpression(node.whenTrue, scope, whenTrueBranch, tTmp);
gWhenTrue.state.goto(getPos(node.whenTrue), function () {
return postBranch;
});
whenFalseBranch = state.branch();
gWhenFalse = generatorTranslateExpression(node.whenFalse, scope, whenFalseBranch, tTmp);
gWhenFalse.state.goto(getPos(node.whenFalse), function () {
return postBranch;
});
postBranch = state.branch();
cleanup = makeCleanup(assignTo, scope, tTmp);
return {
state: postBranch,
tNode: tTmp,
cleanup: function () {
gWhenTrue.cleanup();
gWhenFalse.cleanup();
return cleanup();
}
};
} else {
tWhenTrue = translate(node.whenTrue, scope, "expression");
tWhenFalse = translate(node.whenFalse, scope, "expression");
return handleAssign(assignTo, scope, state, function () {
return ast.If(
getPos(node),
test.tNode(),
(test.cleanup(), tWhenTrue()),
tWhenFalse()
);
});
}
},
Regexp: function (node, scope, state, assignTo) {
var gSource;
gSource = generatorTranslateExpression(node.source, scope, state, false);
return handleAssign(
assignTo,
scope,
state,
function () {
var source;
source = gSource.tNode();
if (source.isConst()) {
return ast.Regex(getPos(node), String(source.constValue()), node.flags);
} else {
return ast.Call(
getPos(node),
ast.Ident(getPos(node), "RegExp"),
[
source,
ast.Const(getPos(node), flags)
]
);
}
},
gSource.cleanup
);
},
TmpWrapper: function (node, scope, state, assignTo) {
var gNode;
gNode = generatorTranslateExpression(node.node, scope, state, false);
return handleAssign(
assignTo,
scope,
gNode.state,
gNode.tNode,
function () {
var _arr, _i, tmp;
gNode.cleanup();
for (_arr = __toArray(node.tmps), _i = _arr.length; _i--; ) {
tmp = _arr[_i];
scope.releaseTmp(tmp);
}
}
);
},
Unary: function (node, scope, state, assignTo) {
var gNode;
gNode = generatorTranslateExpression(node.node, scope, state, false);
return handleAssign(assignTo, scope, gNode.state, function () {
var _ref;
return ast.Unary(getPos(node), node.op, (_ref = gNode.tNode(), gNode.cleanup(), _ref));
});
},
Yield: function (node, scope, state, assignTo) {
var gNode;
gNode = generatorTranslateExpression(node.node, scope, state, false);
state = state["yield"](getPos(node), gNode.tNode);
return handleAssign(
assignTo,
scope,
state,
function () {
return state.builder.receivedIdent;
},
gNode.cleanup
);
}
};
function generatorTranslateExpression(node, scope, state, assignTo) {
var key;
if (!(node instanceof ParserNode)) {
throw TypeError("Expected node to be a " + __name(ParserNode) + ", got " + __typeof(node));
}
if (!(scope instanceof Scope)) {
throw TypeError("Expected scope to be a " + __name(Scope) + ", got " + __typeof(scope));
}
if (!(state instanceof GeneratorState)) {
throw TypeError("Expected state to be a " + __name(GeneratorState) + ", got " + __typeof(state));
}
if (assignTo == null) {
assignTo = false;
} else if (typeof assignTo !== "boolean" && typeof assignTo !== "function") {
throw TypeError("Expected assignTo to be one of Boolean or Function, got " + __typeof(assignTo));
}
key = node.constructor.cappedName;
if (state.hasGeneratorNode(node)) {
if (__owns.call(expressions, key)) {
return expressions[key](node, scope, state, assignTo);
} else {
throw Error("Unknown expression type: " + __typeof(node));
}
} else {
return handleAssign(assignTo, scope, state, translate(node, scope, "expression"));
}
}
statements = {
Block: function (node, scope, state, breakState, continueState) {
var _arr, _i, _len, acc, subnode;
if (node.label != null) {
throw Error("Not implemented: block with label in generator");
}
acc = state;
for (_arr = __toArray(node.nodes), _i = 0, _len = _arr.length; _i < _len; ++_i) {
subnode = _arr[_i];
acc = generatorTranslate(
subnode,
scope,
acc,
breakState,
continueState
);
}
return acc;
},
Break: function (node, scope, state, breakState) {
if (node.label != null) {
throw Error("Not implemented: break with label in a generator");
}
if (breakState == null) {
throw Error("break found outside of a loop or switch");
}
state.goto(getPos(node), breakState);
return state;
},
Continue: function (node, scope, state, breakState, continueState) {
if (node.label != null) {
throw Error("Not implemented: break with label in a generator");
}
if (continueState == null) {
throw Error("continue found outside of a loop");
}
state.goto(getPos(node), continueState);
return state;
},
For: function (node, scope, state) {
var bodyBranch, gTest, postBranch, stepBranch, testBranch;
if (node.label != null) {
throw Error("Not implemented: for with label in generator");
}
if (node.init != null && !(node.init instanceof ParserNode.Nothing)) {
state = generatorTranslate(node.init, scope, state);
}
state.goto(getPos(node), function () {
return testBranch;
});
testBranch = state.branch();
gTest = generatorTranslateExpression(node.test, scope, testBranch, state.hasGeneratorNode(node.test));
testBranch.gotoIf(
getPos(node.test),
function () {
var _ref;
_ref = gTest.tNode();
gTest.cleanup();
return _ref;
},
function () {
return bodyBranch;
},
function () {
return postBranch;
}
);
bodyBranch = state.branch();
generatorTranslate(
node.body,
scope,
bodyBranch,
function () {
return postBranch;
},
function () {
return stepBranch;
}
).goto(getPos(node.body), function () {
return stepBranch || testBranch;
});
stepBranch = null;
if (node.step != null && !(node.step instanceof ParserNode.Nothing)) {
stepBranch = state.branch();
generatorTranslate(node.step, scope, stepBranch).goto(getPos(node.step), function () {
return testBranch;
});
}
postBranch = state.branch();
return postBranch;
},
ForIn: function (node, scope, state) {
var bodyBranch, getKey, gObject, index, keys, length, postBranch, stepBranch, testBranch, tKey;
if (node.label != null) {
throw Error("Not implemented: for-in with label in generator");
}
tKey = translate(node.key, scope, "leftExpression");
gObject = generatorTranslateExpression(node.object, scope, state, false);
state = gObject.state;
keys = scope.reserveIdent(getPos(node), "keys", Type.string.array());
getKey = memoize(function () {
var key;
key = tKey();
if (!(key instanceof ast.Ident)) {
throw Error("Expected an Ident for a for-in key");
}
scope.addVariable(key, Type.string);
return key;
});
index = scope.reserveIdent(getPos(node), "i", Type.number);
length = scope.reserveIdent(getPos(node), "len", Type.number);
scope.addHelper("__allkeys");
state = state.add(function () {
var _ref;
return ast.Block(getPos(node), [
ast.Assign(getPos(node), keys, ast.Call(
getPos(node),
ast.Ident(getPos(node), "__allkeys"),
[(_ref = gObject.tNode(), gObject.cleanup(), _ref)]
)),
ast.Assign(getPos(node), index, 0),
ast.Assign(getPos(node), length, ast.Access(getPos(node), keys, "length"))
]);
});
state.goto(getPos(node), function () {
return testBranch;
});
testBranch = state.branch();
testBranch.gotoIf(
getPos(node),
function () {
return ast.Binary(getPos(node), index, "<", length);
},
function () {
return bodyBranch;
},
function () {
return postBranch;
}
);
bodyBranch = testBranch.branch();
state = bodyBranch.add(function () {
return ast.Assign(getPos(node), getKey(), ast.Access(getPos(node), keys, index));
});
generatorTranslate(
node.body,
scope,
state,
function () {
return postBranch;
},
function () {
return stepBranch;
}
).goto(getPos(node.body), function () {
return stepBranch;
});
stepBranch = bodyBranch.branch();
stepBranch.add(function () {
return ast.Unary(getPos(node), "++", index);
}).goto(getPos(node), function () {
return testBranch;
});
postBranch = stepBranch.branch();
return postBranch;
},
If: function (node, scope, state, breakState, continueState) {
var postBranch, test, tWhenFalse, tWhenTrue, whenFalseBranch, whenTrueBranch;
test = generatorTranslateExpression(node.test, scope, state, state.hasGeneratorNode(node.test));
state = test.state;
if (state.hasGeneratorNode(node.whenTrue) || state.hasGeneratorNode(node.whenFalse)) {
state.gotoIf(
getPos(node),
function () {
var _ref;
_ref = test.tNode();
test.cleanup();
return _ref;
},
function () {
return whenTrueBranch || postBranch;
},
function () {
return whenFalseBranch || postBranch;
}
);
if (node.whenTrue && !(node.whenTrue instanceof ParserNode.Nothing)) {
whenTrueBranch = state.branch();
}
if (whenTrueBranch) {
generatorTranslate(
node.whenTrue,
scope,
whenTrueBranch,
breakState,
continueState
).goto(getPos(node.whenTrue), function () {
return postBranch;
});
}
if (node.whenFalse && !(node.whenFalse instanceof ParserNode.Nothing)) {
whenFalseBranch = state.branch();
}
if (whenFalseBranch) {
generatorTranslate(
node.whenFalse,
scope,
whenFalseBranch,
breakState,
continueState
).goto(getPos(node.whenFalse), function () {
return postBranch;
});
}
postBranch = state.branch();
return postBranch;
} else {
tWhenTrue = translate(node.whenTrue, scope, "statement");
tWhenFalse = translate(node.whenFalse, scope, "statement");
return state.add(function () {
return ast.If(
getPos(node),
test.tNode(),
(test.cleanup(), tWhenTrue()),
tWhenFalse()
);
});
}
},
Return: function (node, scope, state) {
var gNode, pos;
pos = getPos(node);
if (node.node.isConst() && node.node.constValue() === void 0) {
state["return"](getPos(node));
return state;
} else {
gNode = generatorTranslateExpression(node.node, scope, state, false);
state = gNode.state;
state["return"](getPos(node), function () {
var _ref;
_ref = gNode.tNode();
gNode.cleanup();
return _ref;
});
return state;
}
},
Switch: function (node, scope, state, _p, continueState) {
var _arr, _f, _len, bodyStates, defaultBranch, defaultCase, gDefaultBody, gNode, i, postBranch, resultCases;
if (node.label != null) {
throw Error("Not implemented: switch with label in generator");
}
gNode = generatorTranslateExpression(node.node, scope, state, false);
bodyStates = [];
resultCases = [];
gNode.state.add(function () {
return ast.Switch(
getPos(node),
gNode.tNode(),
(function () {
var _arr, _i, _len, case_;
for (_arr = [], _i = 0, _len = resultCases.length; _i < _len; ++_i) {
case_ = resultCases[_i];
_arr.push(case_());
}
return _arr;
}()),
defaultCase()
);
});
gNode.state.add(function () {
return ast.Break(getPos(node));
});
for (_arr = __toArray(node.cases), i = 0, _len = _arr.length, _f = function (case_, i) {
var caseBranch, gCaseBody, tCaseNode, tGoto;
if (state.hasGeneratorNode(case_.node)) {
throw Error("Cannot use yield in the check of a switch's case");
}
tCaseNode = translate(case_.node, scope, "expression");
caseBranch = gNode.state.branch();
bodyStates[i] = caseBranch;
gCaseBody = generatorTranslate(
case_.body,
scope,
caseBranch,
function () {
return postBranch;
},
continueState
);
gCaseBody.goto(getPos(case_.node), case_.fallthrough
? function () {
return bodyStates[i + 1] || postBranch;
}
: function () {
return postBranch;
});
tGoto = caseBranch.makeGoto(getPos(case_.node), function () {
return caseBranch;
});
return resultCases.push(function () {
return ast.Switch.Case(getPos(case_.node), tCaseNode(), ast.Block(getPos(case_.node), [tGoto(), ast.Break(getPos(case_.node))]));
});
}; i < _len; ++i) {
_f.call(this, _arr[i], i);
}
if (node.defaultCase != null) {
defaultBranch = gNode.state.branch();
gDefaultBody = generatorTranslate(
node.defaultCase,
scope,
defaultBranch,
function () {
return postBranch;
},
continueState
);
gDefaultBody.goto(getPos(node.defaultCase), function () {
return postBranch;
});
defaultCase = defaultBranch.makeGoto(getPos(node.defaultCase), function () {
return defaultBranch;
});
} else {
defaultCase = gNode.state.makeGoto(getPos(node), function () {
return postBranch;
});
}
postBranch = state.branch();
return postBranch;
},
Throw: function (node, scope, state, breakState, continueState) {
var gNode;
gNode = generatorTranslateExpression(node.node, scope, state, false);
return gNode.state.add(function () {
var _ref;
return ast.Throw(getPos(node), (_ref = gNode.tNode(), gNode.cleanup(), _ref));
});
},
TmpWrapper: function (node, scope, state, breakState, continueState) {
var _arr, _i, result, tmp;
result = generatorTranslate(
node.node,
scope,
state,
breakState,
continueState
);
for (_arr = __toArray(node.tmps), _i = _arr.length; _i--; ) {
tmp = _arr[_i];
scope.releaseTmp(tmp);
}
return result;
},
TryCatch: function (node, scope, state, breakState, continueState) {
var postBranch;
if (node.label != null) {
throw Error("Not implemented: try-catch with label in generator");
}
state = state.enterTryCatch(getPos(node));
state = generatorTranslate(
node.tryBody,
scope,
state,
breakState,
continueState
);
state = state.exitTryCatch(
getPos(node.tryBody),
translate(node.catchIdent, scope, "leftExpression", false),
function () {
return postBranch;
}
);
state = generatorTranslate(
node.catchBody,
scope,
state,
breakState,
continueState
);
state.goto(getPos(node), function () {
return postBranch;
});
postBranch = state.branch();
return postBranch;
},
TryFinally: function (node, scope, state, breakState, continueState) {
if (node.label != null) {
throw Error("Not implemented: try-finally with label in generator");
}
if (state.hasGeneratorNode(node.finallyBody)) {
throw Error("Cannot use yield in a finally");
}
state = state.pendingFinally(getPos(node), translate(node.finallyBody, scope, "statement"));
state = generatorTranslate(
node.tryBody,
scope,
state,
breakState,
continueState
);
return state.runPendingFinally(getPos(node));
},
Yield: function (node, scope, state) {
var gNode;
gNode = generatorTranslateExpression(node.node, scope, state, false);
return state["yield"](getPos(node), function () {
var _ref;
_ref = gNode.tNode();
gNode.cleanup();
return _ref;
});
}
};
return function (node, scope, state, breakState, continueState) {
var key, ret;
if (!(node instanceof ParserNode)) {
throw TypeError("Expected node to be a " + __name(ParserNode) + ", got " + __typeof(node));
}
if (!(scope instanceof Scope)) {
throw TypeError("Expected scope to be a " + __name(Scope) + ", got " + __typeof(scope));
}
if (!(state instanceof GeneratorState)) {
throw TypeError("Expected state to be a " + __name(GeneratorState) + ", got " + __typeof(state));
}
if (state.hasGeneratorNode(node)) {
key = node.constructor.cappedName;
if (__owns.call(statements, key)) {
ret = statements[key](
node,
scope,
state,
breakState,
continueState
);
if (!(ret instanceof GeneratorState)) {
throw Error("Translated non-GeneratorState from " + __typeof(node) + ": " + __typeof(ret));
}
return ret;
} else {
ret = generatorTranslateExpression(node, scope, state);
return ret.state.add(function () {
var _ref;
_ref = ret.tNode();
ret.cleanup();
return _ref;
});
}
} else {
return state.add(translate(node, scope, "statement", false));
}
};
}());
function arrayTranslate(pos, elements, scope, replaceWithSlice, allowArrayLike, unassigned) {
var _arr, _f, _i, _len, current, element, i, translatedItems;
if (typeof pos !== "object" || pos === null) {
throw TypeError("Expected pos to be an Object, got " + __typeof(pos));
}
translatedItems = [];
current = [];
translatedItems.push(current);
for (_arr = __toArray(flattenSpreadArray(elements)), _i = 0, _len = _arr.length; _i < _len; ++_i) {
element = _arr[_i];
if (element instanceof ParserNode.Spread) {
translatedItems.push({
tNode: translate(
element.node,
scope,
"expression",
null,
unassigned
),
type: element.node.type()
});
current = [];
translatedItems.push(current);
} else {
current.push(translate(
element,
scope,
"expression",
null,
unassigned
));
}
}
if (translatedItems.length === 1) {
return function () {
return ast.Arr(pos, (function () {
var _arr, _arr2, _i, _len, tItem;
for (_arr = [], _arr2 = __toArray(translatedItems[0]), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
tItem = _arr2[_i];
_arr.push(tItem());
}
return _arr;
}()));
};
} else {
for (i = translatedItems.length, _f = function (translatedItem, i) {
if (i % 2 === 0) {
if (__num(translatedItem.length) > 0) {
return translatedItems[i] = function () {
var _arr, _arr2, _i, _len, items, tItem;
for (_arr = [], _arr2 = __toArray(translatedItem), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
tItem = _arr2[_i];
_arr.push(tItem());
}
items = _arr;
return ast.Arr(items[0].pos, items);
};
} else {
return translatedItems.splice(i, 1);
}
} else {
return translatedItems[i] = function () {
var node;
node = translatedItem.tNode();
if (translatedItem.type.isSubsetOf(Type.array)) {
return node;
} else {
scope.addHelper("__toArray");
return ast.Call(
node.pos,
ast.Ident(node.pos, "__toArray"),
[node]
);
}
};
}
}; i--; ) {
_f.call(this, translatedItems[i], i);
}
if (translatedItems.length === 1) {
return function () {
var array;
array = translatedItems[0]();
if (replaceWithSlice && array instanceof ast.Call && array.func instanceof ast.Ident && array.func.name === "__toArray") {
return ast.Call(
pos,
ast.Access(
pos,
ast.Ident(pos, "__slice"),
"call"
),
array.args
);
} else if (allowArrayLike && array instanceof ast.Call && array.func instanceof ast.Ident && array.func.name === "__toArray" && array.args[0] instanceof ast.Arguments) {
return array.args[0];
} else {
return array;
}
};
} else {
return function () {
var _arr, _i, _len, head, item, rest;
head = translatedItems[0]();
for (_arr = [], _i = 1, _len = translatedItems.length; _i < _len; ++_i) {
item = translatedItems[_i];
_arr.push(item());
}
rest = _arr;
return ast.Call(
pos,
ast.Access(pos, head, "concat"),
rest
);
};
}
}
}
translators = {
Access: function (node, scope, location, autoReturn, unassigned) {
var tChild, tParent;
tParent = translate(
node.parent,
scope,
"expression",
null,
unassigned
);
tChild = translate(
node.child,
scope,
"expression",
null,
unassigned
);
return function () {
return autoReturn(ast.Access(getPos(node), tParent(), tChild()));
};
},
Args: function (node, scope, location, autoReturn) {
return function () {
return autoReturn(ast.Arguments(getPos(node)));
};
},
Array: function (node, scope, location, autoReturn, unassigned) {
var tArr;
tArr = arrayTranslate(
getPos(node),
node.elements,
scope,
true,
false,
unassigned
);
return function () {
return autoReturn(tArr());
};
},
Assign: function (node, scope, location, autoReturn, unassigned) {
var op, tLeft, tRight;
op = node.op;
tLeft = translate(node.left, scope, "leftExpression");
tRight = translate(
node.right,
scope,
"expression",
null,
unassigned
);
if (unassigned && node.left instanceof ParserNode.Ident) {
if (op === "=" && unassigned[node.left.name] && node.right.isConst() && node.right.constValue() === void 0) {
return function () {
return ast.Noop(getPos(node));
};
}
unassigned[node.left.name] = false;
}
return function () {
var func, left, right;
left = tLeft();
right = tRight();
if (op === "=" && location === "topStatement" && left instanceof ast.Ident && right instanceof ast.Func && right.name == null && scope.hasOwnVariable(left) && !scope.isVariableMutable(left)) {
scope.markAsFunction(left);
func = ast.Func(
getPos(node),
left,
right.params,
right.variables,
right.body,
right.declarations
);
if (autoReturn !== identity) {
return ast.Block(getPos(node), [func, autoReturn(left)]);
} else {
return func;
}
} else {
return autoReturn(ast.Binary(getPos(node), left, op, right));
}
};
},
Binary: function (node, scope, location, autoReturn, unassigned) {
var tLeft, tRight;
tLeft = translate(
node.left,
scope,
"expression",
null,
unassigned
);
tRight = translate(
node.right,
scope,
"expression",
null,
unassigned
);
return function () {
return autoReturn(ast.Binary(getPos(node), tLeft(), node.op, tRight()));
};
},
Block: function (node, scope, location, autoReturn, unassigned) {
var tLabel, tNodes;
tLabel = node.label && translate(node.label, scope, "label");
tNodes = translateArray(
node.nodes,
scope,
location,
autoReturn,
unassigned
);
return function () {
return ast.Block(
getPos(node),
(function () {
var _arr, _arr2, _i, _len, tNode;
for (_arr = [], _arr2 = __toArray(tNodes), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
tNode = _arr2[_i];
_arr.push(tNode());
}
return _arr;
}()),
typeof tLabel === "function" ? tLabel() : void 0
);
};
},
Break: function (node, scope) {
var tLabel;
tLabel = node.label && translate(node.label, scope, "label");
return function () {
return ast.Break(getPos(node), typeof tLabel === "function" ? tLabel() : void 0);
};
},
Call: function (node, scope, location, autoReturn, unassigned) {
var args, isApply, isNew, tArgArray, tFunc, tStart;
tFunc = translate(
node.func,
scope,
"expression",
null,
unassigned
);
isApply = node.isApply;
isNew = node.isNew;
args = node.args;
if (isApply && (args.length === 0 || !(args[0] instanceof ParserNode.Spread))) {
if (args.length === 0) {
tStart = function () {
return ast.Const(getPos(node), void 0);
};
} else {
tStart = translate(
args[0],
scope,
"expression",
null,
unassigned
);
}
tArgArray = arrayTranslate(
getPos(node),
__slice.call(args, 1),
scope,
false,
true,
unassigned
);
return function () {
var argArray, func, start;
func = tFunc();
start = tStart();
argArray = tArgArray();
if (argArray instanceof ast.Arr) {
return autoReturn(ast.Call(
getPos(node),
ast.Access(getPos(node), func, "call"),
[start].concat(__toArray(argArray.elements))
));
} else {
return autoReturn(ast.Call(
getPos(node),
ast.Access(getPos(node), func, "apply"),
[start, argArray]
));
}
};
} else {
tArgArray = arrayTranslate(
getPos(node),
args,
scope,
false,
true,
unassigned
);
return function () {
var _once, _once2, argArray, func;
func = tFunc();
argArray = tArgArray();
if (isApply) {
return scope.maybeCache(argArray, Type.array, (_once = false, function (setArray, array) {
if (_once) {
throw Error("Attempted to call function more than once");
} else {
_once = true;
}
scope.addHelper("__slice");
return autoReturn(ast.Call(
getPos(node),
ast.Access(getPos(node), func, "apply"),
[
ast.Access(getPos(node), setArray, 0),
ast.Call(
getPos(node),
ast.Access(
getPos(node),
ast.Ident(getPos(node), "__slice"),
"call"
),
[
array,
ast.Const(getPos(node), 1)
]
)
]
));
}));
} else if (argArray instanceof ast.Arr) {
return autoReturn(ast.Call(getPos(node), func, argArray.elements, isNew));
} else if (isNew) {
scope.addHelper("__new");
return autoReturn(ast.Call(
getPos(node),
ast.Access(
getPos(node),
ast.Ident(getPos(node), "__new"),
ast.Const(getPos(node), "apply")
),
[func, argArray]
));
} else if (func instanceof ast.Binary && func.op === ".") {
return scope.maybeCache(func.left, Type["function"], (_once2 = false, function (setParent, parent) {
if (_once2) {
throw Error("Attempted to call function more than once");
} else {
_once2 = true;
}
return autoReturn(ast.Call(
getPos(node),
ast.Access(getPos(node), setParent, func.right, "apply"),
[parent, argArray]
));
}));
} else {
return autoReturn(ast.Call(
getPos(node),
ast.Access(getPos(node), func, "apply"),
[
ast.Const(getPos(node), void 0),
argArray
]
));
}
};
}
},
Comment: function (node, scope, location, autoReturn) {
return function () {
return ast.Comment(getPos(node), node.text);
};
},
Const: function (node, scope, location, autoReturn) {
return function () {
return autoReturn(ast.Const(getPos(node), node.value));
};
},
Continue: function (node, scope) {
var tLabel;
tLabel = node.label && translate(node.label, scope, "label");
return function () {
return ast.Continue(getPos(node), typeof tLabel === "function" ? tLabel() : void 0);
};
},
Debugger: function (node) {
return function () {
return ast.Debugger(getPos(node));
};
},
Def: function (node, scope, location, autoReturn) {
throw Error("Cannot have a stray def");
},
EmbedWrite: function (node, scope, location, autoReturn, unassigned) {
var tText;
tText = translate(
node.text,
scope,
"expression",
null,
unassigned
);
return function () {
return ast.Call(
getPos(node),
ast.Ident(getPos(node), "write"),
[tText()].concat(node.escape
? [ast.Const(getPos(node), true)]
: [])
);
};
},
Eval: function (node, scope, location, autoReturn, unassigned) {
var tCode;
tCode = translate(
node.code,
scope,
"expression",
null,
unassigned
);
return function () {
return autoReturn(ast.Eval(getPos(node), tCode()));
};
},
For: function (node, scope, location, autoReturn, unassigned) {
var tBody, tInit, tLabel, tStep, tTest;
tLabel = node.label && translate(node.label, scope, "label");
if (node.init != null) {
tInit = translate(
node.init,
scope,
"expression",
null,
unassigned
);
}
if (node.test != null) {
tTest = translate(node.test, scope, "expression");
}
if (node.step != null) {
tStep = translate(node.step, scope, "expression");
}
tBody = translate(node.body, scope, "statement");
return function () {
return ast.For(
getPos(node),
typeof tInit === "function" ? tInit() : void 0,
typeof tTest === "function" ? tTest() : void 0,
typeof tStep === "function" ? tStep() : void 0,
tBody(),
typeof tLabel === "function" ? tLabel() : void 0
);
};
},
ForIn: function (node, scope, location, autoReturn, unassigned) {
var tBody, tKey, tLabel, tObject;
tLabel = node.label && translate(node.label, scope, "label");
tKey = translate(node.key, scope, "leftExpression");
tObject = translate(
node.object,
scope,
"expression",
null,
unassigned
);
tBody = translate(node.body, scope, "statement");
return function () {
var key;
key = tKey();
if (!(key instanceof ast.Ident)) {
throw Error("Expected an Ident for a for-in key");
}
scope.addVariable(key, Type.string);
return ast.ForIn(
getPos(node),
key,
tObject(),
tBody(),
typeof tLabel === "function" ? tLabel() : void 0
);
};
},
Function: (function () {
var primitiveTypes, translateParamTypes, translateType, translateTypeChecks;
primitiveTypes = { Boolean: "boolean", String: "string", Number: "number", Function: "function" };
translateTypeChecks = {
Ident: function (node) {
if (__owns.call(primitiveTypes, node.name)) {
return Type[primitiveTypes[node.name]];
} else {
return Type.any;
}
},
Access: function (node) {
return Type.any;
},
TypeUnion: function (node) {
var _arr, _i, _len, result, type;
result = Type.none;
for (_arr = __toArray(node.types), _i = 0, _len = _arr.length; _i < _len; ++_i) {
type = _arr[_i];
if (type instanceof ParserNode.Const) {
if (type.value === null) {
result = result.union(Type["null"]);
} else if (type.value === void 0) {
result = result.union(Type["undefined"]);
} else {
throw Error("Unknown const value for typechecking: " + String(type.value));
}
} else if (type instanceof ParserNode.Ident) {
result = result.union(__owns.call(primitiveTypes, type.name) ? Type[primitiveTypes[type.name]] : Type.any);
} else {
throw Error("Not implemented: typechecking for non-idents/consts within a type-union");
}
}
return result;
},
TypeFunction: function (node) {
return Type["function"];
},
TypeGeneric: function (node) {
if (node.basetype.name === "Array") {
return translateTypeCheck(node.args[0]).array();
} else if (node.basetype.name === "Function") {
return Type["function"];
} else {
return Type.any;
}
},
TypeObject: function (node) {
var _arr, _i, _len, _ref, key, typeData, value;
typeData = {};
for (_arr = __toArray(node.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
key = (_ref = _arr[_i]).key;
value = _ref.value;
if (key instanceof ParserNode.Const) {
typeData[key.value] = translateTypeCheck(value);
}
}
return Type.makeObject(typeData);
}
};
function translateTypeCheck(node) {
if (!__owns.call(translateTypeChecks, node.constructor.cappedName)) {
throw Error("Unknown type: " + String(node.constructor.cappedName));
}
return translateTypeChecks[node.constructor.cappedName](node);
}
translateParamTypes = {
Param: function (param, scope, inner) {
var ident, laterInit, tmp, type;
ident = translate(param.ident, scope, "param")();
laterInit = [];
if (ident instanceof ast.Binary && ident.op === "." && ident.right instanceof ast.Const && typeof ident.right.value === "string") {
tmp = ast.Ident(ident.pos, ident.right.value);
laterInit.push(ast.Binary(ident.pos, ident, "=", tmp));
ident = tmp;
}
if (!(ident instanceof ast.Ident)) {
throw Error("Expecting param to be an Ident, got " + __typeof(ident));
}
if (param.asType) {
type = translateTypeCheck(param.asType);
}
scope.addVariable(ident, type, param.isMutable);
scope.markAsParam(ident);
return { init: laterInit, ident: ident, spread: !!param.spread };
}
};
function translateParam(param, scope, inner) {
var type;
type = param.constructor.cappedName;
if (!__owns.call(translateParamTypes, type)) {
throw Error("Unknown parameter type: " + __strnum(type));
}
return translateParamTypes[type](param, scope, inner);
}
translateType = (function () {
var translateTypes;
translateTypes = {
Ident: (function () {
var primordialTypes;
primordialTypes = {
String: Type.string,
Number: Type.number,
Boolean: Type.boolean,
Function: Type["function"],
Array: Type.array
};
return function (node, scope) {
if (!__owns.call(primordialTypes, node.name)) {
throw Error("Not implemented: custom type " + __strnum(node.name));
}
return primordialTypes[node.name];
};
}()),
Const: function (node, scope) {
switch (node.value) {
case null: return Type["null"];
case void 0: return Type["undefined"];
default: throw Error("Unexpected const type: " + String(node.value));
}
},
TypeGeneric: function (node, scope) {
var _arr, _arr2, _i, _len, arg, args, base;
base = translateType(node.basetype, scope);
for (_arr = [], _arr2 = __toArray(node.args), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
arg = _arr2[_i];
_arr.push(translateType(arg, scope));
}
args = _arr;
return Type.generic.apply(Type, [base].concat(__toArray(args)));
},
TypeUnion: function (node, scope) {
var _arr, _i, _len, current, type;
current = Type.none;
for (_arr = __toArray(node.types), _i = 0, _len = _arr.length; _i < _len; ++_i) {
type = _arr[_i];
current = current.union(translateType(type));
}
return current;
}
};
return function (node, scope) {
if (!__owns.call(translateTypes, node.constructor.cappedName)) {
throw Error("Unknown type to translate: " + String(node.constructor.cappedName));
}
return translateTypes[node.constructor.cappedName](node, scope);
};
}());
return function (node, scope, location, autoReturn) {
return function () {
var _arr, _ref, body, fakeThis, i, initializers, innerScope, len, p, param, paramIdents, realInnerScope, unassigned, wrap;
innerScope = scope.clone(!!node.bound);
realInnerScope = innerScope;
if (node.generator && !innerScope.bound) {
innerScope = innerScope.clone(true);
}
paramIdents = [];
initializers = [];
for (_arr = __toArray(node.params), i = 0, len = _arr.length; i < len; ++i) {
p = _arr[i];
param = translateParam(p, innerScope, false);
if (param.spread) {
throw Error("Encountered a spread parameter");
}
paramIdents.push(param.ident);
initializers.push.apply(initializers, __toArray(param.init));
}
unassigned = {};
body = (_ref = translateFunctionBody(
getPos(node),
node.generator,
node.autoReturn,
innerScope,
node.body,
unassigned
)).body;
wrap = _ref.wrap;
innerScope.releaseTmps();
body = ast.Block(getPos(node.body), __toArray(initializers).concat([body]));
if (innerScope.usedThis || node.bound instanceof ParserNode) {
if (node.bound instanceof ParserNode) {
fakeThis = ast.Ident(getPos(node.body), "_this");
innerScope.addVariable(fakeThis);
body = ast.Block(getPos(node.body), [
ast.Assign(getPos(node.body), fakeThis, translate(
node.bound,
scope,
"expression",
null,
unassigned
)()),
body,
ast.Return(getPos(node.body), fakeThis)
]);
} else {
if (innerScope.bound) {
scope.usedThis = true;
}
if ((innerScope.hasBound || node.generator) && !realInnerScope.bound) {
fakeThis = ast.Ident(getPos(node.body), "_this");
innerScope.addVariable(fakeThis);
body = ast.Block(getPos(node.body), [
ast.Assign(getPos(node.body), fakeThis, ast.This(getPos(node.body))),
body
]);
}
}
}
if (node.curry) {
throw Error("Expected node to already be curried");
}
return autoReturn(wrap(ast.Func(
getPos(node),
null,
paramIdents,
innerScope.getVariables(),
body,
[]
)));
};
};
}()),
Ident: (function () {
var PRIMORDIAL_GLOBALS;
PRIMORDIAL_GLOBALS = {
Object: true,
String: true,
Number: true,
Boolean: true,
Function: true,
Array: true,
Math: true,
JSON: true,
Date: true,
RegExp: true,
Error: true,
RangeError: true,
ReferenceError: true,
SyntaxError: true,
TypeError: true,
URIError: true,
escape: true,
unescape: true,
parseInt: true,
parseFloat: true,
isNaN: true,
isFinite: true,
decodeURI: true,
decodeURIComponent: true,
encodeURI: true,
encodeURIComponent: true
};
return function (node, scope, location, autoReturn) {
var name;
name = node.name;
scope.addHelper(name);
return function () {
var ident;
ident = ast.Ident(getPos(node), name);
if (!scope.options.embedded || __owns.call(PRIMORDIAL_GLOBALS, name) || location !== "expression" || scope.hasVariable(ident) || scope.macros.hasHelper(name)) {
return autoReturn(ident);
} else {
return ast.Access(
getPos(node),
ast.Ident(getPos(node), "context"),
ast.Const(getPos(node), name)
);
}
};
};
}()),
If: function (node, scope, location, autoReturn, unassigned) {
var innerLocation, tLabel, tTest, tWhenFalse, tWhenTrue;
if (location === "statement" || location === "topStatement") {
innerLocation = "statement";
} else {
innerLocation = location;
}
tLabel = node.label && translate(node.label, scope, "label");
tTest = translate(
node.test,
scope,
"expression",
null,
unassigned
);
tWhenTrue = translate(
node.whenTrue,
scope,
innerLocation,
autoReturn,
unassigned
);
if (node.whenFalse != null) {
tWhenFalse = translate(
node.whenFalse,
scope,
innerLocation,
autoReturn,
unassigned
);
}
return function () {
return ast.If(
getPos(node),
tTest(),
tWhenTrue(),
typeof tWhenFalse === "function" ? tWhenFalse() : void 0,
typeof tLabel === "function" ? tLabel() : void 0
);
};
},
Nothing: function (node) {
return function () {
return ast.Noop(getPos(node));
};
},
Object: function (node, scope, location, autoReturn, unassigned) {
var _arr, _i, _len, pair, properties, tKeys, tPrototype, tValues;
tKeys = [];
tValues = [];
properties = [];
for (_arr = __toArray(node.pairs), _i = 0, _len = _arr.length; _i < _len; ++_i) {
pair = _arr[_i];
tKeys.push(translate(
pair.key,
scope,
"expression",
null,
unassigned
));
tValues.push(translate(
pair.value,
scope,
"expression",
null,
unassigned
));
properties.push(pair.property);
}
if (node.prototype != null) {
tPrototype = translate(
node.prototype,
scope,
"expression",
null,
unassigned
);
}
return function () {
var _len, constPairs, currentPair, currentPairs, i, ident, key, lastProperty, obj, postConstPairs, property, prototype, result, tKey, tValue, value;
constPairs = [];
postConstPairs = [];
if (typeof tPrototype === "function") {
prototype = tPrototype();
}
if (prototype != null) {
currentPairs = postConstPairs;
} else {
currentPairs = constPairs;
}
lastProperty = null;
for (i = 0, _len = tKeys.length; i < _len; ++i) {
tKey = tKeys[i];
tValue = tValues[i];
key = tKey();
value = tValue();
property = properties[i];
if (!(key instanceof ast.Const) || property) {
currentPairs = postConstPairs;
}
currentPair = currentPairs[currentPairs.length - 1];
if ((property === "get" || property === "set") && lastProperty && property !== lastProperty && key instanceof ast.Const && currentPair.key instanceof ast.Const && key.value === currentPair.key.value) {
currentPair[lastProperty] = currentPair.value;
currentPair.property = __strnum(lastProperty) + __strnum(property);
delete currentPair.value;
currentPair[property] = value;
lastProperty = null;
} else {
currentPairs.push({ key: key, value: value, property: property });
if (property === "get" || property === "set") {
lastProperty = property;
}
}
}
if (prototype != null) {
scope.addHelper("__create");
obj = ast.Call(
getPos(node),
ast.Ident(getPos(node), "__create"),
[prototype]
);
} else {
obj = ast.Obj(getPos(node), (function () {
var _arr, _i, _len, _ref, key, value;
for (_arr = [], _i = 0, _len = constPairs.length; _i < _len; ++_i) {
key = (_ref = constPairs[_i]).key;
value = _ref.value;
_arr.push(ast.Obj.Pair(key.pos, String(key.value), value));
}
return _arr;
}()));
}
if (postConstPairs.length === 0) {
return autoReturn(obj);
} else {
ident = scope.reserveIdent(getPos(node), "o", Type.object);
result = ast.BlockExpression(getPos(node), [ast.Assign(getPos(node), ident, obj)].concat(
(function () {
var _arr, _i, _len, key, pair, property;
for (_arr = [], _i = 0, _len = postConstPairs.length; _i < _len; ++_i) {
pair = postConstPairs[_i];
key = pair.key;
property = pair.property;
if (property) {
scope.addHelper("__defProp");
_arr.push(ast.Call(
key.pos,
ast.Ident(key.pos, "__defProp"),
[
ident,
key,
property === "property" ? pair.value
: property === "getset"
? ast.Obj(pair.get.pos, [
ast.Obj.Pair(pair.get.pos, "get", pair.get),
ast.Obj.Pair(pair.set.pos, "set", pair.set),
ast.Obj.Pair(pair.set.pos, "configurable", ast.Const(pair.set.pos, true)),
ast.Obj.Pair(pair.set.pos, "enumerable", ast.Const(pair.set.pos, true))
])
: property === "setget"
? ast.Obj(pair.set.pos, [
ast.Obj.Pair(pair.set.pos, "set", pair.set),
ast.Obj.Pair(pair.get.pos, "get", pair.get),
ast.Obj.Pair(pair.get.pos, "configurable", ast.Const(pair.get.pos, true)),
ast.Obj.Pair(pair.get.pos, "enumerable", ast.Const(pair.get.pos, true))
])
: property === "get"
? ast.Obj(pair.value.pos, [
ast.Obj.Pair(pair.value.pos, "get", pair.value),
ast.Obj.Pair(pair.value.pos, "configurable", ast.Const(pair.value.pos, true)),
ast.Obj.Pair(pair.value.pos, "enumerable", ast.Const(pair.value.pos, true))
])
: property === "set"
? ast.Obj(pair.value.pos, [
ast.Obj.Pair(pair.value.pos, "set", pair.value),
ast.Obj.Pair(pair.value.pos, "configurable", ast.Const(pair.value.pos, true)),
ast.Obj.Pair(pair.value.pos, "enumerable", ast.Const(pair.value.pos, true))
])
: __throw(Error("Unknown property type: " + String(property)))
]
));
} else {
_arr.push(ast.Assign(
key.pos,
ast.Access(key.pos, ident, key),
pair.value
));
}
}
return _arr;
}()),
[ident]
));
scope.releaseIdent(ident);
return autoReturn(result);
}
};
},
Regexp: function (node, scope, location, autoReturn, unassigned) {
var tSource;
tSource = translate(
node.source,
scope,
"expression",
null,
unassigned
);
return function () {
var flags, source;
source = tSource();
flags = node.flags;
if (source.isConst()) {
return autoReturn(ast.Regex(getPos(node), String(source.constValue()), flags));
} else {
return autoReturn(ast.Call(
getPos(node),
ast.Ident(getPos(node), "RegExp"),
[
source,
ast.Const(getPos(node), flags)
]
));
}
};
},
Return: function (node, scope, location, autoReturn, unassigned) {
var tValue;
if (location !== "statement" && location !== "topStatement") {
throw Error("Expected Return in statement position");
}
tValue = translate(
node.node,
scope,
"expression",
null,
unassigned
);
return function () {
return ast.Return(getPos(node), tValue());
};
},
Switch: function (node, scope, location, autoReturn, unassigned) {
var _arr, _arr2, _i, _len, case_, tCases, tDefaultCase, tLabel, tNode;
tLabel = node.label && translate(node.label, scope, "label");
tNode = translate(
node.node,
scope,
"expression",
null,
unassigned
);
for (_arr = [], _arr2 = __toArray(node.cases), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
case_ = _arr2[_i];
_arr.push({
pos: getPos(case_.node),
tNode: translate(
case_.node,
scope,
"expression",
null,
unassigned
),
tBody: translate(
case_.body,
scope,
"statement",
null,
unassigned
),
fallthrough: case_.fallthrough
});
}
tCases = _arr;
if (node.defaultCase != null) {
tDefaultCase = translate(
node.defaultCase,
scope,
"statement",
null,
unassigned
);
}
return function () {
return ast.Switch(
getPos(node),
tNode(),
(function () {
var _arr, case_, caseBody, caseNode, i, len;
for (_arr = [], i = 0, len = tCases.length; i < len; ++i) {
case_ = tCases[i];
caseNode = case_.tNode();
caseBody = case_.tBody();
if (!case_.fallthrough || i === len - 1 && defaultCase.isNoop()) {
caseBody = ast.Block(case_.pos, [autoReturn(caseBody), ast.Break(caseBody.pos)]);
}
_arr.push(ast.Switch.Case(case_.pos, caseNode, caseBody));
}
return _arr;
}()),
tDefaultCase != null ? autoReturn(tDefaultCase()) : ast.Noop(getPos(node)),
typeof tLabel === "function" ? tLabel() : void 0
);
};
},
Super: function (node, scope, location, autoReturn) {
throw Error("Cannot have a stray super call");
},
Tmp: function (node, scope, location, autoReturn) {
var ident;
ident = scope.getTmp(getPos(node), node.id, node.name, node.type());
return function () {
return autoReturn(ident);
};
},
TmpWrapper: function (node, scope, location, autoReturn, unassigned) {
var _arr, _i, tmp, tResult;
tResult = translate(
node.node,
scope,
location,
autoReturn,
unassigned
);
for (_arr = __toArray(node.tmps), _i = _arr.length; _i--; ) {
tmp = _arr[_i];
scope.releaseTmp(tmp);
}
return tResult;
},
This: function (node, scope, location, autoReturn) {
return function () {
scope.usedThis = true;
return autoReturn(scope.bound ? ast.Ident(getPos(node), "_this") : ast.This(getPos(node)));
};
},
Throw: function (node, scope, location, autoReturn, unassigned) {
var tNode;
tNode = translate(
node.node,
scope,
"expression",
null,
unassigned
);
return function () {
return ast.Throw(getPos(node), tNode());
};
},
TryCatch: function (node, scope, location, autoReturn, unassigned) {
var innerScope, tCatchBody, tCatchIdent, tLabel, tTryBody;
tLabel = node.label && translate(node.label, scope, "label");
tTryBody = translate(
node.tryBody,
scope,
"statement",
autoReturn,
unassigned
);
innerScope = scope.clone(false);
tCatchIdent = translate(node.catchIdent, innerScope, "leftExpression");
tCatchBody = translate(
node.catchBody,
innerScope,
"statement",
autoReturn,
unassigned
);
return function () {
var catchIdent, result;
catchIdent = tCatchIdent();
if (catchIdent instanceof ast.Ident) {
innerScope.addVariable(catchIdent);
innerScope.markAsParam(catchIdent);
}
result = ast.TryCatch(
getPos(node),
tTryBody(),
catchIdent,
tCatchBody(),
typeof tLabel === "function" ? tLabel() : void 0
);
__import(scope.variables, innerScope.variables);
return result;
};
},
TryFinally: function (node, scope, location, autoReturn, unassigned) {
var tFinallyBody, tLabel, tTryBody;
tLabel = node.label && translate(node.label, scope, "label");
tTryBody = translate(
node.tryBody,
scope,
"statement",
autoReturn,
unassigned
);
tFinallyBody = translate(
node.finallyBody,
scope,
"statement",
null,
unassigned
);
return function () {
return ast.TryFinally(getPos(node), tTryBody(), tFinallyBody(), typeof tLabel === "function" ? tLabel() : void 0);
};
},
Unary: function (node, scope, location, autoReturn, unassigned) {
var _ref, tSubnode;
if (unassigned && ((_ref = node.op) === "++" || _ref === "--" || _ref === "++post" || _ref === "--post") && node.node instanceof ParserNode.Ident) {
unassigned[node.node.name] = false;
}
tSubnode = translate(
node.node,
scope,
"expression",
null,
unassigned
);
return function () {
return autoReturn(ast.Unary(getPos(node), node.op, tSubnode()));
};
},
Var: function (node, scope, location, autoReturn, unassigned) {
var tIdent;
if (unassigned && node.ident instanceof ParserNode.Ident && !__owns.call(unassigned, node.ident.name)) {
unassigned[node.ident.name] = true;
}
tIdent = translate(node.ident, scope, "leftExpression", autoReturn);
return function () {
var ident;
ident = tIdent();
scope.addVariable(ident, Type.any, node.isMutable);
return ast.Noop(getPos(node));
};
}
};
function translate(node, scope, location, autoReturn, unassigned) {
var ret;
if (typeof node !== "object" || node === null) {
throw TypeError("Expected node to be an Object, got " + __typeof(node));
}
if (!(scope instanceof Scope)) {
throw TypeError("Expected scope to be a " + __name(Scope) + ", got " + __typeof(scope));
}
if (typeof location !== "string") {
throw TypeError("Expected location to be a String, got " + __typeof(location));
}
if (typeof autoReturn !== "function") {
autoReturn = makeAutoReturn(autoReturn);
}
if (!__owns.call(translators, node.constructor.cappedName)) {
throw Error("Unable to translate unknown node type: " + String(node.constructor.cappedName));
}
ret = translators[node.constructor.cappedName](
node,
scope,
location,
autoReturn,
unassigned
);
if (typeof ret !== "function") {
throw Error("Translated non-function: " + __typeof(ret));
}
return ret;
}
function translateArray(nodes, scope, location, autoReturn, unassigned) {
var _arr, i, len, node;
if (!__isArray(nodes)) {
throw TypeError("Expected nodes to be an Array, got " + __typeof(nodes));
}
if (!(scope instanceof Scope)) {
throw TypeError("Expected scope to be a " + __name(Scope) + ", got " + __typeof(scope));
}
if (typeof location !== "string") {
throw TypeError("Expected location to be a String, got " + __typeof(location));
}
for (_arr = [], i = 0, len = nodes.length; i < len; ++i) {
node = nodes[i];
_arr.push(translate(
nodes[i],
scope,
location,
i === len - 1 && autoReturn,
unassigned
));
}
return _arr;
}
function translateFunctionBody(pos, isGenerator, autoReturn, scope, body, unassigned) {
var _ref, builder, hasGeneratorNode, isSimpleGenerator, translatedBody;
if (unassigned == null) {
unassigned = {};
}
isSimpleGenerator = false;
if (isGenerator) {
hasGeneratorNode = makeHasGeneratorNode();
isSimpleGenerator = !hasGeneratorNode(body, true);
if (!isSimpleGenerator) {
builder = GeneratorBuilder(pos, scope, hasGeneratorNode);
generatorTranslate(body, scope, builder.start).goto(pos, function () {
return builder.stop;
});
translatedBody = builder.create();
if (pos.file) {
if (!(_ref = translatedBody.pos).file) {
_ref.file = pos.file;
}
}
return {
wrap: function (x) {
return x;
},
body: translatedBody
};
}
}
translatedBody = translate(
body,
scope,
"topStatement",
!isSimpleGenerator && autoReturn,
unassigned
)();
if (pos.file) {
if (!(_ref = translatedBody.pos).file) {
_ref.file = pos.file;
}
}
return {
wrap: isSimpleGenerator
? (scope.addHelper("__generator"), function (x) {
return ast.Call(
pos,
ast.Ident(pos, "__generator"),
[x]
);
})
: function (x) {
return x;
},
body: translatedBody
};
}
function translateRoot(roots, scope) {
var _arr, _i, _len, _ref, bareInit, body, callFunc, comments, fakeThis, helper, ident, init, name, noPos, uncommentedBody, walker, wrap;
if (typeof roots !== "object" || roots === null) {
throw TypeError("Expected roots to be an Object, got " + __typeof(roots));
}
if (!(scope instanceof Scope)) {
throw TypeError("Expected scope to be a " + __name(Scope) + ", got " + __typeof(scope));
}
if (!__isArray(roots)) {
roots = [roots];
}
if (roots.length === 0) {
roots.push({
type: "Root",
line: 0,
column: 0,
body: { type: "Nothing", line: 0, column: 0 }
});
}
function splitComments(body) {
var comments;
comments = [];
while (true) {
if (body instanceof ast.Comment) {
comments.push(body);
body = ast.Noop(body.pos);
} else if (body instanceof ast.Block && body.body[0] instanceof ast.Comment) {
comments.push(body.body[0]);
body = ast.Block(body.pos, __slice.call(body.body, 1));
} else {
break;
}
}
return { comments: comments, body: body };
}
noPos = makePos(0, 0);
if (scope.options.embedded) {
for (_arr = ["write", "context"], _i = 0, _len = _arr.length; _i < _len; ++_i) {
name = _arr[_i];
ident = ast.Ident(
{ line: 0, column: 0 },
name
);
scope.addVariable(ident);
scope.markAsParam(ident);
}
}
wrap = (_ref = roots.length === 1
? (function () {
var _ref, ret, rootPos;
if (!(roots[0] instanceof ParserNode.Root)) {
throw Error("Cannot translate non-Root object");
}
if (roots[0].isGenerator) {
scope = scope.clone(true);
}
rootPos = getPos(roots[0]);
ret = translateFunctionBody(
rootPos,
roots[0].isGenerator,
scope.options["return"] || scope.options["eval"],
scope,
roots[0].body
);
if (!(_ref = ret.body.pos).file) {
_ref.file = rootPos.file;
}
return ret;
}())
: {
wrap: function (x) {
return x;
},
body: ast.Block(noPos, (function () {
var _arr, _arr2, _i, _len, _ref, comments, innerScope, root, rootBody, rootPos;
for (_arr = [], _arr2 = __toArray(roots), _i = 0, _len = _arr2.length; _i < _len; ++_i) {
root = _arr2[_i];
if (!(root instanceof ParserNode.Root)) {
throw Error("Cannot translate non-Root object");
}
innerScope = scope.clone(true);
comments = (_ref = splitComments(translate(
root.body,
innerScope,
"topStatement",
scope.options["return"] || scope.options["eval"],
[]
)())).comments;
rootBody = _ref.body;
rootPos = getPos(root);
_arr.push(ast.Block(rootPos, __toArray(comments).concat([
ast.Call(rootPos, ast.Func(
rootPos,
null,
[],
innerScope.getVariables(),
rootBody
))
])));
}
return _arr;
}()))
}).wrap;
body = _ref.body;
init = [];
if (scope.hasBound && scope.usedThis) {
fakeThis = ast.Ident(body.pos, "_this");
scope.addVariable(fakeThis);
init.push(ast.Assign(body.pos, fakeThis, ast.This(body.pos)));
}
scope.fillHelperDependencies();
for (_arr = __toArray(scope.getHelpers()), _i = 0, _len = _arr.length; _i < _len; ++_i) {
helper = _arr[_i];
if (helper !== "GLOBAL" && scope.macros.hasHelper(helper)) {
ident = ast.Ident(body.pos, helper);
scope.addVariable(ident);
init.push(ast.Assign(body.pos, ident, scope.macros.getHelper(helper)));
}
}
bareInit = [];
if (scope.options["eval"]) {
walker = function (node) {
if (node instanceof ast.Func) {
scope.addHelper("GLOBAL");
if (node.name != null) {
return ast.Block(node.pos, [
node,
ast.Assign(
node.pos,
ast.Access(
node.pos,
ast.Ident(node.pos, "GLOBAL"),
node.name.name
),
node.name
)
]);
} else {
return node;
}
} else if (node instanceof ast.Binary && node.op === "=" && node.left instanceof ast.Ident) {
scope.addHelper("GLOBAL");
return ast.Assign(
node.pos,
ast.Access(
node.pos,
ast.Ident(node.pos, "GLOBAL"),
node.left.name
),
node.walk(walker)
);
}
};
body = body.walk(walker);
body = body.mutateLast(
function (node) {
scope.addHelper("GLOBAL");
return ast.Assign(
node.pos,
ast.Access(
node.pos,
ast.Ident(node.pos, "GLOBAL"),
ast.Const(node.pos, "_")
),
node
);
},
{ "return": true }
);
}
comments = (_ref = splitComments(body)).comments;
uncommentedBody = _ref.body;
if (scope.options.embedded) {
uncommentedBody = ast.Block(body.pos, [
ast.Return(body.pos, wrap(ast.Func(
body.pos,
null,
[
ast.Ident(body.pos, "write"),
ast.Ident(body.pos, "context")
],
[],
ast.Block(body.pos, [
ast.If(
body.pos,
ast.Binary(
body.pos,
ast.Ident(body.pos, "context"),
"==",
ast.Const(body.pos, null)
),
ast.Assign(
body.pos,
ast.Ident(body.pos, "context"),
ast.Obj(body.pos)
)
),
uncommentedBody
])
)))
]);
}
if (scope.options.bare) {
if (scope.hasHelper("GLOBAL")) {
scope.addVariable(ast.Ident(body.pos, "GLOBAL"));
bareInit.unshift(ast.Assign(
body.pos,
ast.Ident(body.pos, "GLOBAL"),
scope.macros.getHelper("GLOBAL")
));
}
if (scope.options.undefinedName != null) {
scope.addVariable(scope.options.undefinedName);
}
return ast.Root(
body.pos,
ast.Block(body.pos, __toArray(comments).concat(__toArray(bareInit), __toArray(init), [uncommentedBody])),
scope.getVariables(),
["use strict"]
);
} else {
callFunc = ast.Call(
body.pos,
ast.Access(
body.pos,
ast.Func(
body.pos,
null,
(scope.hasHelper("GLOBAL")
? [ast.Ident(body.pos, "GLOBAL")]
: []).concat(scope.options.undefinedName != null
? [ast.Ident(body.pos, scope.options.undefinedName, true)]
: []),
scope.getVariables(),
ast.Block(body.pos, __toArray(init).concat([uncommentedBody])),
["use strict"]
),
"call"
),
[ast.This(body.pos)].concat(scope.hasHelper("GLOBAL") ? [scope.macros.getHelper("GLOBAL")] : [])
);
if (scope.options["return"]) {
callFunc = ast.Return(body.pos, callFunc);
}
return ast.Root(
body.pos,
ast.Block(body.pos, __toArray(comments).concat(__toArray(bareInit), [callFunc])),
[],
[]
);
}
}
module.exports = function (node, macros, options) {
var endTime, result, scope, startTime;
if (!(macros instanceof MacroHolder)) {
throw TypeError("Expected macros to be a " + __name(MacroHolder) + ", got " + __typeof(macros));
}
if (options == null) {
options = {};
}
startTime = new Date().getTime();
try {
scope = Scope(options, macros, false);
result = translateRoot(node, scope);
scope.releaseTmps();
} catch (e) {
if (typeof callback !== "undefined" && callback !== null) {
return callback(e);
} else {
throw e;
}
}
endTime = new Date().getTime();
if (typeof options.progress === "function") {
options.progress("translate", __num(endTime) - __num(startTime));
}
return { node: result, time: __num(endTime) - __num(startTime) };
};
module.exports.defineHelper = function (macros, name, value, type, dependencies) {
var helper, ident, scope;
if (!(macros instanceof MacroHolder)) {
throw TypeError("Expected macros to be a " + __name(MacroHolder) + ", got " + __typeof(macros));
}
if (!(type instanceof Type)) {
throw TypeError("Expected type to be a " + __name(Type) + ", got " + __typeof(type));
}
scope = Scope({}, macros, false);
if (typeof name === "string") {
ident = ast.Ident(
makePos(0, 0),
name
);
} else if (name instanceof ParserNode.Ident) {
ident = translate(name, scope, "leftExpression")();
} else {
throw TypeError("Expecting name to be a String or Ident, got " + __typeof(name));
}
if (!(ident instanceof ast.Ident)) {
throw Error("Expected name to be an Ident, got " + __typeof(ident));
}
if (value instanceof AstNode) {
helper = value;
} else if (value instanceof ParserNode) {
helper = translate(value, scope, "expression")();
} else {
throw TypeError("Expected value to be a parser or ast Node, got " + __typeof(value));
}
if (dependencies == null) {
dependencies = scope.getHelpers();
}
macros.addHelper(ident.name, helper, type, dependencies);
return { helper: helper, dependencies: dependencies };
};
}.call(this, typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : this));
return module.exports;
};
require['./gorilla'] = function () {
var module = { exports: this };
var exports = this;
(function (GLOBAL) {
"use strict";
var __defer, __generatorToPromise, __isArray, __lte, __num, __owns, __promise, __slice, __strnum, __toArray, __toPromise, __typeof, fetchAndParsePrelude, fs, init, os, parser, path, setImmediate;
__defer = (function () {
function __defer() {
var deferred, isError, value;
isError = false;
value = null;
deferred = [];
function complete(newIsError, newValue) {
var funcs;
if (deferred) {
funcs = deferred;
deferred = null;
isError = newIsError;
value = newValue;
if (funcs.length) {
setImmediate(function () {
var _end, i;
for (i = 0, _end = funcs.length; i < _end; ++i) {
funcs[i]();
}
});
}
}
}
return {
promise: {
then: function (onFulfilled, onRejected, allowSync) {
var _ref, fulfill, promise, reject;
if (allowSync !== true) {
allowSync = void 0;
}
promise = (_ref = __defer()).promise;
fulfill = _ref.fulfill;
reject = _ref.reject;
function step() {
var f, result;
try {
if (isError) {
f = onRejected;
} else {
f = onFulfilled;
}
if (typeof f === "function") {
result = f(value);
if (result && typeof result.then === "function") {
result.then(fulfill, reject, allowSync);
} else {
fulfill(result);
}
} else {
(isError ? reject : fulfill)(value);
}
} catch (e) {
reject(e);
}
}
if (deferred) {
deferred.push(step);
} else if (allowSync) {
step();
} else {
setImmediate(step);
}
return promise;
},
sync: function () {
var result, state;
state = 0;
result = 0;
this.then(
function (ret) {
state = 1;
return result = ret;
},
function (err) {
state = 2;
return result = err;
},
true
);
switch (state) {
case 0: throw Error("Promise did not execute synchronously");
case 1: return result;
case 2: throw result;
default: throw Error("Unknown state");
}
}
},
fulfill: function (value) {
complete(false, value);
},
reject: function (reason) {
complete(true, reason);
}
};
}
__defer.fulfilled = function (value) {
var d;
d = __defer();
d.fulfill(value);
return d.promise;
};
__defer.rejected = function (reason) {
var d;
d = __defer();
d.reject(reason);
return d.promise;
};
return __defer;
}());
__generatorToPromise = function (generator, allowSync) {
if (typeof generator !== "object" || generator === null) {
throw TypeError("Expected generator to be an Object, got " + __typeof(generator));
} else {
if (typeof generator.send !== "function") {
throw TypeError("Expected generator.send to be a Function, got " + __typeof(generator.send));
}
if (typeof generator["throw"] !== "function") {
throw TypeError("Expected generator.throw to be a Function, got " + __typeof(generator["throw"]));
}
}
if (allowSync == null) {
allowSync = false;
} else if (typeof allowSync !== "boolean") {
throw TypeError("Expected allowSync to be a Boolean, got " + __typeof(allowSync));
}
function continuer(verb, arg) {
var item;
try {
item = generator[verb](arg);
} catch (e) {
return __defer.rejected(e);
}
if (item.done) {
return __defer.fulfilled(item.value);
} else {
return item.value.then(callback, errback, allowSync);
}
}
function callback(value) {
return continuer("send", value);
}
function errback(value) {
return continuer("throw", value);
}
return callback(void 0);
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__lte = function (x, y) {
var type;
type = typeof x;
if (type !== "number" && type !== "string") {
throw TypeError("Cannot compare a non-number/string: " + type);
} else if (type !== typeof y) {
throw TypeError("Cannot compare elements of different types: " + type + " vs " + typeof y);
} else {
return x <= y;
}
};
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__owns = Object.prototype.hasOwnProperty;
__promise = function (value, allowSync) {
var factory;
if (allowSync == null) {
allowSync = false;
} else if (typeof allowSync !== "boolean") {
throw TypeError("Expected allowSync to be a Boolean, got " + __typeof(allowSync));
}
if (typeof value === "function") {
factory = function () {
return __generatorToPromise(value.apply(this, arguments));
};
factory.sync = function () {
return __generatorToPromise(
value.apply(this, arguments),
true
).sync();
};
return factory;
} else {
return __generatorToPromise(value, allowSync);
}
};
__slice = Array.prototype.slice;
__strnum = function (strnum) {
var type;
type = typeof strnum;
if (type === "string") {
return strnum;
} else if (type === "number") {
return String(strnum);
} else {
throw TypeError("Expected a string or number, got " + __typeof(strnum));
}
};
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__toPromise = function (func, context, args) {
var d;
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
d = __defer();
func.apply(context, __toArray(args).concat([
function (err, value) {
if (err != null) {
d.reject(err);
} else {
d.fulfill(value);
}
}
]));
return d.promise;
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
setImmediate = typeof GLOBAL.setImmediate === "function" ? GLOBAL.setImmediate
: typeof process !== "undefined" && typeof process.nextTick === "function"
? (function () {
var nextTick;
nextTick = process.nextTick;
return function (func) {
var args;
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
args = __slice.call(arguments, 1);
if (args.length) {
return nextTick(function () {
func.apply(void 0, __toArray(args));
});
} else {
return nextTick(func);
}
};
}())
: function (func) {
var args;
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
args = __slice.call(arguments, 1);
if (args.length) {
return setTimeout(
function () {
func.apply(void 0, __toArray(args));
},
0
);
} else {
return setTimeout(func, 0);
}
};
parser = require("./parser");
os = require("os");
fs = require("fs");
path = require("path");
exports.version = "0.7.2";
exports.ParserError = parser.ParserError;
exports.MacroError = parser.MacroError;
if (require.extensions) {
require.extensions[".gs"] = function (module, filename) {
var compiled;
compiled = exports.compileSync(
fs.readFileSync(filename, "utf8"),
{ filename: filename }
);
return module._compile(compiled.code, filename);
};
} else if (require.registerExtension) {
require.registerExtension(".gs", function (content) {
return exports.compileSync(content, { filename: filename });
});
}
fetchAndParsePrelude = (function () {
var getPreludeCachePath, getPreludeSrcPath, parsedPreludeByLang, preludePromisesByLang, real__filename, work;
parsedPreludeByLang = {};
if (typeof __filename !== "undefined" && __filename !== null) {
real__filename = fs.realpathSync(__filename);
}
if (real__filename != null) {
getPreludeSrcPath = function (lang) {
return path.join(path.dirname(real__filename), "../src/" + __strnum(lang) + "prelude.gs");
};
}
if (os != null) {
getPreludeCachePath = function (lang) {
return path.join(os.tmpDir(), "gs-" + __strnum(lang) + "prelude-" + __strnum(exports.version) + ".cache");
};
}
preludePromisesByLang = {};
work = __promise(function (lang, sync) {
var _e, _send, _state, _step, _throw, cachePrelude, e, errored, parsedPrelude, prelude, preludeCachePath, preludeCacheStat, preludeSrcPath, preludeSrcStat;
_state = 0;
function _close() {
_state = 31;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (typeof lang !== "string") {
throw TypeError("Expected lang to be a String, got " + __typeof(lang));
}
preludeSrcPath = getPreludeSrcPath(lang);
_state = sync ? 1 : 2;
break;
case 1:
preludeSrcStat = fs.statSync(preludeSrcPath);
_state = 4;
break;
case 2:
++_state;
return {
done: false,
value: __toPromise(fs.stat, fs, [preludeSrcPath])
};
case 3:
preludeSrcStat = _received;
++_state;
case 4:
preludeCachePath = getPreludeCachePath(lang);
preludeCacheStat = void 0;
++_state;
case 5:
_state = sync ? 6 : 7;
break;
case 6:
preludeCacheStat = fs.statSync(preludeCachePath);
_state = 9;
break;
case 7:
++_state;
return {
done: false,
value: __toPromise(fs.stat, fs, [preludeCachePath])
};
case 8:
preludeCacheStat = _received;
++_state;
case 9:
_state = 11;
break;
case 10:
if (e.code !== "ENOENT") {
throw e;
}
++_state;
case 11:
parsedPrelude = void 0;
_state = preludeCacheStat && __lte(preludeSrcStat.mtime.getTime(), preludeCacheStat.mtime.getTime()) ? 12 : 20;
break;
case 12:
_state = sync ? 13 : 14;
break;
case 13:
cachePrelude = fs.readFileSync(preludeCachePath("utf8"));
_state = 16;
break;
case 14:
++_state;
return {
done: false,
value: __toPromise(fs.readFile, fs, [preludeCachePath, "utf8"])
};
case 15:
cachePrelude = _received;
++_state;
case 16:
errored = false;
try {
parsedPrelude = parsedPreludeByLang[lang] = parser.deserializePrelude(cachePrelude);
} catch (e) {
if (e instanceof ReferenceError) {
throw e;
} else {
console.error("Error deserializing prelude, reloading. " + String(e));
errored = true;
}
}
_state = errored ? 17 : 20;
break;
case 17:
_state = sync ? 18 : 19;
break;
case 18:
fs.unlinkSync(preludeCachePath);
_state = 20;
break;
case 19:
++_state;
return {
done: false,
value: __toPromise(fs.unlink, fs, [preludeCachePath])
};
case 20:
_state = parsedPrelude == null ? 21 : 30;
break;
case 21:
_state = sync ? 22 : 23;
break;
case 22:
prelude = fs.readFileSync(preludeSrcPath, "utf8");
_state = 25;
break;
case 23:
++_state;
return {
done: false,
value: __toPromise(fs.readFile, fs, [preludeSrcPath, "utf8"])
};
case 24:
prelude = _received;
++_state;
case 25:
_state = sync ? 26 : 27;
break;
case 26:
parsedPreludeByLang[lang] = parser.sync(prelude, null, { serializeMacros: true, sync: true });
_state = 29;
break;
case 27:
++_state;
return {
done: false,
value: parser(prelude, null, { serializeMacros: true })
};
case 28:
parsedPreludeByLang[lang] = _received;
++_state;
case 29:
parsedPrelude = parsedPreludeByLang[lang];
fs.writeFile(preludeCachePath, parsedPrelude.macros.serialize(), "utf8", function () {});
++_state;
case 30:
delete preludePromisesByLang[lang];
++_state;
return { done: true, value: parsedPrelude };
case 31:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
if (_state === 5 || _state === 6 || _state === 7 || _state === 8 || _state === 9) {
e = _e;
_state = 10;
} else {
_close();
throw _e;
}
}
function _send(_received) {
while (true) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
function f(lang, sync) {
var _ref, parsedPrelude;
if (typeof lang !== "string") {
throw TypeError("Expected lang to be a String, got " + __typeof(lang));
}
if (sync == null) {
sync = false;
} else if (typeof sync !== "boolean") {
throw TypeError("Expected sync to be a Boolean, got " + __typeof(sync));
}
if (__owns.call(parsedPreludeByLang, lang)) {
parsedPrelude = parsedPreludeByLang[lang];
}
if (parsedPrelude != null) {
if (sync) {
return parsedPrelude;
} else {
return __defer.fulfilled(parsedPrelude);
}
} else if (sync) {
return work.sync(lang, true);
} else if ((_ref = preludePromisesByLang[lang]) == null) {
return preludePromisesByLang[lang] = work(lang);
} else {
return _ref;
}
}
f.serialized = __promise(function (lang) {
var _e, _send, _state, _step, _throw;
_state = 0;
function _close() {
_state = 3;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (typeof lang !== "string") {
throw TypeError("Expected lang to be a String, got " + __typeof(lang));
}
++_state;
return { done: false, value: f(lang) };
case 1:
++_state;
return {
done: false,
value: __toPromise(fs.readFile, fs, [getPreludeCachePath(lang), "utf8"])
};
case 2:
++_state;
return { done: true, value: _received };
case 3:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
exports.withPrelude = function (lang, serializedPrelude) {
if (typeof lang !== "string") {
throw TypeError("Expected lang to be a String, got " + __typeof(lang));
}
if (typeof serializedPrelude !== "object" || serializedPrelude === null) {
throw TypeError("Expected serializedPrelude to be an Object, got " + __typeof(serializedPrelude));
}
parsedPreludeByLang[lang] = parser.deserializePrelude(serializedPrelude);
return this;
};
return f;
}());
exports.getSerializedPrelude = fetchAndParsePrelude.serialized;
exports.parse = __promise(function (source, options) {
var _e, _send, _state, _step, _throw, _tmp, macros, sync;
_state = 0;
function _close() {
_state = 12;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (options == null) {
options = {};
}
sync = options.sync;
_state = options.macros ? 1 : 2;
break;
case 1:
macros = options.macros;
_state = 8;
break;
case 2:
_state = options.noPrelude ? 3 : 4;
break;
case 3:
macros = null;
_state = 8;
break;
case 4:
_state = sync ? 5 : 6;
break;
case 5:
macros = fetchAndParsePrelude(options.lang || "js", true).macros;
_state = 8;
break;
case 6:
++_state;
return { done: false, value: fetchAndParsePrelude(options.lang || "js") };
case 7:
_tmp = _received;
macros = _tmp.macros;
++_state;
case 8:
_state = sync ? 9 : 10;
break;
case 9:
_state = 12;
return {
done: true,
value: parser.sync(source, macros, options)
};
case 10:
++_state;
return {
done: false,
value: parser(source, macros, options)
};
case 11:
++_state;
return { done: true, value: _received };
case 12:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
exports.parseSync = function (source, options) {
if (options == null) {
options = {};
}
options.sync = true;
return exports.parse.sync(source, options);
};
exports.getReservedWords = function (options) {
if (options == null) {
options = {};
}
if (options.noPrelude) {
return parser.getReservedWords(null, options);
} else {
return parser.getReservedWords(
fetchAndParsePrelude(options.lang || "js", true).macros,
options
);
}
};
function joinParsedResults(results) {
var _arr, _i, _len, joinedParsed, parsed;
joinedParsed = {
parseTime: 0,
macroExpandTime: 0,
reduceTime: 0,
macros: results[0].macros,
result: []
};
for (_arr = __toArray(results), _i = 0, _len = _arr.length; _i < _len; ++_i) {
parsed = _arr[_i];
joinedParsed.parseTime += __num(parsed.parseTime);
joinedParsed.macroExpandTime += __num(parsed.macroExpandTime);
joinedParsed.reduceTime += __num(parsed.reduceTime);
joinedParsed.result.push(parsed.result);
}
return joinedParsed;
}
exports.ast = __promise(function (source, options) {
var _arr, _arr2, _e, _i, _len, _send, _state, _step, _throw, _tmp, _tmp2, array, item, parsed, startTime, sync, translated, translator;
_state = 0;
function _close() {
_state = 15;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (options == null) {
options = {};
}
startTime = new Date().getTime();
sync = options.sync;
if (typeof options.translator === "function") {
translator = options.translator;
} else {
translator = require(typeof options.translator === "string" ? options.translator : "./jstranslator");
}
_state = __isArray(source) ? 1 : 10;
break;
case 1:
array = [];
_arr = __toArray(source);
_i = 0;
_len = _arr.length;
++_state;
case 2:
_state = _i < _len ? 3 : 9;
break;
case 3:
item = _arr[_i];
if (__isArray(options.filenames)) {
options.filename = options.filenames[i];
}
_tmp2 = array.push;
_arr2 = [];
_state = sync ? 4 : 5;
break;
case 4:
_tmp = exports.parseSync(item, options);
_state = 7;
break;
case 5:
++_state;
return {
done: false,
value: exports.parse(item, options)
};
case 6:
_tmp = _received;
++_state;
case 7:
_arr2.push(_tmp);
_tmp2.apply(void 0, _arr2);
++_state;
case 8:
++_i;
_state = 2;
break;
case 9:
parsed = joinParsedResults(array);
_state = 14;
break;
case 10:
_state = sync ? 11 : 12;
break;
case 11:
parsed = exports.parseSync(source, options);
_state = 14;
break;
case 12:
++_state;
return {
done: false,
value: exports.parse(source, options)
};
case 13:
parsed = _received;
++_state;
case 14:
translated = translator(parsed.result, parsed.macros, options);
++_state;
return {
done: true,
value: {
node: translated.node,
parseTime: parsed.parseTime,
macroExpandTime: parsed.macroExpandTime,
reduceTime: parsed.reduceTime,
translateTime: translated.time,
time: __num(new Date().getTime()) - __num(startTime)
}
};
case 15:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
exports.astSync = function (source, options) {
if (options == null) {
options = {};
}
options.sync = true;
return exports.ast.sync(source, options);
};
exports.compile = __promise(function (source, options) {
var _e, _send, _state, _step, _throw, compiled, startTime, sync, translated;
_state = 0;
function _close() {
_state = 5;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (options == null) {
options = {};
}
sync = options.sync;
startTime = new Date().getTime();
_state = sync ? 1 : 2;
break;
case 1:
translated = exports.astSync(source, options);
_state = 4;
break;
case 2:
++_state;
return {
done: false,
value: exports.ast(source, options)
};
case 3:
translated = _received;
++_state;
case 4:
compiled = translated.node.compile(options);
++_state;
return {
done: true,
value: {
parseTime: translated.parseTime,
macroExpandTime: translated.macroExpandTime,
reduceTime: translated.reduceTime,
translateTime: translated.translateTime,
compileTime: compiled.compileTime,
uglifyTime: compiled.uglifyTime,
time: __num(new Date().getTime()) - __num(startTime),
code: compiled.code
}
};
case 5:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
exports.compileSync = function (source, options) {
if (options == null) {
options = {};
}
options.sync = true;
return exports.compile.sync(source, options);
};
function evaluate(code, options) {
var _arr, _i, _module, _obj, _ref, _require, fun, k, Module, r, sandbox, Script, v;
if (typeof require === "function" && (_ref = require("vm")) != null) {
Script = _ref.Script;
}
if (Script) {
sandbox = Script.createContext();
sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox;
if (options.sandbox != null) {
if (options.sandbox instanceof sandbox.constructor) {
sandbox = options.sandbox;
} else {
_obj = options.sandbox;
for (k in _obj) {
if (__owns.call(_obj, k)) {
v = _obj[k];
sandbox[k] = v;
}
}
}
} else {
for (k in GLOBAL) {
if (__owns.call(GLOBAL, k)) {
v = GLOBAL[k];
sandbox[k] = v;
}
}
}
sandbox.__filename = options.filename || "eval";
sandbox.__dirname = path.dirname(sandbox.__filename);
if (!sandbox.module && !sandbox.require) {
Module = require("module");
_module = sandbox.module = new Module(options.modulename || "eval");
_require = sandbox.require = function (path) {
return Module._load(path, _module);
};
_module.filename = sandbox.__filename;
for (_arr = Object.getOwnPropertyNames(require), _i = _arr.length; _i--; ) {
r = _arr[_i];
try {
_require[r] = require[r];
} catch (e) {}
}
}
if (options.includeGlobals) {
for (k in GLOBAL) {
if (__owns.call(GLOBAL, k) && !(k in sandbox)) {
sandbox[k] = GLOBAL[k];
}
}
}
return Script.runInContext(code, sandbox);
} else {
fun = Function("return " + __strnum(code));
return fun();
}
}
exports["eval"] = __promise(function (source, options) {
var _e, _send, _state, _step, _throw, compiled, result, startTime, sync;
_state = 0;
function _close() {
_state = 5;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (options == null) {
options = {};
}
sync = options.sync;
options["eval"] = true;
options["return"] = false;
_state = sync ? 1 : 2;
break;
case 1:
compiled = exports.compileSync(source, options);
_state = 4;
break;
case 2:
++_state;
return {
done: false,
value: exports.compile(source, options)
};
case 3:
compiled = _received;
++_state;
case 4:
startTime = new Date().getTime();
result = evaluate(compiled.code, options);
if (typeof options.progress === "function") {
options.progress("eval", __num(new Date().getTime()) - __num(startTime));
}
++_state;
return { done: true, value: result };
case 5:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
exports.evalSync = function (source, options) {
if (options == null) {
options = {};
}
options.sync = true;
return exports["eval"].sync(source, options);
};
exports.run = __promise(function (source, options) {
var _e, _send, _state, _step, _throw, compiled, mainModule, Module, sync;
_state = 0;
function _close() {
_state = 12;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (options == null) {
options = {};
}
sync = options.sync;
_state = typeof process === "undefined" ? 1 : 5;
break;
case 1:
_state = sync ? 2 : 3;
break;
case 2:
_state = 12;
return {
done: true,
value: exports.evalSync(source, options)
};
case 3:
++_state;
return {
done: false,
value: exports["eval"](source, options)
};
case 4:
_state = 12;
return { done: true, value: _received };
case 5:
mainModule = require.main;
mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : ".";
if (mainModule.moduleCache) {
mainModule.moduleCache = {};
}
if (process.binding("natives").module) {
Module = require("module").Module;
mainModule.paths = Module._nodeModulePaths(path.dirname(options.filename));
}
_state = path.extname(mainModule.filename) !== ".gs" || require.extensions ? 6 : 11;
break;
case 6:
_state = sync ? 7 : 8;
break;
case 7:
compiled = exports.compileSync(source, options);
_state = 10;
break;
case 8:
++_state;
return {
done: false,
value: exports.compile(source, options)
};
case 9:
compiled = _received;
++_state;
case 10:
mainModule._compile(compiled.code, mainModule.filename);
_state = 12;
break;
case 11:
mainModule._compile(source, mainModule.filename);
++_state;
case 12:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
exports.runSync = function (source, options) {
if (options == null) {
options = {};
}
options.sync = true;
return exports.run.sync(source, options);
};
init = exports.init = __promise(function (options) {
var _e, _send, _state, _step, _throw;
_state = 0;
function _close() {
_state = 3;
}
function _step(_received) {
while (true) {
switch (_state) {
case 0:
if (options == null) {
options = {};
}
_state = options.sync ? 1 : 2;
break;
case 1:
fetchAndParsePrelude(options.lang || "js", true);
_state = 3;
break;
case 2:
++_state;
return { done: false, value: fetchAndParsePrelude(options.lang || "js") };
case 3:
return { done: true, value: void 0 };
default: throw Error("Unknown state: " + _state);
}
}
}
function _throw(_e) {
_close();
throw _e;
}
function _send(_received) {
try {
return _step(_received);
} catch (_e) {
_throw(_e);
}
}
return {
close: _close,
iterator: function () {
return this;
},
next: function () {
return _send(void 0);
},
send: _send,
"throw": function (_e) {
_throw(_e);
return _send(void 0);
}
};
});
exports.initSync = function (options) {
if (options == null) {
options = {};
}
options.sync = true;
init.sync(options);
};
}.call(this, typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : this));
return module.exports;
};
require['./browser'] = function () {
var module = { exports: this };
var exports = this;
(function (GLOBAL) {
"use strict";
var __async, __fromPromise, __isArray, __num, __once, __slice, __toArray, __typeof, GorillaScript, runScripts, setImmediate;
__async = function (limit, length, hasResult, onValue, onComplete) {
var broken, completed, index, result, slotsUsed, sync;
if (typeof limit !== "number") {
throw TypeError("Expected limit to be a Number, got " + __typeof(limit));
}
if (typeof length !== "number") {
throw TypeError("Expected length to be a Number, got " + __typeof(length));
}
if (hasResult == null) {
hasResult = false;
} else if (typeof hasResult !== "boolean") {
throw TypeError("Expected hasResult to be a Boolean, got " + __typeof(hasResult));
}
if (typeof onValue !== "function") {
throw TypeError("Expected onValue to be a Function, got " + __typeof(onValue));
}
if (typeof onComplete !== "function") {
throw TypeError("Expected onComplete to be a Function, got " + __typeof(onComplete));
}
if (hasResult) {
result = [];
} else {
result = null;
}
if (length <= 0) {
return onComplete(null, result);
}
if (limit < 1 || limit !== limit) {
limit = 1/0;
}
broken = null;
slotsUsed = 0;
sync = false;
completed = false;
function onValueCallback(err, value) {
if (completed) {
return;
}
--slotsUsed;
if (err != null && broken == null) {
broken = err;
}
if (hasResult && broken == null && arguments.length > 1) {
result.push(value);
}
if (!sync) {
next();
}
}
index = -1;
function next() {
while (!completed && broken == null && slotsUsed < limit && ++index < length) {
++slotsUsed;
sync = true;
onValue(index, __once(onValueCallback));
sync = false;
}
if (!completed && (broken != null || slotsUsed === 0)) {
completed = true;
if (broken != null) {
onComplete(broken);
} else {
onComplete(null, result);
}
}
}
next();
};
__fromPromise = function (promise) {
if (typeof promise !== "object" || promise === null) {
throw TypeError("Expected promise to be an Object, got " + __typeof(promise));
} else if (typeof promise.then !== "function") {
throw TypeError("Expected promise.then to be a Function, got " + __typeof(promise.then));
}
return function (callback) {
promise.then(
function (value) {
return setImmediate(callback, null, value);
},
function (reason) {
return setImmediate(callback, reason);
}
);
};
};
__isArray = typeof Array.isArray === "function" ? Array.isArray
: (function () {
var _toString;
_toString = Object.prototype.toString;
return function (x) {
return _toString.call(x) === "[object Array]";
};
}());
__num = function (num) {
if (typeof num !== "number") {
throw TypeError("Expected a number, got " + __typeof(num));
} else {
return num;
}
};
__once = (function () {
function replacement() {
throw Error("Attempted to call function more than once");
}
function doNothing() {}
return function (func, silentFail) {
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
if (silentFail == null) {
silentFail = false;
} else if (typeof silentFail !== "boolean") {
throw TypeError("Expected silentFail to be a Boolean, got " + __typeof(silentFail));
}
return function () {
var f;
f = func;
func = silentFail ? doNothing : replacement;
return f.apply(this, arguments);
};
};
}());
__slice = Array.prototype.slice;
__toArray = function (x) {
if (x == null) {
throw TypeError("Expected an object, got " + __typeof(x));
} else if (__isArray(x)) {
return x;
} else if (typeof x === "string") {
return x.split("");
} else {
return __slice.call(x);
}
};
__typeof = (function () {
var _toString;
_toString = Object.prototype.toString;
return function (o) {
if (o === void 0) {
return "Undefined";
} else if (o === null) {
return "Null";
} else {
return o.constructor && o.constructor.name || _toString.call(o).slice(8, -1);
}
};
}());
setImmediate = typeof GLOBAL.setImmediate === "function" ? GLOBAL.setImmediate
: typeof process !== "undefined" && typeof process.nextTick === "function"
? (function () {
var nextTick;
nextTick = process.nextTick;
return function (func) {
var args;
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
args = __slice.call(arguments, 1);
if (args.length) {
return nextTick(function () {
func.apply(void 0, __toArray(args));
});
} else {
return nextTick(func);
}
};
}())
: function (func) {
var args;
if (typeof func !== "function") {
throw TypeError("Expected func to be a Function, got " + __typeof(func));
}
args = __slice.call(arguments, 1);
if (args.length) {
return setTimeout(
function () {
func.apply(void 0, __toArray(args));
},
0
);
} else {
return setTimeout(func, 0);
}
};
GorillaScript = require("./gorilla");
GorillaScript.require = require;
if (typeof window !== "undefined" && window !== null) {
GorillaScript.load = function (url, callback) {
var xhr;
if (typeof url !== "string") {
throw TypeError("Expected url to be a String, got " + __typeof(url));
}
if (typeof callback !== "function") {
throw TypeError("Expected callback to be a Function, got " + __typeof(callback));
}
if (window.ActiveXObject) {
xhr = new (window.ActiveXObject)("Microsoft.XMLHTTP");
} else if (XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else {
throw Error("Unable to create XMLHttpRequest");
}
xhr.open("GET", url, true);
if (typeof xhr.overrideMimeType === "function") {
xhr.overrideMimeType("text/plain");
}
xhr.onreadystatechange = function () {
var _ref;
if (xhr.readyState === 4) {
if ((_ref = xhr.status) === 0 || _ref === 200) {
return __fromPromise(GorillaScript.run(xhr.responseText))(callback);
} else {
return callback(Error("Could not load " + url));
}
}
};
return xhr.send(null);
};
runScripts = function () {
var scripts;
scripts = document.getElementsByTagName("script");
return __async(
1,
__num(scripts.length),
false,
function (_i, next) {
var script;
script = scripts[_i];
if (script.type === "text/gorillascript") {
if (script.src) {
return GorillaScript.load(script.src, next);
} else {
GorillaScript.runSync(script.innerHTML);
return next();
}
} else {
return next();
}
},
function (_err) {}
);
};
if (window.addEventListener) {
addEventListener("DOMContentLoaded", runScripts, false);
} else {
attachEvent("onload", runScripts);
}
}
}.call(this, typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : this));
return module.exports;
};
require("./browser");
return require("./gorilla").withPrelude("js", {
consts: {
"true": true,
"false": false,
"null": null,
"void": {type: "void"},
"undefined": {type: "void"},
Infinity: {type: "Infinity"},
"NaN": {type: "NaN"}
},
syntax: [
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;body=macroData.body;return __node("Call",9,9,__node("Function",9,12,[],__wrap(body),true,true,false,void 0,false,[]),[],false,false);};}.call(this));',
params: [[
"ident",
"body",
"choice",
["ident", "Body"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]],
names: "do",
id: 0
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;return this["debugger"]();};}.call(this));',
params: [["const", ""]],
names: "debugger",
id: 14
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var func,ident,macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;ident=macroData.ident;func=macroData.func;this["let"](ident,false,this.type(func));return this.block([this["var"](ident,false),this.assign(ident,"=",func)]);};}.call(this));',
params: [
["ident", "ident", "ident", "Identifier"],
["ident", "func", "ident", "FunctionDeclaration"]
],
names: "let",
id: 15
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _this,body,elseBody,elseIfs,macroData,macroName,test;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;test=macroData.test;body=macroData.body;elseIfs=macroData.elseIfs;elseBody=macroData.elseBody;function dec(x){return x - 1;};function f(i,current){return i>=0&&f(dec(i),_this["if"](elseIfs[i].test,elseIfs[i].body,current))||current;};return this["if"](macroName==="unless"&&__node("MacroAccess",89,40,3,89,{op:"not",node:__wrap(test)},"expression",false,false)||test,body,f(dec(elseIfs.length),elseBody));};}.call(this));',
params: [
["ident", "test", "ident", "Logic"],
["const", "then"],
["ident", "body"],
[
"ident",
"elseIfs",
"many",
"*",
"sequence",
["const", "else"],
["const", "if"],
["ident", "test", "ident", "Logic"],
["const", "then"],
["ident", "body"]
],
[
"ident",
"elseBody",
"many",
"?",
"sequence",
["const", "else"],
["this"]
]
],
names: ["if", "unless"],
id: 16
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _this,body,elseBody,elseIfs,macroData,macroName,test;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;test=macroData.test;body=macroData.body;elseIfs=macroData.elseIfs;elseBody=macroData.elseBody;function dec(x){return x - 1;};function f(i,current){if(i>=0){return f(dec(i),_this["if"](elseIfs[i].type==="unless"?__node("MacroAccess",94,80,3,94,{op:"not",node:__wrap(elseIfs[i].test)},"expression",false,false):elseIfs[i].test,elseIfs[i].body,current));}else{return current;}};return this["if"](macroName==="unless"?__node("MacroAccess",95,43,3,95,{op:"not",node:__wrap(test)},"expression",false,false):test,body,f(dec(elseIfs.length),elseBody));};}.call(this));',
params: [
["ident", "test", "ident", "Logic"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
[
"ident",
"elseIfs",
"many",
"*",
"sequence",
["const", "\n"],
["const", "else"],
[
"ident",
"type",
"choice",
["const", "if"],
["const", "unless"]
],
["ident", "test", "ident", "Logic"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
[
"ident",
"elseBody",
"many",
"?",
"sequence",
["const", "\n"],
["const", "else"],
[
"this",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
["const", "end"]
],
names: ["if", "unless"],
id: 17
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var label,macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;label=macroData.label;if(this.position==="expression"){this.error("continue can only be used in a statement position");}return this["continue"](label);};}.call(this));',
params: [[
"ident",
"label",
"choice",
["ident", "Identifier"],
["const", ""]
]],
names: "continue",
id: 18
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var label,macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;label=macroData.label;if(this.position==="expression"){this.error("break can only be used in a statement position");}return this["break"](label);};}.call(this));',
params: [[
"ident",
"label",
"choice",
["ident", "Identifier"],
["const", ""]
]],
names: "break",
id: 19
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _ref,_this,declarable,handle,handleItem,macroData,macroName,numRealElements,value;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;declarable=macroData.declarable;value=macroData.value;function inc(x){return x + 1;};declarable=this.macroExpand1(declarable);if(!declarable){this.error("Unknown declarable: "+String(declarable));}if(declarable.type==="ident"){this["let"](declarable.ident,declarable.isMutable,declarable.asType?this.toType(declarable.asType):this.type(value));return this.block([this["var"](declarable.ident,declarable.isMutable),this.mutateLast(value||this.noop(),function(n){return _this.assign(declarable.ident,"=",n);},true)]);}else if(declarable.type==="array"){numRealElements=function(i,acc){if(i<declarable.elements.length){return numRealElements(inc(i),declarable.elements[i]?inc(acc):acc);}else{return acc;}};if(numRealElements(0,0)<=1){handleItem=function(element,index){return _this.macroExpand1(__node("MacroAccess",213,30,38,213,{macroName:"let",macroData:{declarable:__node("MacroAccess",213,34,37,213,__node("MacroAccess",213,34,31,213,{ident:__wrap(element)},"statement",false,false),"statement",false,false),value:__node("Access",213,45,__wrap(value),__wrap(index))}},"statement",false,false));};handle=function(i){if(i<declarable.elements.length){if(declarable.elements[i]){return handleItem(declarable.elements[i],_this["const"](i));}else{return handle(inc(i));}}else{return value;}};return handle(0);}else{return this.maybeCache(value,function(setValue,value){function handleItem(i,element,currentValue,index,block){block.push(_this.macroExpand1(__node("MacroAccess",226,43,38,226,{macroName:"let",macroData:{declarable:__node("MacroAccess",226,47,37,226,__node("MacroAccess",226,47,31,226,{ident:__wrap(element)},"statement",false,false),"statement",false,false),value:__node("Access",226,58,__wrap(currentValue),__wrap(index))}},"statement",false,false)));return handle(inc(i),value,block);};function handle(i,currentValue,block){if(i<declarable.elements.length){if(declarable.elements[i]){return handleItem(i,declarable.elements[i],currentValue,_this["const"](i),block);}else{return handle(inc(i),currentValue,block);}}else{return _this.block(block);}};return handle(0,setValue,[]);});}}else if(declarable.type==="object"){if(declarable.pairs.length===1){handleItem=function(left,key){return _this.macroExpand1(__node("MacroAccess",240,30,38,240,{macroName:"let",macroData:{declarable:__node("MacroAccess",240,34,37,240,__node("MacroAccess",240,34,31,240,{ident:__wrap(left)},"statement",false,false),"statement",false,false),value:__node("Access",240,42,__wrap(value),__wrap(key))}},"statement",false,false));};handle=function(pair){return handleItem(pair.value,pair.key);};return handle(this.macroExpand1(declarable.pairs[0]));}else{return this.maybeCache(value,function(setValue,value){function handleItem(i,left,currentValue,key,block){block.push(_this.macroExpand1(__node("MacroAccess",247,43,38,247,{macroName:"let",macroData:{declarable:__node("MacroAccess",247,47,37,247,__node("MacroAccess",247,47,31,247,{ident:__wrap(left)},"statement",false,false),"statement",false,false),value:__node("Access",247,55,__wrap(currentValue),__wrap(key))}},"statement",false,false)));return handle(inc(i),value,block);};function handlePair(i,currentValue,pair,block){return handleItem(i,pair.value,currentValue,pair.key,block);};function handle(i,currentValue,block){if(i<declarable.pairs.length){return handlePair(i,currentValue,_this.macroExpand1(declarable.pairs[i]),block);}else{return _this.block(block);}};return handle(0,setValue,[]);});}}else{return this.error("Unknown declarable: "+String(declarable+" "+String(declarable!=null&&(_ref=declarable.constructor)!=null?_ref.name:void 0)));}};}.call(this));',
params: [
["ident", "declarable", "ident", "Declarable"],
["const", "="],
["ident", "value", "ident", "ExpressionOrAssignmentOrBody"]
],
names: "let",
id: 38
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _this,macroData,macroName,node;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData.node;if(node){return this.mutateLast(node||this.noop(),function(n){return _this["return"](n);},true);}else{return this["return"]();}};}.call(this));',
params: [["ident", "node", "many", "?", "ident", "Expression"]],
names: "return",
id: 39
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _this,macroData,macroName,node;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData.node;return this.mutateLast(node||this.noop(),function(n){return _this.maybeCache(n,function(setN,n){return __node("MacroAccess",272,1,17,272,{macroName:"if",macroData:{test:__node("MacroAccess",272,13,20,272,{op:"?",node:__wrap(setN)},"statement",false,false),body:__node("MacroAccess",273,1,39,273,{macroName:"return",macroData:{node:__wrap(n)}},"statement",false,false),elseIfs:[]}},"statement",false,false);});},true);};}.call(this));',
params: [["ident", "node", "ident", "Expression"]],
names: "return?",
id: 40
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _this,macroData,macroName,node;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData.node;return this.mutateLast(node||this.noop(),function(n){if(_this.isType(n,"boolean")){return __node("MacroAccess",280,1,17,280,{macroName:"if",macroData:{test:__wrap(n),body:__node("MacroAccess",281,1,39,281,{macroName:"return",macroData:{node:__node("Const",281,19,true)}},"statement",false,false),elseIfs:[]}},"statement",false,false);}else{return _this.maybeCache(n,function(setN,n){return __node("MacroAccess",285,1,17,285,{macroName:"if",macroData:{test:__wrap(setN),body:__node("MacroAccess",286,1,39,286,{macroName:"return",macroData:{node:__wrap(n)}},"statement",false,false),elseIfs:[]}},"statement",false,false);});}},true);};}.call(this));',
params: [["ident", "node", "ident", "Expression"]],
names: "returnif",
id: 41
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _this,macroData,macroName,node;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData.node;return this.mutateLast(node||this.noop(),function(n){if(_this.isType(n,"boolean")){return __node("MacroAccess",293,1,17,293,{macroName:"unless",macroData:{test:__wrap(n),body:__node("MacroAccess",294,1,39,294,{macroName:"return",macroData:{node:__node("Const",294,19,false)}},"statement",false,false),elseIfs:[]}},"statement",false,false);}else{return _this.maybeCache(n,function(setN,n){return __node("MacroAccess",298,1,17,298,{macroName:"unless",macroData:{test:__wrap(setN),body:__node("MacroAccess",299,1,39,299,{macroName:"return",macroData:{node:__wrap(n)}},"statement",false,false),elseIfs:[]}},"statement",false,false);});}},true);};}.call(this));',
params: [["ident", "node", "ident", "Expression"]],
names: "returnunless",
id: 42
},
{
code: 'return (function(){"use strict";var __lt,__num,__typeof;__lt=function(x,y){var type;type=typeof x;if(type!=="number"&&type!=="string"){throw TypeError("Cannot compare a non-number/string: "+type);}else if(type!==typeof y){throw TypeError("Cannot compare elements of different types: "+type+" vs "+typeof y);}else{return x<y;}};__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _this,body,f,locals,macroData,macroName,params,values;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;locals=macroData.locals;body=macroData.body;params=[];values=[];if(locals){if(locals.ident){params.push(this.param(locals.ident));values.push(locals.value);}f=function(i){if(__lt(i,locals.rest.length)){if(locals.rest[i].ident){params.push(_this.param(locals.rest[i].ident));values.push(locals.rest[i].value);}return f(__num(i)+1);}};f(0);}return this.call(this.func(params,body,true,true),values);};}.call(this));',
params: [
[
"ident",
"locals",
"many",
"?",
"sequence",
["ident", "ident", "ident", "Identifier"],
["const", "="],
["ident", "value"],
[
"ident",
"rest",
"many",
"*",
"sequence",
["const", ","],
["ident", "ident", "ident", "Identifier"],
["const", "="],
["ident", "value"]
]
],
[
"ident",
"body",
"choice",
["ident", "Body"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
names: "do",
id: 102
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,func,macroData,macroName,node;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData.node;body=macroData.body;func=__node("Function",926,22,[],__wrap(body),true,false,false,void 0,false,[]);return __node("Call",927,9,__wrap(func),[__wrap(node)],false,true);};}.call(this));',
params: [
["ident", "node", "ident", "Expression"],
[
"ident",
"body",
"choice",
["ident", "Body"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
names: "with",
id: 103
},
{
code: 'return (function(){"use strict";var __strnum,__typeof;__strnum=function(strnum){var type;type=typeof strnum;if(type==="string"){return strnum;}else if(type==="number"){return String(strnum);}else{throw TypeError("Expected a string or number, got "+__typeof(strnum));}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var arr,body,elseBody,init,loop,macroData,macroName,reducer,runElse,step,test;macroName=macroFullData.macroName;macroData=macroFullData.macroData;reducer=macroData.reducer;init=macroData.init;test=macroData.test;step=macroData.step;body=macroData.body;elseBody=macroData.elseBody;if(init==null){init=this.noop();}if(test==null){test=__node("Const",976,17,true);}if(step==null){step=this.noop();}if(reducer){if(reducer==="first"){body=this.mutateLast(body||this.noop(),function(node){return __node("MacroAccess",980,62,39,980,{macroName:"return",macroData:{node:__wrap(node)}},"statement",false,false);});loop=this["for"](init,test,step,body);return __node("MacroAccess",982,13,0,982,{macroName:"do",macroData:{body:__node("Block",983,1,[__wrap(loop),__wrap(elseBody)],null)}},"expression",false,false);}else{if(elseBody){this.error("Cannot use a for loop with an else with "+__strnum(reducer),elseBody);}if(reducer==="some"){body=this.mutateLast(body||this.noop(),function(node){return __node("MacroAccess",990,1,17,990,{macroName:"if",macroData:{test:__wrap(node),body:__node("MacroAccess",991,1,39,991,{macroName:"return",macroData:{node:__node("Const",991,21,true)}},"statement",false,false),elseIfs:[]}},"statement",false,false);});loop=[this["for"](init,test,step,body),__node("MacroAccess",992,57,39,992,{macroName:"return",macroData:{node:__node("Const",992,64,false)}},"statement",false,false)];return __node("MacroAccess",993,15,0,993,{macroName:"do",macroData:{body:__wrap(loop)}},"expression",false,false);}else if(reducer==="every"){body=this.mutateLast(body||this.noop(),function(node){return __node("MacroAccess",997,1,17,997,{macroName:"if",macroData:{test:__node("MacroAccess",997,15,3,997,{op:"not",node:__wrap(node)},"statement",false,false),body:__node("MacroAccess",998,1,39,998,{macroName:"return",macroData:{node:__node("Const",998,21,false)}},"statement",false,false),elseIfs:[]}},"statement",false,false);});loop=[this["for"](init,test,step,body),__node("MacroAccess",999,57,39,999,{macroName:"return",macroData:{node:__node("Const",999,64,true)}},"statement",false,false)];return __node("MacroAccess",1000,15,0,1000,{macroName:"do",macroData:{body:__wrap(loop)}},"expression",false,false);}else{return this.error("Unknown reducer: "+__strnum(reducer));}}}else if(elseBody){if(this.position==="expression"){this.error("Cannot use a for loop with an else with as an expression",elseBody);}runElse=this.tmp("else",false,"boolean");body=__node("Block",1009,1,[__node("MacroAccess",1009,1,30,1009,{left:__wrap(runElse),op:":=",right:__node("Const",1009,21,false)},"statement",false,false),__wrap(body)],null);init=__node("Block",1012,1,[__node("MacroAccess",1012,1,30,1012,{left:__wrap(runElse),op:":=",right:__node("Const",1012,21,true)},"statement",false,false),__wrap(init)],null);loop=this["for"](init,test,step,body);return __node("Block",1016,1,[__wrap(loop),__node("MacroAccess",1017,1,17,1017,{macroName:"if",macroData:{test:__wrap(runElse),body:__wrap(elseBody),elseIfs:[]}},"statement",false,false)],null);}else if(this.position==="expression"){arr=this.tmp("arr",false,this.type(body).array());body=this.mutateLast(body||this.noop(),function(node){return __node("Call",1021,61,__node("Access",1021,61,__wrap(arr),__node("Const",1021,67,"push")),[__wrap(node)],false,false);});init=__node("Block",1023,1,[__node("MacroAccess",1023,1,30,1023,{left:__wrap(arr),op:":=",right:__node("Array",1023,16,[])},"statement",false,false),__wrap(init)],null);loop=this["for"](init,test,step,body);return __node("Block",1027,1,[__wrap(loop),__wrap(arr)],null);}else{return this["for"](init,test,step,body);}};}.call(this));',
params: [
[
"ident",
"reducer",
"many",
"?",
"choice",
["const", "every"],
["const", "some"],
["const", "first"]
],
[
"ident",
"init",
"choice",
["ident", "ExpressionOrAssignment"],
["const", ""]
],
["const", ";"],
[
"ident",
"test",
"choice",
["ident", "Logic"],
["const", ""]
],
["const", ";"],
[
"ident",
"step",
"choice",
["ident", "ExpressionOrAssignment"],
["const", ""]
],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
[
"ident",
"elseBody",
"many",
"?",
"sequence",
["const", "\n"],
["const", "else"],
[
"this",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
["const", "end"]
],
names: "for",
id: 104
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,current,currentStart,init,macroData,macroName,step,test;macroName=macroFullData.macroName;macroData=macroFullData.macroData;init=macroData.init;test=macroData.test;step=macroData.step;current=macroData.current;currentStart=macroData.currentStart;body=macroData.body;if(init==null){init=this.noop();}if(test==null){test=__node("Const",1034,17,true);}if(step==null){step=this.noop();}body=this.mutateLast(body||this.noop(),function(node){return __node("MacroAccess",1037,59,30,1037,{left:__wrap(current),op:":=",right:__wrap(node)},"expression",false,false);});return __node("Block",1039,1,[__node("MacroAccess",1039,1,38,1039,{macroName:"let",macroData:{declarable:__node("MacroAccess",1039,10,37,1039,__node("MacroAccess",1039,10,31,1039,{isMutable:"mutable",ident:__wrap(current)},"statement",false,false),"statement",false,false),value:__wrap(currentStart)}},"statement",false,false),__node("MacroAccess",1040,1,104,1040,{macroName:"for",macroData:{init:__wrap(init),test:__wrap(test),step:__wrap(step),body:__wrap(body)}},"statement",false,false),__wrap(current)],null);};}.call(this));',
params: [
["const", "reduce"],
[
"ident",
"init",
"choice",
["ident", "Expression"],
["const", ""]
],
["const", ";"],
[
"ident",
"test",
"choice",
["ident", "Logic"],
["const", ""]
],
["const", ";"],
[
"ident",
"step",
"choice",
["ident", "Statement"],
["const", ""]
],
["const", ","],
["ident", "current", "ident", "Identifier"],
["const", "="],
["ident", "currentStart"],
[
"ident",
"body",
"choice",
["ident", "Body"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
names: "for",
id: 105
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,elseBody,macroData,macroName,reducer,step,test;macroName=macroFullData.macroName;macroData=macroFullData.macroData;reducer=macroData.reducer;test=macroData.test;step=macroData.step;body=macroData.body;elseBody=macroData.elseBody;if(macroName==="until"){test=__node("MacroAccess",1047,19,3,1047,{op:"not",node:__wrap(test)},"expression",false,false);}if(reducer==="every"){return __node("MacroAccess",1050,11,104,1050,{macroName:"for",macroData:{reducer:"every",test:__wrap(test),step:__wrap(step),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="some"){return __node("MacroAccess",1055,11,104,1055,{macroName:"for",macroData:{reducer:"some",test:__wrap(test),step:__wrap(step),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="first"){return __node("MacroAccess",1060,11,104,1060,{macroName:"for",macroData:{reducer:"first",test:__wrap(test),step:__wrap(step),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(this.position==="expression"){return __node("MacroAccess",1065,11,104,1065,{macroName:"for",macroData:{test:__wrap(test),step:__wrap(step),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else{return __node("MacroAccess",1071,1,104,1071,{macroName:"for",macroData:{test:__wrap(test),step:__wrap(step),body:__wrap(body),elseBody:__wrap(elseBody)}},"statement",false,false);}};}.call(this));',
params: [
[
"ident",
"reducer",
"many",
"?",
"choice",
["const", "every"],
["const", "some"],
["const", "first"]
],
["ident", "test", "ident", "Logic"],
[
"ident",
"step",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "ExpressionOrAssignment"]
],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
[
"ident",
"elseBody",
"many",
"?",
"sequence",
["const", "\n"],
["const", "else"],
[
"this",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
["const", "end"]
],
names: ["while", "until"],
id: 106
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,current,currentStart,macroData,macroName,step,test;macroName=macroFullData.macroName;macroData=macroFullData.macroData;test=macroData.test;step=macroData.step;current=macroData.current;currentStart=macroData.currentStart;body=macroData.body;if(macroName==="until"){test=__node("MacroAccess",1078,19,3,1078,{op:"not",node:__wrap(test)},"expression",false,false);}return __node("MacroAccess",1081,1,105,1081,{macroName:"for",macroData:{test:__wrap(test),step:__wrap(step),current:__wrap(current),currentStart:__wrap(currentStart),body:__wrap(body)}},"statement",false,false);};}.call(this));',
params: [
["const", "reduce"],
["ident", "test", "ident", "Logic"],
[
"ident",
"step",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "ExpressionOrAssignment"]
],
["const", ","],
["ident", "current", "ident", "Identifier"],
["const", "="],
["ident", "currentStart"],
[
"ident",
"body",
"choice",
["ident", "Body"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
names: ["while", "until"],
id: 107
},
{
code: 'return (function(){"use strict";var __num,__strnum,__typeof;__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__strnum=function(strnum){var type;type=typeof strnum;if(type==="string"){return strnum;}else if(type==="number"){return String(strnum);}else{throw TypeError("Expected a string or number, got "+__typeof(strnum));}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _ref,_ref2,args,array,body,elseBody,end,func,hasIndex,hasLength,inclusive,increment,index,init,isString,length,letIndex,letLength,letValue,macroData,macroName,reducer,start,step,test,tmp,value,valueExpr,valueIdent;macroName=macroFullData.macroName;macroData=macroFullData.macroData;reducer=macroData.reducer;value=macroData.value;index=macroData.index;array=macroData.array;body=macroData.body;elseBody=macroData.elseBody;value=this.macroExpand1(value);length=null;if(index){length=index.length;index=index.value;}if(this.isCall(array)&&this.isIdent(this.callFunc(array))&&this.name(this.callFunc(array))==="__toArray"&&!this.callIsApply(array)){array=this.callArgs(array)[0];}if(this.isCall(array)&&this.isIdent(this.callFunc(array))&&this.name(this.callFunc(array))==="__range"&&!this.callIsApply(array)){if(this.isArray(value)||this.isObject(value)){this.error("Cannot assign a number to a complex declarable",value);}value=value.ident;start=(_ref=this.callArgs(array))[0];end=_ref[1];step=_ref[2];inclusive=_ref[3];init=[];if(this.isConst(start)){if(typeof this.value(start)!=="number"){this.error("Cannot start with a non-number: "+__strnum(this.value(start)),start);}}else{start=__node("MacroAccess",1140,22,58,1140,{op:"+",node:__wrap(start)},"expression",false,false);}init.push(this.macroExpandAll(__node("MacroAccess",1141,38,38,1141,{macroName:"let",macroData:{declarable:__node("MacroAccess",1141,42,37,1141,__node("MacroAccess",1141,42,31,1141,{isMutable:"mutable",ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__wrap(start)}},"statement",false,false)));if(this.isConst(end)){if(typeof this.value(end)!=="number"){this.error("Cannot end with a non-number: "+__strnum(this.value(end)),end);}}else if(this.isComplex(end)){end=this.cache(__node("MacroAccess",1147,28,58,1147,{op:"+",node:__wrap(end)},"expression",false,false),init,"end",false);}else{init.push(__node("MacroAccess",1149,23,58,1149,{op:"+",node:__wrap(end)},"expression",false,false));}if(this.isConst(step)){if(typeof this.value(step)!=="number"){this.error("Cannot step with a non-number: "+__strnum(this.value(step)),step);}}else if(this.isComplex(step)){step=this.cache(__node("MacroAccess",1155,29,58,1155,{op:"+",node:__wrap(step)},"expression",false,false),init,"step",false);}else{init.push(__node("MacroAccess",1157,23,58,1157,{op:"+",node:__wrap(step)},"expression",false,false));}if(this.isComplex(inclusive)){inclusive=this.cache(__wrap(inclusive),init,"incl",false);}if(this.isConst(step)){if(__num(this.value(step))>0){if(this.isConst(end)&&this.value(end)===1/0){test=__node("Const",1165,17,true);}else{test=__node("MacroAccess",1167,17,16,1167,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1167,36,9,1167,{left:__wrap(value),inverted:false,op:"~<=",right:__wrap(end)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1167,57,9,1167,{left:__wrap(value),inverted:false,op:"~<",right:__wrap(end)},"expression",false,false)}},"expression",false,false);}}else if(this.isConst(end)&&this.value(end)===-1/0){test=__node("Const",1170,17,true);}else{test=__node("MacroAccess",1172,17,16,1172,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1172,36,10,1172,{left:__wrap(value),inverted:false,op:"~>=",right:__wrap(end)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1172,57,10,1172,{left:__wrap(value),inverted:false,op:"~>",right:__wrap(end)},"expression",false,false)}},"expression",false,false);}}else{test=__node("MacroAccess",1174,13,17,1174,{macroName:"if",macroData:{test:__node("MacroAccess",1174,16,10,1174,{left:__wrap(step),inverted:false,op:"~>",right:__node("Const",1174,26,0)},"expression",false,false),body:__node("MacroAccess",1175,1,16,1175,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1175,29,9,1175,{left:__wrap(value),inverted:false,op:"~<=",right:__wrap(end)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1175,50,9,1175,{left:__wrap(value),inverted:false,op:"~<",right:__wrap(end)},"expression",false,false)}},"statement",false,false),elseIfs:[],elseBody:__node("MacroAccess",1177,1,16,1177,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1177,29,10,1177,{left:__wrap(value),inverted:false,op:"~>=",right:__wrap(end)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1177,50,10,1177,{left:__wrap(value),inverted:false,op:"~>",right:__wrap(end)},"expression",false,false)}},"statement",false,false)}},"expression",false,false);}increment=__node("MacroAccess",1179,35,52,1179,{left:__wrap(value),op:"~+=",right:__wrap(step)},"expression",false,false);if(length){init.push(this.macroExpandAll(__node("MacroAccess",1182,40,38,1182,{macroName:"let",macroData:{declarable:__node("MacroAccess",1182,44,37,1182,__node("MacroAccess",1182,44,31,1182,{ident:__wrap(length)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1182,54,17,1182,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1183,1,45,1183,{left:__node("MacroAccess",1183,12,49,1183,{left:__node("MacroAccess",1183,12,49,1183,{left:__wrap(end),inverted:false,op:"~-",right:__wrap(start)},"expression",false,false),inverted:false,op:"~+",right:__wrap(step)},"expression",false,false),inverted:false,op:"~\\\\",right:__wrap(step)},"statement",false,false),elseIfs:[],elseBody:__node("MacroAccess",1185,1,45,1185,{left:__node("MacroAccess",1185,12,49,1185,{left:__wrap(end),inverted:false,op:"~-",right:__wrap(start)},"expression",false,false),inverted:false,op:"~\\\\",right:__wrap(step)},"statement",false,false)}},"expression",false,false)}},"statement",false,false)));}if(index){init.push(this.macroExpandAll(__node("MacroAccess",1188,40,38,1188,{macroName:"let",macroData:{declarable:__node("MacroAccess",1188,44,37,1188,__node("MacroAccess",1188,44,31,1188,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("Const",1188,62,0)}},"statement",false,false)));increment=__node("Block",1190,1,[__wrap(increment),__node("MacroAccess",1191,1,101,1191,{left:__wrap(index),op:"+=",right:__node("Const",1191,21,1)},"statement",false,false)],null);if(this.hasFunc(body)){func=this.tmp("f",false,"function");init.push(__node("MacroAccess",1194,25,38,1194,{macroName:"let",macroData:{declarable:__node("MacroAccess",1194,29,37,1194,__node("MacroAccess",1194,29,31,1194,{ident:__wrap(func)},"statement",false,false),"statement",false,false),value:__node("Function",1194,39,[__node("Param",1194,40,__wrap(value),void 0,false,false,void 0),__node("Param",1194,47,__wrap(index),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,false,[])}},"statement",false,false));body=__node("Call",1195,24,__wrap(func),[__node("This",1195,32),__wrap(value),__wrap(index)],false,true);}}else if(this.hasFunc(body)){func=this.tmp("f",false,"function");init.push(__node("MacroAccess",1198,23,38,1198,{macroName:"let",macroData:{declarable:__node("MacroAccess",1198,27,37,1198,__node("MacroAccess",1198,27,31,1198,{ident:__wrap(func)},"statement",false,false),"statement",false,false),value:__node("Function",1198,37,[__node("Param",1198,38,__wrap(value),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,false,[])}},"statement",false,false));body=__node("Call",1199,22,__wrap(func),[__node("This",1199,30),__wrap(value)],false,true);}if(reducer==="every"){return __node("MacroAccess",1202,13,104,1202,{macroName:"for",macroData:{reducer:"every",init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="some"){return __node("MacroAccess",1207,13,104,1207,{macroName:"for",macroData:{reducer:"some",init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="first"){return __node("MacroAccess",1212,13,104,1212,{macroName:"for",macroData:{reducer:"first",init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="filter"){body=this.mutateLast(body,function(node){return __node("MacroAccess",1218,14,17,1218,{macroName:"if",macroData:{test:__wrap(node),body:__wrap(value),elseIfs:[]}},"statement",false,false);});return __node("MacroAccess",1220,13,104,1220,{macroName:"for",macroData:{init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(this.position==="expression"){return __node("MacroAccess",1225,13,104,1225,{macroName:"for",macroData:{init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else{return __node("MacroAccess",1231,1,104,1231,{macroName:"for",macroData:{init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"statement",false,false);}}else{init=[];isString=this.isType(array,"string");hasIndex=index!=null;if(index==null){index=this.tmp("i",false,"number");}hasLength=length!=null;if(length==null){length=this.tmp("len",false,"number");}this.macroExpandAll(__node("MacroAccess",1244,28,38,1244,{macroName:"let",macroData:{declarable:__node("MacroAccess",1244,32,37,1244,__node("MacroAccess",1244,32,31,1244,{ident:__wrap(length)},"statement",false,false),"statement",false,false),value:__node("Const",1244,43,0)}},"statement",false,false));array=this.macroExpandAll(array);step=__node("Const",1248,31,1);start=__node("Const",1249,32,0);end=__node("Const",1250,29,1/0);inclusive=__node("Const",1251,35,false);if(this.isCall(array)&&this.isIdent(this.callFunc(array))){if(this.name(this.callFunc(array))==="__step"&&!this.callIsApply(array)){args=this.callArgs(array);array=args[0];step=args[1];if(this.isConst(step)){if(__num(this.value(step))>=0){start=__node("Const",1259,29,0);end=__node("Const",1260,26,1/0);}else{start=__node("Const",1262,28,1/0);end=__node("Const",1263,27,0);}}else{start=void 0;end=void 0;}inclusive=__node("Const",1267,28,true);}else if(this.name(this.callFunc(array))==="__slice"&&this.callIsApply(array)){args=this.callArgs(array);array=args[0];start=args[1];end=args[2];if(this.isConst(end)&&this.value(end)===void 0){end=__node("Const",1274,24,1/0);}}else if(this.name(this.callFunc(array))==="__sliceStep"&&!this.callIsApply(array)){args=this.callArgs(array);array=args[0];start=args[1];end=args[2];step=args[3];inclusive=args[4];}}if(this.isConst(step)){if(typeof this.value(step)!=="number"){this.error("Expected step to be a number, got "+__typeof(this.value(step)),step);}else if(__num(this.value(step))%1!==0){this.error("Expected step to be an integer, got "+__strnum(this.value(step)),step);}else if(this.value(step)===0){this.error("Expected step to non-zero",step);}}if(start&&this.isConst(start)&&this.value(start)!==1/0&&(typeof this.value(start)!=="number"||__num(this.value(start))%1!==0)){this.error("Expected start to be an integer, got "+__typeof(this.value(start))+" ("+String(this.value(start))+")",start);}if(end&&this.isConst(end)&&this.value(end)!==1/0&&(typeof this.value(end)!=="number"||__num(this.value(end))%1!==0)){this.error("Expected end to be an integer, got "+__typeof(this.value(end))+" ("+String(this.value(end))+")",end);}if(!isString&&!this.isType(array,"arrayLike")){array=__node("Call",1295,22,__node("Ident",1295,22,"__toArray"),[__wrap(array)],false,false);}array=this.cache(array,init,isString?"str":"arr",false);valueExpr=__node("MacroAccess",1298,28,16,1298,{macroName:"if",macroData:{test:__wrap(isString),body:__node("Call",1298,47,__node("Access",1298,47,__wrap(array),__node("Const",1298,55,"charAt")),[__wrap(index)],false,false),elseIfs:[],elseBody:__node("Access",1298,75,__wrap(array),__wrap(index))}},"expression",false,false);letIndex=this.macroExpandAll(__node("MacroAccess",1299,44,38,1299,{macroName:"let",macroData:{declarable:__node("MacroAccess",1299,48,37,1299,__node("MacroAccess",1299,48,31,1299,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("Const",1299,66,0)}},"statement",false,false));if(value&&value.type==="ident"&&!value.isMutable){valueIdent=value.ident;}else{valueIdent=this.tmp("v",false);}letValue=this.macroExpandAll(__node("MacroAccess",1301,44,38,1301,{macroName:"let",macroData:{declarable:__node("MacroAccess",1301,48,37,1301,__node("MacroAccess",1301,48,31,1301,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__wrap(valueExpr)}},"statement",false,false));letLength=this.macroExpandAll(__node("MacroAccess",1302,45,38,1302,{macroName:"let",macroData:{declarable:__node("MacroAccess",1302,49,37,1302,__node("MacroAccess",1302,49,31,1302,{ident:__wrap(length)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1302,59,58,1302,{op:"+",node:__node("Access",1302,61,__wrap(array),__node("Const",1302,68,"length"))},"expression",false,false)}},"statement",false,false));test=(_ref=this.isConst(step)?__num(this.value(step))>0?(this.isConst(start)?__num(this.value(start))>=0?(init.push(__node("MacroAccess",1308,28,38,1308,{macroName:"let",macroData:{declarable:__node("MacroAccess",1308,32,37,1308,__node("MacroAccess",1308,32,31,1308,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__wrap(start)}},"statement",false,false)),init.push(letLength)):(init.push(letLength),init.push(__node("MacroAccess",1312,28,38,1312,{macroName:"let",macroData:{declarable:__node("MacroAccess",1312,32,37,1312,__node("MacroAccess",1312,32,31,1312,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1312,49,64,1312,{left:__wrap(length),inverted:false,op:"+",right:__wrap(start)},"expression",false,false)}},"statement",false,false))):(init.push(letLength),init.push(__node("MacroAccess",1315,26,38,1315,{macroName:"let",macroData:{declarable:__node("MacroAccess",1315,30,37,1315,__node("MacroAccess",1315,30,31,1315,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("Call",1315,47,__node("Ident",1315,47,"__int"),[__wrap(start)],false,false)}},"statement",false,false)),init.push(__node("MacroAccess",1316,27,16,1316,{macroName:"if",macroData:{test:__node("MacroAccess",1316,30,9,1316,{left:__wrap(index),inverted:false,op:"~<",right:__node("Const",1316,41,0)},"expression",false,false),body:__node("MacroAccess",1316,49,101,1316,{left:__wrap(index),op:"+=",right:__wrap(length)},"expression",false,false),elseIfs:[]}},"expression",false,false))),this.isConst(end)&&(this.value(end)===1/0||this.isConst(inclusive)&&this.value(inclusive)&&this.value(end)===-1)?[__node("MacroAccess",1318,18,9,1318,{left:__wrap(index),inverted:false,op:"~<",right:__wrap(length)},"expression",false,false),__node("MacroAccess",1318,44,52,1318,{left:__wrap(index),op:"~+=",right:__wrap(step)},"expression",false,false)]:(tmp=this.tmp("end",false,"number"),init.push(__node("MacroAccess",1321,26,38,1321,{macroName:"let",macroData:{declarable:__node("MacroAccess",1321,30,37,1321,__node("MacroAccess",1321,30,31,1321,{isMutable:"mutable",ident:__wrap(tmp)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1321,45,58,1321,{op:"+",node:__wrap(end)},"expression",false,false)}},"statement",false,false)),!this.isConst(end)?init.push(__node("MacroAccess",1323,29,16,1323,{macroName:"if",macroData:{test:__node("MacroAccess",1323,32,9,1323,{left:__wrap(tmp),inverted:false,op:"~<",right:__node("Const",1323,41,0)},"expression",false,false),body:__node("MacroAccess",1323,49,52,1323,{left:__wrap(tmp),op:"~+=",right:__wrap(length)},"expression",false,false),elseIfs:[]}},"expression",false,false)):__num(this.value(end))<0?init.push(__node("MacroAccess",1325,29,52,1325,{left:__wrap(tmp),op:"~+=",right:__wrap(length)},"expression",false,false)):void 0,init.push(__node("MacroAccess",1326,27,16,1326,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1326,48,30,1326,{left:__wrap(tmp),op:":=",right:__node("MacroAccess",1326,55,2,1326,{left:__node("MacroAccess",1326,55,64,1326,{left:__wrap(tmp),inverted:false,op:"+",right:__node("Const",1326,63,1)},"expression",false,false),inverted:false,op:"or",right:__node("Const",1326,67,1/0)},"expression",false,false)},"expression",false,false),elseIfs:[]}},"expression",false,false)),init.push(__node("MacroAccess",1327,27,84,1327,{left:__wrap(tmp),op:"~min=",right:__wrap(length)},"expression",false,false)),[__node("MacroAccess",1328,18,9,1328,{left:__wrap(index),inverted:false,op:"~<",right:__wrap(tmp)},"expression",false,false),__node("MacroAccess",1328,39,52,1328,{left:__wrap(index),op:"~+=",right:__wrap(step)},"expression",false,false)])):this.value(step)===-1&&(!start||this.isConst(start)&&((_ref2=this.value(start))===-1||_ref2===1/0)&&this.isConst(end)&&this.value(end)===0&&this.isConst(inclusive)&&this.value(inclusive))?(hasLength?(init.push(letLength),init.push(__node("MacroAccess",1332,26,38,1332,{macroName:"let",macroData:{declarable:__node("MacroAccess",1332,30,37,1332,__node("MacroAccess",1332,30,31,1332,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__wrap(length)}},"statement",false,false))):init.push(__node("MacroAccess",1334,26,38,1334,{macroName:"let",macroData:{declarable:__node("MacroAccess",1334,30,37,1334,__node("MacroAccess",1334,30,31,1334,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1334,47,58,1334,{op:"+",node:__node("Access",1334,49,__wrap(array),__node("Const",1334,56,"length"))},"expression",false,false)}},"statement",false,false)),[__node("MacroAccess",1335,16,13,1335,{op:"postDec!",node:__wrap(index)},"expression",false,false),this.noop()]):(!this.isConst(end)||__num(this.value(end))<0?(hasLength=true):void 0,this.isConst(start)?(_ref2=this.value(start))===-1||_ref2===1/0?hasLength?(init.push(letLength),init.push(__node("MacroAccess",1343,30,38,1343,{macroName:"let",macroData:{declarable:__node("MacroAccess",1343,34,37,1343,__node("MacroAccess",1343,34,31,1343,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1343,51,49,1343,{left:__wrap(length),inverted:false,op:"~-",right:__node("Const",1343,63,1)},"expression",false,false)}},"statement",false,false))):init.push(__node("MacroAccess",1345,30,38,1345,{macroName:"let",macroData:{declarable:__node("MacroAccess",1345,34,37,1345,__node("MacroAccess",1345,34,31,1345,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1345,51,49,1345,{left:__node("MacroAccess",1345,51,58,1345,{op:"+",node:__node("Access",1345,53,__wrap(array),__node("Const",1345,60,"length"))},"expression",false,false),inverted:false,op:"~-",right:__node("Const",1345,70,1)},"expression",false,false)}},"statement",false,false)):(init.push(letLength),__num(this.value(start))>=0?init.push(__node("MacroAccess",1349,30,38,1349,{macroName:"let",macroData:{declarable:__node("MacroAccess",1349,34,37,1349,__node("MacroAccess",1349,34,31,1349,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1349,51,16,1349,{macroName:"if",macroData:{test:__node("MacroAccess",1349,54,9,1349,{left:__wrap(start),inverted:false,op:"~<",right:__wrap(length)},"expression",false,false),body:__wrap(start),elseIfs:[],elseBody:__node("MacroAccess",1349,89,49,1349,{left:__wrap(length),inverted:false,op:"~-",right:__node("Const",1349,101,1)},"expression",false,false)}},"expression",false,false)}},"statement",false,false)):init.push(__node("MacroAccess",1351,30,38,1351,{macroName:"let",macroData:{declarable:__node("MacroAccess",1351,34,37,1351,__node("MacroAccess",1351,34,31,1351,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1351,51,49,1351,{left:__wrap(length),inverted:false,op:"~+",right:__node("MacroAccess",1351,62,58,1351,{op:"+",node:__wrap(start)},"expression",false,false)},"expression",false,false)}},"statement",false,false))):(init.push(letLength),init.push(__node("MacroAccess",1354,26,38,1354,{macroName:"let",macroData:{declarable:__node("MacroAccess",1354,30,37,1354,__node("MacroAccess",1354,30,31,1354,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1354,47,58,1354,{op:"+",node:__wrap(start)},"expression",false,false)}},"statement",false,false)),init.push(__node("MacroAccess",1355,26,16,1355,{macroName:"if",macroData:{test:__node("MacroAccess",1355,29,9,1355,{left:__wrap(index),inverted:false,op:"~<",right:__node("Const",1355,40,0)},"statement",false,false),body:__node("MacroAccess",1355,48,52,1355,{left:__wrap(index),op:"~+=",right:__wrap(length)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1355,74,84,1355,{left:__wrap(index),op:"~min=",right:__wrap(length)},"expression",false,false)}},"statement",false,false)),init.push(__node("MacroAccess",1356,26,53,1356,{left:__wrap(index),op:"~-=",right:__node("Const",1356,38,1)},"statement",false,false))),this.isConst(end)?__num(this.value(end))>=0?[__node("MacroAccess",1359,20,16,1359,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1359,39,10,1359,{left:__wrap(index),inverted:false,op:"~>=",right:__wrap(end)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1359,60,10,1359,{left:__wrap(index),inverted:false,op:"~>",right:__wrap(end)},"expression",false,false)}},"expression",false,false),__node("MacroAccess",1359,81,52,1359,{left:__wrap(index),op:"~+=",right:__wrap(step)},"expression",false,false)]:[__node("MacroAccess",1361,20,16,1361,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1361,39,10,1361,{left:__wrap(index),inverted:false,op:"~>=",right:__node("MacroAccess",1361,50,64,1361,{left:__wrap(end),inverted:false,op:"+",right:__wrap(length)},"expression",false,false)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1361,70,10,1361,{left:__wrap(index),inverted:false,op:"~>",right:__node("MacroAccess",1361,80,64,1361,{left:__wrap(end),inverted:false,op:"+",right:__wrap(length)},"expression",false,false)},"expression",false,false)}},"expression",false,false),__node("MacroAccess",1361,101,52,1361,{left:__wrap(index),op:"~+=",right:__wrap(step)},"expression",false,false)]:(tmp=this.tmp("end",false,"number"),init.push(__node("MacroAccess",1364,26,38,1364,{macroName:"let",macroData:{declarable:__node("MacroAccess",1364,30,37,1364,__node("MacroAccess",1364,30,31,1364,{isMutable:"mutable",ident:__wrap(tmp)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1364,45,58,1364,{op:"+",node:__wrap(end)},"expression",false,false)}},"statement",false,false)),init.push(__node("MacroAccess",1365,26,16,1365,{macroName:"if",macroData:{test:__node("MacroAccess",1365,29,9,1365,{left:__wrap(tmp),inverted:false,op:"~<",right:__node("Const",1365,38,0)},"statement",false,false),body:__node("MacroAccess",1365,46,52,1365,{left:__wrap(tmp),op:"~+=",right:__wrap(length)},"expression",false,false),elseIfs:[]}},"statement",false,false)),[__node("MacroAccess",1366,18,16,1366,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1366,37,10,1366,{left:__wrap(index),inverted:false,op:"~>=",right:__wrap(tmp)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1366,58,10,1366,{left:__wrap(index),inverted:false,op:"~>",right:__wrap(tmp)},"expression",false,false)}},"expression",false,false),__node("MacroAccess",1366,79,52,1366,{left:__wrap(index),op:"~+=",right:__wrap(step)},"expression",false,false)])):(this.isComplex(step)?(step=this.cache(__node("Call",1369,31,__node("Ident",1369,31,"__int"),[__node("Call",1369,38,__node("Ident",1369,38,"__nonzero"),[__wrap(step)],false,false)],false,false),init,"step",false)):init.unshift(__node("Call",1371,28,__node("Ident",1371,28,"__int"),[__node("Call",1371,35,__node("Ident",1371,35,"__nonzero"),[__wrap(step)],false,false)],false,false)),init.push(letLength),!start?(init.push(__node("MacroAccess",1374,24,38,1374,{macroName:"let",macroData:{declarable:__node("MacroAccess",1374,28,37,1374,__node("MacroAccess",1374,28,31,1374,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1374,45,16,1374,{macroName:"if",macroData:{test:__node("MacroAccess",1374,48,10,1374,{left:__wrap(step),inverted:false,op:"~>",right:__node("Const",1374,58,0)},"expression",false,false),body:__node("Const",1374,65,0),elseIfs:[],elseBody:__node("MacroAccess",1374,71,49,1374,{left:__wrap(length),inverted:false,op:"~-",right:__node("Const",1374,83,1)},"expression",false,false)}},"expression",false,false)}},"statement",false,false)),[__node("MacroAccess",1376,17,16,1376,{macroName:"if",macroData:{test:__node("MacroAccess",1376,20,10,1376,{left:__wrap(step),inverted:false,op:"~>",right:__node("Const",1376,30,0)},"expression",false,false),body:__node("MacroAccess",1376,36,9,1376,{left:__wrap(index),inverted:false,op:"~<",right:__wrap(length)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1376,59,10,1376,{left:__wrap(index),inverted:false,op:"~>=",right:__node("Const",1376,71,0)},"expression",false,false)}},"expression",false,false),__node("MacroAccess",1377,17,52,1377,{left:__wrap(index),op:"~+=",right:__wrap(step)},"expression",false,false)]):(this.isConst(start)?this.value(start)===1/0?init.push(__node("MacroAccess",1382,28,38,1382,{macroName:"let",macroData:{declarable:__node("MacroAccess",1382,32,37,1382,__node("MacroAccess",1382,32,31,1382,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1382,49,49,1382,{left:__wrap(length),inverted:false,op:"~-",right:__node("Const",1382,61,1)},"expression",false,false)}},"statement",false,false)):init.push(__node("MacroAccess",1384,28,38,1384,{macroName:"let",macroData:{declarable:__node("MacroAccess",1384,32,37,1384,__node("MacroAccess",1384,32,31,1384,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1384,49,16,1384,{macroName:"if",macroData:{test:__node("MacroAccess",1384,52,10,1384,{left:__wrap(start),inverted:false,op:"~>=",right:__node("Const",1384,64,0)},"expression",false,false),body:__wrap(start),elseIfs:[],elseBody:__node("MacroAccess",1384,82,64,1384,{left:__wrap(start),inverted:false,op:"+",right:__wrap(length)},"expression",false,false)}},"expression",false,false)}},"statement",false,false)):(init.push(__node("MacroAccess",1386,26,38,1386,{macroName:"let",macroData:{declarable:__node("MacroAccess",1386,30,37,1386,__node("MacroAccess",1386,30,31,1386,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__wrap(start)}},"statement",false,false)),init.push(__node("MacroAccess",1387,26,16,1387,{macroName:"if",macroData:{test:__node("MacroAccess",1387,29,9,1387,{left:__wrap(index),inverted:false,op:"~<",right:__node("Const",1387,40,0)},"statement",false,false),body:__node("MacroAccess",1387,48,101,1387,{left:__wrap(index),op:"+=",right:__wrap(length)},"expression",false,false),elseIfs:[{test:__node("MacroAccess",1387,74,9,1387,{left:__wrap(step),inverted:false,op:"~<",right:__node("Const",1387,84,0)},"statement",false,false),body:__node("MacroAccess",1387,92,84,1387,{left:__wrap(index),op:"~min=",right:__wrap(length)},"expression",false,false)}]}},"statement",false,false))),tmp=this.tmp("end",false,"number"),this.isConst(end)?init.push(__node("MacroAccess",1390,26,38,1390,{macroName:"let",macroData:{declarable:__node("MacroAccess",1390,30,37,1390,__node("MacroAccess",1390,30,31,1390,{isMutable:"mutable",ident:__wrap(tmp)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1390,45,16,1390,{macroName:"if",macroData:{test:__node("MacroAccess",1390,48,9,1390,{left:__wrap(end),inverted:false,op:"~<",right:__node("Const",1390,57,0)},"expression",false,false),body:__node("MacroAccess",1390,63,49,1390,{left:__wrap(end),inverted:false,op:"~+",right:__wrap(length)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1390,84,81,1390,{left:__wrap(end),inverted:false,op:"max",right:__node("MacroAccess",1390,95,16,1390,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1390,113,49,1390,{left:__wrap(length),inverted:false,op:"~-",right:__node("Const",1390,125,1)},"expression",false,false),elseIfs:[],elseBody:__wrap(length)}},"expression",false,false)},"expression",false,false)}},"expression",false,false)}},"statement",false,false)):(init.push(__node("MacroAccess",1392,26,38,1392,{macroName:"let",macroData:{declarable:__node("MacroAccess",1392,30,37,1392,__node("MacroAccess",1392,30,31,1392,{isMutable:"mutable",ident:__wrap(tmp)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1392,45,58,1392,{op:"+",node:__wrap(end)},"expression",false,false)}},"statement",false,false)),init.push(__node("MacroAccess",1393,26,16,1393,{macroName:"if",macroData:{test:__node("MacroAccess",1393,29,9,1393,{left:__wrap(tmp),inverted:false,op:"~<",right:__node("Const",1393,38,0)},"statement",false,false),body:__node("MacroAccess",1393,46,101,1393,{left:__wrap(tmp),op:"+=",right:__wrap(length)},"expression",false,false),elseIfs:[{test:__node("MacroAccess",1393,70,10,1393,{left:__wrap(step),inverted:false,op:"~>",right:__node("Const",1393,80,0)},"statement",false,false),body:__node("MacroAccess",1393,88,84,1393,{left:__wrap(tmp),op:"~min=",right:__node("MacroAccess",1393,98,16,1393,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1393,117,49,1393,{left:__wrap(length),inverted:false,op:"~-",right:__node("Const",1393,129,1)},"expression",false,false),elseIfs:[],elseBody:__wrap(length)}},"expression",false,false)},"expression",false,false)}],elseBody:__node("MacroAccess",1393,151,85,1393,{left:__wrap(tmp),op:"~max=",right:__node("MacroAccess",1393,163,16,1393,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("Const",1393,182,0),elseIfs:[],elseBody:__node("MacroAccess",1393,188,59,1393,{op:"-",node:__node("Const",1393,190,1)},"expression",false,false)}},"expression",false,false)},"expression",false,false)}},"statement",false,false))),end=tmp,[__node("MacroAccess",1396,17,17,1396,{macroName:"if",macroData:{test:__node("MacroAccess",1396,20,10,1396,{left:__wrap(step),inverted:false,op:"~>",right:__node("Const",1396,30,0)},"expression",false,false),body:__node("MacroAccess",1397,1,16,1397,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1397,33,9,1397,{left:__wrap(index),inverted:false,op:"~<=",right:__wrap(end)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1397,54,9,1397,{left:__wrap(index),inverted:false,op:"~<",right:__wrap(end)},"expression",false,false)}},"statement",false,false),elseIfs:[],elseBody:__node("MacroAccess",1399,1,16,1399,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",1399,33,10,1399,{left:__wrap(index),inverted:false,op:"~>=",right:__wrap(end)},"expression",false,false),elseIfs:[],elseBody:__node("MacroAccess",1399,54,9,1399,{left:__wrap(index),inverted:false,op:"~<",right:__wrap(end)},"expression",false,false)}},"statement",false,false)}},"expression",false,false),__node("MacroAccess",1400,17,52,1400,{left:__wrap(index),op:"~+=",right:__wrap(step)},"expression",false,false)])))[0];increment=_ref[1];if(this.hasFunc(body)){func=this.tmp("f",false,"function");if(value&&valueIdent!==value.ident){body=__node("Block",1407,1,[__node("MacroAccess",1407,1,38,1407,{macroName:"let",macroData:{declarable:__node("MacroAccess",1407,16,37,1407,__node("MacroAccess",1407,16,31,1407,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__wrap(valueIdent)}},"statement",false,false),__wrap(body)],null);}if(hasIndex){init.push(__node("MacroAccess",1410,24,38,1410,{macroName:"let",macroData:{declarable:__node("MacroAccess",1410,28,37,1410,__node("MacroAccess",1410,28,31,1410,{ident:__wrap(func)},"statement",false,false),"statement",false,false),value:__node("Function",1410,38,[__node("Param",1410,39,__wrap(valueIdent),void 0,false,false,void 0),__node("Param",1410,52,__wrap(index),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,false,[])}},"statement",false,false));body=__node("Call",1411,23,__wrap(func),[__node("This",1411,31),__wrap(valueExpr),__wrap(index)],false,true);}else{init.push(__node("MacroAccess",1413,24,38,1413,{macroName:"let",macroData:{declarable:__node("MacroAccess",1413,28,37,1413,__node("MacroAccess",1413,28,31,1413,{ident:__wrap(func)},"statement",false,false),"statement",false,false),value:__node("Function",1413,38,[__node("Param",1413,39,__wrap(valueIdent),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,false,[])}},"statement",false,false));body=__node("Call",1414,23,__wrap(func),[__node("This",1414,31),__wrap(valueExpr)],false,true);}}else if(valueIdent===value.ident||reducer!=="filter"){body=__node("Block",1417,1,[__node("MacroAccess",1417,1,38,1417,{macroName:"let",macroData:{declarable:__node("MacroAccess",1417,14,37,1417,__node("MacroAccess",1417,14,31,1417,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__wrap(valueExpr)}},"statement",false,false),__wrap(body)],null);}else{body=__node("Block",1421,1,[__node("MacroAccess",1421,1,38,1421,{macroName:"let",macroData:{declarable:__node("MacroAccess",1421,14,37,1421,__node("MacroAccess",1421,14,31,1421,{ident:__wrap(valueIdent)},"statement",false,false),"statement",false,false),value:__wrap(valueExpr)}},"statement",false,false),__node("MacroAccess",1422,1,38,1422,{macroName:"let",macroData:{declarable:__node("MacroAccess",1422,14,37,1422,__node("MacroAccess",1422,14,31,1422,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__wrap(valueIdent)}},"statement",false,false),__wrap(body)],null);}if(reducer==="every"){return __node("MacroAccess",1426,13,104,1426,{macroName:"for",macroData:{reducer:"every",init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="some"){return __node("MacroAccess",1431,13,104,1431,{macroName:"for",macroData:{reducer:"some",init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="first"){return __node("MacroAccess",1436,13,104,1436,{macroName:"for",macroData:{reducer:"first",init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="filter"){body=this.mutateLast(body,function(node){return __node("MacroAccess",1442,14,17,1442,{macroName:"if",macroData:{test:__wrap(node),body:__wrap(valueIdent),elseIfs:[]}},"statement",false,false);});return __node("MacroAccess",1444,13,104,1444,{macroName:"for",macroData:{init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(this.position==="expression"){return __node("MacroAccess",1449,13,104,1449,{macroName:"for",macroData:{init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else{return __node("MacroAccess",1455,1,104,1455,{macroName:"for",macroData:{init:__wrap(init),test:__wrap(test),step:__wrap(increment),body:__wrap(body),elseBody:__wrap(elseBody)}},"statement",false,false);}}};}.call(this));',
params: [
[
"ident",
"reducer",
"many",
"?",
"choice",
["const", "every"],
["const", "some"],
["const", "first"],
["const", "filter"]
],
["ident", "value", "ident", "Declarable"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["ident", "value", "ident", "Identifier"],
[
"ident",
"length",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
]
],
["const", "in"],
["ident", "array", "ident", "Logic"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
[
"ident",
"elseBody",
"many",
"?",
"sequence",
["const", "\n"],
["const", "else"],
[
"this",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
["const", "end"]
],
names: "for",
id: 111
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var array,body,current,currentStart,index,length,macroData,macroName,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;value=macroData.value;index=macroData.index;array=macroData.array;current=macroData.current;currentStart=macroData.currentStart;body=macroData.body;value=this.macroExpand1(value);body=this.mutateLast(body||this.noop(),function(node){return __node("MacroAccess",1462,59,30,1462,{left:__wrap(current),op:":=",right:__wrap(node)},"expression",false,false);});if(index!=null){length=index.length;}index=index!=null?index.value:void 0;return __node("Block",1466,1,[__node("MacroAccess",1466,1,38,1466,{macroName:"let",macroData:{declarable:__node("MacroAccess",1466,10,37,1466,__node("MacroAccess",1466,10,31,1466,{isMutable:"mutable",ident:__wrap(current)},"statement",false,false),"statement",false,false),value:__wrap(currentStart)}},"statement",false,false),__node("MacroAccess",1467,1,111,1467,{macroName:"for",macroData:{value:__node("MacroAccess",1467,10,37,1467,__node("MacroAccess",1467,10,31,1467,{ident:__wrap(value)},"statement",false,false),"statement",false,false),index:{value:__wrap(index),length:__wrap(length)},array:__wrap(array),body:__wrap(body)}},"statement",false,false),__wrap(current)],null);};}.call(this));',
params: [
["const", "reduce"],
["ident", "value", "ident", "Declarable"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["ident", "value", "ident", "Identifier"],
[
"ident",
"length",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
]
],
["const", "in"],
["ident", "array", "ident", "Logic"],
["const", ","],
["ident", "current", "ident", "Identifier"],
["const", "="],
["ident", "currentStart"],
[
"ident",
"body",
"choice",
["ident", "Body"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
names: "for",
id: 112
},
{
code: 'return (function(){"use strict";var __strnum,__typeof;__strnum=function(strnum){var type;type=typeof strnum;if(type==="string"){return strnum;}else if(type==="number"){return String(strnum);}else{throw TypeError("Expected a string or number, got "+__typeof(strnum));}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var arr,body,elseBody,func,index,init,key,letIndex,letValue,loop,macroData,macroName,object,own,post,reducer,runElse,type,value,valueIdent;macroName=macroFullData.macroName;macroData=macroFullData.macroData;reducer=macroData.reducer;key=macroData.key;value=macroData.value;type=macroData.type;object=macroData.object;body=macroData.body;elseBody=macroData.elseBody;index=null;if(value){index=value.index;value=this.macroExpand1(value.value);}own=type==="of";init=[];if(own||value){object=this.cache(object,init,"obj",false);}this["let"](key,false,this.type("string"));letValue=value&&this.macroExpandAll(__node("MacroAccess",1483,52,38,1483,{macroName:"let",macroData:{declarable:__node("MacroAccess",1483,56,37,1483,__node("MacroAccess",1483,56,31,1483,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__node("Access",1483,65,__wrap(object),__wrap(key))}},"statement",false,false));letIndex=index&&this.macroExpandAll(__node("MacroAccess",1484,52,38,1484,{macroName:"let",macroData:{declarable:__node("MacroAccess",1484,56,37,1484,__node("MacroAccess",1484,56,31,1484,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1484,73,59,1484,{op:"-",node:__node("Const",1484,75,1)},"expression",false,false)}},"statement",false,false));if(this.hasFunc(body)){func=this.tmp("f",false,"function");if(value){if(value.type==="ident"){valueIdent=value.ident;}else{valueIdent=this.tmp("v",false);}}if(value&&valueIdent!==value.ident){body=__node("Block",1490,1,[__node("MacroAccess",1490,1,38,1490,{macroName:"let",macroData:{declarable:__node("MacroAccess",1490,14,37,1490,__node("MacroAccess",1490,14,31,1490,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__wrap(valueIdent)}},"statement",false,false),__wrap(body)],null);}if(index){init.push(__node("MacroAccess",1493,23,38,1493,{macroName:"let",macroData:{declarable:__node("MacroAccess",1493,27,37,1493,__node("MacroAccess",1493,27,31,1493,{ident:__wrap(func)},"statement",false,false),"statement",false,false),value:__node("Function",1493,37,[__node("Param",1493,38,__wrap(key),void 0,false,false,void 0),__node("Param",1493,43,__wrap(valueIdent),void 0,false,false,void 0),__node("Param",1493,57,__wrap(index),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,false,[])}},"statement",false,false));body=__node("Call",1494,22,__wrap(func),[__node("This",1494,30),__wrap(key),__node("Access",1494,41,__wrap(object),__wrap(key)),__wrap(index)],false,true);}else if(value){init.push(__node("MacroAccess",1496,23,38,1496,{macroName:"let",macroData:{declarable:__node("MacroAccess",1496,27,37,1496,__node("MacroAccess",1496,27,31,1496,{ident:__wrap(func)},"statement",false,false),"statement",false,false),value:__node("Function",1496,37,[__node("Param",1496,38,__wrap(key),void 0,false,false,void 0),__node("Param",1496,43,__wrap(valueIdent),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,false,[])}},"statement",false,false));body=__node("Call",1497,22,__wrap(func),[__node("This",1497,30),__wrap(key),__node("Access",1497,41,__wrap(object),__wrap(key))],false,true);}else{init.push(__node("MacroAccess",1499,23,38,1499,{macroName:"let",macroData:{declarable:__node("MacroAccess",1499,27,37,1499,__node("MacroAccess",1499,27,31,1499,{ident:__wrap(func)},"statement",false,false),"statement",false,false),value:__node("Function",1499,37,[__node("Param",1499,38,__wrap(key),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,false,[])}},"statement",false,false));body=__node("Call",1500,22,__wrap(func),[__node("This",1500,30),__wrap(key)],false,true);}}else if(value){body=__node("Block",1503,1,[__wrap(letValue),__wrap(body)],null);}post=[];if(elseBody){runElse=this.tmp("else",false,"boolean");init.push(__node("MacroAccess",1509,21,38,1509,{macroName:"let",macroData:{declarable:__node("MacroAccess",1509,25,37,1509,__node("MacroAccess",1509,25,31,1509,{ident:__wrap(runElse)},"statement",false,false),"statement",false,false),value:__node("Const",1509,37,true)}},"statement",false,false));body=__node("Block",1511,1,[__node("MacroAccess",1511,1,30,1511,{left:__wrap(runElse),op:":=",right:__node("Const",1511,21,false)},"statement",false,false),__wrap(body)],null);post.push(__node("MacroAccess",1514,1,17,1514,{macroName:"if",macroData:{test:__wrap(runElse),body:__wrap(elseBody),elseIfs:[]}},"statement",false,false));}if(index){init.push(letIndex);body=__node("Block",1520,1,[__node("MacroAccess",1520,1,52,1520,{left:__wrap(index),op:"~+=",right:__node("Const",1520,20,1)},"statement",false,false),__wrap(body)],null);}if(own){body=__node("MacroAccess",1525,1,17,1525,{macroName:"if",macroData:{test:__node("MacroAccess",1525,11,71,1525,{left:__wrap(object),inverted:false,op:"ownskey",right:__wrap(key)},"statement",false,false),body:__wrap(body),elseIfs:[]}},"statement",false,false);}if(reducer){if(reducer==="first"){body=this.mutateLast(body||this.noop(),function(node){return __node("MacroAccess",1530,62,39,1530,{macroName:"return",macroData:{node:__wrap(node)}},"statement",false,false);});loop=this.forIn(key,object,body);return __node("MacroAccess",1532,12,0,1532,{macroName:"do",macroData:{body:__node("Block",1533,1,[__wrap(init),__wrap(loop),__wrap(elseBody)],null)}},"statement",false,false);}else{if(elseBody){this.error("Cannot use a for loop with an else with "+__strnum(reducer),elseBody);}if(reducer==="some"){body=this.mutateLast(body||this.noop(),function(node){return __node("MacroAccess",1541,1,17,1541,{macroName:"if",macroData:{test:__wrap(node),body:__node("MacroAccess",1542,1,39,1542,{macroName:"return",macroData:{node:__node("Const",1542,21,true)}},"statement",false,false),elseIfs:[]}},"statement",false,false);});loop=this.forIn(key,object,body);return __node("MacroAccess",1544,14,0,1544,{macroName:"do",macroData:{body:__node("Block",1545,1,[__wrap(init),__wrap(loop),__node("Const",1547,1,false)],null)}},"statement",false,false);}else if(reducer==="every"){body=this.mutateLast(body||this.noop(),function(node){return __node("MacroAccess",1550,1,17,1550,{macroName:"if",macroData:{test:__node("MacroAccess",1550,15,3,1550,{op:"not",node:__wrap(node)},"statement",false,false),body:__node("MacroAccess",1551,1,39,1551,{macroName:"return",macroData:{node:__node("Const",1551,21,false)}},"statement",false,false),elseIfs:[]}},"statement",false,false);});loop=this.forIn(key,object,body);return __node("MacroAccess",1553,14,0,1553,{macroName:"do",macroData:{body:__node("Block",1554,1,[__wrap(init),__wrap(loop),__node("Const",1556,1,true)],null)}},"statement",false,false);}else{return this.error("Unknown reducer: "+__strnum(reducer));}}}else if(this.position==="expression"){if(elseBody){this.error("Cannot use a for loop with an else as an expression",elseBody);}arr=this.tmp("arr",false,this.type(body).array());body=this.mutateLast(body||this.noop(),function(node){return __node("Call",1563,61,__node("Access",1563,61,__wrap(arr),__node("Const",1563,67,"push")),[__wrap(node)],false,false);});init.unshift(__node("MacroAccess",1564,23,38,1564,{macroName:"let",macroData:{declarable:__node("MacroAccess",1564,27,37,1564,__node("MacroAccess",1564,27,31,1564,{ident:__wrap(arr)},"statement",false,false),"statement",false,false),value:__node("Array",1564,34,[])}},"statement",false,false));loop=this.forIn(key,object,body);return __node("Block",1567,1,[__wrap(init),__wrap(loop),__wrap(arr)],null);}else{loop=this.forIn(key,object,body);return __node("Block",1573,1,[__wrap(init),__wrap(loop),__wrap(post)],null);}};}.call(this));',
params: [
[
"ident",
"reducer",
"many",
"?",
"choice",
["const", "every"],
["const", "some"],
["const", "first"]
],
["ident", "key", "ident", "Identifier"],
[
"ident",
"value",
"many",
"?",
"sequence",
["const", ","],
["ident", "value", "ident", "Declarable"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
]
],
[
"ident",
"type",
"choice",
["const", "of"],
["const", "ofall"]
],
["ident", "object", "ident", "Logic"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
[
"ident",
"elseBody",
"many",
"?",
"sequence",
["const", "\n"],
["const", "else"],
[
"this",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
["const", "end"]
],
names: "for",
id: 113
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,current,currentStart,index,key,loop,macroData,macroName,object,type,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;key=macroData.key;value=macroData.value;type=macroData.type;object=macroData.object;current=macroData.current;currentStart=macroData.currentStart;body=macroData.body;body=this.mutateLast(body||this.noop(),function(node){return __node("MacroAccess",1578,59,30,1578,{left:__wrap(current),op:":=",right:__wrap(node)},"expression",false,false);});if(value!=null){index=value.index;}value=value!=null?value.value:void 0;if(type==="of"){loop=__node("MacroAccess",1582,10,113,1582,{macroName:"for",macroData:{key:__wrap(key),value:{value:__node("MacroAccess",1582,20,37,1582,__node("MacroAccess",1582,20,31,1582,{ident:__wrap(value)},"statement",false,false),"statement",false,false),index:__wrap(index)},type:"of",object:__wrap(object),body:__wrap(body)}},"statement",false,false);}else{loop=__node("MacroAccess",1585,10,113,1585,{macroName:"for",macroData:{key:__wrap(key),value:{value:__node("MacroAccess",1585,20,37,1585,__node("MacroAccess",1585,20,31,1585,{ident:__wrap(value)},"statement",false,false),"statement",false,false),index:__wrap(index)},type:"ofall",object:__wrap(object),body:__wrap(body)}},"statement",false,false);}return __node("Block",1588,1,[__node("MacroAccess",1588,1,38,1588,{macroName:"let",macroData:{declarable:__node("MacroAccess",1588,10,37,1588,__node("MacroAccess",1588,10,31,1588,{isMutable:"mutable",ident:__wrap(current)},"statement",false,false),"statement",false,false),value:__wrap(currentStart)}},"statement",false,false),__wrap(loop),__wrap(current)],null);};}.call(this));',
params: [
["const", "reduce"],
["ident", "key", "ident", "Identifier"],
[
"ident",
"value",
"many",
"?",
"sequence",
["const", ","],
["ident", "value", "ident", "Declarable"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
]
],
[
"ident",
"type",
"choice",
["const", "of"],
["const", "ofall"]
],
["ident", "object", "ident", "Logic"],
["const", ","],
["ident", "current", "ident", "Identifier"],
["const", "="],
["ident", "currentStart"],
[
"ident",
"body",
"choice",
["ident", "Body"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
names: "for",
id: 114
},
{
code: 'return (function(){"use strict";var __isArray,__slice,__toArray,__typeof;__isArray=typeof Array.isArray==="function"?Array.isArray:(function(){var _toString;_toString=Object.prototype.toString;return function(x){return _toString.call(x)==="[object Array]";};}());__slice=Array.prototype.slice;__toArray=function(x){if(x==null){throw TypeError("Expected an object, got "+__typeof(x));}else if(__isArray(x)){return x;}else if(typeof x==="string"){return x.split("");}else{return __slice.call(x);}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _this,catchBody,catchIdent,catchPart,current,elseBody,finallyBody,hasElse,init,macroData,macroName,runElse,tryBody,typedCatches;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;tryBody=macroData.tryBody;typedCatches=macroData.typedCatches;catchPart=macroData.catchPart;elseBody=macroData.elseBody;finallyBody=macroData.finallyBody;hasElse=!!elseBody;if(typedCatches.length===0&&!catchPart&&!hasElse&&!finallyBody){this.error("Must provide at least a catch, else, or finally to a try block");}if(catchPart!=null){catchIdent=catchPart.ident;}if(catchPart!=null){catchBody=catchPart.body;}if(typedCatches.length!==0){if(!catchIdent){catchIdent=typedCatches[0].ident;}catchBody=(function(){var _arr,_f,_i,current;current=catchBody||__node("MacroAccess",1996,94,11,1996,{op:"throw",node:__wrap(catchIdent)},"statement",false,false);for(_arr=__toArray(typedCatches), _i=_arr.length, _f=function(typeCatch){var _this,letErr,typeIdent,types,value;_this=this;typeIdent=typeCatch.ident;if(this.name(typeIdent)!==this.name(catchIdent)){letErr=__node("MacroAccess",1999,14,38,1999,{macroName:"let",macroData:{declarable:__node("MacroAccess",1999,18,37,1999,__node("MacroAccess",1999,18,31,1999,{ident:__wrap(typeIdent)},"statement",false,false),"statement",false,false),value:__wrap(catchIdent)}},"statement",false,false);}else{letErr=this.noop();}if(typeCatch.check.type==="as"){types=this.array((function(){var _arr,_arr2,_i,_len,type;for(_arr=[], _arr2=__toArray(_this.isTypeUnion(typeCatch.check.value)?_this.types(typeCatch.check.value):[typeCatch.check.value]), _i=0, _len=_arr2.length;_i<_len;++_i){type=_arr2[_i];if(_this.isTypeArray(type)){_this.error("Expected a normal type, cannot use an array type",type);}else if(_this.isTypeGeneric(type)){_this.error("Expected a normal type, cannot use a generic type",type);}else if(_this.isTypeFunction(type)){_this.error("Expected a normal type, cannot use a function type",type);}else if(_this.isTypeObject(type)){_this.error("Expected a normal type, cannot use an object type",type);}_arr.push(type);}return _arr;}()));return current=__node("MacroAccess",2014,1,17,2014,{macroName:"if",macroData:{test:__node("MacroAccess",2014,15,116,2014,{left:__wrap(catchIdent),inverted:false,op:"instanceofsome",right:__wrap(types)},"statement",false,false),body:__node("Block",2015,1,[__wrap(letErr),__wrap(typeCatch.body)],null),elseIfs:[],elseBody:__wrap(current)}},"statement",false,false);}else{value=typeCatch.check.value;return current=__node("MacroAccess",2022,1,17,2022,{macroName:"if",macroData:{test:__node("MacroAccess",2022,15,5,2022,{left:__wrap(catchIdent),inverted:false,op:"==",right:__wrap(value)},"statement",false,false),body:__node("Block",2023,1,[__wrap(letErr),__wrap(typeCatch.body)],null),elseIfs:[],elseBody:__wrap(current)}},"statement",false,false);}};_i--;){_f.call(_this,_arr[_i]);}return current;}());}init=[];if(hasElse){runElse=this.tmp("else",false,"boolean");init.push(__node("MacroAccess",2031,20,38,2031,{macroName:"let",macroData:{declarable:__node("MacroAccess",2031,24,37,2031,__node("MacroAccess",2031,24,31,2031,{ident:__wrap(runElse)},"statement",false,false),"statement",false,false),value:__node("Const",2031,36,true)}},"statement",false,false));if(catchBody){catchBody=__node("Block",2034,1,[__node("MacroAccess",2034,1,30,2034,{left:__wrap(runElse),op:":=",right:__node("Const",2034,23,false)},"statement",false,false),__wrap(catchBody)],null);}else{catchIdent=this.tmp("err");catchBody=__node("Block",2039,1,[__node("MacroAccess",2039,1,30,2039,{left:__wrap(runElse),op:":=",right:__node("Const",2039,23,false)},"statement",false,false),__node("MacroAccess",2040,1,11,2040,{op:"throw",node:__wrap(catchIdent)},"statement",false,false)],null);}}current=tryBody;if(catchBody){current=this.tryCatch(current,catchIdent||this.tmp("err"),catchBody);}if(hasElse){current=this.tryFinally(current,__node("MacroAccess",2047,1,17,2047,{macroName:"if",macroData:{test:__wrap(runElse),body:__wrap(elseBody),elseIfs:[]}},"statement",false,false));}if(finallyBody){current=this.tryFinally(current,finallyBody);}return __node("Block",2053,1,[__wrap(init),__wrap(current)],null);};}.call(this));',
params: [
[
"ident",
"tryBody",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
[
"ident",
"typedCatches",
"many",
"*",
"sequence",
["const", "\n"],
["const", "catch"],
["ident", "ident", "ident", "Identifier"],
[
"ident",
"check",
"choice",
[
"sequence",
["ident", "type", "const", "as"],
["ident", "value", "ident", "Type"]
],
[
"sequence",
["ident", "type", "const", "=="],
["ident", "value", "ident", "Expression"]
]
],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
[
"ident",
"catchPart",
"many",
"?",
"sequence",
["const", "\n"],
["const", "catch"],
["ident", "ident", "many", "?", "ident", "Identifier"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
[
"ident",
"elseBody",
"many",
"?",
"sequence",
["const", "\n"],
["const", "else"],
[
"this",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
[
"ident",
"finallyBody",
"many",
"?",
"sequence",
["const", "\n"],
["const", "finally"],
[
"this",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
["const", "end"]
],
names: "try",
id: 117
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,captureValue,elseBody,err,func,index,init,item,iterable,iterator,macroData,macroName,main,post,reducer,runElse,step,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;reducer=macroData.reducer;value=macroData.value;index=macroData.index;iterable=macroData.iterable;body=macroData.body;elseBody=macroData.elseBody;init=[];iterator=this.cache(__node("Call",2089,30,__node("Ident",2089,30,"__iter"),[__wrap(iterable)],false,false),init,"iter",false);item=this.tmp("item",false);err=this.tmp("e",true);step=[];if(index){init.push(__node("MacroAccess",2095,20,38,2095,{macroName:"let",macroData:{declarable:__node("MacroAccess",2095,24,37,2095,__node("MacroAccess",2095,24,31,2095,{isMutable:"mutable",ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("Const",2095,42,0)}},"statement",false,false));step.push(__node("MacroAccess",2096,21,52,2096,{left:__wrap(index),op:"~+=",right:__node("Const",2096,33,1)},"expression",false,false));}captureValue=__node("Block",2099,1,[__node("MacroAccess",2099,1,38,2099,{macroName:"let",macroData:{declarable:__node("MacroAccess",2099,10,37,2099,__node("MacroAccess",2099,10,31,2099,{ident:__wrap(item)},"statement",false,false),"statement",false,false),value:__node("Call",2099,18,__node("Access",2099,18,__wrap(iterator),__node("Const",2099,29,"next")),[],false,false)}},"statement",false,false),__node("MacroAccess",2100,1,17,2100,{macroName:"if",macroData:{test:__node("Access",2100,9,__wrap(item),__node("Const",2100,16,"done")),body:__node("MacroAccess",2101,1,19,2101,{macroName:"break",macroData:{}},"statement",false,false),elseIfs:[]}},"statement",false,false),__node("MacroAccess",2102,1,38,2102,{macroName:"let",macroData:{declarable:__node("MacroAccess",2102,10,37,2102,__node("MacroAccess",2102,10,31,2102,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__node("Access",2102,19,__wrap(item),__node("Const",2102,26,"value"))}},"statement",false,false)],null);post=[];if(elseBody&&!reducer&&this.position!=="expression"){runElse=this.tmp("else",false,"boolean");init.push(__node("MacroAccess",2107,21,38,2107,{macroName:"let",macroData:{declarable:__node("MacroAccess",2107,25,37,2107,__node("MacroAccess",2107,25,31,2107,{ident:__wrap(runElse)},"statement",false,false),"statement",false,false),value:__node("Const",2107,37,true)}},"statement",false,false));body=__node("Block",2109,1,[__node("MacroAccess",2109,1,30,2109,{left:__wrap(runElse),op:":=",right:__node("Const",2109,21,false)},"statement",false,false),__wrap(body)],null);post.push(__node("MacroAccess",2112,1,17,2112,{macroName:"if",macroData:{test:__wrap(runElse),body:__wrap(elseBody),elseIfs:[]}},"statement",false,false));}if(this.hasFunc(body)){func=this.tmp("f",false,"function");if(!index){init.push(__node("MacroAccess",2118,22,38,2118,{macroName:"let",macroData:{declarable:__node("MacroAccess",2118,26,37,2118,__node("MacroAccess",2118,26,31,2118,{ident:__wrap(func)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",2118,36,115,2118,{op:"",node:__node("Function",2118,36,[__node("Param",2118,37,__wrap(value),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,false,[])},"expression",false,false)}},"statement",false,false));body=__node("Block",2120,1,[__wrap(captureValue),__node("Call",2121,1,__wrap(func),[__node("This",2121,18),__wrap(value)],false,true)],null);}else{init.push(__node("MacroAccess",2123,22,38,2123,{macroName:"let",macroData:{declarable:__node("MacroAccess",2123,26,37,2123,__node("MacroAccess",2123,26,31,2123,{ident:__wrap(func)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",2123,36,115,2123,{op:"",node:__node("Function",2123,36,[__node("Param",2123,37,__wrap(value),void 0,false,false,void 0),__node("Param",2123,44,__wrap(index),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,false,[])},"expression",false,false)}},"statement",false,false));body=__node("Block",2125,1,[__wrap(captureValue),__node("Call",2126,1,__wrap(func),[__node("This",2126,18),__wrap(value),__wrap(index)],false,true)],null);}}else{body=__node("Block",2129,1,[__wrap(captureValue),__wrap(body)],null);}if(reducer==="every"){main=__node("MacroAccess",2133,11,104,2133,{macroName:"for",macroData:{reducer:"every",init:__wrap(init),test:__node("Const",2133,28,true),step:__wrap(step),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="some"){main=__node("MacroAccess",2138,11,104,2138,{macroName:"for",macroData:{reducer:"some",init:__wrap(init),test:__node("Const",2138,27,true),step:__wrap(step),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="first"){main=__node("MacroAccess",2143,11,104,2143,{macroName:"for",macroData:{reducer:"first",init:__wrap(init),test:__node("Const",2143,28,true),step:__wrap(step),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(reducer==="filter"){body=this.mutateLast(body,function(node){return __node("MacroAccess",2149,12,17,2149,{macroName:"if",macroData:{test:__wrap(node),body:__wrap(value),elseIfs:[]}},"statement",false,false);});main=__node("MacroAccess",2151,11,104,2151,{macroName:"for",macroData:{init:__wrap(init),test:__node("Const",2151,22,true),step:__wrap(step),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else if(this.position==="expression"){main=__node("MacroAccess",2156,11,104,2156,{macroName:"for",macroData:{init:__wrap(init),test:__node("Const",2156,22,true),step:__wrap(step),body:__wrap(body),elseBody:__wrap(elseBody)}},"expression",false,false);}else{main=__node("Block",2162,1,[__node("MacroAccess",2162,1,104,2162,{macroName:"for",macroData:{init:__wrap(init),test:__node("Const",2162,19,true),step:__wrap(step),body:__wrap(body)}},"statement",false,false),__wrap(post)],null);}return __node("MacroAccess",2166,8,117,2166,{macroName:"try",macroData:{tryBody:__wrap(main),typedCatches:[],finallyBody:__node("MacroAccess",2169,1,117,2169,{macroName:"try",macroData:{tryBody:__node("Call",2170,1,__node("Access",2170,1,__wrap(iterator),__node("Const",2170,19,"close")),[],false,false),typedCatches:[],catchPart:{ident:__wrap(err),body:__node("Const",2172,1,void 0)}}},"statement",false,false)}},"statement",false,false);};}.call(this));',
params: [
[
"ident",
"reducer",
"many",
"?",
"choice",
["const", "every"],
["const", "some"],
["const", "first"],
["const", "filter"]
],
["ident", "value", "ident", "Identifier"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", "from"],
["ident", "iterable", "ident", "Logic"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
[
"ident",
"elseBody",
"many",
"?",
"sequence",
["const", "\n"],
["const", "else"],
[
"this",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
["const", "end"]
],
names: "for",
id: 118
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,current,currentStart,index,iterator,macroData,macroName,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;value=macroData.value;index=macroData.index;iterator=macroData.iterator;current=macroData.current;currentStart=macroData.currentStart;body=macroData.body;body=this.mutateLast(body||this.noop(),function(node){return __node("MacroAccess",2175,59,30,2175,{left:__wrap(current),op:":=",right:__wrap(node)},"expression",false,false);});return __node("Block",2177,1,[__node("MacroAccess",2177,1,38,2177,{macroName:"let",macroData:{declarable:__node("MacroAccess",2177,10,37,2177,__node("MacroAccess",2177,10,31,2177,{isMutable:"mutable",ident:__wrap(current)},"statement",false,false),"statement",false,false),value:__wrap(currentStart)}},"statement",false,false),__node("MacroAccess",2178,1,118,2178,{macroName:"for",macroData:{value:__wrap(value),index:__wrap(index),iterable:__wrap(iterator),body:__wrap(body)}},"statement",false,false),__wrap(current)],null);};}.call(this));',
params: [
["const", "reduce"],
["ident", "value", "ident", "Identifier"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", "from"],
["ident", "iterator", "ident", "Logic"],
["const", ","],
["ident", "current", "ident", "Identifier"],
["const", "="],
["ident", "currentStart"],
[
"ident",
"body",
"choice",
["ident", "Body"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
names: "for",
id: 119
},
{
code: 'return (function(){"use strict";var __isArray,__num,__slice,__toArray,__typeof;__isArray=typeof Array.isArray==="function"?Array.isArray:(function(){var _toString;_toString=Object.prototype.toString;return function(x){return _toString.call(x)==="[object Array]";};}());__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__slice=Array.prototype.slice;__toArray=function(x){if(x==null){throw TypeError("Expected an object, got "+__typeof(x));}else if(__isArray(x)){return x;}else if(typeof x==="string"){return x.split("");}else{return __slice.call(x);}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _arr,_arr2,_i,_i2,_len,_len2,body,case_,caseNode,caseNodes,cases,defaultCase,isFallthrough,lastNode,macroData,macroName,node,nodes,resultCases;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData.node;cases=macroData.cases;defaultCase=macroData.defaultCase;resultCases=[];for(_arr=__toArray(cases), _i=0, _len=_arr.length;_i<_len;++_i){case_=_arr[_i];caseNodes=[case_.nodeHead].concat(case_.nodeTail);body=case_.body;isFallthrough=false;if(this.isBlock(body)){nodes=this.nodes(body);lastNode=nodes[__num(nodes.length)-1];if(this.isIdent(lastNode)&&this.name(lastNode)==="fallthrough"){body=this.block(nodes.slice(0,-1));isFallthrough=true;}}else if(this.isIdent(body)&&this.name(body)==="fallthrough"){body=this.noop();isFallthrough=true;}for(_arr2=__toArray(caseNodes.slice(0,-1)), _i2=0, _len2=_arr2.length;_i2<_len2;++_i2){caseNode=_arr2[_i2];resultCases.push({node:caseNode,body:this.noop(),fallthrough:true});}resultCases.push({node:caseNodes[__num(caseNodes.length)-1],body:body,fallthrough:isFallthrough});}return this["switch"](node,resultCases,defaultCase);};}.call(this));',
params: [
["ident", "node", "ident", "Logic"],
[
"ident",
"cases",
"many",
"*",
"sequence",
["const", "\n"],
["const", "case"],
["ident", "nodeHead", "ident", "Logic"],
[
"ident",
"nodeTail",
"many",
"*",
"sequence",
["const", ","],
["this", "ident", "Logic"]
],
[
"ident",
"body",
"many",
"?",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
[
"ident",
"defaultCase",
"many",
"?",
"sequence",
["const", "\n"],
["const", "default"],
[
"this",
"many",
"?",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
["const", "end"]
],
names: "switch",
id: 120
},
{
code: 'return (function(){"use strict";var __isArray,__num,__slice,__toArray,__typeof;__isArray=typeof Array.isArray==="function"?Array.isArray:(function(){var _toString;_toString=Object.prototype.toString;return function(x){return _toString.call(x)==="[object Array]";};}());__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__slice=Array.prototype.slice;__toArray=function(x){if(x==null){throw TypeError("Expected an object, got "+__typeof(x));}else if(__isArray(x)){return x;}else if(typeof x==="string"){return x.split("");}else{return __slice.call(x);}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _arr,_i,body,case_,cases,current,defaultCase,fall,isFallthrough,lastNode,macroData,macroName,nodes,result,test;macroName=macroFullData.macroName;macroData=macroFullData.macroData;cases=macroData.cases;defaultCase=macroData.defaultCase;current=defaultCase;for(_arr=__toArray(cases), _i=_arr.length;_i--;){case_=_arr[_i];test=case_.test;body=case_.body;isFallthrough=false;result=void 0;if(this.isBlock(body)){nodes=this.nodes(body);lastNode=nodes[__num(nodes.length)-1];if(this.isIdent(lastNode)&&this.name(lastNode)==="fallthrough"){body=this.block(nodes.slice(0,-1));result=this.isIf(current)?(fall=this.tmp("fall",false,"boolean"),__node("Block",2224,1,[__node("MacroAccess",2224,1,38,2224,{macroName:"let",macroData:{declarable:__node("MacroAccess",2224,18,37,2224,__node("MacroAccess",2224,18,31,2224,{isMutable:"mutable",ident:__wrap(fall)},"statement",false,false),"statement",false,false),value:__node("Const",2224,34,false)}},"statement",false,false),__node("MacroAccess",2225,1,17,2225,{macroName:"if",macroData:{test:__wrap(test),body:__node("Block",2226,1,[__node("MacroAccess",2226,1,30,2226,{left:__wrap(fall),op:":=",right:__node("Const",2226,25,true)},"statement",false,false),__wrap(body)],null),elseIfs:[]}},"statement",false,false),__node("MacroAccess",2228,1,17,2228,{macroName:"if",macroData:{test:__node("MacroAccess",2228,17,2,2228,{left:__wrap(fall),inverted:false,op:"or",right:__wrap(this.test(current))},"statement",false,false),body:__wrap(this.whenTrue(current)),elseIfs:[],elseBody:__wrap(this.whenFalse(current))}},"statement",false,false)],null)):__node("Block",2234,1,[__node("MacroAccess",2234,1,17,2234,{macroName:"if",macroData:{test:__wrap(test),body:__wrap(body),elseIfs:[]}},"statement",false,false),__wrap(current)],null);}}else if(this.isIdent(body)&&this.name(body)==="fallthrough"){if(this.isIf(current)){result=__node("MacroAccess",2239,24,17,2239,{macroName:"if",macroData:{test:__node("MacroAccess",2239,27,2,2239,{left:__wrap(test),inverted:false,op:"or",right:__wrap(this.test(current))},"statement",false,false),body:__wrap(this.whenTrue(current)),elseIfs:[],elseBody:__wrap(this.whenFalse(current))}},"statement",false,false);}else{result=__node("Block",2245,1,[__wrap(test),__wrap(current)],null);}}current=result||__node("MacroAccess",2248,20,17,2248,{macroName:"if",macroData:{test:__wrap(case_.test),body:__wrap(body),elseIfs:[],elseBody:__wrap(current)}},"statement",false,false);}return current;};}.call(this));',
params: [
[
"ident",
"cases",
"many",
"*",
"sequence",
["const", "\n"],
["const", "case"],
["ident", "test", "ident", "Logic"],
[
"ident",
"body",
"many",
"?",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
[
"ident",
"defaultCase",
"many",
"?",
"sequence",
["const", "\n"],
["const", "default"],
[
"this",
"many",
"?",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
["const", "end"]
],
names: "switch",
id: 121
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,call,func,macroData,macroName,params;macroName=macroFullData.macroName;macroData=macroFullData.macroData;params=macroData.params;call=macroData.call;body=macroData.body;if(!this.isCall(call)){this.error("async call expression must be a call",call);}if(body==null){body=this.noop();}params=params?[params.head].concat(params.tail):[];func=this.func(params,body,true,true);return this.call(this.callFunc(call),this.callArgs(call).concat([__node("MacroAccess",2364,58,124,2364,{macroName:"once!",macroData:[__node("MacroAccess",2364,66,115,2364,{op:"mutateFunction!",node:__wrap(func)},"expression",false,false)]},"expression",false,false)]),this.callIsNew(call),this.callIsApply(call));};}.call(this));',
params: [
[
"ident",
"params",
"many",
"?",
"sequence",
["ident", "head", "ident", "Parameter"],
[
"ident",
"tail",
"many",
"*",
"sequence",
["const", ","],
["this", "ident", "Parameter"]
]
],
["const", "<-"],
["ident", "call", "ident", "Expression"],
["ident", "body", "ident", "DedentedBody"]
],
names: "async",
id: 125
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,call,callback,error,func,macroData,macroName,params;macroName=macroFullData.macroName;macroData=macroFullData.macroData;callback=macroData.callback;params=macroData.params;call=macroData.call;body=macroData.body;if(!this.isCall(call)){this.error("async! call expression must be a call",call);}if(body==null){body=this.noop();}error=this.tmp("e",false);params=[this.param(error)].concat(params);func=this.func(params,callback==="throw"?__node("Block",2378,1,[__node("MacroAccess",2378,1,100,2378,{op:"throw?",node:__wrap(error)},"statement",false,false),__wrap(body)],null):__node("Block",2382,1,[__node("MacroAccess",2382,1,17,2382,{macroName:"if",macroData:{test:__node("MacroAccess",2382,13,20,2382,{op:"?",node:__wrap(error)},"statement",false,false),body:__node("MacroAccess",2383,1,39,2383,{macroName:"return",macroData:{node:__node("Call",2383,19,__wrap(callback),[__wrap(error)],false,false)}},"statement",false,false),elseIfs:[]}},"statement",false,false),__wrap(body)],null),true,true);return this.call(this.callFunc(call),this.callArgs(call).concat([__node("MacroAccess",2387,58,124,2387,{macroName:"once!",macroData:[__node("MacroAccess",2387,66,115,2387,{op:"mutateFunction!",node:__wrap(func)},"expression",false,false)]},"expression",false,false)]),this.callIsNew(call),this.callIsApply(call));};}.call(this));',
params: [
[
"ident",
"callback",
"choice",
["const", "throw"],
["ident", "Expression"]
],
[
"ident",
"params",
"many",
"*",
"sequence",
["const", ","],
["this", "ident", "Parameter"]
],
["const", "<-"],
["ident", "call", "ident", "Expression"],
["ident", "body", "ident", "DedentedBody"]
],
names: "async!",
id: 126
},
{
code: 'return (function(){"use strict";var __isArray,__num,__slice,__toArray,__typeof;__isArray=typeof Array.isArray==="function"?Array.isArray:(function(){var _toString;_toString=Object.prototype.toString;return function(x){return _toString.call(x)==="[object Array]";};}());__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__slice=Array.prototype.slice;__toArray=function(x){if(x==null){throw TypeError("Expected an object, got "+__typeof(x));}else if(__isArray(x)){return x;}else if(typeof x==="string"){return x.split("");}else{return __slice.call(x);}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _arr,_i,_len,ident,identName,key,macroData,macroName,name,obj,path,requires,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;name=macroData.name;if(this.isConst(name)&&typeof this.value(name)!=="string"){this.error("Expected a constant string, got "+__typeof(this.value(name)),name);}if(this.isConst(name)){identName=this.value(name);if(identName.indexOf("/")!==-1){identName=identName.substring(__num(identName.lastIndexOf("/"))+1);}ident=this.ident(identName);return __node("MacroAccess",2400,10,38,2400,{macroName:"let",macroData:{declarable:__node("MacroAccess",2400,14,37,2400,__node("MacroAccess",2400,14,31,2400,{ident:__wrap(ident)},"statement",false,false),"statement",false,false),value:__node("Call",2400,23,__node("Ident",2400,23,"require"),[__wrap(name)],false,false)}},"statement",false,false);}else if(this.isIdent(name)){path=this.name(name);return __node("MacroAccess",2403,10,38,2403,{macroName:"let",macroData:{declarable:__node("MacroAccess",2403,14,37,2403,__node("MacroAccess",2403,14,31,2403,{ident:__wrap(name)},"statement",false,false),"statement",false,false),value:__node("Call",2403,22,__node("Ident",2403,22,"require"),[__wrap(path)],false,false)}},"statement",false,false);}else if(this.isObject(name)){requires=[];for(_arr=__toArray(this.pairs(name)), _i=0, _len=_arr.length;_i<_len;++_i){obj=_arr[_i];key=obj.key;value=obj.value;if(!this.isConst(key)){this.error("If providing an object to require!, all keys must be constant strings",key);}identName=this.value(key);if(identName.indexOf("/")!==-1){identName=identName.substring(__num(identName.lastIndexOf("/"))+1);}ident=this.ident(identName);if(this.isConst(value)){requires.push(__node("MacroAccess",2415,28,38,2415,{macroName:"let",macroData:{declarable:__node("MacroAccess",2415,32,37,2415,__node("MacroAccess",2415,32,31,2415,{ident:__wrap(ident)},"statement",false,false),"statement",false,false),value:__node("Call",2415,41,__node("Ident",2415,41,"require"),[__wrap(value)],false,false)}},"statement",false,false));}else if(this.isIdent(value)){path=this.name(value);requires.push(__node("MacroAccess",2418,28,38,2418,{macroName:"let",macroData:{declarable:__node("MacroAccess",2418,32,37,2418,__node("MacroAccess",2418,32,31,2418,{ident:__wrap(ident)},"statement",false,false),"statement",false,false),value:__node("Call",2418,41,__node("Ident",2418,41,"require"),[__wrap(path)],false,false)}},"statement",false,false));}else{this.error("If providing an object to require!, all values must be constant strings or idents",value);}}return this.block(requires);}else{return this.error("Expected either a constant string or ident or object",name);}};}.call(this));',
params: [["ident", "name", "ident", "Expression"]],
names: "require!",
id: 127
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _ref,arr,body,done,err,first,init,macroData,macroName,next,rest,result,results,step,test,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;results=macroData.results;next=macroData.next;init=macroData.init;test=macroData.test;step=macroData.step;body=macroData.body;rest=macroData.rest;err=(_ref=results!=null?results:{}).err;result=_ref.result;if(err==null){err=this.tmp("err",true);}if(init==null){init=this.noop();}if(test==null){test=__node("Const",2521,17,true);}if(step==null){step=this.noop();}if(rest==null){rest=this.noop();}done=this.tmp("done",true,"function");if(!result){if(!step){return __node("Block",2528,1,[__wrap(init),__node("MacroAccess",2529,1,15,2529,{macroName:"let",macroData:{ident:__wrap(next),func:__node("MacroAccess",2529,20,115,2529,{op:"",node:__node("Function",2529,20,[__node("Param",2529,21,__wrap(err),void 0,false,false,void 0)],__node("Block",2530,1,[__node("MacroAccess",2530,1,17,2530,{macroName:"if",macroData:{test:__node("MacroAccess",2530,15,20,2530,{op:"?",node:__wrap(err)},"statement",false,false),body:__node("MacroAccess",2531,1,39,2531,{macroName:"return",macroData:{node:__node("Call",2531,21,__wrap(done),[__wrap(err)],false,false)}},"statement",false,false),elseIfs:[]}},"statement",false,false),__node("MacroAccess",2532,1,17,2532,{macroName:"unless",macroData:{test:__wrap(test),body:__node("MacroAccess",2533,1,39,2533,{macroName:"return",macroData:{node:__node("Call",2533,21,__wrap(done),[__node("Const",2533,28,null)],false,false)}},"statement",false,false),elseIfs:[]}},"statement",false,false),__wrap(body)],null),true,true,false,void 0,false,[])},"statement",false,false)}},"statement",false,false),__node("MacroAccess",2535,1,15,2535,{macroName:"let",macroData:{ident:__wrap(done),func:__node("MacroAccess",2535,20,115,2535,{op:"",node:__node("Function",2535,20,[__node("Param",2535,21,__wrap(err),void 0,false,false,void 0)],__wrap(rest),true,true,false,void 0,false,[])},"statement",false,false)}},"statement",false,false),__node("Call",2537,1,__wrap(next),[],false,false)],null);}else{first=this.tmp("first",true,"boolean");return __node("Block",2541,1,[__wrap(init),__node("MacroAccess",2542,1,38,2542,{macroName:"let",macroData:{declarable:__node("MacroAccess",2542,14,37,2542,__node("MacroAccess",2542,14,31,2542,{ident:__wrap(first)},"statement",false,false),"statement",false,false),value:__node("Const",2542,23,true)}},"statement",false,false),__node("MacroAccess",2543,1,15,2543,{macroName:"let",macroData:{ident:__wrap(next),func:__node("MacroAccess",2543,20,115,2543,{op:"",node:__node("Function",2543,20,[__node("Param",2543,21,__wrap(err),void 0,false,false,void 0)],__node("Block",2544,1,[__node("MacroAccess",2544,1,17,2544,{macroName:"if",macroData:{test:__node("MacroAccess",2544,15,20,2544,{op:"?",node:__wrap(err)},"statement",false,false),body:__node("MacroAccess",2545,1,39,2545,{macroName:"return",macroData:{node:__node("Call",2545,21,__wrap(done),[__wrap(err)],false,false)}},"statement",false,false),elseIfs:[]}},"statement",false,false),__node("MacroAccess",2546,1,17,2546,{macroName:"if",macroData:{test:__wrap(first),body:__node("MacroAccess",2547,1,30,2547,{left:__wrap(first),op:":=",right:__node("Const",2547,24,false)},"statement",false,false),elseIfs:[],elseBody:__wrap(step)}},"statement",false,false),__node("MacroAccess",2550,1,17,2550,{macroName:"unless",macroData:{test:__wrap(test),body:__node("MacroAccess",2551,1,39,2551,{macroName:"return",macroData:{node:__node("Call",2551,21,__wrap(done),[__node("Const",2551,28,null)],false,false)}},"statement",false,false),elseIfs:[]}},"statement",false,false),__wrap(body)],null),true,true,false,void 0,false,[])},"statement",false,false)}},"statement",false,false),__node("MacroAccess",2553,1,15,2553,{macroName:"let",macroData:{ident:__wrap(done),func:__node("MacroAccess",2553,20,115,2553,{op:"",node:__node("Function",2553,20,[__node("Param",2553,21,__wrap(err),void 0,false,false,void 0)],__wrap(rest),true,true,false,void 0,false,[])},"statement",false,false)}},"statement",false,false),__node("Call",2555,1,__wrap(next),[],false,false)],null);}}else{first=this.tmp("first",true,"boolean");value=this.tmp("value",true);arr=this.tmp("arr",true);return __node("Block",2561,1,[__wrap(init),__node("MacroAccess",2562,1,38,2562,{macroName:"let",macroData:{declarable:__node("MacroAccess",2562,12,37,2562,__node("MacroAccess",2562,12,31,2562,{ident:__wrap(first)},"statement",false,false),"statement",false,false),value:__node("Const",2562,21,true)}},"statement",false,false),__node("MacroAccess",2563,1,38,2563,{macroName:"let",macroData:{declarable:__node("MacroAccess",2563,12,37,2563,__node("MacroAccess",2563,12,31,2563,{ident:__wrap(arr)},"statement",false,false),"statement",false,false),value:__node("Array",2563,19,[])}},"statement",false,false),__node("MacroAccess",2564,1,15,2564,{macroName:"let",macroData:{ident:__wrap(next),func:__node("MacroAccess",2564,18,115,2564,{op:"",node:__node("Function",2564,18,[__node("Param",2564,19,__wrap(err),void 0,false,false,void 0),__node("Param",2564,24,__wrap(value),void 0,false,false,void 0)],__node("Block",2565,1,[__node("MacroAccess",2565,1,17,2565,{macroName:"if",macroData:{test:__node("MacroAccess",2565,13,20,2565,{op:"?",node:__wrap(err)},"statement",false,false),body:__node("MacroAccess",2566,1,39,2566,{macroName:"return",macroData:{node:__node("Call",2566,19,__wrap(done),[__wrap(err)],false,false)}},"statement",false,false),elseIfs:[]}},"statement",false,false),__node("MacroAccess",2567,1,17,2567,{macroName:"if",macroData:{test:__wrap(first),body:__node("MacroAccess",2568,1,30,2568,{left:__wrap(first),op:":=",right:__node("Const",2568,22,false)},"statement",false,false),elseIfs:[],elseBody:__node("Block",2570,1,[__wrap(step),__node("MacroAccess",2571,1,17,2571,{macroName:"if",macroData:{test:__node("MacroAccess",2571,15,10,2571,{left:__node("Access",2571,15,__node("Args",2571,15),__node("Const",2571,26,"length")),inverted:false,op:"~>",right:__node("Const",2571,36,1)},"statement",false,false),body:__node("Call",2572,1,__node("Access",2572,1,__wrap(arr),__node("Const",2572,20,"push")),[__wrap(value)],false,false),elseIfs:[]}},"statement",false,false)],null)}},"statement",false,false),__node("MacroAccess",2573,1,17,2573,{macroName:"unless",macroData:{test:__wrap(test),body:__node("MacroAccess",2574,1,39,2574,{macroName:"return",macroData:{node:__node("Call",2574,19,__wrap(done),[__node("Const",2574,26,null),__wrap(arr)],false,false)}},"statement",false,false),elseIfs:[]}},"statement",false,false),__wrap(body)],null),true,true,false,void 0,false,[])},"statement",false,false)}},"statement",false,false),__node("MacroAccess",2576,1,15,2576,{macroName:"let",macroData:{ident:__wrap(done),func:__node("MacroAccess",2576,18,115,2576,{op:"",node:__node("Function",2576,18,[__node("Param",2576,19,__wrap(err),void 0,false,false,void 0),__node("Param",2576,24,__wrap(result),void 0,false,false,void 0)],__wrap(rest),true,true,false,void 0,false,[])},"statement",false,false)}},"statement",false,false),__node("Call",2578,1,__wrap(next),[],false,false)],null);}};}.call(this));',
params: [
[
"ident",
"results",
"many",
"?",
"sequence",
["ident", "err", "ident", "Identifier"],
[
"ident",
"result",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", "<-"]
],
["ident", "next", "ident", "Identifier"],
["const", ","],
[
"ident",
"init",
"choice",
["ident", "Statement"],
["const", ""]
],
["const", ";"],
[
"ident",
"test",
"choice",
["ident", "Logic"],
["const", ""]
],
["const", ";"],
[
"ident",
"step",
"choice",
["ident", "Statement"],
["const", ""]
],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
["const", "end"],
["ident", "rest", "ident", "DedentedBody"]
],
names: "asyncfor",
id: 128
},
{
code: 'return (function(){"use strict";var __strnum,__typeof;__strnum=function(strnum){var type;type=typeof strnum;if(type==="string"){return strnum;}else if(type==="number"){return String(strnum);}else{throw TypeError("Expected a string or number, got "+__typeof(strnum));}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _ref,array,body,end,err,hasResult,inclusive,index,init,length,lengthCalc,macroData,macroName,next,parallelism,rest,result,results,start,step,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;parallelism=macroData.parallelism;results=macroData.results;next=macroData.next;value=macroData.value;index=macroData.index;array=macroData.array;body=macroData.body;rest=macroData.rest;err=(_ref=results!=null?results:{}).err;result=_ref.result;hasResult=!!result;if(err==null){err=this.tmp("err",true);}init=[];if(rest==null){rest=this.noop();}value=this.macroExpand1(value);length=null;if(index){length=index.length;index=index.value;}if(parallelism==null){parallelism=__node("Const",2594,25,1);}if(index==null){index=this.tmp("i",true,"number");}if(this.isCall(array)&&this.isIdent(this.callFunc(array))&&this.name(this.callFunc(array))==="__range"&&!this.callIsApply(array)){if(this.isArray(value)||this.isObject(value)){this.error("Cannot assign a number to a complex declarable",value);}value=value.ident;start=(_ref=this.callArgs(array))[0];end=_ref[1];step=_ref[2];inclusive=_ref[3];if(this.isConst(start)){if(typeof this.value(start)!=="number"){this.error("Cannot start with a non-number: "+__strnum(this.value(start)),start);}}else{start=__node("MacroAccess",2607,22,58,2607,{op:"+",node:__wrap(start)},"expression",false,false);}if(this.isConst(end)){if(typeof this.value(end)!=="number"){this.error("Cannot end with a non-number: "+__strnum(this.value(end)),end);}}else if(this.isComplex(end)){end=this.cache(__node("MacroAccess",2613,28,58,2613,{op:"+",node:__wrap(end)},"expression",false,false),init,"end",false);}else{init.push(__node("MacroAccess",2615,23,58,2615,{op:"+",node:__wrap(end)},"expression",false,false));}if(this.isConst(step)){if(typeof this.value(step)!=="number"){this.error("Cannot step with a non-number: "+__strnum(this.value(step)),step);}}else if(this.isComplex(step)){step=this.cache(__node("MacroAccess",2621,29,58,2621,{op:"+",node:__wrap(step)},"expression",false,false),init,"step",false);}else{init.push(__node("MacroAccess",2623,23,58,2623,{op:"+",node:__wrap(step)},"expression",false,false));}body=__node("Block",2626,1,[__node("MacroAccess",2626,1,38,2626,{macroName:"let",macroData:{declarable:__node("MacroAccess",2626,12,37,2626,__node("MacroAccess",2626,12,31,2626,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",2626,21,49,2626,{left:__node("MacroAccess",2626,21,45,2626,{left:__wrap(index),inverted:false,op:"~*",right:__wrap(step)},"expression",false,false),inverted:false,op:"~+",right:__wrap(start)},"expression",false,false)}},"statement",false,false),__wrap(body)],null);lengthCalc=__node("MacroAccess",2629,29,17,2629,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",2630,1,45,2630,{left:__node("MacroAccess",2630,10,49,2630,{left:__node("MacroAccess",2630,10,49,2630,{left:__wrap(end),inverted:false,op:"~-",right:__wrap(start)},"expression",false,false),inverted:false,op:"~+",right:__wrap(step)},"expression",false,false),inverted:false,op:"~\\\\",right:__wrap(step)},"statement",false,false),elseIfs:[],elseBody:__node("MacroAccess",2632,1,45,2632,{left:__node("MacroAccess",2632,10,49,2632,{left:__wrap(end),inverted:false,op:"~-",right:__wrap(start)},"expression",false,false),inverted:false,op:"~\\\\",right:__wrap(step)},"statement",false,false)}},"expression",false,false);if(!length){length=lengthCalc;}else{init.push(__node("MacroAccess",2636,22,38,2636,{macroName:"let",macroData:{declarable:__node("MacroAccess",2636,26,37,2636,__node("MacroAccess",2636,26,31,2636,{ident:__wrap(length)},"statement",false,false),"statement",false,false),value:__wrap(lengthCalc)}},"statement",false,false));}}else{array=this.cache(array,init,"arr",true);body=__node("Block",2641,1,[__node("MacroAccess",2641,1,38,2641,{macroName:"let",macroData:{declarable:__node("MacroAccess",2641,12,37,2641,__node("MacroAccess",2641,12,31,2641,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__node("Access",2641,21,__wrap(array),__wrap(index))}},"statement",false,false),__wrap(body)],null);if(!length){length=__node("MacroAccess",2645,23,58,2645,{op:"+",node:__node("Access",2645,25,__wrap(array),__node("Const",2645,32,"length"))},"expression",false,false);}else{init.push(__node("MacroAccess",2647,22,38,2647,{macroName:"let",macroData:{declarable:__node("MacroAccess",2647,26,37,2647,__node("MacroAccess",2647,26,31,2647,{ident:__wrap(length)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",2647,36,58,2647,{op:"+",node:__node("Access",2647,38,__wrap(array),__node("Const",2647,45,"length"))},"expression",false,false)}},"statement",false,false));}}return __node("Block",2650,1,[__wrap(init),__node("Call",2651,1,__node("Ident",2651,1,"__async"),[__node("MacroAccess",2651,15,58,2651,{op:"+",node:__wrap(parallelism)},"expression",false,false),__wrap(length),__wrap(hasResult),__node("MacroAccess",2652,10,115,2652,{op:"",node:__node("Function",2652,10,[__node("Param",2652,11,__wrap(index),void 0,false,false,void 0),__node("Param",2652,18,__wrap(next),void 0,false,false,void 0)],__wrap(body),true,true,false,void 0,false,[])},"expression",false,false),__node("MacroAccess",2653,9,17,2653,{macroName:"if",macroData:{test:__wrap(hasResult),body:__node("MacroAccess",2654,12,115,2654,{op:"",node:__node("Function",2654,12,[__node("Param",2654,13,__wrap(err),void 0,false,false,void 0),__node("Param",2654,18,__wrap(result),void 0,false,false,void 0)],__wrap(rest),true,true,false,void 0,false,[])},"statement",false,false),elseIfs:[],elseBody:__node("MacroAccess",2656,12,115,2656,{op:"",node:__node("Function",2656,12,[__node("Param",2656,13,__wrap(err),void 0,false,false,void 0)],__wrap(rest),true,true,false,void 0,false,[])},"statement",false,false)}},"expression",false,false)],false,false)],null);};}.call(this));',
params: [
[
"ident",
"parallelism",
"many",
"?",
"sequence",
["const", "("],
["this", "ident", "Expression"],
["const", ")"]
],
[
"ident",
"results",
"many",
"?",
"sequence",
["ident", "err", "ident", "Identifier"],
[
"ident",
"result",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", "<-"]
],
["ident", "next", "ident", "Identifier"],
["const", ","],
["ident", "value", "ident", "Declarable"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["ident", "value", "ident", "Identifier"],
[
"ident",
"length",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
]
],
["const", "in"],
["ident", "array"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
["const", "end"],
["ident", "rest", "ident", "DedentedBody"]
],
names: "asyncfor",
id: 129
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _ref,body,err,index,init,key,keys,macroData,macroName,next,object,own,parallelism,rest,result,results,type,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;parallelism=macroData.parallelism;results=macroData.results;next=macroData.next;key=macroData.key;value=macroData.value;type=macroData.type;object=macroData.object;body=macroData.body;rest=macroData.rest;err=(_ref=results!=null?results:{}).err;result=_ref.result;own=type==="of";init=[];object=this.cache(object,init,"obj",true);if(rest==null){rest=this.noop();}index=null;if(value){index=value.index;value=this.macroExpand1(value.value);}if(value){body=__node("Block",2672,1,[__node("MacroAccess",2672,1,38,2672,{macroName:"let",macroData:{declarable:__node("MacroAccess",2672,12,37,2672,__node("MacroAccess",2672,12,31,2672,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__node("Access",2672,21,__wrap(object),__wrap(key))}},"statement",false,false),__wrap(body)],null);}keys=this.tmp("keys",true,"stringArray");return __node("Block",2677,1,[__wrap(init),__node("MacroAccess",2678,1,38,2678,{macroName:"let",macroData:{declarable:__node("MacroAccess",2678,10,37,2678,__node("MacroAccess",2678,10,31,2678,{ident:__wrap(keys)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",2678,18,17,2678,{macroName:"if",macroData:{test:__wrap(own),body:__node("Call",2679,1,__node("Ident",2679,1,"__keys"),[__wrap(object)],false,false),elseIfs:[],elseBody:__node("Call",2681,1,__node("Ident",2681,1,"__allkeys"),[__wrap(object)],false,false)}},"expression",false,false)}},"statement",false,false),__node("MacroAccess",2682,1,129,2682,{macroName:"asyncfor",macroData:{parallelism:__wrap(parallelism),results:{err:__wrap(err),result:__wrap(result)},next:__wrap(next),value:__node("MacroAccess",2682,53,37,2682,__node("MacroAccess",2682,53,31,2682,{ident:__wrap(key)},"statement",false,false),"statement",false,false),index:{value:__wrap(index)},array:__wrap(keys),body:__wrap(body),rest:__wrap(rest)}},"statement",false,false)],null);};}.call(this));',
params: [
[
"ident",
"parallelism",
"many",
"?",
"sequence",
["const", "("],
["this", "ident", "Expression"],
["const", ")"]
],
[
"ident",
"results",
"many",
"?",
"sequence",
["ident", "err", "ident", "Identifier"],
[
"ident",
"result",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", "<-"]
],
["ident", "next", "ident", "Identifier"],
["const", ","],
["ident", "key", "ident", "Identifier"],
[
"ident",
"value",
"many",
"?",
"sequence",
["const", ","],
["ident", "value", "ident", "Declarable"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
]
],
[
"ident",
"type",
"choice",
["const", "of"],
["const", "ofall"]
],
["ident", "object"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
["const", "end"],
["ident", "rest", "ident", "DedentedBody"]
],
names: "asyncfor",
id: 130
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _ref,body,err,hasResult,index,iterator,macroData,macroName,next,parallelism,rest,result,results,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;parallelism=macroData.parallelism;results=macroData.results;next=macroData.next;value=macroData.value;index=macroData.index;iterator=macroData.iterator;body=macroData.body;rest=macroData.rest;err=(_ref=results!=null?results:{}).err;result=_ref.result;hasResult=!!result;if(rest==null){rest=this.noop();}if(index==null){index=this.tmp("i",true);}if(err==null){err=this.tmp("err",true);}if(parallelism==null){parallelism=__node("Const",2694,25,1);}return __node("Call",2696,9,__node("Ident",2696,9,"__asyncIter"),[__node("MacroAccess",2696,23,58,2696,{op:"+",node:__wrap(parallelism)},"expression",false,false),__node("Call",2696,37,__node("Ident",2696,37,"__iter"),[__wrap(iterator)],false,false),__wrap(hasResult),__node("MacroAccess",2697,8,115,2697,{op:"",node:__node("Function",2697,8,[__node("Param",2697,9,__wrap(value),void 0,false,false,void 0),__node("Param",2697,16,__wrap(index),void 0,false,false,void 0),__node("Param",2697,24,__wrap(next),void 0,false,false,void 0)],__wrap(body),true,true,false,void 0,false,[])},"expression",false,false),__node("MacroAccess",2698,7,17,2698,{macroName:"if",macroData:{test:__wrap(hasResult),body:__node("MacroAccess",2699,10,115,2699,{op:"",node:__node("Function",2699,10,[__node("Param",2699,11,__wrap(err),void 0,false,false,void 0),__node("Param",2699,16,__wrap(result),void 0,false,false,void 0)],__wrap(rest),true,true,false,void 0,false,[])},"statement",false,false),elseIfs:[],elseBody:__node("MacroAccess",2701,10,115,2701,{op:"",node:__node("Function",2701,10,[__node("Param",2701,11,__wrap(err),void 0,false,false,void 0)],__wrap(rest),true,true,false,void 0,false,[])},"statement",false,false)}},"expression",false,false)],false,false);};}.call(this));',
params: [
[
"ident",
"parallelism",
"many",
"?",
"sequence",
["const", "("],
["this", "ident", "Expression"],
["const", ")"]
],
[
"ident",
"results",
"many",
"?",
"sequence",
["ident", "err", "ident", "Identifier"],
[
"ident",
"result",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", "<-"]
],
["ident", "next", "ident", "Identifier"],
["const", ","],
["ident", "value", "ident", "Identifier"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", "from"],
["ident", "iterator"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
["const", "end"],
["ident", "rest", "ident", "DedentedBody"]
],
names: "asyncfor",
id: 131
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _ref,body,err,macroData,macroName,next,rest,result,results,step,test;macroName=macroFullData.macroName;macroData=macroFullData.macroData;results=macroData.results;next=macroData.next;test=macroData.test;step=macroData.step;body=macroData.body;rest=macroData.rest;if(macroName==="asyncuntil"){test=__node("MacroAccess",2706,19,3,2706,{op:"not",node:__wrap(test)},"expression",false,false);}if(rest==null){rest=this.noop();}err=(_ref=results!=null?results:{}).err;result=_ref.result;return __node("MacroAccess",2712,1,128,2712,{macroName:"asyncfor",macroData:{results:{err:__wrap(err),result:__wrap(result)},next:__wrap(next),test:__wrap(test),step:__wrap(step),body:__wrap(body),rest:__wrap(rest)}},"statement",false,false);};}.call(this));',
params: [
[
"ident",
"results",
"many",
"?",
"sequence",
["ident", "err", "ident", "Identifier"],
[
"ident",
"result",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", "<-"]
],
["ident", "next", "ident", "Identifier"],
["const", ","],
["ident", "test", "ident", "Logic"],
[
"ident",
"step",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Statement"]
],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
["const", "end"],
["ident", "rest", "ident", "DedentedBody"]
],
names: ["asyncwhile", "asyncuntil"],
id: 132
},
{
code: 'return (function(){"use strict";var __num,__typeof;__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _ref,body,current,done,elseBody,elseIf,elseIfs,err,f,i,innerTest,macroData,macroName,rest,result,results,test;macroName=macroFullData.macroName;macroData=macroFullData.macroData;results=macroData.results;done=macroData.done;test=macroData.test;body=macroData.body;elseIfs=macroData.elseIfs;elseBody=macroData.elseBody;rest=macroData.rest;if(macroName==="asyncunless"){test=__node("MacroAccess",2719,19,3,2719,{op:"not",node:__wrap(test)},"expression",false,false);}err=(_ref=results!=null?results:{}).err;result=_ref.result;f=this.tmp("f",false);if(rest==null){rest=this.noop();}if(elseBody){current=__node("MacroAccess",2727,11,30,2727,{left:__wrap(f),op:":=",right:__node("MacroAccess",2727,19,115,2727,{op:"",node:__node("Function",2727,19,[__node("Param",2727,20,__wrap(done),void 0,false,false,void 0)],__wrap(elseBody),true,true,false,void 0,false,[])},"expression",false,false)},"expression",false,false);}else{current=__node("MacroAccess",2729,11,30,2729,{left:__wrap(f),op:":=",right:__node("MacroAccess",2729,19,115,2729,{op:"",node:__node("Function",2729,19,[__node("Param",2729,20,__wrap(done),void 0,false,false,void 0)],__node("Call",2729,30,__wrap(done),[],false,false),true,true,false,void 0,false,[])},"expression",false,false)},"expression",false,false);}i=__num(elseIfs.length)-1;for(;i>=0;--i){elseIf=elseIfs[i];innerTest=elseIf.test;if(elseIf.type==="unless"){innerTest=__node("MacroAccess",2736,27,3,2736,{op:"not",node:__wrap(innerTest)},"expression",false,false);}current=__node("MacroAccess",2737,21,17,2737,{macroName:"if",macroData:{test:__wrap(innerTest),body:__node("MacroAccess",2738,1,30,2738,{left:__wrap(f),op:":=",right:__node("MacroAccess",2738,16,115,2738,{op:"",node:__node("Function",2738,16,[__node("Param",2738,17,__wrap(done),void 0,false,false,void 0)],__wrap(elseIf.body),true,true,false,void 0,false,[])},"expression",false,false)},"statement",false,false),elseIfs:[],elseBody:__wrap(current)}},"statement",false,false);}current=__node("MacroAccess",2742,19,17,2742,{macroName:"if",macroData:{test:__wrap(test),body:__node("MacroAccess",2743,1,30,2743,{left:__wrap(f),op:":=",right:__node("MacroAccess",2743,14,115,2743,{op:"",node:__node("Function",2743,14,[__node("Param",2743,15,__wrap(done),void 0,false,false,void 0)],__wrap(body),true,true,false,void 0,false,[])},"expression",false,false)},"statement",false,false),elseIfs:[],elseBody:__wrap(current)}},"statement",false,false);if(!err&&!result){return __node("Block",2749,1,[__wrap(current),__node("Call",2750,1,__wrap(f),[__node("MacroAccess",2750,13,115,2750,{op:"",node:__node("Function",2750,13,[],__wrap(rest),true,true,false,void 0,false,[])},"expression",false,false)],false,false)],null);}else if(!result){return __node("Block",2753,1,[__wrap(current),__node("Call",2754,1,__wrap(f),[__node("MacroAccess",2754,13,115,2754,{op:"",node:__node("Function",2754,13,[__node("Param",2754,14,__wrap(err),void 0,false,false,void 0)],__wrap(rest),true,true,false,void 0,false,[])},"expression",false,false)],false,false)],null);}else{if(err==null){err=this.tmp("err",true);}return __node("Block",2758,1,[__wrap(current),__node("Call",2759,1,__wrap(f),[__node("MacroAccess",2759,13,115,2759,{op:"",node:__node("Function",2759,13,[__node("Param",2759,14,__wrap(err),void 0,false,false,void 0),__node("Param",2759,19,__wrap(result),void 0,false,false,void 0)],__wrap(rest),true,true,false,void 0,false,[])},"expression",false,false)],false,false)],null);}};}.call(this));',
params: [
[
"ident",
"results",
"many",
"?",
"sequence",
["ident", "err", "ident", "Identifier"],
[
"ident",
"result",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", "<-"]
],
["ident", "done", "ident", "Identifier"],
["const", ","],
["ident", "test", "ident", "Logic"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
],
[
"ident",
"elseIfs",
"many",
"*",
"sequence",
["const", "\n"],
["const", "else"],
[
"ident",
"type",
"choice",
["const", "if"],
["const", "unless"]
],
["ident", "test", "ident", "Logic"],
[
"ident",
"body",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
[
"ident",
"elseBody",
"many",
"?",
"sequence",
["const", "\n"],
["const", "else"],
[
"this",
"choice",
["ident", "BodyNoEnd"],
[
"sequence",
["const", ";"],
["this", "ident", "Statement"]
]
]
],
["const", "end"],
["ident", "rest", "ident", "DedentedBody"]
],
names: ["asyncif", "asyncunless"],
id: 133
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var func,key,macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;key=macroData.key;func=macroData.func;return this.def(key,func);};}.call(this));',
params: [
["ident", "key", "ident", "ObjectKey"],
["ident", "func", "ident", "FunctionDeclaration"]
],
names: "def",
id: 134
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var key,macroData,macroName,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;key=macroData.key;value=macroData.value;return this.def(key,value);};}.call(this));',
params: [
["ident", "key", "ident", "ObjectKey"],
["const", "="],
["ident", "value", "ident", "ExpressionOrAssignment"]
],
names: "def",
id: 135
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var key,macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;key=macroData.key;return this.def(key,void 0);};}.call(this));',
params: [["ident", "key", "ident", "ObjectKey"]],
names: "def",
id: 136
},
{
code: 'return (function(){"use strict";var __isArray,__owns,__slice,__strnum,__toArray,__typeof;__isArray=typeof Array.isArray==="function"?Array.isArray:(function(){var _toString;_toString=Object.prototype.toString;return function(x){return _toString.call(x)==="[object Array]";};}());__owns=Object.prototype.hasOwnProperty;__slice=Array.prototype.slice;__strnum=function(strnum){var type;type=typeof strnum;if(type==="string"){return strnum;}else if(type==="number"){return String(strnum);}else{throw TypeError("Expected a string or number, got "+__typeof(strnum));}};__toArray=function(x){if(x==null){throw TypeError("Expected an object, got "+__typeof(x));}else if(__isArray(x)){return x;}else if(typeof x==="string"){return x.split("");}else{return __slice.call(x);}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _arr,_i,_len,_ref,_this,assignment,body,constructorCount,ctor,declaration,displayName,generic,genericArg,genericArgs,genericCache,genericParams,hasSuperclass,hasTopLevelConstructor,i,init,instanceofLets,instanceofs,item,key,macroData,macroName,makeClassFunc,makeClassIdent,name,parts,prototype,result,self,sup,superclass,superproto;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;name=macroData.name;generic=macroData.generic;superclass=macroData.superclass;body=macroData.body;if(generic!=null){genericArgs=[generic.head].concat(__toArray(generic.tail));}else{genericArgs=[];}if(this.isIdent(name)){declaration=name;}else if(this.isAccess(name)){assignment=name;if(this.isConst(this.child(name))&&typeof this.value(this.child(name))==="string"){name=(_ref=this.ident(this.value(this.child(name))))!=null?_ref:this.tmp("class",false,"function");}else{name=this.tmp("class",false,"function");}}else{name=this.tmp("class",false,"function");}hasSuperclass=!!superclass;sup=superclass&&(this.isIdent(superclass)?superclass:this.tmp("super",false,"function"));init=[];if(!superclass){superproto=__node("Access",2791,11,__node("Ident",2791,11,"Object"),__node("Const",2791,19,"prototype"));}else{superproto=this.tmp(this.isIdent(sup)?__strnum(this.name(sup))+"_prototype":"super_prototype",false,"object");}prototype=this.tmp(this.isIdent(name)?__strnum(this.name(name))+"_prototype":"prototype",false,"object");if(superclass){init.push(__node("MacroAccess",2796,20,38,2796,{macroName:"let",macroData:{declarable:__node("MacroAccess",2796,24,37,2796,__node("MacroAccess",2796,24,31,2796,{ident:__wrap(superproto)},"statement",false,false),"statement",false,false),value:__node("Access",2796,38,__wrap(sup),__node("Const",2796,44,"prototype"))}},"statement",false,false));init.push(__node("MacroAccess",2797,20,38,2797,{macroName:"let",macroData:{declarable:__node("MacroAccess",2797,24,37,2797,__node("MacroAccess",2797,24,31,2797,{ident:__wrap(prototype)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",2797,37,30,2797,{left:__node("Access",2797,37,__wrap(name),__node("Const",2797,44,"prototype")),op:":=",right:__node("Object",2797,56,[],__wrap(superproto))},"expression",false,false)}},"statement",false,false));init.push(__node("MacroAccess",2798,21,30,2798,{left:__node("Access",2798,21,__wrap(prototype),__node("Const",2798,33,"constructor")),op:":=",right:__wrap(name)},"expression",false,false));}else{init.push(__node("MacroAccess",2800,20,38,2800,{macroName:"let",macroData:{declarable:__node("MacroAccess",2800,24,37,2800,__node("MacroAccess",2800,24,31,2800,{ident:__wrap(prototype)},"statement",false,false),"statement",false,false),value:__node("Access",2800,37,__wrap(name),__node("Const",2800,44,"prototype"))}},"statement",false,false));}if(this.isIdent(name)){displayName=this["const"](this.name(name));}if(displayName!=null){if(genericArgs.length>0){parts=[displayName,this["const"]("<")];for(i=0, _len=genericArgs.length;i<_len;++i){genericArg=genericArgs[i];if(i>0){parts.push(this["const"](", "));}parts.push(__node("MacroAccess",2809,26,16,2809,{macroName:"if",macroData:{test:__node("MacroAccess",2809,29,8,2809,{left:__wrap(genericArg),inverted:false,op:"!~=",right:__node("Const",2809,46,null)},"expression",false,false),body:__node("Call",2809,56,__node("Ident",2809,56,"__name"),[__wrap(genericArg)],false,false),elseIfs:[],elseBody:__node("Const",2809,82,"")}},"expression",false,false));}parts.push(this["const"](">"));displayName=this.binaryChain("+",parts);}init.push(__node("MacroAccess",2812,21,30,2812,{left:__node("Access",2812,21,__wrap(name),__node("Const",2812,28,"displayName")),op:":=",right:__wrap(displayName)},"expression",false,false));}if(superclass){init.push(__node("If",2815,20,__node("Binary",2815,20,__node("Unary",2815,20,"typeof",__node("Access",2815,20,__wrap(sup),__node("Const",2815,26,"extended"))),"===",__node("Const",2815,20,"function")),__node("Call",2815,20,__node("Access",2815,20,__wrap(sup),__node("Const",2815,26,"extended")),[__wrap(name)],false,false),__node("Nothing",0,0),null));}function fixSupers(node){return _this.walk(node,function(node){var _arr,_arr2,_i,_len,args,child,superArg;if(_this.isSuper(node)){child=_this.superChild(node);if(child!=null){child=fixSupers(child);}for(_arr=[], _arr2=__toArray(_this.superArgs(node)), _i=0, _len=_arr2.length;_i<_len;++_i){superArg=_arr2[_i];_arr.push(fixSupers(superArg));}args=_arr;return _this.call(child!=null?__node("Access",2827,17,__wrap(superproto),__wrap(child)):!superclass?__node("Ident",2829,17,"Object"):__wrap(sup),[__node("This",2832,16)].concat(args),false,true);}});};body=fixSupers(this.macroExpandAll(body));constructorCount=0;this.walk(body,function(node){var key;if(_this.isDef(node)){key=_this.left(node);if(_this.isConst(key)&&_this.value(key)==="constructor"){++constructorCount;}}return;});hasTopLevelConstructor=false;if(constructorCount===1){this.walk(body,function(node){var key;if(_this.isDef(node)){key=_this.left(node);if(_this.isConst(key)&&_this.value(key)==="constructor"&&_this.isFunc(_this.right(node))&&!_this.funcIsCurried(_this.right(node))){hasTopLevelConstructor=true;}return node;}else{return node;}});}self=this.tmp("this");if(hasTopLevelConstructor){body=this.walk(body,function(node){var constructor,key,value;if(_this.isDef(node)){key=_this.left(node);if(_this.isConst(key)&&_this.value(key)==="constructor"){value=_this.right(node);constructor=_this.rewrap(_this.func(_this.funcParams(value),_this.funcBody(value),false,__node("MacroAccess",2869,18,16,2869,{macroName:"if",macroData:{test:__node("MacroAccess",2869,21,72,2869,{left:__node("Eval",2869,21,__node("Const",2869,27,"this")),inverted:false,op:"instanceof",right:__wrap(name)},"statement",false,false),body:__node("Eval",2869,56,__node("Const",2869,62,"this")),elseIfs:[],elseBody:__node("Object",2869,74,[],__wrap(prototype))}},"statement",false,false)),value);init.unshift(__node("MacroAccess",2870,29,38,2870,{macroName:"let",macroData:{declarable:__node("MacroAccess",2870,33,37,2870,__node("MacroAccess",2870,33,31,2870,{ident:__wrap(name)},"statement",false,false),"statement",false,false),value:__wrap(constructor)}},"statement",false,false));return _this.noop();}}else{return node;}});}else if(constructorCount!==0){ctor=this.tmp("ctor",false,"function");result=this.tmp("ref");init.push(__node("Block",2878,1,[__node("MacroAccess",2878,1,38,2878,{macroName:"let",macroData:{declarable:__node("MacroAccess",2878,12,37,2878,__node("MacroAccess",2878,12,31,2878,{isMutable:"mutable",ident:__wrap(ctor)},"statement",false,false),"statement",false,false),value:__node("Const",2878,28,void 0)}},"statement",false,false),__node("MacroAccess",2879,1,15,2879,{macroName:"let",macroData:{ident:__wrap(name),func:__node("MacroAccess",2879,18,115,2879,{op:"",node:__node("Function",2879,18,[],__node("Block",2880,1,[__node("MacroAccess",2880,1,38,2880,{macroName:"let",macroData:{declarable:__node("MacroAccess",2880,14,37,2880,__node("MacroAccess",2880,14,31,2880,{ident:__wrap(self)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",2880,22,16,2880,{macroName:"if",macroData:{test:__node("MacroAccess",2880,25,72,2880,{left:__node("This",2880,25),inverted:false,op:"instanceof",right:__wrap(name)},"expression",false,false),body:__node("This",2880,52),elseIfs:[],elseBody:__node("Object",2880,62,[],__wrap(prototype))}},"expression",false,false)}},"statement",false,false),__node("MacroAccess",2882,1,17,2882,{macroName:"if",macroData:{test:__node("MacroAccess",2882,13,26,2882,{op:"isFunction!",node:__wrap(ctor)},"statement",false,false),body:__node("Block",2883,1,[__node("MacroAccess",2883,1,38,2883,{macroName:"let",macroData:{declarable:__node("MacroAccess",2883,16,37,2883,__node("MacroAccess",2883,16,31,2883,{ident:__wrap(result)},"statement",false,false),"statement",false,false),value:__node("Call",2883,26,__wrap(ctor),[__wrap(self),__node("Spread",2883,40,__node("Args",2883,44))],false,true)}},"statement",false,false),__node("MacroAccess",2884,1,17,2884,{macroName:"if",macroData:{test:__node("MacroAccess",2884,15,5,2884,{left:__node("Call",2884,15,__node("Ident",2884,15,"Object"),[__wrap(result)],false,false),inverted:false,op:"==",right:__wrap(result)},"statement",false,false),body:__node("MacroAccess",2885,1,39,2885,{macroName:"return",macroData:{node:__wrap(result)}},"statement",false,false),elseIfs:[]}},"statement",false,false)],null),elseIfs:[{type:"if",test:__wrap(hasSuperclass),body:__node("Block",2887,1,[__node("MacroAccess",2887,1,38,2887,{macroName:"let",macroData:{declarable:__node("MacroAccess",2887,16,37,2887,__node("MacroAccess",2887,16,31,2887,{ident:__wrap(result)},"statement",false,false),"statement",false,false),value:__node("Call",2887,26,__wrap(sup),[__wrap(self),__node("Spread",2887,39,__node("Args",2887,43))],false,true)}},"statement",false,false),__node("MacroAccess",2888,1,17,2888,{macroName:"if",macroData:{test:__node("MacroAccess",2888,15,5,2888,{left:__node("Call",2888,15,__node("Ident",2888,15,"Object"),[__wrap(result)],false,false),inverted:false,op:"==",right:__wrap(result)},"statement",false,false),body:__node("MacroAccess",2889,1,39,2889,{macroName:"return",macroData:{node:__wrap(result)}},"statement",false,false),elseIfs:[]}},"statement",false,false)],null)}]}},"statement",false,false),__wrap(self)],null),true,false,false,void 0,false,[])},"statement",false,false)}},"statement",false,false)],null));body=this.walk(body,function(node){var constructor,firstArg,key,value;if(_this.isDef(node)){key=_this.left(node);if(_this.isConst(key)&&_this.value(key)==="constructor"){value=_this.right(node);if(_this.isCall(value)&&_this.isIdent(_this.callFunc(value))&&_this.name(_this.callFunc(value))==="__curry"&&_this.callArgs(value).length===2&&_this.isFunc(_this.callArgs(value)[1])){firstArg=_this.callArgs(value)[0];constructor=_this.callArgs(value)[1];constructor=_this.rewrap(_this.func(_this.funcParams(constructor),_this.funcBody(constructor),false,__node("MacroAccess",2903,20,16,2903,{macroName:"if",macroData:{test:__node("MacroAccess",2903,23,72,2903,{left:__node("Eval",2903,23,__node("Const",2903,29,"this")),inverted:false,op:"instanceof",right:__wrap(name)},"statement",false,false),body:__node("Eval",2903,58,__node("Const",2903,64,"this")),elseIfs:[],elseBody:__node("Object",2903,76,[],__wrap(prototype))}},"statement",false,false),false),value);return __node("MacroAccess",2905,19,30,2905,{left:__wrap(ctor),op:":=",right:__node("Call",2905,28,__node("Ident",2905,28,"__curry"),[__wrap(firstArg),__wrap(constructor)],false,false)},"expression",false,false);}else if(_this.isFunc(value)){constructor=_this.rewrap(_this.func(_this.funcParams(value),_this.funcBody(value),false,__node("MacroAccess",2911,20,16,2911,{macroName:"if",macroData:{test:__node("MacroAccess",2911,23,72,2911,{left:__node("Eval",2911,23,__node("Const",2911,29,"this")),inverted:false,op:"instanceof",right:__wrap(name)},"statement",false,false),body:__node("Eval",2911,58,__node("Const",2911,64,"this")),elseIfs:[],elseBody:__node("Object",2911,76,[],__wrap(prototype))}},"statement",false,false),_this.funcIsCurried(value)),value);return __node("MacroAccess",2913,19,30,2913,{left:__wrap(ctor),op:":=",right:__wrap(constructor)},"expression",false,false);}else{return __node("MacroAccess",2915,19,30,2915,{left:__wrap(ctor),op:":=",right:__wrap(value)},"expression",false,false);}}}});}else if(!superclass){init.push(__node("MacroAccess",2919,1,15,2919,{macroName:"let",macroData:{ident:__wrap(name),func:__node("MacroAccess",2919,20,115,2919,{op:"",node:__node("Function",2919,20,[],__node("MacroAccess",2919,25,16,2919,{macroName:"if",macroData:{test:__node("MacroAccess",2919,28,72,2919,{left:__node("This",2919,28),inverted:false,op:"instanceof",right:__wrap(name)},"statement",false,false),body:__node("This",2919,55),elseIfs:[],elseBody:__node("Object",2919,65,[],__wrap(prototype))}},"statement",false,false),true,false,false,void 0,false,[])},"statement",false,false)}},"statement",false,false));}else{result=this.tmp("ref");init.push(__node("MacroAccess",2923,1,15,2923,{macroName:"let",macroData:{ident:__wrap(name),func:__node("MacroAccess",2923,20,115,2923,{op:"",node:__node("Function",2923,20,[],__node("Block",2924,1,[__node("MacroAccess",2924,1,38,2924,{macroName:"let",macroData:{declarable:__node("MacroAccess",2924,16,37,2924,__node("MacroAccess",2924,16,31,2924,{ident:__wrap(self)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",2924,24,16,2924,{macroName:"if",macroData:{test:__node("MacroAccess",2924,27,72,2924,{left:__node("This",2924,27),inverted:false,op:"instanceof",right:__wrap(name)},"expression",false,false),body:__node("This",2924,54),elseIfs:[],elseBody:__node("Object",2924,64,[],__wrap(prototype))}},"expression",false,false)}},"statement",false,false),__node("MacroAccess",2925,1,38,2925,{macroName:"let",macroData:{declarable:__node("MacroAccess",2925,16,37,2925,__node("MacroAccess",2925,16,31,2925,{ident:__wrap(result)},"statement",false,false),"statement",false,false),value:__node("Call",2925,26,__wrap(sup),[__wrap(self),__node("Spread",2925,39,__node("Args",2925,43))],false,true)}},"statement",false,false),__node("MacroAccess",2926,1,17,2926,{macroName:"if",macroData:{test:__node("MacroAccess",2926,15,5,2926,{left:__node("Call",2926,15,__node("Ident",2926,15,"Object"),[__wrap(result)],false,false),inverted:false,op:"==",right:__wrap(result)},"statement",false,false),body:__wrap(result),elseIfs:[],elseBody:__wrap(self)}},"statement",false,false)],null),true,false,false,void 0,false,[])},"statement",false,false)}},"statement",false,false));}function changeDefs(node){return _this.walk(node,function(node){var _ref,key,value;if(_this.isDef(node)){key=_this.left(node);if((_ref=_this.right(node))!=null){value=_ref;}else{value=__node("MacroAccess",2934,42,115,2934,{op:"",node:__node("Function",2934,42,[],__node("MacroAccess",2934,44,11,2934,{op:"throw",node:__node("Call",2934,50,__node("Ident",2934,50,"Error"),[__node("MacroAccess",2934,57,67,2934,{left:__node("MacroAccess",2934,57,67,2934,{left:__node("MacroAccess",2934,57,67,2934,{left:__node("MacroAccess",2934,57,67,2934,{left:__node("Const",2934,57,"Not implemented: "),op:"",right:__node("Call",2934,77,__node("Ident",2934,77,"__name"),[__node("Access",2934,84,__node("This",2934,84),__node("Const",2934,85,"constructor"))],false,false)},"expression",false,false),op:"",right:__node("Const",2934,57,".")},"expression",false,false),op:"",right:__wrap(key)},"expression",false,false),op:"",right:__node("Const",2934,57,"()")},"expression",false,false)],false,false)},"statement",false,false),true,false,false,void 0,false,[])},"expression",false,false);}return changeDefs(__node("MacroAccess",2935,25,30,2935,{left:__node("Access",2935,25,__wrap(prototype),__wrap(key)),op:":=",right:__wrap(value)},"expression",false,false));}});};body=changeDefs(body);body=this.walk(body,function(node){if(_this.isFunc(node)){if(!_this.funcIsBound(node)){return node;}}else if(_this.isThis(node)){return name;}});result=__node("MacroAccess",2945,29,102,2945,{macroName:"do",macroData:{locals:{ident:__wrap(sup),value:__wrap(superclass),rest:[]},body:__node("Block",2946,1,[__wrap(init),__wrap(body),__node("MacroAccess",2948,1,39,2948,{macroName:"return",macroData:{node:__wrap(name)}},"statement",false,false)],null)}},"statement",false,false);if(genericArgs.length>0){genericCache=this.tmp("cache",false,"object");for(_arr=[], _i=0, _len=genericArgs.length;_i<_len;++_i){genericArg=genericArgs[_i];_arr.push(this.param(genericArg));}genericParams=_arr;makeClassIdent=this.tmp("make",false,"function");instanceofs={};for(_i=0, _len=genericArgs.length;_i<_len;++_i){genericArg=genericArgs[_i];name=this.name(genericArg);key=this.tmp("instanceof_"+__strnum(name),false,"function");instanceofs[name]={key:key,"let":__node("MacroAccess",2960,19,38,2960,{macroName:"let",macroData:{declarable:__node("MacroAccess",2960,23,37,2960,__node("MacroAccess",2960,23,31,2960,{ident:__wrap(key)},"statement",false,false),"statement",false,false),value:__node("Call",2960,30,__node("Ident",2960,30,"__getInstanceof"),[__wrap(genericArg)],false,false)}},"statement",false,false),used:false};}result=this.walk(this.macroExpandAll(result),function(node){var func,left,name,right;if(_this.isBinary(node)&&_this.op(node)==="instanceof"){right=_this.right(node);if(_this.isIdent(right)){name=_this.name(right);if(__owns.call(instanceofs,name)){func=instanceofs[name].key;instanceofs[name].used=true;left=_this.left(node);return __node("Call",2972,26,__wrap(func),[__wrap(left)],false,false);}}}});_arr=[];for(name in instanceofs){if(__owns.call(instanceofs,name)){item=instanceofs[name];if(item.used){_arr.push(item["let"]);}}}instanceofLets=_arr;if(instanceofLets.length){result=__node("Block",2978,1,[__wrap(instanceofLets),__wrap(result)],null);}makeClassFunc=this.func(genericParams,result,true,false);result=__node("Call",2981,20,__node("Ident",2981,20,"__genericFunc"),[__wrap(genericArgs.length),__wrap(makeClassFunc)],false,false);}if(declaration!=null){return __node("MacroAccess",2984,10,38,2984,{macroName:"let",macroData:{declarable:__node("MacroAccess",2984,14,37,2984,__node("MacroAccess",2984,14,31,2984,{ident:__wrap(declaration)},"statement",false,false),"statement",false,false),value:__wrap(result)}},"statement",false,false);}else if(assignment!=null){return __node("MacroAccess",2986,11,30,2986,{left:__wrap(assignment),op:":=",right:__wrap(result)},"expression",false,false);}else{return result;}};}.call(this));',
params: [
["ident", "name", "many", "?", "ident", "SimpleAssignable"],
[
"ident",
"generic",
"many",
"?",
"sequence",
["const", "<"],
["ident", "head", "ident", "Identifier"],
[
"ident",
"tail",
"many",
"*",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", ">"]
],
[
"ident",
"superclass",
"many",
"?",
"sequence",
["const", "extends"],
["this"]
],
["ident", "body", "many", "?", "ident", "Body"]
],
names: "class",
id: 137
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _ref,_this,assignment,body,declaration,index,macroData,macroName,name,result;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;name=macroData.name;body=macroData.body;if(this.isIdent(name)){declaration=name;}else if(this.isAccess(name)){assignment=name;if(this.isConst(this.child(name))&&typeof this.value(this.child(name))==="string"){name=(_ref=this.ident(this.value(this.child(name))))!=null?_ref:this.tmp("enum",false,"object");}else{name=this.tmp("enum",false,"object");}}else{name=this.tmp("enum",false,"object");}index=0;body=this.walk(this.macroExpandAll(body),function(node){var key,value;if(_this.isDef(node)){key=_this.left(node);value=_this.right(node);if(!_this.isConst(key)){_this.error("Cannot have non-const enum keys",key);}if(!value){++index;value=index;}return __node("MacroAccess",3015,13,30,3015,{left:__node("Access",3015,13,__node("This",3015,13),__wrap(key)),op:":=",right:__wrap(value)},"expression",false,false);}else{return node;}});result=__node("MacroAccess",3019,22,103,3019,{macroName:"with",macroData:{node:__node("Object",3019,27,[],void 0),body:__node("Block",3020,1,[__wrap(body),__node("MacroAccess",3021,1,39,3021,{macroName:"return",macroData:{node:__node("This",3021,13)}},"statement",false,false)],null)}},"expression",false,false);if(declaration!=null){return __node("MacroAccess",3024,10,38,3024,{macroName:"let",macroData:{declarable:__node("MacroAccess",3024,14,37,3024,__node("MacroAccess",3024,14,31,3024,{ident:__wrap(declaration)},"statement",false,false),"statement",false,false),value:__wrap(result)}},"statement",false,false);}else if(assignment!=null){return __node("MacroAccess",3026,11,30,3026,{left:__wrap(assignment),op:":=",right:__wrap(result)},"expression",false,false);}else{return result;}};}.call(this));',
params: [
["ident", "name", "many", "?", "ident", "SimpleAssignable"],
["ident", "body", "many", "?", "ident", "Body"]
],
names: "enum",
id: 138
},
{
code: 'return (function(){"use strict";var __isArray,__slice,__toArray,__typeof;__isArray=typeof Array.isArray==="function"?Array.isArray:(function(){var _toString;_toString=Object.prototype.toString;return function(x){return _toString.call(x)==="[object Array]";};}());__slice=Array.prototype.slice;__toArray=function(x){if(x==null){throw TypeError("Expected an object, got "+__typeof(x));}else if(__isArray(x)){return x;}else if(typeof x==="string"){return x.split("");}else{return __slice.call(x);}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _ref,_this,assignment,body,declaration,init,macroData,macroName,name,result,sup,superobject;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;name=macroData.name;superobject=macroData.superobject;body=macroData.body;if(this.isIdent(name)){declaration=name;}else if(this.isAccess(name)){assignment=name;if(this.isConst(this.child(name))&&typeof this.value(this.child(name))==="string"){name=(_ref=this.ident(this.value(this.child(name))))!=null?_ref:this.tmp("ns",false,"object");}else{name=this.tmp("ns",false,"object");}}else{name=this.tmp("ns",false,"object");}sup=superobject&&(this.isIdent(superobject)?superobject:this.tmp("super",false,"object"));init=[];if(!superobject){init.push(__node("MacroAccess",3048,20,38,3048,{macroName:"let",macroData:{declarable:__node("MacroAccess",3048,24,37,3048,__node("MacroAccess",3048,24,31,3048,{ident:__wrap(name)},"statement",false,false),"statement",false,false),value:__node("Object",3048,32,[],void 0)}},"statement",false,false));}else{init.push(__node("MacroAccess",3050,20,38,3050,{macroName:"let",macroData:{declarable:__node("MacroAccess",3050,24,37,3050,__node("MacroAccess",3050,24,31,3050,{ident:__wrap(name)},"statement",false,false),"statement",false,false),value:__node("Object",3050,32,[],__wrap(sup))}},"statement",false,false));}function fixSupers(node){return _this.walk(node,function(node){var _arr,_arr2,_i,_len,args,child,parent,superArg;if(_this.isSuper(node)){child=_this.superChild(node);if(child!=null){child=fixSupers(child);}for(_arr=[], _arr2=__toArray(_this.superArgs(node)), _i=0, _len=_arr2.length;_i<_len;++_i){superArg=_arr2[_i];_arr.push(fixSupers(superArg));}args=_arr;if(!superobject){parent=__node("Access",3060,15,__node("Ident",3060,15,"Object"),__node("Const",3060,23,"prototype"));}else{parent=__wrap(sup);}return _this.call(child!=null?__node("Access",3065,17,__wrap(parent),__wrap(child)):__wrap(parent),[__node("This",3068,16)].concat(args),false,true);}});};body=fixSupers(this.macroExpandAll(body));function changeDefs(node){return _this.walk(node,function(node){var key,value;if(_this.isDef(node)){key=_this.left(node);value=_this.right(node);return changeDefs(__node("MacroAccess",3077,25,30,3077,{left:__node("Access",3077,25,__wrap(name),__wrap(key)),op:":=",right:__wrap(value)},"expression",false,false));}});};body=changeDefs(body);body=this.walk(body,function(node){if(_this.isFunc(node)){if(!_this.funcIsBound(node)){return node;}}else if(_this.isThis(node)){return name;}});result=__node("MacroAccess",3087,29,102,3087,{macroName:"do",macroData:{locals:{ident:__wrap(sup),value:__wrap(superobject),rest:[]},body:__node("Block",3088,1,[__wrap(init),__wrap(body),__node("MacroAccess",3090,1,39,3090,{macroName:"return",macroData:{node:__wrap(name)}},"statement",false,false)],null)}},"statement",false,false);if(declaration!=null){return __node("MacroAccess",3093,10,38,3093,{macroName:"let",macroData:{declarable:__node("MacroAccess",3093,14,37,3093,__node("MacroAccess",3093,14,31,3093,{ident:__wrap(declaration)},"statement",false,false),"statement",false,false),value:__wrap(result)}},"statement",false,false);}else if(assignment!=null){return __node("MacroAccess",3095,11,30,3095,{left:__wrap(assignment),op:":=",right:__wrap(result)},"expression",false,false);}else{return result;}};}.call(this));',
params: [
["ident", "name", "many", "?", "ident", "SimpleAssignable"],
[
"ident",
"superobject",
"many",
"?",
"sequence",
["const", "extends"],
["this"]
],
["ident", "body", "many", "?", "ident", "Body"]
],
names: "namespace",
id: 139
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var _this,macroData,macroName,node;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData.node;if(!this.inGenerator){this.error("Can only use yield in a generator function");}return this.mutateLast(node||this.noop(),function(n){return _this["yield"](n);},true);};}.call(this));',
params: [["ident", "node", "many", "?", "ident", "Expression"]],
names: "yield",
id: 140
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var err,index,init,item,iterator,length,macroData,macroName,node,received,send;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData.node;if(!this.inGenerator){this.error("Can only use yield* in a generator function");}init=[];if(this.isType(node,"arrayLike")){index=this.tmp("i",false,"number");init.push(__node("MacroAccess",3112,20,38,3112,{macroName:"let",macroData:{declarable:__node("MacroAccess",3112,24,37,3112,__node("MacroAccess",3112,24,31,3112,{ident:__wrap(index)},"statement",false,false),"statement",false,false),value:__node("Const",3112,34,0)}},"statement",false,false));length=this.tmp("len",false,"number");node=this.cache(node,init,"arr",false);init.push(__node("MacroAccess",3115,20,38,3115,{macroName:"let",macroData:{declarable:__node("MacroAccess",3115,24,37,3115,__node("MacroAccess",3115,24,31,3115,{ident:__wrap(length)},"statement",false,false),"statement",false,false),value:__node("Access",3115,34,__wrap(node),__node("Const",3115,41,"length"))}},"statement",false,false));return __node("Block",3117,1,[__node("MacroAccess",3117,1,104,3117,{macroName:"for",macroData:{init:__wrap(init),test:__node("MacroAccess",3117,19,9,3117,{left:__wrap(index),inverted:false,op:"~<",right:__wrap(length)},"statement",false,false),step:__node("MacroAccess",3117,38,101,3117,{left:__wrap(index),op:"+=",right:__node("Const",3117,49,1)},"expression",false,false),body:__node("MacroAccess",3118,1,140,3118,{macroName:"yield",macroData:{node:__node("Access",3118,16,__wrap(node),__wrap(index))}},"statement",false,false)}},"statement",false,false),__node("Const",3119,1,void 0)],null);}else{iterator=this.cache(__node("Call",3121,33,__node("Ident",3121,33,"__iter"),[__wrap(node)],false,false),init,"iter",false);err=this.tmp("e",true);send=this.tmp("send");item=this.tmp("item");received=this.tmp("tmp");return __node("Block",3127,1,[__wrap(init),__node("MacroAccess",3128,1,38,3128,{macroName:"let",macroData:{declarable:__node("MacroAccess",3128,12,37,3128,__node("MacroAccess",3128,12,31,3128,{isMutable:"mutable",ident:__wrap(received)},"statement",false,false),"statement",false,false),value:__node("Const",3128,32,void 0)}},"statement",false,false),__node("MacroAccess",3129,1,38,3129,{macroName:"let",macroData:{declarable:__node("MacroAccess",3129,12,37,3129,__node("MacroAccess",3129,12,31,3129,{isMutable:"mutable",ident:__wrap(send)},"statement",false,false),"statement",false,false),value:__node("Const",3129,28,true)}},"statement",false,false),__node("MacroAccess",3131,1,106,3131,{macroName:"while",macroData:{test:__node("Const",3131,14,true),body:__node("Block",3132,1,[__node("MacroAccess",3132,1,38,3132,{macroName:"let",macroData:{declarable:__node("MacroAccess",3132,14,37,3132,__node("MacroAccess",3132,14,31,3132,{ident:__wrap(item)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",3132,22,16,3132,{macroName:"if",macroData:{test:__wrap(send),body:__node("Call",3132,36,__node("Access",3132,36,__wrap(iterator),__node("Const",3132,47,"send")),[__wrap(received)],false,false),elseIfs:[],elseBody:__node("Call",3132,67,__node("Access",3132,67,__wrap(iterator),__node("Const",3132,78,"throw")),[__wrap(received)],false,false)}},"expression",false,false)}},"statement",false,false),__node("MacroAccess",3133,1,17,3133,{macroName:"if",macroData:{test:__node("Access",3133,13,__wrap(item),__node("Const",3133,20,"done")),body:__node("MacroAccess",3134,1,19,3134,{macroName:"break",macroData:{}},"statement",false,false),elseIfs:[]}},"statement",false,false),__node("MacroAccess",3135,1,117,3135,{macroName:"try",macroData:{tryBody:__node("Block",3136,1,[__node("MacroAccess",3136,1,30,3136,{left:__wrap(received),op:":=",right:__node("MacroAccess",3136,25,140,3136,{macroName:"yield",macroData:{node:__node("Access",3136,31,__wrap(item),__node("Const",3136,38,"value"))}},"expression",false,false)},"statement",false,false),__node("MacroAccess",3137,1,30,3137,{left:__wrap(send),op:":=",right:__node("Const",3137,21,true)},"statement",false,false)],null),typedCatches:[],catchPart:{ident:__wrap(err),body:__node("Block",3139,1,[__node("MacroAccess",3139,1,30,3139,{left:__wrap(received),op:":=",right:__wrap(err)},"statement",false,false),__node("MacroAccess",3140,1,30,3140,{left:__wrap(send),op:":=",right:__node("Const",3140,21,false)},"statement",false,false)],null)}}},"statement",false,false)],null)}},"statement",false,false),__node("MacroAccess",3141,1,117,3141,{macroName:"try",macroData:{tryBody:__node("Call",3142,1,__node("Access",3142,1,__wrap(iterator),__node("Const",3142,21,"close")),[],false,false),typedCatches:[],catchPart:{ident:__wrap(err),body:__node("Const",3144,1,void 0)}}},"statement",false,false),__node("Access",3145,1,__wrap(item),__node("Const",3145,15,"value"))],null);}};}.call(this));',
params: [["ident", "node", "ident", "Expression"]],
names: "yield*",
id: 141
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var macroData,macroName,node,rest;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData.node;rest=macroData.rest;if(rest==null){rest=this.noop();}return __node("Block",3151,1,[__wrap(rest),__node("MacroAccess",3152,1,39,3152,{macroName:"return",macroData:{node:__wrap(node)}},"statement",false,false)],null);};}.call(this));',
params: [
["ident", "node", "ident", "Expression"],
["ident", "rest", "ident", "DedentedBody"]
],
names: "returning",
id: 142
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var label,macroData,macroName,node;macroName=macroFullData.macroName;macroData=macroFullData.macroData;label=macroData.label;node=macroData.node;return this.withLabel(node,label);};}.call(this));',
params: [
["ident", "label", "ident", "Identifier"],
[
"ident",
"node",
"choice",
["ident", "Statement"],
["ident", "Body"]
]
],
names: "label!",
id: 145
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var macroData,macroName,node,sync;macroName=macroFullData.macroName;macroData=macroFullData.macroData;sync=macroData.sync;node=macroData.node;if(this.isFunc(node)&&!this.funcIsGenerator(node)){this.error("promise! must be used with a generator function",node);}if(sync&&this.isFunc(node)){this.error("Use .sync() to retrieve asynchronously",sync);}if(!sync||this.isConst(sync)&&!this.value(sync)){return __node("Call",3708,11,__node("Ident",3708,11,"__promise"),[__wrap(node)],false,false);}else{return __node("Call",3710,11,__node("Ident",3710,11,"__promise"),[__wrap(node),__wrap(sync)],false,false);}};}.call(this));',
params: [
[
"ident",
"sync",
"many",
"?",
"sequence",
["const", "("],
["this", "ident", "Expression"],
["const", ")"]
],
["ident", "node", "ident", "Expression"]
],
names: "promise!",
id: 156
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,func,macroData,macroName,sync;macroName=macroFullData.macroName;macroData=macroFullData.macroData;sync=macroData.sync;body=macroData.body;func=this.rewrap(this.func([],body,true,true,false,null,true),body);if(!sync||this.isConst(sync)&&!this.value(sync)){return __node("Call",3722,11,__node("Ident",3722,11,"__generatorToPromise"),[__node("Call",3722,35,__wrap(func),[],false,false)],false,false);}else{return __node("Call",3724,11,__node("Ident",3724,11,"__generatorToPromise"),[__node("Call",3724,35,__wrap(func),[],false,false),__wrap(sync)],false,false);}};}.call(this));',
params: [
[
"ident",
"sync",
"many",
"?",
"sequence",
["const", "("],
["this", "ident", "Expression"],
["const", ")"]
],
["ident", "body", "ident", "GeneratorBody"]
],
names: "promise!",
id: 157
},
{
code: 'return (function(){"use strict";var __strnum,__typeof;__strnum=function(strnum){var type;type=typeof strnum;if(type==="string"){return strnum;}else if(type==="number"){return String(strnum);}else{throw TypeError("Expected a string or number, got "+__typeof(strnum));}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _ref,array,body,end,inclusive,index,init,length,lengthCalc,macroData,macroName,parallelism,start,step,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;parallelism=macroData.parallelism;value=macroData.value;index=macroData.index;array=macroData.array;body=macroData.body;init=[];value=this.macroExpand1(value);length=null;if(index){length=index.length;index=index.value;}if(parallelism==null){parallelism=__node("Const",3946,25,1);}if(index==null){index=this.tmp("i",true,"number");}if(this.isCall(array)&&this.isIdent(this.callFunc(array))&&this.name(this.callFunc(array))==="__range"&&!this.callIsApply(array)){if(this.isArray(value)||this.isObject(value)){this.error("Cannot assign a number to a complex declarable",value);}value=value.ident;start=(_ref=this.callArgs(array))[0];end=_ref[1];step=_ref[2];inclusive=_ref[3];if(this.isConst(start)){if(typeof this.value(start)!=="number"){this.error("Cannot start with a non-number: "+__strnum(this.value(start)),start);}}else{start=__node("MacroAccess",3959,22,58,3959,{op:"+",node:__wrap(start)},"expression",false,false);}if(this.isConst(end)){if(typeof this.value(end)!=="number"){this.error("Cannot end with a non-number: "+__strnum(this.value(end)),end);}}else if(this.isComplex(end)){end=this.cache(__node("MacroAccess",3965,28,58,3965,{op:"+",node:__wrap(end)},"expression",false,false),init,"end",false);}else{init.push(__node("MacroAccess",3967,23,58,3967,{op:"+",node:__wrap(end)},"expression",false,false));}if(this.isConst(step)){if(typeof this.value(step)!=="number"){this.error("Cannot step with a non-number: "+__strnum(this.value(step)),step);}}else if(this.isComplex(step)){step=this.cache(__node("MacroAccess",3973,29,58,3973,{op:"+",node:__wrap(step)},"expression",false,false),init,"step",false);}else{init.push(__node("MacroAccess",3975,23,58,3975,{op:"+",node:__wrap(step)},"expression",false,false));}body=__node("Block",3978,1,[__node("MacroAccess",3978,1,38,3978,{macroName:"let",macroData:{declarable:__node("MacroAccess",3978,12,37,3978,__node("MacroAccess",3978,12,31,3978,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",3978,21,49,3978,{left:__node("MacroAccess",3978,21,45,3978,{left:__wrap(index),inverted:false,op:"~*",right:__wrap(step)},"expression",false,false),inverted:false,op:"~+",right:__wrap(start)},"expression",false,false)}},"statement",false,false),__wrap(body)],null);lengthCalc=__node("MacroAccess",3981,29,17,3981,{macroName:"if",macroData:{test:__wrap(inclusive),body:__node("MacroAccess",3982,1,45,3982,{left:__node("MacroAccess",3982,10,49,3982,{left:__node("MacroAccess",3982,10,49,3982,{left:__wrap(end),inverted:false,op:"~-",right:__wrap(start)},"expression",false,false),inverted:false,op:"~+",right:__wrap(step)},"expression",false,false),inverted:false,op:"~\\\\",right:__wrap(step)},"statement",false,false),elseIfs:[],elseBody:__node("MacroAccess",3984,1,45,3984,{left:__node("MacroAccess",3984,10,49,3984,{left:__wrap(end),inverted:false,op:"~-",right:__wrap(start)},"expression",false,false),inverted:false,op:"~\\\\",right:__wrap(step)},"statement",false,false)}},"expression",false,false);if(!length){length=lengthCalc;}else{init.push(__node("MacroAccess",3988,22,38,3988,{macroName:"let",macroData:{declarable:__node("MacroAccess",3988,26,37,3988,__node("MacroAccess",3988,26,31,3988,{ident:__wrap(length)},"statement",false,false),"statement",false,false),value:__wrap(lengthCalc)}},"statement",false,false));}}else{array=this.cache(array,init,"arr",true);body=__node("Block",3993,1,[__node("MacroAccess",3993,1,38,3993,{macroName:"let",macroData:{declarable:__node("MacroAccess",3993,12,37,3993,__node("MacroAccess",3993,12,31,3993,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__node("Access",3993,21,__wrap(array),__wrap(index))}},"statement",false,false),__wrap(body)],null);if(!length){length=__node("MacroAccess",3997,23,58,3997,{op:"+",node:__node("Access",3997,25,__wrap(array),__node("Const",3997,32,"length"))},"expression",false,false);}else{init.push(__node("MacroAccess",3999,22,38,3999,{macroName:"let",macroData:{declarable:__node("MacroAccess",3999,26,37,3999,__node("MacroAccess",3999,26,31,3999,{ident:__wrap(length)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",3999,36,58,3999,{op:"+",node:__node("Access",3999,38,__wrap(array),__node("Const",3999,45,"length"))},"expression",false,false)}},"statement",false,false));}}return __node("Block",4002,1,[__wrap(init),__node("Call",4003,1,__node("Ident",4003,1,"__promiseLoop"),[__node("MacroAccess",4003,22,58,4003,{op:"+",node:__wrap(parallelism)},"expression",false,false),__wrap(length),__node("Call",4003,45,__node("Ident",4003,45,"__promise"),[__node("MacroAccess",4003,57,115,4003,{op:"",node:__node("Function",4003,57,[__node("Param",4003,58,__wrap(index),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,true,[])},"expression",false,false)],false,false)],false,false)],null);};}.call(this));',
params: [
["const", "("],
["ident", "parallelism", "ident", "Expression"],
["const", ")"],
["ident", "value", "ident", "Declarable"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["ident", "value", "ident", "Identifier"],
[
"ident",
"length",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
]
],
["const", "in"],
["ident", "array"],
["ident", "body", "ident", "GeneratorBody"]
],
names: "promisefor",
id: 165
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,index,init,key,keys,macroData,macroName,object,own,parallelism,type,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;parallelism=macroData.parallelism;key=macroData.key;value=macroData.value;type=macroData.type;object=macroData.object;body=macroData.body;own=type==="of";init=[];object=this.cache(object,init,"obj",true);index=null;if(value){index=value.index;value=this.macroExpand1(value.value);}if(value){body=__node("Block",4016,1,[__node("MacroAccess",4016,1,38,4016,{macroName:"let",macroData:{declarable:__node("MacroAccess",4016,14,37,4016,__node("MacroAccess",4016,14,31,4016,{ident:__wrap(value)},"statement",false,false),"statement",false,false),value:__node("Access",4016,23,__wrap(object),__wrap(key))}},"statement",false,false),__wrap(body)],null);}keys=this.tmp("keys",true,"stringArray");return __node("Block",4021,1,[__wrap(init),__node("MacroAccess",4022,1,38,4022,{macroName:"let",macroData:{declarable:__node("MacroAccess",4022,12,37,4022,__node("MacroAccess",4022,12,31,4022,{ident:__wrap(keys)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",4022,20,17,4022,{macroName:"if",macroData:{test:__wrap(own),body:__node("Call",4023,1,__node("Ident",4023,1,"__keys"),[__wrap(object)],false,false),elseIfs:[],elseBody:__node("Call",4025,1,__node("Ident",4025,1,"__allkeys"),[__wrap(object)],false,false)}},"expression",false,false)}},"statement",false,false),__node("MacroAccess",4026,1,165,4026,{macroName:"promisefor",macroData:{parallelism:__wrap(parallelism),value:__node("MacroAccess",4026,33,37,4026,__node("MacroAccess",4026,33,31,4026,{ident:__wrap(key)},"statement",false,false),"statement",false,false),index:{value:__wrap(index)},array:__wrap(keys),body:__wrap(body)}},"statement",false,false)],null);};}.call(this));',
params: [
["const", "("],
["ident", "parallelism", "ident", "Expression"],
["const", ")"],
["ident", "key", "ident", "Identifier"],
[
"ident",
"value",
"many",
"?",
"sequence",
["const", ","],
["ident", "value", "ident", "Declarable"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
]
],
[
"ident",
"type",
"choice",
["const", "of"],
["const", "ofall"]
],
["ident", "object"],
["ident", "body", "ident", "GeneratorBody"]
],
names: "promisefor",
id: 166
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,index,iterator,macroData,macroName,parallelism,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;parallelism=macroData.parallelism;value=macroData.value;index=macroData.index;iterator=macroData.iterator;body=macroData.body;if(index==null){index=this.tmp("i",true);}return __node("Call",4033,1,__node("Ident",4033,1,"__promiseIter"),[__node("MacroAccess",4033,22,58,4033,{op:"+",node:__wrap(parallelism)},"expression",false,false),__node("Call",4033,36,__node("Ident",4033,36,"__iter"),[__wrap(iterator)],false,false),__node("Call",4033,55,__node("Ident",4033,55,"__promise"),[__node("MacroAccess",4033,67,115,4033,{op:"",node:__node("Function",4033,67,[__node("Param",4033,68,__wrap(value),void 0,false,false,void 0),__node("Param",4033,75,__wrap(index),void 0,false,false,void 0)],__wrap(body),true,false,false,void 0,true,[])},"expression",false,false)],false,false)],false,false);};}.call(this));',
params: [
["const", "("],
["ident", "parallelism", "ident", "Expression"],
["const", ")"],
["ident", "value", "ident", "Identifier"],
[
"ident",
"index",
"many",
"?",
"sequence",
["const", ","],
["this", "ident", "Identifier"]
],
["const", "from"],
["ident", "iterator"],
["ident", "body", "ident", "GeneratorBody"]
],
names: "promisefor",
id: 167
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;return this["const"](this.line());};}.call(this));',
options: {type: "number"},
params: [["const", ""]],
names: "__LINE__",
id: 168
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;return this["const"](this.column());};}.call(this));',
options: {type: "number"},
params: [["const", ""]],
names: "__COLUMN__",
id: 169
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;return this["const"](this.file());};}.call(this));',
options: {type: "string"},
params: [["const", ""]],
names: "__FILE__",
id: 170
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;return this["const"](new Date().getTime());};}.call(this));',
options: {type: "number"},
params: [["const", ""]],
names: "__DATEMSEC__",
id: 171
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var macroData,macroName;macroName=macroFullData.macroName;macroData=macroFullData.macroData;return this["const"](this.version());};}.call(this));',
options: {type: "string"},
params: [["const", ""]],
names: "__VERSION__",
id: 172
}
],
binaryOperator: [
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.binary(left,"&&",right);};}.call(this));',
operators: "and",
options: {precedence: 1},
id: 1
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.binary(left,"||",right);};}.call(this));',
operators: "or",
options: {precedence: 1},
id: 2
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.binary(left,"===",right);};}.call(this));',
operators: "==",
options: {precedence: 2, maximum: 1, type: "boolean"},
id: 5
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("MacroAccess",43,7,3,43,{op:"not",node:__node("MacroAccess",43,13,5,43,{left:__wrap(left),inverted:false,op:"==",right:__wrap(right)},"expression",false,false)},"expression",false,false);};}.call(this));',
operators: "!=",
options: {precedence: 2, maximum: 1, type: "boolean"},
id: 6
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.binary(left,"==",right);};}.call(this));',
operators: "~=",
options: {precedence: 2, maximum: 1, type: "boolean"},
id: 7
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("MacroAccess",49,7,3,49,{op:"not",node:__node("MacroAccess",49,13,7,49,{left:__wrap(left),inverted:false,op:"~=",right:__wrap(right)},"expression",false,false)},"expression",false,false);};}.call(this));',
operators: "!~=",
options: {precedence: 2, maximum: 1, type: "boolean"},
id: 8
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.binary(left,op==="~<"&&"<"||"<=",right);};}.call(this));',
operators: ["~<", "~<="],
options: {precedence: 2, maximum: 1, type: "boolean"},
id: 9
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return op==="~>"&&__node("MacroAccess",57,23,3,57,{op:"not",node:__node("MacroAccess",57,29,9,57,{left:__wrap(left),inverted:false,op:"~<=",right:__wrap(right)},"expression",false,false)},"expression",false,false)||__node("MacroAccess",57,55,3,57,{op:"not",node:__node("MacroAccess",57,61,9,57,{left:__wrap(left),inverted:false,op:"~<",right:__wrap(right)},"expression",false,false)},"expression",false,false);};}.call(this));',
operators: ["~>", "~>="],
options: {precedence: 2, maximum: 1, type: "boolean"},
id: 10
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(this.hasType(left,"numeric")&&this.hasType(right,"numeric")){return this.binary(this.binary(this["const"](""),"+",left),"+",right);}else if(this.isConst(left)&&this.value(left)===""&&this.isType(right,"string")){return right;}else if(this.isConst(right)&&this.value(right)===""&&this.isType(left,"string")){return left;}else{return this.binary(left,"+",right);}};}.call(this));',
operators: "~&",
options: {precedence: 7, type: "string"},
id: 29
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(op==="~\\\\"){return __node("Call",312,9,__node("Access",312,9,__node("Ident",312,9,"Math"),__node("Const",312,15,"floor")),[__wrap(this.binary(left,"/",right))],false,false);}else if(op==="~*"){return this.binary(left,"*",right);}else if(op==="~/"){return this.binary(left,"/",right);}else{return this.binary(left,"%",right);}};}.call(this));',
operators: ["~*", "~/", "~%", "~\\"],
options: {precedence: 11, type: "number"},
id: 45
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(op==="~+"){if(!this.isType(right,"numeric")){return this.binary(left,"-",__node("MacroAccess",357,30,48,357,{op:"~-",node:__wrap(right)},"expression",false,false));}else{if(!this.isType(left,"numeric")){left=__node("MacroAccess",360,21,48,360,{op:"~+",node:__wrap(left)},"expression",false,false);}return this.binary(left,"+",right);}}else{return this.binary(left,"-",right);}};}.call(this));',
operators: ["~+", "~-"],
options: {precedence: 10, type: "number"},
id: 49
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right,value;left=macroData.left;op=macroData.op;right=macroData.right;if(this.isConst(right)){value=this.value(right);if(value===0){return __node("Block",370,1,[__wrap(left),__node("Const",371,9,1)],null);}else if(value===0.5){return __node("Call",373,18,__node("Access",373,18,__node("Ident",373,18,"Math"),__node("Const",373,24,"sqrt")),[__wrap(left)],false,false);}else if(value===1){return __node("MacroAccess",375,18,48,375,{op:"~+",node:__wrap(left)},"expression",false,false);}else if(value===2){return this.maybeCache(left,function(setLeft,left){return __node("MacroAccess",378,13,45,378,{left:__wrap(setLeft),inverted:false,op:"~*",right:__wrap(left)},"expression",false,false);});}else if(value===3){return this.maybeCache(left,function(setLeft,left){return __node("MacroAccess",381,13,45,381,{left:__node("MacroAccess",381,13,45,381,{left:__wrap(setLeft),inverted:false,op:"~*",right:__wrap(left)},"expression",false,false),inverted:false,op:"~*",right:__wrap(left)},"expression",false,false);});}else if(value===-0.5){return __node("MacroAccess",383,18,45,383,{left:__node("Const",383,19,1),inverted:false,op:"~/",right:__node("Call",383,23,__node("Access",383,23,__node("Ident",383,23,"Math"),__node("Const",383,29,"sqrt")),[__wrap(left)],false,false)},"expression",false,false);}else if(value===-1){return __node("MacroAccess",385,18,45,385,{left:__node("Const",385,19,1),inverted:false,op:"~/",right:__wrap(left)},"expression",false,false);}else if(value===-2){return this.maybeCache(left,function(setLeft,left){return __node("MacroAccess",388,13,45,388,{left:__node("Const",388,14,1),inverted:false,op:"~/",right:__node("MacroAccess",388,20,45,388,{left:__wrap(setLeft),inverted:false,op:"~*",right:__wrap(left)},"expression",false,false)},"expression",false,false);});}else if(value===-3){return this.maybeCache(left,function(setLeft,left){return __node("MacroAccess",391,13,45,391,{left:__node("Const",391,14,1),inverted:false,op:"~/",right:__node("MacroAccess",391,20,45,391,{left:__node("MacroAccess",391,20,45,391,{left:__wrap(setLeft),inverted:false,op:"~*",right:__wrap(left)},"expression",false,false),inverted:false,op:"~*",right:__wrap(left)},"expression",false,false)},"expression",false,false);});}}return __node("Call",392,7,__node("Access",392,7,__node("Ident",392,7,"Math"),__node("Const",392,13,"pow")),[__wrap(left),__wrap(right)],false,false);};}.call(this));',
operators: "~^",
options: {precedence: 12, rightToLeft: true, type: "number"},
id: 50
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(op==="~bitlshift"){return this.binary(left,"<<",right);}else if(op==="~bitrshift"){return this.binary(left,">>",right);}else{return this.binary(left,">>>",right);}};}.call(this));',
operators: ["~bitlshift", "~bitrshift", "~biturshift"],
options: {precedence: 9, maximum: 1, type: "number"},
id: 54
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("MacroAccess",525,7,50,525,{left:__node("MacroAccess",525,7,58,525,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~^",right:__node("MacroAccess",525,17,58,525,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);};}.call(this));',
operators: "^",
options: {precedence: 12, rightToLeft: true, type: "number"},
id: 60
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(op==="*"){return __node("MacroAccess",533,9,45,533,{left:__node("MacroAccess",533,9,58,533,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~*",right:__node("MacroAccess",533,19,58,533,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="/"){return __node("MacroAccess",535,9,45,535,{left:__node("MacroAccess",535,9,58,535,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~/",right:__node("MacroAccess",535,19,58,535,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="%"){return __node("MacroAccess",537,9,45,537,{left:__node("MacroAccess",537,9,58,537,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~%",right:__node("MacroAccess",537,19,58,537,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else{return __node("MacroAccess",539,9,45,539,{left:__node("MacroAccess",539,9,58,539,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~\\\\",right:__node("MacroAccess",539,19,58,539,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}};}.call(this));',
operators: ["*", "/", "%", "\\"],
options: {precedence: 11, type: "number"},
id: 62
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(op==="+"){return __node("MacroAccess",546,9,49,546,{left:__node("MacroAccess",546,9,58,546,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~+",right:__node("MacroAccess",546,19,58,546,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else{return __node("MacroAccess",548,9,49,548,{left:__node("MacroAccess",548,9,58,548,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~-",right:__node("MacroAccess",548,19,58,548,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}};}.call(this));',
operators: ["+", "-"],
options: {precedence: 10, type: "number"},
id: 64
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(op==="bitlshift"){return __node("MacroAccess",552,9,54,552,{left:__node("MacroAccess",552,9,58,552,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~bitlshift",right:__node("MacroAccess",552,27,58,552,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="bitrshift"){return __node("MacroAccess",554,9,54,554,{left:__node("MacroAccess",554,9,58,554,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~bitrshift",right:__node("MacroAccess",554,27,58,554,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else{return __node("MacroAccess",556,9,54,556,{left:__node("MacroAccess",556,9,58,556,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~biturshift",right:__node("MacroAccess",556,28,58,556,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}};}.call(this));',
operators: ["bitlshift", "bitrshift", "biturshift"],
options: {precedence: 9, maximum: 1, type: "number"},
id: 65
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(!this.isType(left,"stringOrNumber")){left=!this.hasType(left,"number")?__node("Call",565,11,__node("Ident",565,11,"__str"),[__wrap(left)],false,false):__node("Call",567,11,__node("Ident",567,11,"__strnum"),[__wrap(left)],false,false);}if(!this.isType(right,"stringOrNumber")){right=!this.hasType(right,"number")?__node("Call",570,11,__node("Ident",570,11,"__str"),[__wrap(right)],false,false):__node("Call",572,11,__node("Ident",572,11,"__strnum"),[__wrap(right)],false,false);}return __node("MacroAccess",573,7,29,573,{left:__wrap(left),inverted:false,op:"~&",right:__wrap(right)},"expression",false,false);};}.call(this));',
operators: "&",
options: {precedence: 7, type: "string", label: "stringConcat"},
id: 67
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var elements,f,left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(this.isArray(right)){elements=this.elements(right);if(elements.length===0){if(this.isComplex(left)){return __node("Block",588,1,[__wrap(left),__node("Const",589,1,false)],null);}else{return __node("Const",591,13,false);}}else if(elements.length===1){return __node("MacroAccess",593,11,5,593,{left:__wrap(left),inverted:false,op:"==",right:__wrap(elements[0])},"expression",false,false);}else{f=function(i,current,left){if(i<elements.length){return f(+i+1,__node("MacroAccess",597,25,2,597,{left:__wrap(current),inverted:false,op:"or",right:__node("MacroAccess",597,37,5,597,{left:__wrap(left),inverted:false,op:"==",right:__wrap(elements[i])},"expression",false,false)},"expression",false,false),left);}else{return current;}};return this.maybeCache(left,function(setLeft,left){return f(1,__node("MacroAccess",601,18,5,601,{left:__wrap(setLeft),inverted:false,op:"==",right:__wrap(elements[0])},"expression",false,false),left);});}}else{return __node("Call",603,9,__node("Ident",603,9,"__in"),[__wrap(left),__wrap(right)],false,false);}};}.call(this));',
operators: "in",
options: {precedence: 6, maximum: 1, invertible: true, type: "boolean"},
id: 69
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.binary(right,"in",left);};}.call(this));',
operators: "haskey",
options: {precedence: 6, maximum: 1, invertible: true, type: "boolean"},
id: 70
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("Call",611,7,__node("Ident",611,7,"__owns"),[__wrap(left),__wrap(right)],false,true);};}.call(this));',
operators: "ownskey",
options: {precedence: 6, maximum: 1, invertible: true, type: "boolean", label: "ownership"},
id: 71
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(this.isIdent(right)){if(this.name(right)==="String"){return __node("MacroAccess",616,18,23,616,{op:"isString!",node:__wrap(left)},"expression",false,false);}else if(this.name(right)==="Number"){return __node("MacroAccess",618,18,24,618,{op:"isNumber!",node:__wrap(left)},"expression",false,false);}else if(this.name(right)==="Boolean"){return __node("MacroAccess",620,18,25,620,{op:"isBoolean!",node:__wrap(left)},"expression",false,false);}else if(this.name(right)==="Function"){return __node("MacroAccess",622,18,26,622,{op:"isFunction!",node:__wrap(left)},"expression",false,false);}else if(this.name(right)==="Array"){return __node("MacroAccess",624,18,27,624,{op:"isArray!",node:__wrap(left)},"expression",false,false);}else if(this.name(right)==="Object"){return __node("MacroAccess",626,18,28,626,{op:"isObject!",node:__wrap(left)},"expression",false,false);}}return this.binary(left,"instanceof",right);};}.call(this));',
operators: "instanceof",
options: {precedence: 6, maximum: 1, invertible: true, type: "boolean"},
id: 72
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("Call",644,7,__node("Ident",644,7,"__cmp"),[__wrap(left),__wrap(right)],false,false);};}.call(this));',
operators: "<=>",
options: {precedence: 5, maximum: 1, type: "number"},
id: 73
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("MacroAccess",647,7,5,647,{left:__node("MacroAccess",647,7,62,647,{left:__wrap(left),inverted:false,op:"%",right:__wrap(right)},"expression",false,false),inverted:false,op:"==",right:__node("Const",647,26,0)},"expression",false,false);};}.call(this));',
operators: "%%",
options: {precedence: 2, maximum: 1, invertible: true, type: "boolean"},
id: 74
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("MacroAccess",650,7,5,650,{left:__node("MacroAccess",650,7,45,650,{left:__wrap(left),inverted:false,op:"~%",right:__wrap(right)},"expression",false,false),inverted:false,op:"==",right:__node("Const",650,27,0)},"expression",false,false);};}.call(this));',
operators: "~%%",
options: {precedence: 2, maximum: 1, invertible: true, type: "boolean"},
id: 75
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(this.isType(left,"number")){if(this.isType(right,"number")){if(op==="<"){return __node("MacroAccess",688,13,9,688,{left:__wrap(left),inverted:false,op:"~<",right:__wrap(right)},"expression",false,false);}else{return __node("MacroAccess",690,13,9,690,{left:__wrap(left),inverted:false,op:"~<=",right:__wrap(right)},"expression",false,false);}}else if(op==="<"){return __node("MacroAccess",693,13,9,693,{left:__wrap(left),inverted:false,op:"~<",right:__node("Call",693,22,__node("Ident",693,22,"__num"),[__wrap(right)],false,false)},"expression",false,false);}else{return __node("MacroAccess",695,13,9,695,{left:__wrap(left),inverted:false,op:"~<=",right:__node("Call",695,23,__node("Ident",695,23,"__num"),[__wrap(right)],false,false)},"expression",false,false);}}else if(this.isType(left,"string")){if(this.isType(right,"string")){if(op==="<"){return __node("MacroAccess",699,13,9,699,{left:__wrap(left),inverted:false,op:"~<",right:__wrap(right)},"expression",false,false);}else{return __node("MacroAccess",701,13,9,701,{left:__wrap(left),inverted:false,op:"~<=",right:__wrap(right)},"expression",false,false);}}else if(op==="<"){return __node("MacroAccess",704,13,9,704,{left:__wrap(left),inverted:false,op:"~<",right:__node("Call",704,22,__node("Ident",704,22,"__str"),[__wrap(right)],false,false)},"expression",false,false);}else{return __node("MacroAccess",706,13,9,706,{left:__wrap(left),inverted:false,op:"~<=",right:__node("Call",706,23,__node("Ident",706,23,"__str"),[__wrap(right)],false,false)},"expression",false,false);}}else if(this.isType(right,"number")){if(op==="<"){return __node("MacroAccess",709,11,9,709,{left:__node("Call",709,11,__node("Ident",709,11,"__num"),[__wrap(left)],false,false),inverted:false,op:"~<",right:__wrap(right)},"expression",false,false);}else{return __node("MacroAccess",711,11,9,711,{left:__node("Call",711,11,__node("Ident",711,11,"__num"),[__wrap(left)],false,false),inverted:false,op:"~<=",right:__wrap(right)},"expression",false,false);}}else if(this.isType(right,"string")){if(op==="<"){return __node("MacroAccess",714,11,9,714,{left:__node("Call",714,11,__node("Ident",714,11,"__str"),[__wrap(left)],false,false),inverted:false,op:"~<",right:__wrap(right)},"expression",false,false);}else{return __node("MacroAccess",716,11,9,716,{left:__node("Call",716,11,__node("Ident",716,11,"__str"),[__wrap(left)],false,false),inverted:false,op:"~<=",right:__wrap(right)},"expression",false,false);}}else if(op==="<"){return __node("Call",718,9,__node("Ident",718,9,"__lt"),[__wrap(left),__wrap(right)],false,false);}else{return __node("Call",720,9,__node("Ident",720,9,"__lte"),[__wrap(left),__wrap(right)],false,false);}};}.call(this));',
operators: ["<", "<="],
options: {precedence: 2, maximum: 1, type: "boolean"},
id: 76
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(op===">"){return __node("MacroAccess",724,9,3,724,{op:"not",node:__node("MacroAccess",724,15,76,724,{left:__wrap(left),inverted:false,op:"<=",right:__wrap(right)},"expression",false,false)},"expression",false,false);}else{return __node("MacroAccess",726,9,3,726,{op:"not",node:__node("MacroAccess",726,15,76,726,{left:__wrap(left),inverted:false,op:"<",right:__wrap(right)},"expression",false,false)},"expression",false,false);}};}.call(this));',
operators: [">", ">="],
options: {precedence: 2, maximum: 1, type: "boolean"},
id: 77
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCache(left,function(setLeft,left){return _this.maybeCache(right,function(setRight,right){return __node("MacroAccess",731,11,16,731,{macroName:"if",macroData:{test:__node("MacroAccess",731,14,9,731,{left:__wrap(setLeft),inverted:false,op:"~<",right:__wrap(setRight)},"expression",false,false),body:__wrap(left),elseIfs:[],elseBody:__wrap(right)}},"expression",false,false);});});};}.call(this));',
operators: "~min",
options: {precedence: 8},
id: 78
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCache(left,function(setLeft,left){return _this.maybeCache(right,function(setRight,right){return __node("MacroAccess",736,11,16,736,{macroName:"if",macroData:{test:__node("MacroAccess",736,14,10,736,{left:__wrap(setLeft),inverted:false,op:"~>",right:__wrap(setRight)},"expression",false,false),body:__wrap(left),elseIfs:[],elseBody:__wrap(right)}},"expression",false,false);});});};}.call(this));',
operators: "~max",
options: {precedence: 8},
id: 79
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCache(left,function(setLeft,left){return _this.maybeCache(right,function(setRight,right){return __node("MacroAccess",741,11,16,741,{macroName:"if",macroData:{test:__node("MacroAccess",741,14,76,741,{left:__wrap(setLeft),inverted:false,op:"<",right:__wrap(setRight)},"expression",false,false),body:__wrap(left),elseIfs:[],elseBody:__wrap(right)}},"expression",false,false);});});};}.call(this));',
operators: "min",
options: {precedence: 8},
id: 80
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCache(left,function(setLeft,left){return _this.maybeCache(right,function(setRight,right){return __node("MacroAccess",746,11,16,746,{macroName:"if",macroData:{test:__node("MacroAccess",746,14,77,746,{left:__wrap(setLeft),inverted:false,op:">",right:__wrap(setRight)},"expression",false,false),body:__wrap(left),elseIfs:[],elseBody:__wrap(right)}},"expression",false,false);});});};}.call(this));',
operators: "max",
options: {precedence: 8},
id: 81
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("Call",749,7,__node("Ident",749,7,"__xor"),[__wrap(left),__wrap(right)],false,false);};}.call(this));',
operators: "xor",
options: {precedence: 1},
id: 82
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCache(left,function(setLeft,left){return __node("MacroAccess",753,9,16,753,{macroName:"if",macroData:{test:__node("MacroAccess",753,12,20,753,{op:"?",node:__wrap(setLeft)},"expression",false,false),body:__wrap(left),elseIfs:[],elseBody:__wrap(right)}},"expression",false,false);});};}.call(this));',
operators: "?",
options: {precedence: 1},
id: 83
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.binary(left,"&",right);};}.call(this));',
operators: "~bitand",
options: {precedence: 1, type: "number"},
id: 90
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.binary(left,"|",right);};}.call(this));',
operators: "~bitor",
options: {precedence: 1, type: "number"},
id: 91
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.binary(left,"^",right);};}.call(this));',
operators: "~bitxor",
options: {precedence: 1, type: "number"},
id: 92
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("MacroAccess",821,7,90,821,{left:__node("MacroAccess",821,7,58,821,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~bitand",right:__node("MacroAccess",821,22,58,821,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);};}.call(this));',
operators: "bitand",
options: {precedence: 1, type: "number"},
id: 94
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("MacroAccess",824,7,91,824,{left:__node("MacroAccess",824,7,58,824,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~bitor",right:__node("MacroAccess",824,21,58,824,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);};}.call(this));',
operators: "bitor",
options: {precedence: 1, type: "number"},
id: 95
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("MacroAccess",827,7,92,827,{left:__node("MacroAccess",827,7,58,827,{op:"+",node:__wrap(left)},"expression",false,false),inverted:false,op:"~bitxor",right:__node("MacroAccess",827,22,58,827,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);};}.call(this));',
operators: "bitxor",
options: {precedence: 1, type: "number"},
id: 96
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("Call",1085,7,__node("Ident",1085,7,"__range"),[__wrap(left),__wrap(right),__node("Const",1085,31,1),__node("Const",1085,33,true)],false,false);};}.call(this));',
operators: "to",
options: {maximum: 1, precedence: 4, type: "array"},
id: 108
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("Call",1088,7,__node("Ident",1088,7,"__range"),[__wrap(left),__wrap(right),__node("Const",1088,31,1),__node("Const",1088,33,false)],false,false);};}.call(this));',
operators: "til",
options: {maximum: 1, precedence: 4, type: "array"},
id: 109
},
{
code: 'return (function(){"use strict";var __num,__typeof;__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroData,__wrap,__node){var callArgs,left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(!this.hasType(right,"number")){this.error("Must provide a number to the \'by\' operator",right);}if(this.isConst(right)&&this.value(right)===0){this.error("\'by\' step must be non-zero",right);}if(this.isCall(left)&&this.isIdent(this.callFunc(left))&&this.name(this.callFunc(left))==="__range"&&!this.callIsApply(left)){callArgs=this.callArgs(left);return __node("Call",1097,9,__node("Ident",1097,9,"__range"),[__wrap(callArgs[0]),__wrap(callArgs[1]),__wrap(right),__wrap(callArgs[3])],false,false);}else{if(this.isConst(right)&&__num(this.value(right))%1!==0){this.error("\'by\' step must be an integer",right);}return __node("Call",1101,9,__node("Ident",1101,9,"__step"),[__wrap(left),__wrap(right)],false,false);}};}.call(this));',
operators: "by",
options: {maximum: 1, precedence: 3, type: "array"},
id: 110
},
{
code: 'return (function(){"use strict";var __lt,__num,__typeof;__lt=function(x,y){var type;type=typeof x;if(type!=="number"&&type!=="string"){throw TypeError("Cannot compare a non-number/string: "+type);}else if(type!==typeof y){throw TypeError("Cannot compare elements of different types: "+type+" vs "+typeof y);}else{return x<y;}};__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroData,__wrap,__node){var element,elements,f,left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;if(this.isArray(right)){elements=this.elements(right);if(elements.length===0){if(this.isComplex(left)){return __node("Block",1965,1,[__wrap(left),__node("Const",1966,1,false)],null);}else{return __node("Const",1968,13,false);}}else if(elements.length===1){element=elements[0];return __node("MacroAccess",1971,11,72,1971,{left:__wrap(left),inverted:false,op:"instanceof",right:__wrap(element)},"expression",false,false);}else{f=function(i,current,left){var element;if(__lt(i,elements.length)){element=elements[i];return f(__num(i)+1,__node("MacroAccess",1976,24,2,1976,{left:__wrap(current),inverted:false,op:"or",right:__node("MacroAccess",1976,36,72,1976,{left:__wrap(left),inverted:false,op:"instanceof",right:__wrap(element)},"expression",false,false)},"expression",false,false),left);}else{return current;}};return this.maybeCache(left,function(setLeft,left){var element;element=elements[0];return f(1,__node("MacroAccess",1981,18,72,1981,{left:__wrap(setLeft),inverted:false,op:"instanceof",right:__wrap(element)},"expression",false,false),left);});}}else{return __node("Call",1983,9,__node("Ident",1983,9,"__instanceofsome"),[__wrap(left),__wrap(right)],false,false);}};}.call(this));',
operators: "instanceofsome",
options: {precedence: 6, maximum: 1, invertible: true, type: "boolean"},
id: 116
},
{
code: 'return (function(){"use strict";var __is,__num,__typeof;__is=typeof Object.is==="function"?Object.is:function(x,y){if(x===y){return x!==0||1/x===1/y;}else{return x!==x&&y!==y;}};__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroData,__wrap,__node){var _this,left,op,result,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;if(this.hasType(left,"number")&&this.hasType(right,"number")){if(this.isConst(left)){if(this.isConst(right)){result=__is(this.value(left),this.value(right));return __wrap(result);}else if(typeof this.value(left)==="number"&&isNaN(this.value(left))){return this.maybeCache(right,function(setRight,right){return __node("MacroAccess",3172,17,6,3172,{left:__wrap(setRight),inverted:false,op:"!=",right:__wrap(right)},"expression",false,false);});}else if(this.value(left)===0){return this.maybeCache(right,function(setRight,right){if(1/__num(_this.value(left))<0){return __node("MacroAccess",3176,19,1,3176,{left:__node("MacroAccess",3176,19,5,3176,{left:__wrap(setRight),inverted:false,op:"==",right:__node("Const",3176,34,0)},"expression",false,false),inverted:false,op:"and",right:__node("MacroAccess",3176,39,76,3176,{left:__node("MacroAccess",3176,39,45,3176,{left:__node("Const",3176,40,1),inverted:false,op:"~/",right:__wrap(right)},"expression",false,false),inverted:false,op:"<",right:__node("Const",3176,54,0)},"expression",false,false)},"expression",false,false);}else{return __node("MacroAccess",3178,19,1,3178,{left:__node("MacroAccess",3178,19,5,3178,{left:__wrap(setRight),inverted:false,op:"==",right:__node("Const",3178,34,0)},"expression",false,false),inverted:false,op:"and",right:__node("MacroAccess",3178,39,77,3178,{left:__node("MacroAccess",3178,39,45,3178,{left:__node("Const",3178,40,1),inverted:false,op:"~/",right:__wrap(right)},"expression",false,false),inverted:false,op:">",right:__node("Const",3178,54,0)},"expression",false,false)},"expression",false,false);}});}else{return __node("MacroAccess",3180,15,5,3180,{left:__wrap(left),inverted:false,op:"==",right:__wrap(right)},"expression",false,false);}}else if(this.isConst(right)){if(typeof this.value(right)==="number"&&isNaN(this.value(right))){return this.maybeCache(left,function(setLeft,left){return __node("MacroAccess",3184,15,6,3184,{left:__wrap(setLeft),inverted:false,op:"!=",right:__wrap(left)},"expression",false,false);});}else if(this.value(right)===0){return this.maybeCache(left,function(setLeft,left){if(1/__num(_this.value(right))<0){return __node("MacroAccess",3188,17,1,3188,{left:__node("MacroAccess",3188,17,5,3188,{left:__wrap(setLeft),inverted:false,op:"==",right:__node("Const",3188,31,0)},"expression",false,false),inverted:false,op:"and",right:__node("MacroAccess",3188,36,76,3188,{left:__node("MacroAccess",3188,36,45,3188,{left:__node("Const",3188,37,1),inverted:false,op:"~/",right:__wrap(left)},"expression",false,false),inverted:false,op:"<",right:__node("Const",3188,50,0)},"expression",false,false)},"expression",false,false);}else{return __node("MacroAccess",3190,17,1,3190,{left:__node("MacroAccess",3190,17,5,3190,{left:__wrap(setLeft),inverted:false,op:"==",right:__node("Const",3190,31,0)},"expression",false,false),inverted:false,op:"and",right:__node("MacroAccess",3190,36,77,3190,{left:__node("MacroAccess",3190,36,45,3190,{left:__node("Const",3190,37,1),inverted:false,op:"~/",right:__wrap(left)},"expression",false,false),inverted:false,op:">",right:__node("Const",3190,50,0)},"expression",false,false)},"expression",false,false);}});}else{return __node("MacroAccess",3192,13,5,3192,{left:__wrap(left),inverted:false,op:"==",right:__wrap(right)},"expression",false,false);}}else{return __node("Call",3194,11,__node("Ident",3194,11,"__is"),[__wrap(left),__wrap(right)],false,false);}}else{return __node("MacroAccess",3196,9,5,3196,{left:__wrap(left),inverted:false,op:"==",right:__wrap(right)},"expression",false,false);}};}.call(this));',
operators: "is",
options: {precedence: 2, maximum: 1, type: "boolean"},
id: 143
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("MacroAccess",3199,7,3,3199,{op:"not",node:__node("MacroAccess",3199,13,143,3199,{left:__wrap(left),inverted:false,op:"is",right:__wrap(right)},"expression",false,false)},"expression",false,false);};}.call(this));',
operators: "isnt",
options: {precedence: 2, maximum: 1, type: "boolean"},
id: 144
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("Call",3258,7,__node("Ident",3258,7,"__compose"),[__wrap(left),__wrap(right)],false,false);};}.call(this));',
operators: "<<",
options: {precedence: 13, type: "function"},
id: 146
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right,tmp;left=macroData.left;op=macroData.op;right=macroData.right;if(!this.isNoop(left)&&!this.isNoop(right)){tmp=this.tmp("ref");return __node("Block",3264,1,[__node("MacroAccess",3264,1,38,3264,{macroName:"let",macroData:{declarable:__node("MacroAccess",3264,10,37,3264,__node("MacroAccess",3264,10,31,3264,{ident:__wrap(tmp)},"statement",false,false),"statement",false,false),value:__wrap(left)}},"statement",false,false),__node("Call",3265,1,__node("Ident",3265,1,"__compose"),[__wrap(right),__wrap(tmp)],false,false)],null);}else{return __node("Call",3267,9,__node("Ident",3267,9,"__compose"),[__wrap(right),__wrap(left)],false,false);}};}.call(this));',
operators: ">>",
options: {precedence: 13, type: "function", rightToLeft: true},
id: 147
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return __node("Call",3286,7,__wrap(left),[__wrap(right)],false,false);};}.call(this));',
operators: "<|",
options: {precedence: 0, rightToLeft: true},
id: 148
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right,tmp;left=macroData.left;op=macroData.op;right=macroData.right;if(!this.isNoop(left)&&!this.isNoop(right)){tmp=this.tmp("ref");return __node("Block",3292,1,[__node("MacroAccess",3292,1,38,3292,{macroName:"let",macroData:{declarable:__node("MacroAccess",3292,10,37,3292,__node("MacroAccess",3292,10,31,3292,{ident:__wrap(tmp)},"statement",false,false),"statement",false,false),value:__wrap(left)}},"statement",false,false),__node("Call",3293,1,__wrap(right),[__wrap(tmp)],false,false)],null);}else{return __node("Call",3295,9,__wrap(right),[__wrap(left)],false,false);}};}.call(this));',
operators: "|>",
options: {precedence: 0},
id: 149
},
{
code: 'return (function(){"use strict";var __isArray,__slice,__strnum,__toArray,__typeof;__isArray=typeof Array.isArray==="function"?Array.isArray:(function(){var _toString;_toString=Object.prototype.toString;return function(x){return _toString.call(x)==="[object Array]";};}());__slice=Array.prototype.slice;__strnum=function(strnum){var type;type=typeof strnum;if(type==="string"){return strnum;}else if(type==="number"){return String(strnum);}else{throw TypeError("Expected a string or number, got "+__typeof(strnum));}};__toArray=function(x){if(x==null){throw TypeError("Expected an object, got "+__typeof(x));}else if(__isArray(x)){return x;}else if(typeof x==="string"){return x.split("");}else{return __slice.call(x);}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;if(this.isObject(right)){return this.maybeCache(left,function(setLeft,nextLeft){var _arr,_ref,block,currentLeft,descriptor,i,key,len,pairs,property,value;currentLeft=setLeft;block=[];pairs=_this.pairs(right);for(_arr=__toArray(pairs), i=0, len=_arr.length;i<len;++i){key=(_ref=_arr[i]).key;value=_ref.value;property=_ref.property;if(property!=null){if((property==="get"||property==="set")&&i<len-1&&pairs[i+1].property!=null&&_this.eq(key,pairs[i+1].key)&&pairs[i+1].property!==property&&((_ref=pairs[i+1].property)==="get"||_ref==="set")){continue;}if(property==="property"){block.push(__node("Call",3314,27,__node("Ident",3314,27,"__defProp"),[__wrap(currentLeft),__wrap(key),__wrap(value)],false,false));}else if(property==="get"||property==="set"){if(i>0&&pairs[i-1].property!=null&&_this.eq(key,pairs[i-1].key)&&pairs[i-1].property!==property&&((_ref=pairs[i-1].property)==="get"||_ref==="set")){descriptor=__node("Object",3317,19,[{key:__wrap(pairs[i-1].property),value:__wrap(pairs[i-1].value),property:void 0},{key:__wrap(property),value:__wrap(value),property:void 0},{key:__node("Const",3320,17,"enumerable"),value:__node("Const",3320,28,true),property:void 0},{key:__node("Const",3321,17,"configurable"),value:__node("Const",3321,30,true),property:void 0}],void 0);}else{descriptor=__node("Object",3324,19,[{key:__wrap(property),value:__wrap(value),property:void 0},{key:__node("Const",3326,17,"enumerable"),value:__node("Const",3326,28,true),property:void 0},{key:__node("Const",3327,17,"configurable"),value:__node("Const",3327,30,true),property:void 0}],void 0);}block.push(__node("Call",3329,27,__node("Ident",3329,27,"__defProp"),[__wrap(currentLeft),__wrap(key),__wrap(descriptor)],false,false));}else{_this.error("Unknown property: "+__strnum(property),key);}}else{block.push(__node("MacroAccess",3333,25,30,3333,{left:__node("Access",3333,25,__wrap(currentLeft),__wrap(key)),op:":=",right:__wrap(value)},"statement",false,false));}currentLeft=nextLeft;}block.push(__wrap(currentLeft));return __wrap(block);});}else{return __node("Call",3338,9,__node("Ident",3338,9,"__import"),[__wrap(left),__wrap(right)],false,false);}};}.call(this));',
operators: "<<<",
options: {precedence: 6},
id: 150
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right,tmp;left=macroData.left;op=macroData.op;right=macroData.right;if(!this.isNoop(left)&&!this.isNoop(right)){tmp=this.tmp("ref");return __node("Block",3344,1,[__node("MacroAccess",3344,1,38,3344,{macroName:"let",macroData:{declarable:__node("MacroAccess",3344,10,37,3344,__node("MacroAccess",3344,10,31,3344,{ident:__wrap(tmp)},"statement",false,false),"statement",false,false),value:__wrap(left)}},"statement",false,false),__node("MacroAccess",3345,1,150,3345,{left:__wrap(right),inverted:false,op:"<<<",right:__wrap(tmp)},"statement",false,false)],null);}else{return __node("MacroAccess",3347,9,150,3347,{left:__wrap(right),inverted:false,op:"<<<",right:__wrap(left)},"expression",false,false);}};}.call(this));',
operators: ">>>",
options: {precedence: 6, rightToLeft: true},
id: 151
}
],
unaryOperator: [
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,node,op;_this=this;op=macroData.op;node=macroData.node;return this.mutateLast(node||this.noop(),function(n){return _this.unary("!",n);},true);};}.call(this));',
operators: "not",
options: {type: "boolean"},
id: 3
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,node,op;_this=this;op=macroData.op;node=macroData.node;return this.mutateLast(node||this.noop(),function(n){return _this.unary("typeof",n);},true);};}.call(this));',
operators: "typeof",
options: {type: "string"},
id: 4
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,node,op;_this=this;op=macroData.op;node=macroData.node;return this.mutateLast(node||this.noop(),function(n){return _this["throw"](n);},true);};}.call(this));',
operators: "throw",
options: {type: "none"},
id: 11
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return this.unary("++post",node);};}.call(this));',
operators: "postInc!",
options: {type: "number"},
id: 12
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return this.unary("--post",node);};}.call(this));',
operators: "postDec!",
options: {type: "number"},
id: 13
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;if(this.isIdentOrTmp(node)&&!this.hasVariable(node)){return __node("MacroAccess",111,9,1,111,{left:__node("MacroAccess",111,9,6,111,{left:__node("MacroAccess",111,9,4,111,{op:"typeof",node:__wrap(node)},"expression",false,false),inverted:false,op:"!=",right:__node("Const",111,27,"undefined")},"expression",false,false),inverted:false,op:"and",right:__node("MacroAccess",111,40,6,111,{left:__wrap(node),inverted:false,op:"!=",right:__node("Const",111,49,null)},"expression",false,false)},"expression",false,false);}else{return __node("MacroAccess",113,9,8,113,{left:__wrap(node),inverted:false,op:"!~=",right:__node("Const",113,19,null)},"expression",false,false);}};}.call(this));',
operators: "?",
options: {postfix: true, type: "boolean", label: "existential"},
id: 20
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;if(this.isIdentOrTmp(node)&&!this.hasVariable(node)){return __node("MacroAccess",117,9,5,117,{left:__node("MacroAccess",117,9,4,117,{op:"typeof",node:__wrap(node)},"expression",false,false),inverted:false,op:"==",right:__node("Const",117,27,"undefined")},"expression",false,false);}else{return __node("MacroAccess",119,9,5,119,{left:__wrap(node),inverted:false,op:"==",right:__node("Const",119,18,void 0)},"expression",false,false);}};}.call(this));',
operators: ["isVoid!", "isUndefined!"],
options: {type: "boolean"},
id: 21
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;if(this.isIdentOrTmp(node)&&!this.hasVariable(node)){return __node("MacroAccess",123,9,1,123,{left:__node("MacroAccess",123,9,6,123,{left:__node("MacroAccess",123,9,4,123,{op:"typeof",node:__wrap(node)},"expression",false,false),inverted:false,op:"!=",right:__node("Const",123,27,"undefined")},"expression",false,false),inverted:false,op:"and",right:__node("MacroAccess",123,40,5,123,{left:__wrap(node),inverted:false,op:"==",right:__node("Const",123,49,null)},"expression",false,false)},"expression",false,false);}else{return __node("MacroAccess",125,9,5,125,{left:__wrap(node),inverted:false,op:"==",right:__node("Const",125,18,null)},"expression",false,false);}};}.call(this));',
operators: "isNull!",
options: {type: "boolean"},
id: 22
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return __node("MacroAccess",128,7,5,128,{left:__node("MacroAccess",128,7,4,128,{op:"typeof",node:__wrap(node)},"expression",false,false),inverted:false,op:"==",right:__node("Const",128,25,"string")},"expression",false,false);};}.call(this));',
operators: "isString!",
options: {type: "boolean"},
id: 23
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return __node("MacroAccess",131,7,5,131,{left:__node("MacroAccess",131,7,4,131,{op:"typeof",node:__wrap(node)},"expression",false,false),inverted:false,op:"==",right:__node("Const",131,25,"number")},"expression",false,false);};}.call(this));',
operators: "isNumber!",
options: {type: "boolean"},
id: 24
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return __node("MacroAccess",134,7,5,134,{left:__node("MacroAccess",134,7,4,134,{op:"typeof",node:__wrap(node)},"expression",false,false),inverted:false,op:"==",right:__node("Const",134,25,"boolean")},"expression",false,false);};}.call(this));',
operators: "isBoolean!",
options: {type: "boolean"},
id: 25
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return __node("MacroAccess",137,7,5,137,{left:__node("MacroAccess",137,7,4,137,{op:"typeof",node:__wrap(node)},"expression",false,false),inverted:false,op:"==",right:__node("Const",137,25,"function")},"expression",false,false);};}.call(this));',
operators: "isFunction!",
options: {type: "boolean"},
id: 26
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,node,op;_this=this;op=macroData.op;node=macroData.node;return this.mutateLast(node||this.noop(),function(n){return _this.isIdentOrTmp(n)&&!_this.hasVariable(n)&&__node("MacroAccess",140,97,1,140,{left:__node("MacroAccess",140,97,5,140,{left:__node("MacroAccess",140,97,4,140,{op:"typeof",node:__wrap(n)},"expression",false,false),inverted:false,op:"==",right:__node("Const",140,112,"object")},"expression",false,false),inverted:false,op:"and",right:__node("Call",140,122,__node("Ident",140,122,"__isArray"),[__wrap(n)],false,false)},"expression",false,false)||__node("Call",140,146,__node("Ident",140,146,"__isArray"),[__wrap(n)],false,false);},true);};}.call(this));',
operators: "isArray!",
options: {type: "boolean"},
id: 27
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,node,op;_this=this;op=macroData.op;node=macroData.node;return this.mutateLast(node||this.noop(),function(n){return __node("MacroAccess",143,47,1,143,{left:__node("MacroAccess",143,47,5,143,{left:__node("MacroAccess",143,47,4,143,{op:"typeof",node:__wrap(n)},"expression",false,false),inverted:false,op:"==",right:__node("Const",143,62,"object")},"expression",false,false),inverted:false,op:"and",right:__node("MacroAccess",143,72,6,143,{left:__wrap(n),inverted:false,op:"!=",right:__node("Const",143,78,null)},"expression",false,false)},"expression",false,false);},true);};}.call(this));',
operators: "isObject!",
options: {type: "boolean"},
id: 28
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,negate,node,op,value;_this=this;op=macroData.op;node=macroData.node;if(this.isConst(node)){value=Number(this.value(node));if(op==="~-"){negate=function(x){return -x;};value=negate(value);}return this["const"](value);}else{return this.mutateLast(node||this.noop(),function(n){return _this.unary(op==="~+"?"+":"-",n);},true);}};}.call(this));',
operators: ["~+", "~-"],
options: {type: "number"},
id: 48
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,node,op;_this=this;op=macroData.op;node=macroData.node;if(this.isIdentOrTmp(node)&&!this.hasVariable(node)){return __node("MacroAccess",484,9,16,484,{macroName:"if",macroData:{test:__node("MacroAccess",484,12,5,484,{left:__node("MacroAccess",484,12,4,484,{op:"typeof",node:__wrap(node)},"expression",false,false),inverted:false,op:"==",right:__node("Const",484,30,"undefined")},"expression",false,false),body:__node("Const",484,45,"Undefined"),elseIfs:[],elseBody:__node("Call",484,61,__node("Ident",484,61,"__typeof"),[__wrap(node)],false,false)}},"expression",false,false);}else{return this.mutateLast(node||this.noop(),function(n){return __node("Call",486,49,__node("Ident",486,49,"__typeof"),[__wrap(n)],false,false);},true);}};}.call(this));',
operators: "typeof!",
options: {type: "string"},
id: 57
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,node,op;_this=this;op=macroData.op;node=macroData.node;return this.mutateLast(node||this.noop(),function(n){if(_this.isType(n,"number")){return n;}else{return __node("Call",516,11,__node("Ident",516,11,"__num"),[__wrap(n)],false,false);}},true);};}.call(this));',
operators: "+",
options: {type: "number"},
id: 58
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;if(this.isConst(node)&&typeof this.value(node)==="number"){return this["const"](-this.value(node));}else{return __node("MacroAccess",522,9,48,522,{op:"~-",node:__node("MacroAccess",522,13,58,522,{op:"+",node:__wrap(node)},"expression",false,false)},"expression",false,false);}};}.call(this));',
operators: "-",
options: {type: "number"},
id: 59
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return __node("MacroAccess",542,7,62,542,{left:__wrap(node),inverted:false,op:"/",right:__node("Const",542,16,100)},"expression",false,false);};}.call(this));',
operators: "%",
options: {postfix: true, type: "number"},
id: 63
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,node,op;_this=this;op=macroData.op;node=macroData.node;return this.mutateLast(node||this.noop(),function(n){return _this.unary("~",n);},true);};}.call(this));',
operators: "~bitnot",
options: {type: "number"},
id: 97
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return __node("MacroAccess",833,7,97,833,{op:"~bitnot",node:__node("MacroAccess",833,15,58,833,{op:"+",node:__wrap(node)},"expression",false,false)},"expression",false,false);};}.call(this));',
operators: "bitnot",
options: {type: "number"},
id: 98
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,node,op;_this=this;op=macroData.op;node=macroData.node;if(!this.isAccess(node)){this.error("Can only use delete on an access");}if(this.position==="expression"){return this.maybeCacheAccess(node,function(setNode,node){var del,tmp;tmp=_this.tmp("ref");del=_this.unary("delete",node);return __node("Block",843,1,[__node("MacroAccess",843,1,38,843,{macroName:"let",macroData:{declarable:__node("MacroAccess",843,12,37,843,__node("MacroAccess",843,12,31,843,{ident:__wrap(tmp)},"statement",false,false),"statement",false,false),value:__wrap(setNode)}},"statement",false,false),__wrap(del),__wrap(tmp)],null);});}else{return this.unary("delete",node);}};}.call(this));',
operators: "delete",
options: {standalone: false},
id: 99
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return this.maybeCache(node,function(setNode,node){return __node("MacroAccess",851,9,16,851,{macroName:"if",macroData:{test:__node("MacroAccess",851,12,20,851,{op:"?",node:__wrap(setNode)},"expression",false,false),body:__node("MacroAccess",851,28,11,851,{op:"throw",node:__wrap(node)},"expression",false,false),elseIfs:[]}},"expression",false,false);});};}.call(this));',
operators: "throw?",
options: {type: "undefined"},
id: 100
},
{
code: 'return (function(){"use strict";var __isArray,__num,__owns,__slice,__strnum,__toArray,__typeof,__xor;__isArray=typeof Array.isArray==="function"?Array.isArray:(function(){var _toString;_toString=Object.prototype.toString;return function(x){return _toString.call(x)==="[object Array]";};}());__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__owns=Object.prototype.hasOwnProperty;__slice=Array.prototype.slice;__strnum=function(strnum){var type;type=typeof strnum;if(type==="string"){return strnum;}else if(type==="number"){return String(strnum);}else{throw TypeError("Expected a string or number, got "+__typeof(strnum));}};__toArray=function(x){if(x==null){throw TypeError("Expected an object, got "+__typeof(x));}else if(__isArray(x)){return x;}else if(typeof x==="string"){return x.split("");}else{return __slice.call(x);}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());__xor=function(x,y){if(x){return !y&&x;}else{return y||x;}};return function(macroData,__wrap,__node){var _arr,_arr2,_i,_len,_this,body,changed,foundSpread,genericArg,genericArgs,genericCache,genericParams,i,ident,init,initIndex,instanceofLets,instanceofs,item,key,len,makeFunctionFunc,makeFunctionIdent,name,node,op,p,param,params,PRIMORDIAL_TYPES,result,spreadCounter;_this=this;op=macroData.op;node=macroData.node;function article(text){if(/^[aeiou]/i.test(text)){return "an";}else{return "a";}};function withArticle(text){return article(text)+" "+__strnum(text);};PRIMORDIAL_TYPES={Number:true,String:true,Boolean:true,Function:true,Array:true,Object:true};function translateGenericType(type){var _ref,basetype,typeArguments;if(!_this.isTypeGeneric(type)){return type;}else{basetype=_this.basetype(type);if((_ref=_this.name(basetype))==="Array"||_ref==="Function"){return basetype;}else{typeArguments=_this.array((function(){var _arr,_arr2,_i,_len,subtype;for(_arr=[], _arr2=__toArray(_this.typeArguments(type)), _i=0, _len=_arr2.length;_i<_len;++_i){subtype=_arr2[_i];_arr.push(translateGenericType(subtype));}return _arr;}()));return __node("Call",1634,13,__node("Access",1634,13,__wrap(basetype),__node("Const",1634,24,"generic")),[__node("Spread",1634,32,__wrap(typeArguments))],false,false);}}};function translateTypeCheck(value,valueName,type,hasDefaultValue){var _arr,_arr2,_i,_len,_ref,check,checks,current,genericType,hasBoolean,hasNull,hasVoid,index,key,name,names,pairValue,result,subCheck,t,test,tests,typeNames;if(_this.isIdent(type)){if(__owns.call(PRIMORDIAL_TYPES,_this.name(type))){result=__node("MacroAccess",1639,1,17,1639,{macroName:"if",macroData:{test:__node("MacroAccess",1639,13,72,1639,{left:__wrap(value),inverted:true,op:"instanceof",right:__wrap(type)},"statement",false,false),body:__node("MacroAccess",1640,1,11,1640,{op:"throw",node:__node("Call",1640,18,__node("Ident",1640,18,"TypeError"),[__node("MacroAccess",1640,29,67,1640,{left:__node("MacroAccess",1640,29,67,1640,{left:__node("MacroAccess",1640,29,67,1640,{left:__node("MacroAccess",1640,29,67,1640,{left:__node("MacroAccess",1640,29,67,1640,{left:__node("Const",1640,29,"Expected "),op:"",right:__wrap(valueName)},"expression",false,false),op:"",right:__node("Const",1640,29," to be ")},"expression",false,false),op:"",right:__wrap(withArticle(_this.name(type)))},"expression",false,false),op:"",right:__node("Const",1640,29,", got ")},"expression",false,false),op:"",right:__node("MacroAccess",1640,98,57,1640,{op:"typeof!",node:__wrap(value)},"expression",false,false)},"expression",false,false)],false,false)},"statement",false,false),elseIfs:[]}},"statement",false,false);}else{result=__node("MacroAccess",1643,1,17,1643,{macroName:"if",macroData:{test:__node("MacroAccess",1643,13,72,1643,{left:__wrap(value),inverted:true,op:"instanceof",right:__wrap(type)},"statement",false,false),body:__node("MacroAccess",1644,1,11,1644,{op:"throw",node:__node("Call",1644,18,__node("Ident",1644,18,"TypeError"),[__node("MacroAccess",1644,29,67,1644,{left:__node("MacroAccess",1644,29,67,1644,{left:__node("MacroAccess",1644,29,67,1644,{left:__node("MacroAccess",1644,29,67,1644,{left:__node("MacroAccess",1644,29,67,1644,{left:__node("Const",1644,29,"Expected "),op:"",right:__wrap(valueName)},"expression",false,false),op:"",right:__node("Const",1644,29," to be a ")},"expression",false,false),op:"",right:__node("Call",1644,64,__node("Ident",1644,64,"__name"),[__wrap(type)],false,false)},"expression",false,false),op:"",right:__node("Const",1644,29,", got ")},"expression",false,false),op:"",right:__node("MacroAccess",1644,85,57,1644,{op:"typeof!",node:__wrap(value)},"expression",false,false)},"expression",false,false)],false,false)},"statement",false,false),elseIfs:[]}},"statement",false,false);}if(!hasDefaultValue&&_this.name(type)==="Boolean"){return __node("MacroAccess",1646,13,17,1646,{macroName:"if",macroData:{test:__node("MacroAccess",1646,16,3,1646,{op:"not",node:__node("MacroAccess",1646,20,20,1646,{op:"?",node:__wrap(value)},"statement",false,true)},"statement",false,true),body:__node("MacroAccess",1647,1,30,1647,{left:__wrap(value),op:":=",right:__node("Const",1647,20,false)},"statement",false,true),elseIfs:[],elseBody:__wrap(result)}},"statement",false,true);}else{return result;}}else if(_this.isAccess(type)){return __node("MacroAccess",1654,1,17,1654,{macroName:"if",macroData:{test:__node("MacroAccess",1654,11,72,1654,{left:__wrap(value),inverted:true,op:"instanceof",right:__wrap(type)},"statement",false,false),body:__node("MacroAccess",1655,1,11,1655,{op:"throw",node:__node("Call",1655,16,__node("Ident",1655,16,"TypeError"),[__node("MacroAccess",1655,27,67,1655,{left:__node("MacroAccess",1655,27,67,1655,{left:__node("MacroAccess",1655,27,67,1655,{left:__node("MacroAccess",1655,27,67,1655,{left:__node("MacroAccess",1655,27,67,1655,{left:__node("Const",1655,27,"Expected "),op:"",right:__wrap(valueName)},"expression",false,false),op:"",right:__node("Const",1655,27," to be ")},"expression",false,false),op:"",right:__wrap(withArticle(_this.value(_this.child(type))))},"expression",false,false),op:"",right:__node("Const",1655,27,", got ")},"expression",false,false),op:"",right:__node("MacroAccess",1655,105,57,1655,{op:"typeof!",node:__wrap(value)},"expression",false,false)},"expression",false,false)],false,false)},"statement",false,false),elseIfs:[]}},"statement",false,false);}else if(_this.isTypeUnion(type)){hasBoolean=false;hasVoid=false;hasNull=false;names=[];tests=[];for(_arr=__toArray(_this.types(type)), _i=0, _len=_arr.length;_i<_len;++_i){t=_arr[_i];if(_this.isConst(t)){if(_this.value(t)===null){hasNull=true;names.push(_this["const"]("null"));}else if(_this.value(t)===void 0){hasVoid=true;names.push(_this["const"]("undefined"));}else{_this.error("Unknown const for type-checking: "+String(_this.value(t)),t);}}else if(_this.isIdent(t)){if(_this.name(t)==="Boolean"){hasBoolean=true;}if(__owns.call(PRIMORDIAL_TYPES,_this.name(t))){names.push(_this["const"](_this.name(t)));}else{names.push(__node("Call",1679,28,__node("Ident",1679,28,"__name"),[__wrap(t)],false,false));}tests.push(__node("MacroAccess",1680,26,72,1680,{left:__wrap(value),inverted:true,op:"instanceof",right:__wrap(t)},"expression",false,false));}else{_this.error("Not implemented: typechecking for non-idents/consts within a type-union",t);}}if(tests.length){test=_this.binaryChain("&&",tests);}else{test=__node("Const",1687,13,true);}current=names[0];for(_i=1, _len=names.length;_i<_len;++_i){name=names[_i];current=__node("MacroAccess",1689,14,67,1689,{left:__node("MacroAccess",1689,14,67,1689,{left:__wrap(current),op:"",right:__node("Const",1689,14," or ")},"expression",false,false),op:"",right:__wrap(name)},"expression",false,false);}typeNames=current;result=__node("MacroAccess",1690,31,17,1690,{macroName:"if",macroData:{test:__wrap(test),body:__node("MacroAccess",1691,1,11,1691,{op:"throw",node:__node("Call",1691,14,__node("Ident",1691,14,"TypeError"),[__node("MacroAccess",1691,25,67,1691,{left:__node("MacroAccess",1691,25,67,1691,{left:__node("MacroAccess",1691,25,67,1691,{left:__node("MacroAccess",1691,25,67,1691,{left:__node("MacroAccess",1691,25,67,1691,{left:__node("Const",1691,25,"Expected "),op:"",right:__wrap(valueName)},"expression",false,false),op:"",right:__node("Const",1691,25," to be one of ")},"expression",false,false),op:"",right:__wrap(typeNames)},"expression",false,false),op:"",right:__node("Const",1691,25,", got ")},"expression",false,false),op:"",right:__node("MacroAccess",1691,85,57,1691,{op:"typeof!",node:__wrap(value)},"expression",false,false)},"expression",false,false)],false,false)},"statement",false,false),elseIfs:[]}},"statement",false,false);if(!hasDefaultValue){if(hasNull||hasVoid){if(__xor(hasNull,hasVoid)){result=__node("MacroAccess",1696,27,17,1696,{macroName:"if",macroData:{test:__node("MacroAccess",1696,30,3,1696,{op:"not",node:__node("MacroAccess",1696,34,20,1696,{op:"?",node:__wrap(value)},"statement",false,true)},"statement",false,true),body:__node("MacroAccess",1697,1,30,1697,{left:__wrap(value),op:":=",right:__node("MacroAccess",1697,24,16,1697,{macroName:"if",macroData:{test:__wrap(hasNull),body:__node("Const",1697,42,null),elseIfs:[],elseBody:__node("Const",1697,52,void 0)}},"expression",false,true)},"statement",false,true),elseIfs:[],elseBody:__wrap(result)}},"statement",false,true);}else{result=__node("MacroAccess",1701,26,17,1701,{macroName:"if",macroData:{test:__node("MacroAccess",1701,29,20,1701,{op:"?",node:__wrap(value)},"statement",false,false),body:__wrap(result),elseIfs:[]}},"statement",false,false);}}else if(hasBoolean){result=__node("MacroAccess",1704,25,17,1704,{macroName:"if",macroData:{test:__node("MacroAccess",1704,28,3,1704,{op:"not",node:__node("MacroAccess",1704,32,20,1704,{op:"?",node:__wrap(value)},"statement",false,true)},"statement",false,true),body:__node("MacroAccess",1705,1,30,1705,{left:__wrap(value),op:":=",right:__node("Const",1705,22,false)},"statement",false,true),elseIfs:[],elseBody:__wrap(result)}},"statement",false,true);}}return result;}else if(_this.isTypeGeneric(type)){if(_this.name(_this.basetype(type))==="Array"){index=_this.tmp("i",false,"number");subCheck=translateTypeCheck(__node("Access",1712,51,__wrap(value),__wrap(index)),__node("MacroAccess",1712,74,67,1712,{left:__node("MacroAccess",1712,74,67,1712,{left:__node("MacroAccess",1712,74,67,1712,{left:__wrap(valueName),inverted:false,op:"&",right:__node("Const",1712,89,"[")},"expression",false,false),inverted:false,op:"&",right:__wrap(index)},"expression",false,false),inverted:false,op:"&",right:__node("Const",1712,104,"]")},"expression",false,false),_this.typeArguments(type)[0],false);return __node("MacroAccess",1713,12,17,1713,{macroName:"if",macroData:{test:__node("MacroAccess",1713,15,3,1713,{op:"not",node:__node("MacroAccess",1713,19,27,1713,{op:"isArray!",node:__wrap(value)},"statement",false,false)},"statement",false,false),body:__node("MacroAccess",1714,1,11,1714,{op:"throw",node:__node("Call",1714,16,__node("Ident",1714,16,"TypeError"),[__node("MacroAccess",1714,27,67,1714,{left:__node("MacroAccess",1714,27,67,1714,{left:__node("MacroAccess",1714,27,67,1714,{left:__node("Const",1714,27,"Expected "),op:"",right:__wrap(valueName)},"expression",false,false),op:"",right:__node("Const",1714,27," to be an Array, got ")},"expression",false,false),op:"",right:__node("MacroAccess",1714,74,57,1714,{op:"typeof!",node:__wrap(value)},"expression",false,false)},"expression",false,false)],false,false)},"statement",false,false),elseIfs:[],elseBody:__node("MacroAccess",1716,1,104,1716,{macroName:"for",macroData:{init:__node("MacroAccess",1716,16,38,1716,{macroName:"let",macroData:{declarable:__node("MacroAccess",1716,19,37,1716,__node("MacroAccess",1716,19,31,1716,{isMutable:"mutable",ident:__wrap(index)},"expression",false,false),"expression",false,false),value:__node("Access",1716,36,__wrap(value),__node("Const",1716,44,"length"))}},"expression",false,false),test:__node("MacroAccess",1716,52,13,1716,{op:"postDec!",node:__wrap(index)},"statement",false,false),body:__wrap(subCheck)}},"statement",false,false)}},"statement",false,false);}else if(_this.name(_this.basetype(type))==="Function"){return translateTypeCheck(value,valueName,_this.basetype(type),hasDefaultValue);}else{genericType=translateGenericType(type);return __node("MacroAccess",1723,1,17,1723,{macroName:"if",macroData:{test:__node("MacroAccess",1723,13,72,1723,{left:__wrap(value),inverted:true,op:"instanceof",right:__wrap(genericType)},"statement",false,false),body:__node("MacroAccess",1724,1,11,1724,{op:"throw",node:__node("Call",1724,18,__node("Ident",1724,18,"TypeError"),[__node("MacroAccess",1724,29,67,1724,{left:__node("MacroAccess",1724,29,67,1724,{left:__node("MacroAccess",1724,29,67,1724,{left:__node("MacroAccess",1724,29,67,1724,{left:__node("MacroAccess",1724,29,67,1724,{left:__node("Const",1724,29,"Expected "),op:"",right:__wrap(valueName)},"expression",false,false),op:"",right:__node("Const",1724,29," to be a ")},"expression",false,false),op:"",right:__node("Call",1724,64,__node("Ident",1724,64,"__name"),[__wrap(genericType)],false,false)},"expression",false,false),op:"",right:__node("Const",1724,29,", got ")},"expression",false,false),op:"",right:__node("MacroAccess",1724,93,57,1724,{op:"typeof!",node:__wrap(value)},"expression",false,false)},"expression",false,false)],false,false)},"statement",false,false),elseIfs:[]}},"statement",false,false);}}else if(_this.isTypeObject(type)){for(_arr=[], _arr2=__toArray(_this.pairs(type)), _i=0, _len=_arr2.length;_i<_len;++_i){key=(_ref=_arr2[_i]).key;pairValue=_ref.value;_arr.push(translateTypeCheck(__node("Access",1727,35,__wrap(value),__wrap(key)),__node("MacroAccess",1727,56,67,1727,{left:__node("MacroAccess",1727,56,67,1727,{left:__wrap(valueName),inverted:false,op:"&",right:__node("Const",1727,71,".")},"expression",false,false),inverted:false,op:"&",right:__wrap(key)},"expression",false,false),pairValue,false));}checks=_arr;return __node("MacroAccess",1728,10,17,1728,{macroName:"if",macroData:{test:__node("MacroAccess",1728,13,3,1728,{op:"not",node:__node("MacroAccess",1728,17,28,1728,{op:"isObject!",node:__wrap(value)},"statement",false,false)},"statement",false,false),body:__node("MacroAccess",1729,1,11,1729,{op:"throw",node:__node("Call",1729,14,__node("Ident",1729,14,"TypeError"),[__node("MacroAccess",1729,25,67,1729,{left:__node("MacroAccess",1729,25,67,1729,{left:__node("MacroAccess",1729,25,67,1729,{left:__node("Const",1729,25,"Expected "),op:"",right:__wrap(valueName)},"expression",false,false),op:"",right:__node("Const",1729,25," to be an Object, got ")},"expression",false,false),op:"",right:__node("MacroAccess",1729,73,57,1729,{op:"typeof!",node:__wrap(value)},"expression",false,false)},"expression",false,false)],false,false)},"statement",false,false),elseIfs:[],elseBody:__wrap(checks)}},"statement",false,false);}else{return _this.error("Unknown type to translate: "+__typeof(type),type);}};init=[];changed=false;function translateParam(param,inDestructure){var _arr,_i,_len,arrayIdent,asType,blankIdent,defaultValue,element,elementIdent,elementParam,foundSpread,i,ident,initIndex,key,len,objectIdent,pair,paramIdent,spreadCounter,typeCheck,value,valueIdent;if(_this.isArray(param)){changed=true;arrayIdent=_this.tmp("p",false,"array");foundSpread=-1;for(_arr=__toArray(_this.elements(param)), i=0, len=_arr.length;i<len;++i){element=_arr[i];initIndex=init.length;elementParam=translateParam(element,true);if(elementParam!=null){elementIdent=_this.paramIdent(elementParam);if(!_this.paramIsSpread(elementParam)){if(foundSpread===-1){init.splice(initIndex,0,__node("MacroAccess",1749,45,38,1749,{macroName:"let",macroData:{declarable:__node("MacroAccess",1749,49,37,1749,__node("MacroAccess",1749,49,31,1749,{ident:__wrap(elementIdent)},"statement",false,false),"statement",false,false),value:__node("Access",1749,66,__wrap(arrayIdent),__wrap(i))}},"statement",false,false));}else{init.splice(initIndex,0,__node("MacroAccess",1751,45,38,1751,{macroName:"let",macroData:{declarable:__node("MacroAccess",1751,49,37,1751,__node("MacroAccess",1751,49,31,1751,{ident:__wrap(elementIdent)},"statement",false,false),"statement",false,false),value:__node("Access",1751,66,__wrap(arrayIdent),__node("MacroAccess",1751,80,64,1751,{left:__wrap(spreadCounter),inverted:false,op:"+",right:__node("MacroAccess",1751,99,64,1751,{left:__node("MacroAccess",1751,99,64,1751,{left:__wrap(i),inverted:false,op:"-",right:__wrap(foundSpread)},"expression",false,false),inverted:false,op:"-",right:__node("Const",1751,120,1)},"expression",false,false)},"expression",false,false))}},"statement",false,false));}}else{if(foundSpread!==-1){_this.error("Cannot have multiple spread parameters in an array destructure",element);}foundSpread=i;if(i===len-1){init.splice(initIndex,0,__node("MacroAccess",1757,45,38,1757,{macroName:"let",macroData:{declarable:__node("MacroAccess",1757,49,37,1757,__node("MacroAccess",1757,49,31,1757,{ident:__wrap(elementIdent)},"statement",false,false),"statement",false,false),value:__node("Call",1757,66,__node("Ident",1757,66,"__slice"),[__wrap(arrayIdent),__node("Spread",1757,89,__node("MacroAccess",1757,94,16,1757,{macroName:"if",macroData:{test:__node("MacroAccess",1757,96,5,1757,{left:__wrap(i),inverted:false,op:"==",right:__node("Const",1757,103,0)},"expression",false,false),body:__node("Array",1757,109,[]),elseIfs:[],elseBody:__node("Array",1757,117,[__wrap(i)])}},"expression",false,false))],false,true)}},"statement",false,false));}else{spreadCounter=_this.tmp("i",false,"number");init.splice(initIndex,0,__node("Block",1761,1,[__node("MacroAccess",1761,1,38,1761,{macroName:"let",macroData:{declarable:__node("MacroAccess",1761,20,37,1761,__node("MacroAccess",1761,20,31,1761,{isMutable:"mutable",ident:__wrap(spreadCounter)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1761,46,64,1761,{left:__node("Access",1761,46,__wrap(arrayIdent),__node("Const",1761,60,"length")),inverted:false,op:"-",right:__node("MacroAccess",1761,70,64,1761,{left:__node("MacroAccess",1761,70,64,1761,{left:__wrap(len),inverted:false,op:"-",right:__wrap(i)},"expression",false,false),inverted:false,op:"-",right:__node("Const",1761,82,1)},"expression",false,false)},"expression",false,false)}},"statement",false,false),__node("MacroAccess",1762,1,38,1762,{macroName:"let",macroData:{declarable:__node("MacroAccess",1762,20,37,1762,__node("MacroAccess",1762,20,31,1762,{ident:__wrap(elementIdent)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1762,37,17,1762,{macroName:"if",macroData:{test:__node("MacroAccess",1762,40,77,1762,{left:__wrap(spreadCounter),inverted:false,op:">",right:__wrap(i)},"expression",false,false),body:__node("Call",1763,1,__node("Ident",1763,1,"__slice"),[__wrap(arrayIdent),__wrap(i),__wrap(spreadCounter)],false,true),elseIfs:[],elseBody:__node("Block",1765,1,[__node("MacroAccess",1765,1,30,1765,{left:__wrap(spreadCounter),op:":=",right:__wrap(i)},"statement",false,false),__node("Array",1766,1,[])],null)}},"expression",false,false)}},"statement",false,false)],null));}}}}return _this.rewrap(_this.param(arrayIdent,null,false,false,null),param);}else if(_this.isObject(param)){changed=true;objectIdent=_this.tmp("p",false,"object");for(_arr=__toArray(_this.pairs(param)), _i=0, _len=_arr.length;_i<_len;++_i){pair=_arr[_i];initIndex=init.length;value=translateParam(pair.value,true);if(value!=null){valueIdent=_this.paramIdent(value);key=pair.key;init.splice(initIndex,0,__node("MacroAccess",1778,41,38,1778,{macroName:"let",macroData:{declarable:__node("MacroAccess",1778,45,37,1778,__node("MacroAccess",1778,45,31,1778,{ident:__wrap(valueIdent)},"statement",false,false),"statement",false,false),value:__node("Access",1778,60,__wrap(objectIdent),__wrap(key))}},"statement",false,false));}}return _this.rewrap(_this.param(objectIdent,null,false,false,null),param);}else if(_this.isParam(param)){defaultValue=_this.paramDefaultValue(param);asType=_this.paramType(param);paramIdent=_this.paramIdent(param);if(defaultValue!=null||asType!=null||!_this.isIdentOrTmp(paramIdent)){changed=true;if(_this.isIdentOrTmp(paramIdent)){ident=paramIdent;}else if(_this.isAccess(paramIdent)){ident=_this.ident(_this.value(_this.child(paramIdent)));}else{ident=_this.error("Not an ident or this-access: "+__typeof(paramIdent)+" "+__strnum(paramIdent.inspect()),paramIdent);}if(asType!=null){typeCheck=translateTypeCheck(ident,_this.name(ident),asType,defaultValue!=null);}else{typeCheck=_this.noop();}init.push(defaultValue!=null?__node("MacroAccess",1799,1,17,1799,{macroName:"if",macroData:{test:__node("MacroAccess",1799,15,3,1799,{op:"not",node:__node("MacroAccess",1799,19,20,1799,{op:"?",node:__wrap(ident)},"statement",false,true)},"statement",false,true),body:__node("MacroAccess",1800,1,30,1800,{left:__wrap(ident),op:":=",right:__wrap(defaultValue)},"statement",false,true),elseIfs:[],elseBody:__wrap(typeCheck)}},"statement",false,true):typeCheck);if(paramIdent!==ident){init.push(__node("MacroAccess",1806,24,30,1806,{left:__wrap(paramIdent),op:":=",right:__wrap(ident)},"statement",false,false));}return _this.rewrap(_this.param(ident,null,_this.paramIsSpread(param),_this.paramIsMutable(param),null),param);}else{return param;}}else if(_this.isNothing(param)){changed=true;if(inDestructure){return null;}else{blankIdent=_this.tmp("p",false,"object");return _this.rewrap(_this.param(blankIdent,null,false,false,null),param);}}else{return _this.error("Unknown param type: "+__typeof(param),param);}};foundSpread=-1;params=[];for(_arr=__toArray(this.funcParams(node)), i=0, len=_arr.length;i<len;++i){param=_arr[i];initIndex=init.length;p=translateParam(param,false);ident=this.paramIdent(p);if(this.paramIsSpread(p)){if(foundSpread!==-1){this.error("Cannot have two spread parameters",p);}changed=true;foundSpread=i;if(i===len-1){init.splice(initIndex,0,__node("MacroAccess",1834,1,38,1834,{macroName:"let",macroData:{declarable:__node("MacroAccess",1834,14,37,1834,__node("MacroAccess",1834,14,31,1834,{ident:__wrap(ident)},"statement",false,false),"statement",false,false),value:__node("Call",1834,23,__node("Ident",1834,23,"__slice"),[__node("Args",1834,33),__node("Spread",1834,43,__node("MacroAccess",1834,48,16,1834,{macroName:"if",macroData:{test:__node("MacroAccess",1834,50,5,1834,{left:__wrap(i),inverted:false,op:"==",right:__node("Const",1834,57,0)},"expression",false,false),body:__node("Array",1834,63,[]),elseIfs:[],elseBody:__node("Array",1834,71,[__wrap(i)])}},"expression",false,false))],false,true)}},"statement",false,false));}else{spreadCounter=this.tmp("i",false,"number");init.splice(initIndex,0,__node("Block",1838,1,[__node("MacroAccess",1838,1,38,1838,{macroName:"let",macroData:{declarable:__node("MacroAccess",1838,14,37,1838,__node("MacroAccess",1838,14,31,1838,{isMutable:"mutable",ident:__wrap(spreadCounter)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1838,40,64,1838,{left:__node("Access",1838,40,__node("Args",1838,40),__node("Const",1838,51,"length")),inverted:false,op:"-",right:__node("MacroAccess",1838,61,64,1838,{left:__node("MacroAccess",1838,61,64,1838,{left:__wrap(len),inverted:false,op:"-",right:__wrap(i)},"expression",false,false),inverted:false,op:"-",right:__node("Const",1838,73,1)},"expression",false,false)},"expression",false,false)}},"statement",false,false),__node("MacroAccess",1839,1,38,1839,{macroName:"let",macroData:{declarable:__node("MacroAccess",1839,14,37,1839,__node("MacroAccess",1839,14,31,1839,{ident:__wrap(ident)},"statement",false,false),"statement",false,false),value:__node("MacroAccess",1839,23,17,1839,{macroName:"if",macroData:{test:__node("MacroAccess",1839,26,77,1839,{left:__wrap(spreadCounter),inverted:false,op:">",right:__wrap(i)},"expression",false,false),body:__node("Call",1840,1,__node("Ident",1840,1,"__slice"),[__node("Args",1840,22),__wrap(i),__wrap(spreadCounter)],false,true),elseIfs:[],elseBody:__node("Block",1842,1,[__node("MacroAccess",1842,1,30,1842,{left:__wrap(spreadCounter),op:":=",right:__wrap(i)},"statement",false,false),__node("Array",1843,1,[])],null)}},"expression",false,false)}},"statement",false,false)],null));}}else if(foundSpread===-1){params.push(p);}else{init.splice(initIndex,0,__node("MacroAccess",1849,1,38,1849,{macroName:"let",macroData:{declarable:__node("MacroAccess",1849,14,37,1849,__node("MacroAccess",1849,14,31,1849,{ident:__wrap(ident)},"statement",false,false),"statement",false,false),value:__node("Access",1849,23,__node("Args",1849,23),__node("MacroAccess",1849,34,64,1849,{left:__wrap(spreadCounter),inverted:false,op:"+",right:__node("MacroAccess",1849,53,64,1849,{left:__node("MacroAccess",1849,53,64,1849,{left:__wrap(i),inverted:false,op:"-",right:__wrap(foundSpread)},"expression",false,false),inverted:false,op:"-",right:__node("Const",1849,74,1)},"expression",false,false)},"expression",false,false))}},"statement",false,false));}}if(init.length||changed||this.funcIsCurried(node)){body=this.funcBody(node);result=this.rewrap(this.func(params,__node("Block",1855,1,[__wrap(init),__wrap(body)],null),this.funcIsAutoReturn(node)&&!this.isNothing(body),this.funcIsBound(node),false,this.funcAsType(node),this.funcIsGenerator(node),this.funcGeneric(node)),node);}else{result=node;}if(this.funcIsCurried(node)){result=__node("Call",1867,19,__node("Ident",1867,19,"__curry"),[__wrap(params.length),__wrap(result)],false,false);}genericArgs=this.funcGeneric(node);if(__num(genericArgs.length)>0){genericCache=this.tmp("cache",false,"object");for(_arr=[], _arr2=__toArray(genericArgs), _i=0, _len=_arr2.length;_i<_len;++_i){genericArg=_arr2[_i];_arr.push(this.param(genericArg));}genericParams=_arr;makeFunctionIdent=this.tmp("make",false,"function");instanceofs={};for(_arr=__toArray(genericArgs), _i=0, _len=_arr.length;_i<_len;++_i){genericArg=_arr[_i];name=this.name(genericArg);key=this.tmp("instanceof_"+__strnum(name),false,"function");instanceofs[name]={key:key,"let":__node("MacroAccess",1880,17,38,1880,{macroName:"let",macroData:{declarable:__node("MacroAccess",1880,21,37,1880,__node("MacroAccess",1880,21,31,1880,{ident:__wrap(key)},"statement",false,false),"statement",false,false),value:__node("Call",1880,28,__node("Ident",1880,28,"__getInstanceof"),[__wrap(genericArg)],false,false)}},"statement",false,false),used:false};}result=this.walk(this.macroExpandAll(result),function(node){var func,left,name,right;if(_this.isBinary(node)&&_this.op(node)==="instanceof"){right=_this.right(node);if(_this.isIdent(right)){name=_this.name(right);if(__owns.call(instanceofs,name)){func=instanceofs[name].key;instanceofs[name].used=true;left=_this.left(node);return __node("Call",1892,24,__wrap(func),[__wrap(left)],false,false);}}}});_arr=[];for(name in instanceofs){if(__owns.call(instanceofs,name)){item=instanceofs[name];if(item.used){_arr.push(item["let"]);}}}instanceofLets=_arr;if(instanceofLets.length){result=__node("Block",1898,1,[__wrap(instanceofLets),__wrap(result)],null);}makeFunctionFunc=this.func(genericParams,result,true,false);result=__node("Call",1901,18,__node("Ident",1901,18,"__genericFunc"),[__wrap(genericArgs.length),__wrap(makeFunctionFunc)],false,false);}return result;};}.call(this));',
operators: "mutateFunction!",
options: {type: "node", label: "mutateFunction"},
id: 115
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return __node("Call",2263,7,__node("Ident",2263,7,"__keys"),[__wrap(node)],false,false);};}.call(this));',
operators: "keys!",
id: 122
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var node,op;op=macroData.op;node=macroData.node;return __node("Call",2272,7,__node("Ident",2272,7,"__allkeys"),[__wrap(node)],false,false);};}.call(this));',
operators: "allkeys!",
id: 123
},
{
code: 'return (function(){"use strict";var __isArray,__slice,__toArray,__typeof;__isArray=typeof Array.isArray==="function"?Array.isArray:(function(){var _toString;_toString=Object.prototype.toString;return function(x){return _toString.call(x)==="[object Array]";};}());__slice=Array.prototype.slice;__toArray=function(x){if(x==null){throw TypeError("Expected an object, got "+__typeof(x));}else if(__isArray(x)){return x;}else if(typeof x==="string"){return x.split("");}else{return __slice.call(x);}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroData,__wrap,__node){var _arr,_i,_len,element,item,node,op,parts,set;op=macroData.op;node=macroData.node;set=this.tmp("s",false,"object");if(this.isArray(node)&&!this.arrayHasSpread(node)){if(this.elements(node).length===0){return __node("Call",3525,11,__node("Ident",3525,11,"Set"),[],false,false);}else{parts=[];for(_arr=__toArray(this.elements(node)), _i=0, _len=_arr.length;_i<_len;++_i){element=_arr[_i];parts.push(__node("Call",3529,23,__node("Access",3529,23,__wrap(set),__node("Const",3529,29,"add")),[__wrap(element)],false,false));}return __node("Block",3531,1,[__node("MacroAccess",3531,1,38,3531,{macroName:"let",macroData:{declarable:__node("MacroAccess",3531,12,37,3531,__node("MacroAccess",3531,12,31,3531,{ident:__wrap(set)},"statement",false,false),"statement",false,false),value:__node("Call",3531,19,__node("Ident",3531,19,"Set"),[],false,false)}},"statement",false,false),__wrap(parts),__wrap(set)],null);}}else{item=this.tmp("x",false,"any");return __node("Block",3537,1,[__node("MacroAccess",3537,1,38,3537,{macroName:"let",macroData:{declarable:__node("MacroAccess",3537,10,37,3537,__node("MacroAccess",3537,10,31,3537,{ident:__wrap(set)},"statement",false,false),"statement",false,false),value:__node("Call",3537,17,__node("Ident",3537,17,"Set"),[],false,false)}},"statement",false,false),__node("MacroAccess",3538,1,111,3538,{macroName:"for",macroData:{value:__node("MacroAccess",3538,10,37,3538,__node("MacroAccess",3538,10,31,3538,{ident:__wrap(item)},"statement",false,false),"statement",false,false),array:__wrap(node),body:__node("Call",3539,1,__node("Access",3539,1,__wrap(set),__node("Const",3539,14,"add")),[__wrap(item)],false,false)}},"statement",false,false),__wrap(set)],null);}};}.call(this));',
operators: "set!",
options: {type: "object", label: "constructSet"},
id: 152
},
{
code: 'return (function(){"use strict";var __isArray,__slice,__toArray,__typeof;__isArray=typeof Array.isArray==="function"?Array.isArray:(function(){var _toString;_toString=Object.prototype.toString;return function(x){return _toString.call(x)==="[object Array]";};}());__slice=Array.prototype.slice;__toArray=function(x){if(x==null){throw TypeError("Expected an object, got "+__typeof(x));}else if(__isArray(x)){return x;}else if(typeof x==="string"){return x.split("");}else{return __slice.call(x);}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroData,__wrap,__node){var _arr,_i,_len,_ref,key,map,node,op,pairs,parts,property,value;op=macroData.op;node=macroData.node;if(!this.isObject(node)){this.error("map! can only be used on literal objects",node);}pairs=this.pairs(node);if(pairs.length===0){return __node("Call",3548,9,__node("Ident",3548,9,"Map"),[],false,false);}else{map=this.tmp("m",false,"object");parts=[];for(_arr=__toArray(pairs), _i=0, _len=_arr.length;_i<_len;++_i){key=(_ref=_arr[_i]).key;value=_ref.value;property=_ref.property;if(property!=null){this.error("Cannot use map! on an object with custom properties",key);}parts.push(__node("Call",3555,21,__node("Access",3555,21,__wrap(map),__node("Const",3555,27,"set")),[__wrap(key),__wrap(value)],false,false));}return __node("Block",3557,1,[__node("MacroAccess",3557,1,38,3557,{macroName:"let",macroData:{declarable:__node("MacroAccess",3557,10,37,3557,__node("MacroAccess",3557,10,31,3557,{ident:__wrap(map)},"statement",false,false),"statement",false,false),value:__node("Call",3557,17,__node("Ident",3557,17,"Map"),[],false,false)}},"statement",false,false),__wrap(parts),__wrap(map)],null);}};}.call(this));',
operators: "map!",
options: {type: "object", label: "constructMap"},
id: 153
}
],
helpers: {
__throw: {
helper: [
"Func",
62,
26,
0,
0,
[["Ident", 62, 27, 0, "err"]],
[],
[],
"Throw",
62,
34,
0,
"Ident",
62,
40,
0,
"err"
],
type: {type: "generic", base: "functionBase", args: ["none"]},
dependencies: ["__throw"]
},
GLOBAL: {
helper: [
"IfExpression",
145,
23,
0,
[
"Binary",
145,
26,
0,
[
"Unary",
117,
9,
0,
"typeof",
"Ident",
145,
39,
0,
"window"
],
"!==",
"Const",
117,
27,
0,
"undefined"
],
["Ident", 145, 51, 0, "window"],
"IfExpression",
145,
23,
0,
[
"Binary",
145,
66,
0,
[
"Unary",
117,
9,
0,
"typeof",
"Ident",
145,
79,
0,
"global"
],
"!==",
"Const",
117,
27,
0,
"undefined"
],
["Ident", 145, 91, 0, "global"],
"This",
145,
103,
0
],
type: "any",
dependencies: ["GLOBAL"]
},
__xor: {
helper: [
"Func",
147,
24,
0,
0,
[
["Ident", 147, 25, 0, "x"],
["Ident", 147, 27, 0, "y"]
],
[],
[],
"IfStatement",
148,
1,
0,
0,
["Ident", 148, 5, 0, "x"],
[
"Return",
149,
1,
0,
"Binary",
149,
1,
0,
[
"Unary",
149,
1,
0,
"!",
"Ident",
149,
8,
0,
"y"
],
"&&",
"Ident",
149,
14,
0,
"x"
],
"Return",
151,
1,
0,
"Binary",
151,
1,
0,
["Ident", 151, 1, 0, "y"],
"||",
"Ident",
151,
9,
0,
"x"
],
type: "function",
dependencies: ["__xor"]
},
__typeof: {
helper: [
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
["_toString"],
[],
"BlockStatement",
473,
1,
0,
0,
[
"Binary",
473,
1,
0,
["Ident", 473, 6, 0, "_toString"],
"=",
"Binary",
473,
19,
0,
[
"Binary",
473,
19,
0,
["Ident", 473, 19, 0, "Object"],
".",
"Const",
473,
27,
0,
"prototype"
],
".",
"Const",
473,
37,
0,
"toString"
],
[
"Return",
474,
4,
0,
"Func",
474,
4,
0,
0,
[["Ident", 474, 5, 0, "o"]],
[],
[],
"IfStatement",
475,
1,
0,
0,
[
"Binary",
119,
9,
0,
["Ident", 475, 16, 0, "o"],
"===",
"Const",
119,
18,
0
],
[
"Return",
476,
7,
0,
"Const",
476,
7,
0,
"Undefined"
],
"IfStatement",
475,
1,
0,
0,
[
"Binary",
125,
9,
0,
["Ident", 477, 21, 0, "o"],
"===",
"Const",
125,
18,
0,
null
],
[
"Return",
478,
7,
0,
"Const",
478,
7,
0,
"Null"
],
"Return",
480,
1,
0,
"Binary",
480,
1,
0,
[
"Binary",
480,
8,
0,
[
"Binary",
480,
8,
0,
["Ident", 480, 8, 0, "o"],
".",
"Const",
480,
10,
0,
"constructor"
],
"&&",
"Binary",
480,
25,
0,
[
"Binary",
480,
25,
0,
["Ident", 480, 25, 0, "o"],
".",
"Const",
480,
28,
0,
"constructor"
],
".",
"Const",
480,
40,
0,
"name"
],
"||",
"Call",
480,
48,
0,
[
"Binary",
480,
48,
0,
[
"Call",
480,
48,
0,
[
"Binary",
480,
48,
0,
["Ident", 480, 48, 0, "_toString"],
".",
"Const",
480,
48,
0,
"call"
],
0,
["Ident", 480, 61, 0, "o"]
],
".",
"Const",
480,
64,
0,
"slice"
],
0,
["Const", 480, 70, 0, 8],
["Const", 480, 72, 0, -1]
]
],
0
],
type: {type: "generic", base: "functionBase", args: ["string"]},
dependencies: ["__typeof"]
},
__num: {
helper: [
"Func",
488,
24,
0,
0,
[["Ident", 488, 25, 0, "num"]],
[],
[],
"IfStatement",
489,
1,
0,
0,
[
"Binary",
489,
5,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
489,
20,
0,
"num"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
490,
1,
0,
"Call",
490,
10,
0,
["Ident", 490, 10, 0, "TypeError"],
0,
[
"Binary",
490,
21,
0,
["Const", 490, 21, 0, "Expected a number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 490, 57, 0, "num"]
]
],
"Return",
492,
1,
0,
"Ident",
492,
1,
0,
"num"
],
type: {type: "generic", base: "functionBase", args: ["number"]},
dependencies: ["__num", "__typeof"]
},
__str: {
helper: [
"Func",
494,
24,
0,
0,
[["Ident", 494, 25, 0, "str"]],
[],
[],
"IfStatement",
495,
1,
0,
0,
[
"Binary",
495,
5,
0,
[
"Unary",
128,
7,
0,
"typeof",
"Ident",
495,
20,
0,
"str"
],
"!==",
"Const",
128,
25,
0,
"string"
],
[
"Throw",
496,
1,
0,
"Call",
496,
10,
0,
["Ident", 496, 10, 0, "TypeError"],
0,
[
"Binary",
496,
21,
0,
["Const", 496, 21, 0, "Expected a string, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 496, 57, 0, "str"]
]
],
"Return",
498,
1,
0,
"Ident",
498,
1,
0,
"str"
],
type: {type: "generic", base: "functionBase", args: ["string"]},
dependencies: ["__str", "__typeof"]
},
__strnum: {
helper: [
"Func",
500,
27,
0,
0,
[["Ident", 500, 28, 0, "strnum"]],
["type"],
[],
"BlockStatement",
501,
1,
0,
0,
[
"Binary",
501,
1,
0,
["Ident", 501, 6, 0, "type"],
"=",
"Unary",
501,
13,
0,
"typeof",
"Ident",
501,
20,
0,
"strnum"
],
[
"IfStatement",
502,
1,
0,
0,
[
"Binary",
502,
5,
0,
["Ident", 502, 5, 0, "type"],
"===",
"Const",
502,
15,
0,
"string"
],
[
"Return",
503,
1,
0,
"Ident",
503,
1,
0,
"strnum"
],
"IfStatement",
502,
1,
0,
0,
[
"Binary",
504,
10,
0,
["Ident", 504, 10, 0, "type"],
"===",
"Const",
504,
20,
0,
"number"
],
[
"Return",
505,
1,
0,
"Call",
505,
1,
0,
["Ident", 505, 1, 0, "String"],
0,
["Ident", 505, 12, 0, "strnum"]
],
"Throw",
507,
1,
0,
"Call",
507,
10,
0,
["Ident", 507, 10, 0, "TypeError"],
0,
[
"Binary",
507,
21,
0,
["Const", 507, 21, 0, "Expected a string or number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 507, 67, 0, "strnum"]
]
]
],
type: {type: "generic", base: "functionBase", args: ["string"]},
dependencies: ["__strnum", "__typeof"]
},
__owns: {
helper: [
"Binary",
608,
23,
0,
[
"Binary",
608,
23,
0,
["Ident", 608, 23, 0, "Object"],
".",
"Const",
608,
31,
0,
"prototype"
],
".",
"Const",
608,
41,
0,
"hasOwnProperty"
],
type: "any",
dependencies: ["__owns"]
},
__cmp: {
helper: [
"Func",
629,
24,
0,
0,
[
["Ident", 629, 25, 0, "left"],
["Ident", 629, 30, 0, "right"]
],
["type"],
[],
"IfStatement",
630,
1,
0,
0,
[
"Binary",
630,
5,
0,
["Ident", 630, 5, 0, "left"],
"===",
"Ident",
630,
13,
0,
"right"
],
[
"Return",
631,
5,
0,
"Const",
631,
5,
0,
0
],
"BlockStatement",
633,
1,
0,
0,
[
"Binary",
633,
1,
0,
["Ident", 633, 8, 0, "type"],
"=",
"Unary",
633,
15,
0,
"typeof",
"Ident",
633,
22,
0,
"left"
],
[
"IfStatement",
634,
1,
0,
0,
[
"Binary",
634,
7,
0,
[
"Binary",
43,
7,
0,
["Ident", 634, 7, 0, "type"],
"!==",
"Const",
634,
17,
0,
"number"
],
"&&",
"Binary",
43,
7,
0,
["Ident", 634, 27, 0, "type"],
"!==",
"Const",
634,
37,
0,
"string"
],
[
"Throw",
635,
1,
0,
"Call",
635,
12,
0,
["Ident", 635, 12, 0, "TypeError"],
0,
[
"Binary",
635,
23,
0,
["Const", 635, 23, 0, "Cannot compare a non-number/string: "],
"+",
"Ident",
635,
64,
0,
"type"
]
],
"IfStatement",
634,
1,
0,
0,
[
"Binary",
43,
7,
0,
["Ident", 636, 12, 0, "type"],
"!==",
"Unary",
636,
20,
0,
"typeof",
"Ident",
636,
27,
0,
"right"
],
[
"Throw",
637,
1,
0,
"Call",
637,
12,
0,
["Ident", 637, 12, 0, "TypeError"],
0,
[
"Binary",
637,
23,
0,
[
"Binary",
637,
23,
0,
[
"Binary",
637,
23,
0,
["Const", 637, 23, 0, "Cannot compare elements of different types: "],
"+",
"Ident",
637,
72,
0,
"type"
],
"+",
"Const",
637,
81,
0,
" vs "
],
"+",
"Unary",
637,
90,
0,
"typeof",
"Ident",
637,
97,
0,
"right"
]
],
"IfStatement",
634,
1,
0,
0,
[
"Binary",
638,
12,
0,
["Ident", 638, 12, 0, "left"],
"<",
"Ident",
638,
20,
0,
"right"
],
[
"Return",
639,
1,
0,
"Const",
639,
1,
0,
-1
],
"Return",
641,
7,
0,
"Const",
641,
7,
0,
1
]
],
type: {type: "generic", base: "functionBase", args: ["number"]},
dependencies: ["__cmp"]
},
__int: {
helper: [
"Func",
652,
24,
0,
0,
[["Ident", 652, 25, 0, "num"]],
[],
[],
"IfStatement",
653,
1,
0,
0,
[
"Binary",
653,
5,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
653,
20,
0,
"num"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
654,
1,
0,
"Call",
654,
10,
0,
["Ident", 654, 10, 0, "TypeError"],
0,
[
"Binary",
654,
21,
0,
["Const", 654, 21, 0, "Expected a number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 654, 57, 0, "num"]
]
],
"IfStatement",
653,
1,
0,
0,
[
"Binary",
650,
7,
0,
[
"Binary",
650,
7,
0,
["Ident", 655, 10, 0, "num"],
"%",
"Const",
655,
23,
0,
1
],
"!==",
"Const",
650,
27,
0,
0
],
[
"Throw",
656,
1,
0,
"Call",
656,
10,
0,
["Ident", 656, 10, 0, "TypeError"],
0,
[
"Binary",
656,
21,
0,
["Const", 656, 21, 0, "Expected an integer, got "],
"+",
"Ident",
656,
51,
0,
"num"
]
],
"Return",
658,
1,
0,
"Ident",
658,
1,
0,
"num"
],
type: {type: "generic", base: "functionBase", args: ["number"]},
dependencies: ["__int", "__typeof"]
},
__nonzero: {
helper: [
"Func",
660,
28,
0,
0,
[["Ident", 660, 29, 0, "num"]],
[],
[],
"IfStatement",
661,
1,
0,
0,
[
"Binary",
661,
5,
0,
["Ident", 661, 5, 0, "num"],
"===",
"Const",
661,
13,
0,
0
],
[
"Throw",
662,
1,
0,
"Call",
662,
10,
0,
["Ident", 662, 10, 0, "RangeError"],
0,
[
"Binary",
662,
22,
0,
["Const", 662, 22, 0, "Expected non-zero, got "],
"+",
"Ident",
662,
50,
0,
"num"
]
],
"Return",
664,
1,
0,
"Ident",
664,
1,
0,
"num"
],
type: "function",
dependencies: ["__nonzero"]
},
__lt: {
helper: [
"Func",
666,
23,
0,
0,
[
["Ident", 666, 24, 0, "x"],
["Ident", 666, 26, 0, "y"]
],
["type"],
[],
"BlockStatement",
667,
1,
0,
0,
[
"Binary",
667,
1,
0,
["Ident", 667, 6, 0, "type"],
"=",
"Unary",
667,
13,
0,
"typeof",
"Ident",
667,
20,
0,
"x"
],
[
"IfStatement",
668,
1,
0,
0,
[
"Binary",
597,
25,
0,
[
"Binary",
601,
18,
0,
["Ident", 668, 5, 0, "type"],
"!==",
"Const",
668,
20,
0,
"number"
],
"&&",
"Binary",
597,
37,
0,
["Ident", 668, 5, 0, "type"],
"!==",
"Const",
668,
29,
0,
"string"
],
[
"Throw",
669,
1,
0,
"Call",
669,
10,
0,
["Ident", 669, 10, 0, "TypeError"],
0,
[
"Binary",
669,
21,
0,
["Const", 669, 21, 0, "Cannot compare a non-number/string: "],
"+",
"Ident",
669,
62,
0,
"type"
]
],
"IfStatement",
668,
1,
0,
0,
[
"Binary",
43,
7,
0,
["Ident", 670, 10, 0, "type"],
"!==",
"Unary",
670,
18,
0,
"typeof",
"Ident",
670,
25,
0,
"y"
],
[
"Throw",
671,
1,
0,
"Call",
671,
10,
0,
["Ident", 671, 10, 0, "TypeError"],
0,
[
"Binary",
671,
21,
0,
[
"Binary",
671,
21,
0,
[
"Binary",
671,
21,
0,
["Const", 671, 21, 0, "Cannot compare elements of different types: "],
"+",
"Ident",
671,
70,
0,
"type"
],
"+",
"Const",
671,
79,
0,
" vs "
],
"+",
"Unary",
671,
88,
0,
"typeof",
"Ident",
671,
95,
0,
"y"
]
],
"Return",
673,
1,
0,
"Binary",
673,
1,
0,
["Ident", 673, 1, 0, "x"],
"<",
"Ident",
673,
9,
0,
"y"
]
],
type: {type: "generic", base: "functionBase", args: ["boolean"]},
dependencies: ["__lt"]
},
__lte: {
helper: [
"Func",
675,
24,
0,
0,
[
["Ident", 675, 25, 0, "x"],
["Ident", 675, 27, 0, "y"]
],
["type"],
[],
"BlockStatement",
676,
1,
0,
0,
[
"Binary",
676,
1,
0,
["Ident", 676, 6, 0, "type"],
"=",
"Unary",
676,
13,
0,
"typeof",
"Ident",
676,
20,
0,
"x"
],
[
"IfStatement",
677,
1,
0,
0,
[
"Binary",
597,
25,
0,
[
"Binary",
601,
18,
0,
["Ident", 677, 5, 0, "type"],
"!==",
"Const",
677,
20,
0,
"number"
],
"&&",
"Binary",
597,
37,
0,
["Ident", 677, 5, 0, "type"],
"!==",
"Const",
677,
29,
0,
"string"
],
[
"Throw",
678,
1,
0,
"Call",
678,
10,
0,
["Ident", 678, 10, 0, "TypeError"],
0,
[
"Binary",
678,
21,
0,
["Const", 678, 21, 0, "Cannot compare a non-number/string: "],
"+",
"Ident",
678,
62,
0,
"type"
]
],
"IfStatement",
677,
1,
0,
0,
[
"Binary",
43,
7,
0,
["Ident", 679, 10, 0, "type"],
"!==",
"Unary",
679,
18,
0,
"typeof",
"Ident",
679,
25,
0,
"y"
],
[
"Throw",
680,
1,
0,
"Call",
680,
10,
0,
["Ident", 680, 10, 0, "TypeError"],
0,
[
"Binary",
680,
21,
0,
[
"Binary",
680,
21,
0,
[
"Binary",
680,
21,
0,
["Const", 680, 21, 0, "Cannot compare elements of different types: "],
"+",
"Ident",
680,
70,
0,
"type"
],
"+",
"Const",
680,
79,
0,
" vs "
],
"+",
"Unary",
680,
88,
0,
"typeof",
"Ident",
680,
95,
0,
"y"
]
],
"Return",
682,
1,
0,
"Binary",
682,
1,
0,
["Ident", 682, 1, 0, "x"],
"<=",
"Ident",
682,
10,
0,
"y"
]
],
type: {type: "generic", base: "functionBase", args: ["boolean"]},
dependencies: ["__lte"]
},
__slice: {
helper: [
"Binary",
929,
24,
0,
[
"Binary",
929,
24,
0,
["Ident", 929, 24, 0, "Array"],
".",
"Const",
929,
31,
0,
"prototype"
],
".",
"Const",
929,
41,
0,
"slice"
],
type: "any",
dependencies: ["__slice"]
},
__freeze: {
helper: [
"IfExpression",
931,
25,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
931,
41,
0,
["Ident", 931, 41, 0, "Object"],
".",
"Const",
931,
49,
0,
"freeze"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Binary",
932,
1,
0,
["Ident", 932, 1, 0, "Object"],
".",
"Const",
932,
10,
0,
"freeze"
],
"Func",
934,
4,
0,
0,
[["Ident", 934, 5, 0, "x"]],
[],
[],
"Return",
934,
10,
0,
"Ident",
934,
10,
0,
"x"
],
type: "any",
dependencies: ["__freeze"]
},
__freezeFunc: {
helper: [
"Func",
936,
32,
0,
0,
[["Ident", 936, 33, 0, "x"]],
[],
[],
"BlockStatement",
937,
1,
0,
0,
[
"IfStatement",
937,
1,
0,
0,
[
"Binary",
49,
7,
0,
[
"Binary",
937,
5,
0,
["Ident", 937, 5, 0, "x"],
".",
"Const",
937,
8,
0,
"prototype"
],
"!=",
"Const",
113,
19,
0,
null
],
[
"Call",
938,
1,
0,
["Ident", 938, 1, 0, "__freeze"],
0,
[
"Binary",
938,
14,
0,
["Ident", 938, 14, 0, "x"],
".",
"Const",
938,
16,
0,
"prototype"
]
]
],
[
"Return",
939,
1,
0,
"Call",
939,
1,
0,
["Ident", 939, 1, 0, "__freeze"],
0,
["Ident", 939, 12, 0, "x"]
]
],
type: "function",
dependencies: ["__freeze", "__freezeFunc"]
},
__isArray: {
helper: [
"IfExpression",
941,
27,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
941,
43,
0,
["Ident", 941, 43, 0, "Array"],
".",
"Const",
941,
50,
0,
"isArray"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Binary",
942,
1,
0,
["Ident", 942, 1, 0, "Array"],
".",
"Const",
942,
9,
0,
"isArray"
],
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
["_toString"],
[],
"BlockStatement",
945,
1,
0,
0,
[
"Binary",
945,
1,
0,
["Ident", 945, 8, 0, "_toString"],
"=",
"Binary",
945,
21,
0,
[
"Binary",
945,
21,
0,
["Ident", 945, 21, 0, "Object"],
".",
"Const",
945,
29,
0,
"prototype"
],
".",
"Const",
945,
39,
0,
"toString"
],
[
"Return",
946,
6,
0,
"Func",
946,
6,
0,
0,
[["Ident", 946, 7, 0, "x"]],
[],
[],
"Return",
946,
23,
0,
"Binary",
946,
23,
0,
[
"Call",
946,
23,
0,
[
"Binary",
946,
23,
0,
["Ident", 946, 23, 0, "_toString"],
".",
"Const",
946,
23,
0,
"call"
],
0,
["Ident", 946, 36, 0, "x"]
],
"===",
"Const",
946,
42,
0,
"[object Array]"
]
],
0
],
type: "any",
dependencies: ["__isArray"]
},
__isObject: {
helper: [
"Func",
948,
30,
0,
0,
[["Ident", 948, 31, 0, "x"]],
[],
[],
"Return",
948,
47,
0,
"Binary",
948,
47,
0,
[
"Binary",
948,
47,
0,
[
"Unary",
948,
47,
0,
"typeof",
"Ident",
948,
54,
0,
"x"
],
"===",
"Const",
948,
61,
0,
"object"
],
"&&",
"Binary",
43,
7,
0,
["Ident", 948, 71, 0, "x"],
"!==",
"Const",
948,
76,
0,
null
],
type: {type: "generic", base: "functionBase", args: ["boolean"]},
dependencies: ["__isObject"]
},
__toArray: {
helper: [
"Func",
950,
29,
0,
0,
[["Ident", 950, 30, 0, "x"]],
[],
[],
"IfStatement",
951,
1,
0,
0,
[
"Binary",
951,
5,
0,
["Ident", 951, 9, 0, "x"],
"==",
"Const",
113,
19,
0,
null
],
[
"Throw",
952,
1,
0,
"Call",
952,
10,
0,
["Ident", 952, 10, 0, "TypeError"],
0,
[
"Binary",
952,
21,
0,
["Const", 952, 21, 0, "Expected an object, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 952, 58, 0, "x"]
]
],
"IfStatement",
951,
1,
0,
0,
[
"Call",
140,
146,
0,
["Ident", 140, 146, 0, "__isArray"],
0,
["Ident", 953, 20, 0, "x"]
],
[
"Return",
954,
1,
0,
"Ident",
954,
1,
0,
"x"
],
"IfStatement",
951,
1,
0,
0,
[
"Binary",
955,
10,
0,
[
"Unary",
955,
10,
0,
"typeof",
"Ident",
955,
17,
0,
"x"
],
"===",
"Const",
955,
24,
0,
"string"
],
[
"Return",
956,
1,
0,
"Call",
956,
1,
0,
[
"Binary",
956,
1,
0,
["Ident", 956, 1, 0, "x"],
".",
"Const",
956,
7,
0,
"split"
],
0,
["Const", 956, 13, 0, ""]
],
"Return",
958,
1,
0,
"Call",
958,
1,
0,
[
"Binary",
958,
1,
0,
["Ident", 958, 1, 0, "__slice"],
".",
"Const",
958,
1,
0,
"call"
],
0,
["Ident", 958, 14, 0, "x"]
],
type: {type: "generic", base: "functionBase", args: ["array"]},
dependencies: ["__isArray", "__slice", "__toArray", "__typeof"]
},
__create: {
helper: [
"IfExpression",
960,
25,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
960,
41,
0,
["Ident", 960, 41, 0, "Object"],
".",
"Const",
960,
49,
0,
"create"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Binary",
961,
1,
0,
["Ident", 961, 1, 0, "Object"],
".",
"Const",
961,
10,
0,
"create"
],
"Func",
963,
4,
0,
0,
[["Ident", 963, 5, 0, "x"]],
[],
[],
"BlockStatement",
964,
1,
0,
0,
[
"Func",
964,
1,
0,
["Ident", 964, 8, 0, "F"],
[],
[],
[]
],
[
"Binary",
965,
1,
0,
[
"Binary",
965,
1,
0,
["Ident", 965, 1, 0, "F"],
".",
"Const",
965,
7,
0,
"prototype"
],
"=",
"Ident",
965,
19,
0,
"x"
],
[
"Return",
966,
1,
0,
"Call",
966,
1,
0,
["Ident", 966, 8, 0, "F"],
1
]
],
type: "any",
dependencies: ["__create"]
},
__pow: {
helper: [
"Binary",
968,
22,
0,
["Ident", 968, 22, 0, "Math"],
".",
"Const",
968,
28,
0,
"pow"
],
type: "any",
dependencies: ["__pow"]
},
__floor: {
helper: [
"Binary",
969,
24,
0,
["Ident", 969, 24, 0, "Math"],
".",
"Const",
969,
30,
0,
"floor"
],
type: "any",
dependencies: ["__floor"]
},
__sqrt: {
helper: [
"Binary",
970,
23,
0,
["Ident", 970, 23, 0, "Math"],
".",
"Const",
970,
29,
0,
"sqrt"
],
type: "any",
dependencies: ["__sqrt"]
},
__log: {
helper: [
"Binary",
971,
22,
0,
["Ident", 971, 22, 0, "Math"],
".",
"Const",
971,
28,
0,
"log"
],
type: "any",
dependencies: ["__log"]
},
__in: {
helper: [
"IfExpression",
1103,
21,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
1103,
37,
0,
[
"Binary",
1103,
37,
0,
["Ident", 1103, 37, 0, "Array"],
".",
"Const",
1103,
44,
0,
"prototype"
],
".",
"Const",
1103,
54,
0,
"indexOf"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
["indexOf"],
[],
"BlockStatement",
1105,
1,
0,
0,
[
"Binary",
1105,
1,
0,
["Ident", 1105, 8, 0, "indexOf"],
"=",
"Binary",
1105,
19,
0,
[
"Binary",
1105,
19,
0,
["Ident", 1105, 19, 0, "Array"],
".",
"Const",
1105,
26,
0,
"prototype"
],
".",
"Const",
1105,
36,
0,
"indexOf"
],
[
"Return",
1106,
6,
0,
"Func",
1106,
6,
0,
0,
[
["Ident", 1106, 7, 0, "child"],
["Ident", 1106, 13, 0, "parent"]
],
[],
[],
"Return",
43,
7,
0,
"Binary",
43,
7,
0,
[
"Call",
1106,
35,
0,
[
"Binary",
1106,
35,
0,
["Ident", 1106, 35, 0, "indexOf"],
".",
"Const",
1106,
35,
0,
"call"
],
0,
["Ident", 1106, 46, 0, "parent"],
["Ident", 1106, 53, 0, "child"]
],
"!==",
"Const",
1106,
63,
0,
-1
]
],
0
],
"Func",
1108,
4,
0,
0,
[
["Ident", 1108, 5, 0, "child"],
["Ident", 1108, 11, 0, "parent"]
],
["i", "len"],
[],
"BlockStatement",
1109,
1,
0,
0,
[
"Binary",
1109,
1,
0,
["Ident", 1109, 8, 0, "len"],
"=",
"Unary",
1109,
14,
0,
"+",
"Binary",
1109,
17,
0,
["Ident", 1109, 17, 0, "parent"],
".",
"Const",
1109,
24,
0,
"length"
],
[
"Binary",
1110,
1,
0,
["Ident", 1110, 16, 0, "i"],
"=",
"Const",
1110,
20,
0,
-1
],
[
"For",
1071,
1,
0,
0,
0,
[
"Binary",
688,
13,
0,
[
"Unary",
1111,
12,
0,
"++",
"Ident",
1111,
12,
0,
"i"
],
"<",
"Ident",
1111,
22,
0,
"len"
],
0,
"IfStatement",
1112,
1,
0,
0,
[
"Binary",
1112,
9,
0,
[
"Binary",
1112,
9,
0,
["Ident", 1112, 9, 0, "child"],
"===",
"Binary",
1112,
18,
0,
["Ident", 1112, 18, 0, "parent"],
".",
"Ident",
1112,
26,
0,
"i"
],
"&&",
"Binary",
1112,
32,
0,
["Ident", 1112, 46, 0, "i"],
"in",
"Ident",
1112,
32,
0,
"parent"
],
[
"Return",
1113,
1,
0,
"Const",
1113,
15,
0,
true
]
],
[
"Return",
1114,
1,
0,
"Const",
1114,
1,
0,
false
]
],
type: {type: "generic", base: "functionBase", args: ["boolean"]},
dependencies: ["__in"]
},
__genericFunc: {
helper: [
"Func",
1592,
33,
0,
0,
[
["Ident", 1592, 34, 0, "numArgs"],
["Ident", 1592, 53, 0, "make"]
],
["any", "cache", "result"],
[],
"BlockStatement",
1593,
1,
0,
0,
[
"Binary",
1593,
1,
0,
["Ident", 1593, 6, 0, "cache"],
"=",
"Call",
1593,
14,
0,
["Ident", 1593, 14, 0, "WeakMap"],
0
],
[
"Binary",
1594,
1,
0,
["Ident", 1594, 6, 0, "any"],
"=",
"Obj",
1594,
12,
0
],
[
"Func",
1595,
1,
0,
["Ident", 1595, 6, 0, "generic"],
[],
["_ref", "current", "i", "item", "type"],
[],
"BlockStatement",
1466,
1,
0,
0,
[
"Binary",
1466,
1,
0,
["Ident", 1596, 45, 0, "current"],
"=",
"Ident",
1596,
55,
0,
"cache"
],
[
"For",
1231,
1,
0,
0,
[
"Binary",
1141,
38,
0,
["Ident", 1596, 15, 0, "i"],
"=",
"Binary",
548,
9,
0,
["Ident", 1596, 20, 0, "numArgs"],
"-",
"Const",
1596,
32,
0,
1
],
[
"Binary",
57,
55,
0,
["Ident", 1596, 15, 0, "i"],
">=",
"Const",
1596,
37,
0,
0
],
[
"Unary",
1179,
35,
0,
"--",
"Ident",
1596,
15,
0,
"i"
],
"BlockStatement",
1597,
1,
0,
0,
[
"IfStatement",
753,
9,
0,
0,
[
"Binary",
49,
7,
0,
[
"Binary",
1597,
17,
0,
["Ident", 1597, 17, 0, "_ref"],
"=",
"Binary",
1597,
17,
0,
["Arguments", 1597, 17, 0],
".",
"Ident",
1597,
28,
0,
"i"
],
"!=",
"Const",
113,
19,
0,
null
],
[
"Binary",
1597,
1,
0,
["Ident", 1597, 10, 0, "type"],
"=",
"Ident",
1597,
17,
0,
"_ref"
],
"Binary",
1597,
1,
0,
["Ident", 1597, 10, 0, "type"],
"=",
"Ident",
1597,
32,
0,
"any"
],
[
"Binary",
1598,
1,
0,
["Ident", 1598, 18, 0, "item"],
"=",
"Call",
1598,
25,
0,
[
"Binary",
1598,
25,
0,
["Ident", 1598, 25, 0, "current"],
".",
"Const",
1598,
34,
0,
"get"
],
0,
["Ident", 1598, 38, 0, "type"]
],
[
"IfStatement",
1599,
1,
0,
0,
[
"Binary",
1599,
9,
0,
["Ident", 1599, 13, 0, "item"],
"==",
"Const",
113,
19,
0,
null
],
[
"BlockStatement",
1600,
1,
0,
0,
[
"Binary",
1600,
1,
0,
["Ident", 1600, 1, 0, "item"],
"=",
"IfExpression",
1600,
16,
0,
[
"Binary",
1600,
19,
0,
["Ident", 1600, 19, 0, "i"],
"===",
"Const",
1600,
25,
0,
0
],
[
"Call",
1601,
1,
0,
[
"Binary",
1601,
1,
0,
["Ident", 1601, 1, 0, "make"],
".",
"Const",
1601,
1,
0,
"apply"
],
0,
["This", 1601, 17, 0],
["Arguments", 1601, 26, 0]
],
"Call",
1603,
1,
0,
["Ident", 1603, 1, 0, "WeakMap"],
0
],
[
"Call",
1604,
1,
0,
[
"Binary",
1604,
1,
0,
["Ident", 1604, 1, 0, "current"],
".",
"Const",
1604,
17,
0,
"set"
],
0,
["Ident", 1604, 21, 0, "type"],
["Ident", 1604, 26, 0, "item"]
]
]
],
[
"Binary",
1462,
59,
0,
["Ident", 1596, 45, 0, "current"],
"=",
"Ident",
1605,
1,
0,
"item"
]
],
[
"Return",
1596,
45,
0,
"Ident",
1596,
45,
0,
"current"
]
],
[
"Binary",
1606,
1,
0,
["Ident", 1606, 6, 0, "result"],
"=",
"Call",
1606,
15,
0,
["Ident", 1606, 15, 0, "generic"],
0
],
[
"Binary",
1607,
1,
0,
[
"Binary",
1607,
1,
0,
["Ident", 1607, 1, 0, "result"],
".",
"Const",
1607,
10,
0,
"generic"
],
"=",
"Ident",
1607,
20,
0,
"generic"
],
[
"Return",
1608,
1,
0,
"Ident",
1608,
1,
0,
"result"
]
],
type: "function",
dependencies: ["__genericFunc", "__toArray", "WeakMap"]
},
__range: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 1904, 27, 0, "start"],
["Ident", 1904, 43, 0, "end"],
["Ident", 1904, 58, 0, "step"],
["Ident", 1904, 74, 0, "inclusive"]
],
["i", "result"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
1904,
27,
0,
"start"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected start to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 1904, 27, 0, "start"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
1904,
43,
0,
"end"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected end to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 1904, 43, 0, "end"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
1904,
58,
0,
"step"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected step to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 1904, 58, 0, "step"]
]
]
],
[
"IfStatement",
1646,
13,
0,
0,
[
"Binary",
1646,
16,
0,
["Ident", 1904, 74, 0, "inclusive"],
"==",
"Const",
113,
19,
0,
null
],
[
"Binary",
1647,
1,
0,
["Ident", 1904, 74, 0, "inclusive"],
"=",
"Const",
1647,
20,
0,
false
],
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
620,
18,
0,
[
"Unary",
134,
7,
0,
"typeof",
"Ident",
1904,
74,
0,
"inclusive"
],
"!==",
"Const",
134,
25,
0,
"boolean"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected inclusive to be a Boolean, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 1904, 74, 0, "inclusive"]
]
]
],
[
"IfStatement",
1905,
1,
0,
0,
[
"Binary",
1905,
5,
0,
["Ident", 1905, 5, 0, "step"],
"===",
"Const",
1905,
14,
0,
0
],
[
"Throw",
1906,
1,
0,
"Call",
1906,
10,
0,
["Ident", 1906, 10, 0, "RangeError"],
0,
["Const", 1906, 22, 0, "step cannot be zero"]
],
"IfStatement",
1905,
1,
0,
0,
[
"Unary",
1907,
10,
0,
"!",
"Call",
1907,
14,
0,
["Ident", 1907, 14, 0, "isFinite"],
0,
["Ident", 1907, 25, 0, "start"]
],
[
"Throw",
1908,
1,
0,
"Call",
1908,
10,
0,
["Ident", 1908, 10, 0, "RangeError"],
0,
["Const", 1908, 22, 0, "start must be finite"]
],
"IfStatement",
1905,
1,
0,
0,
[
"Unary",
1909,
10,
0,
"!",
"Call",
1909,
14,
0,
["Ident", 1909, 14, 0, "isFinite"],
0,
["Ident", 1909, 25, 0, "end"]
],
[
"Throw",
1910,
1,
0,
"Call",
1910,
10,
0,
["Ident", 1910, 10, 0, "RangeError"],
0,
["Const", 1910, 22, 0, "end must be finite"]
]
],
[
"Binary",
1911,
1,
0,
["Ident", 1911, 6, 0, "result"],
"=",
"Arr",
1911,
15,
0
],
[
"Binary",
1912,
1,
0,
["Ident", 1912, 14, 0, "i"],
"=",
"Ident",
1912,
18,
0,
"start"
],
[
"IfStatement",
1913,
1,
0,
0,
[
"Binary",
57,
23,
0,
["Ident", 1913, 5, 0, "step"],
">",
"Const",
1913,
14,
0,
0
],
[
"BlockStatement",
1914,
1,
0,
0,
[
"For",
1071,
1,
0,
0,
0,
[
"Binary",
1914,
10,
0,
["Ident", 1914, 10, 0, "i"],
"<",
"Ident",
1914,
15,
0,
"end"
],
[
"Binary",
1914,
20,
0,
["Ident", 1914, 20, 0, "i"],
"+=",
"Ident",
1914,
26,
0,
"step"
],
"Call",
1915,
1,
0,
[
"Binary",
1915,
1,
0,
["Ident", 1915, 1, 0, "result"],
".",
"Const",
1915,
14,
0,
"push"
],
0,
["Ident", 1915, 19, 0, "i"]
],
[
"IfStatement",
1916,
1,
0,
0,
[
"Binary",
1916,
7,
0,
["Ident", 1916, 7, 0, "inclusive"],
"&&",
"Binary",
1916,
21,
0,
["Ident", 1916, 21, 0, "i"],
"<=",
"Ident",
1916,
27,
0,
"end"
],
[
"Call",
1917,
1,
0,
[
"Binary",
1917,
1,
0,
["Ident", 1917, 1, 0, "result"],
".",
"Const",
1917,
14,
0,
"push"
],
0,
["Ident", 1917, 19, 0, "i"]
]
]
],
"BlockStatement",
1919,
1,
0,
0,
[
"For",
1071,
1,
0,
0,
0,
[
"Binary",
57,
23,
0,
["Ident", 1919, 10, 0, "i"],
">",
"Ident",
1919,
15,
0,
"end"
],
[
"Binary",
1919,
20,
0,
["Ident", 1919, 20, 0, "i"],
"+=",
"Ident",
1919,
26,
0,
"step"
],
"Call",
1920,
1,
0,
[
"Binary",
1920,
1,
0,
["Ident", 1920, 1, 0, "result"],
".",
"Const",
1920,
14,
0,
"push"
],
0,
["Ident", 1920, 19, 0, "i"]
],
[
"IfStatement",
1921,
1,
0,
0,
[
"Binary",
1921,
7,
0,
["Ident", 1921, 7, 0, "inclusive"],
"&&",
"Binary",
57,
55,
0,
["Ident", 1921, 21, 0, "i"],
">=",
"Ident",
1921,
27,
0,
"end"
],
[
"Call",
1922,
1,
0,
[
"Binary",
1922,
1,
0,
["Ident", 1922, 1, 0, "result"],
".",
"Const",
1922,
14,
0,
"push"
],
0,
["Ident", 1922, 19, 0, "i"]
]
]
],
[
"Return",
1923,
1,
0,
"Ident",
1923,
1,
0,
"result"
]
],
type: {type: "generic", base: "functionBase", args: ["numberArray"]},
dependencies: ["__range", "__typeof"]
},
__step: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 1925, 26, 0, "array"],
["Ident", 1925, 32, 0, "step"]
],
["i", "len", "result"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
1925,
32,
0,
"step"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected step to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 1925, 32, 0, "step"]
]
]
],
[
"IfStatement",
1926,
1,
0,
0,
[
"Binary",
1926,
5,
0,
["Ident", 1926, 5, 0, "step"],
"===",
"Const",
1926,
14,
0,
0
],
[
"Throw",
1927,
1,
0,
"Call",
1927,
10,
0,
["Ident", 1927, 10, 0, "RangeError"],
0,
["Const", 1927, 22, 0, "step cannot be zero"]
],
"IfStatement",
1926,
1,
0,
0,
[
"Binary",
1928,
10,
0,
["Ident", 1928, 10, 0, "step"],
"===",
"Const",
1928,
19,
0,
1
],
[
"Return",
1929,
1,
0,
"Call",
1929,
1,
0,
["Ident", 1929, 1, 0, "__toArray"],
0,
["Ident", 1929, 16, 0, "array"]
],
"IfStatement",
1926,
1,
0,
0,
[
"Binary",
1930,
10,
0,
["Ident", 1930, 10, 0, "step"],
"===",
"Const",
1930,
18,
0,
-1
],
[
"Return",
1931,
1,
0,
"Call",
1931,
1,
0,
[
"Binary",
1931,
1,
0,
[
"Call",
1931,
1,
0,
[
"Binary",
1931,
1,
0,
["Ident", 1931, 1, 0, "__slice"],
".",
"Const",
1931,
1,
0,
"call"
],
0,
["Ident", 1931, 14, 0, "array"]
],
".",
"Const",
1931,
21,
0,
"reverse"
],
0
],
"IfStatement",
1926,
1,
0,
0,
[
"Binary",
647,
7,
0,
[
"Binary",
537,
9,
0,
["Ident", 1932, 10, 0, "step"],
"%",
"Const",
1932,
23,
0,
1
],
"!==",
"Const",
647,
26,
0,
0
],
[
"Throw",
1933,
1,
0,
"Call",
1933,
10,
0,
["Ident", 1933, 10, 0, "RangeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 1933, 22, 0, "step must be an integer, got "],
"+",
"Call",
1933,
54,
0,
["Ident", 1933, 54, 0, "String"],
0,
["Ident", 1933, 61, 0, "step"]
]
],
"BlockStatement",
1935,
1,
0,
0,
[
"Binary",
1935,
1,
0,
["Ident", 1935, 8, 0, "result"],
"=",
"Arr",
1935,
17,
0
],
[
"IfStatement",
1936,
1,
0,
0,
[
"Binary",
724,
9,
0,
["Ident", 1936, 7, 0, "step"],
">",
"Const",
1936,
15,
0,
0
],
[
"BlockStatement",
1937,
1,
0,
0,
[
"Binary",
1937,
1,
0,
["Ident", 1937, 18, 0, "i"],
"=",
"Const",
1937,
23,
0,
0
],
[
"Binary",
1938,
1,
0,
["Ident", 1938, 10, 0, "len"],
"=",
"Call",
516,
11,
0,
["Ident", 516, 11, 0, "__num"],
0,
[
"Binary",
1938,
18,
0,
["Ident", 1938, 18, 0, "array"],
".",
"Const",
1938,
24,
0,
"length"
]
],
[
"For",
1071,
1,
0,
0,
0,
[
"Binary",
688,
13,
0,
["Ident", 1939, 12, 0, "i"],
"<",
"Ident",
1939,
16,
0,
"len"
],
[
"Binary",
862,
11,
0,
["Ident", 1939, 21, 0, "i"],
"+=",
"Ident",
1939,
26,
0,
"step"
],
"Call",
1940,
1,
0,
[
"Binary",
1940,
1,
0,
["Ident", 1940, 1, 0, "result"],
".",
"Const",
1940,
16,
0,
"push"
],
0,
[
"Binary",
1940,
21,
0,
["Ident", 1940, 21, 0, "array"],
".",
"Ident",
1940,
27,
0,
"i"
]
]
],
"BlockStatement",
1942,
1,
0,
0,
[
"Binary",
1942,
1,
0,
["Ident", 1942, 18, 0, "i"],
"=",
"Binary",
548,
9,
0,
[
"Call",
516,
11,
0,
["Ident", 516, 11, 0, "__num"],
0,
[
"Binary",
1942,
22,
0,
["Ident", 1942, 22, 0, "array"],
".",
"Const",
1942,
29,
0,
"length"
]
],
"-",
"Const",
1942,
38,
0,
1
],
[
"For",
1071,
1,
0,
0,
0,
[
"Binary",
726,
9,
0,
["Ident", 1943, 12, 0, "i"],
">=",
"Const",
1943,
18,
0,
0
],
[
"Binary",
862,
11,
0,
["Ident", 1943, 20, 0, "i"],
"+=",
"Ident",
1943,
25,
0,
"step"
],
"Call",
1944,
1,
0,
[
"Binary",
1944,
1,
0,
["Ident", 1944, 1, 0, "result"],
".",
"Const",
1944,
16,
0,
"push"
],
0,
[
"Binary",
1944,
21,
0,
["Ident", 1944, 21, 0, "array"],
".",
"Ident",
1944,
27,
0,
"i"
]
]
],
[
"Return",
1945,
1,
0,
"Ident",
1945,
1,
0,
"result"
]
]
],
type: {type: "generic", base: "functionBase", args: ["array"]},
dependencies: ["__num", "__slice", "__step", "__toArray", "__typeof"]
},
__sliceStep: {
helper: [
"Func",
1947,
31,
0,
0,
[
["Ident", 1947, 32, 0, "array"],
["Ident", 1947, 38, 0, "start"],
["Ident", 1947, 45, 0, "end"],
["Ident", 1947, 58, 0, "step"],
["Ident", 1947, 64, 0, "inclusive"]
],
["arr"],
[],
"BlockStatement",
1948,
1,
0,
0,
[
"IfStatement",
1948,
12,
0,
0,
[
"Binary",
1948,
15,
0,
["Ident", 1948, 15, 0, "step"],
"<",
"Const",
1948,
24,
0,
0
],
[
"Binary",
1948,
1,
0,
["Ident", 1948, 6, 0, "arr"],
"=",
"Call",
1949,
1,
0,
[
"Binary",
1949,
1,
0,
["Ident", 1949, 1, 0, "__slice"],
".",
"Const",
1949,
1,
0,
"call"
],
0,
["Ident", 1949, 14, 0, "array"],
[
"IfExpression",
1949,
20,
0,
["Ident", 1949, 23, 0, "inclusive"],
["Ident", 1949, 38, 0, "end"],
"Binary",
1949,
47,
0,
[
"Unary",
360,
21,
0,
"+",
"Ident",
1949,
47,
0,
"end"
],
"+",
"Const",
1949,
55,
0,
1
],
[
"Binary",
1949,
57,
0,
[
"Binary",
1949,
57,
0,
[
"Unary",
360,
21,
0,
"+",
"Ident",
1949,
57,
0,
"start"
],
"+",
"Const",
1949,
67,
0,
1
],
"||",
"Const",
1949,
71,
0,
1,
1
]
],
"Binary",
1948,
1,
0,
["Ident", 1948, 6, 0, "arr"],
"=",
"Call",
1951,
1,
0,
[
"Binary",
1951,
1,
0,
["Ident", 1951, 1, 0, "__slice"],
".",
"Const",
1951,
1,
0,
"call"
],
0,
["Ident", 1951, 14, 0, "array"],
["Ident", 1951, 20, 0, "start"],
[
"IfExpression",
1951,
27,
0,
["Ident", 1951, 30, 0, "inclusive"],
[
"Binary",
1951,
45,
0,
[
"Binary",
1951,
45,
0,
[
"Unary",
360,
21,
0,
"+",
"Ident",
1951,
45,
0,
"end"
],
"+",
"Const",
1951,
53,
0,
1
],
"||",
"Const",
1951,
57,
0,
1,
1
],
"Ident",
1951,
71,
0,
"end"
]
],
[
"IfStatement",
1952,
1,
0,
0,
[
"Binary",
1952,
5,
0,
["Ident", 1952, 5, 0, "step"],
"===",
"Const",
1952,
14,
0,
1
],
[
"Return",
1953,
1,
0,
"Ident",
1953,
1,
0,
"arr"
],
"IfStatement",
1952,
1,
0,
0,
[
"Binary",
1954,
10,
0,
["Ident", 1954, 10, 0, "step"],
"===",
"Const",
1954,
18,
0,
-1
],
[
"Return",
1955,
1,
0,
"Call",
1955,
1,
0,
[
"Binary",
1955,
1,
0,
["Ident", 1955, 1, 0, "arr"],
".",
"Const",
1955,
9,
0,
"reverse"
],
0
],
"Return",
1957,
1,
0,
"Call",
1957,
1,
0,
["Ident", 1957, 1, 0, "__step"],
0,
["Ident", 1957, 12, 0, "arr"],
["Ident", 1957, 16, 0, "step"]
]
],
type: {type: "generic", base: "functionBase", args: ["array"]},
dependencies: ["__slice", "__sliceStep", "__step"]
},
__arrayToIter: {
helper: [
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
["proto"],
[],
"BlockStatement",
2057,
1,
0,
0,
[
"Binary",
2057,
1,
0,
["Ident", 2057, 6, 0, "proto"],
"=",
"Obj",
2057,
14,
0,
2058,
5,
null,
"iterator",
[
"Func",
2058,
16,
0,
0,
[],
[],
[],
"Return",
2058,
18,
0,
"This",
2058,
18,
0
],
2059,
5,
null,
"next",
[
"Func",
2059,
12,
0,
0,
[],
["array", "i"],
[],
"BlockStatement",
2060,
1,
0,
0,
[
"Binary",
2060,
1,
0,
["Ident", 2060, 10, 0, "i"],
"=",
"Binary",
546,
9,
0,
[
"Call",
516,
11,
0,
["Ident", 516, 11, 0, "__num"],
0,
[
"Binary",
2060,
14,
0,
["This", 2060, 14, 0],
".",
"Const",
2060,
16,
0,
"index"
]
],
"+",
"Const",
2060,
24,
0,
1
],
[
"Binary",
2061,
1,
0,
["Ident", 2061, 10, 0, "array"],
"=",
"Binary",
2061,
18,
0,
["This", 2061, 18, 0],
".",
"Const",
2061,
20,
0,
"array"
],
[
"IfStatement",
2062,
1,
0,
0,
[
"Binary",
726,
9,
0,
["Ident", 2062, 9, 0, "i"],
">=",
"Call",
693,
22,
0,
["Ident", 693, 22, 0, "__num"],
0,
[
"Binary",
2062,
14,
0,
["Ident", 2062, 14, 0, "array"],
".",
"Const",
2062,
21,
0,
"length"
]
],
[
"Return",
2063,
1,
0,
"Obj",
2063,
1,
0,
2063,
11,
null,
"done",
["Const", 2063, 16, 0, true],
2063,
22,
null,
"value",
["Const", 2063, 29, 0]
],
"BlockStatement",
2065,
1,
0,
0,
[
"Binary",
2065,
1,
0,
[
"Binary",
2065,
1,
0,
["This", 2065, 1, 0],
".",
"Const",
2065,
10,
0,
"index"
],
"=",
"Ident",
2065,
18,
0,
"i"
],
[
"Return",
2066,
1,
0,
"Obj",
2066,
1,
0,
2066,
11,
null,
"done",
["Const", 2066, 16, 0, false],
2066,
23,
null,
"value",
[
"Binary",
2066,
30,
0,
["Ident", 2066, 30, 0, "array"],
".",
"Ident",
2066,
37,
0,
"i"
]
]
]
]
],
[
"Return",
1855,
1,
0,
"Func",
1855,
1,
0,
0,
[["Ident", 2068, 5, 0, "array"]],
["_o"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Unary",
624,
18,
0,
"!",
"Call",
140,
146,
0,
["Ident", 140, 146, 0, "__isArray"],
0,
["Ident", 2068, 5, 0, "array"]
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected array to be an Array, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2068, 5, 0, "array"]
]
]
],
[
"Binary",
2069,
1,
0,
["Ident", 2069, 1, 0, "_o"],
"=",
"Call",
2069,
1,
0,
["Ident", 2069, 1, 0, "__create"],
0,
["Ident", 2069, 14, 0, "proto"]
],
[
"Binary",
2070,
7,
0,
[
"Binary",
2070,
7,
0,
["Ident", 2069, 1, 0, "_o"],
".",
"Const",
2070,
7,
0,
"array"
],
"=",
"Ident",
2070,
7,
0,
"array"
],
[
"Binary",
2071,
7,
0,
[
"Binary",
2071,
7,
0,
["Ident", 2069, 1, 0, "_o"],
".",
"Const",
2071,
7,
0,
"index"
],
"=",
"Const",
2071,
13,
0,
-1
],
[
"Return",
2069,
1,
0,
"Ident",
2069,
1,
0,
"_o"
]
]
],
0
],
type: {
type: "generic",
base: "functionBase",
args: [{
type: "object",
pairs: {array: "array", index: "number"}
}]
},
dependencies: ["__arrayToIter", "__create", "__isArray", "__num", "__typeof"]
},
__iter: {
helper: [
"Func",
2074,
25,
0,
0,
[["Ident", 2074, 26, 0, "iterable"]],
[],
[],
"IfStatement",
2075,
1,
0,
0,
[
"Binary",
2075,
5,
0,
["Ident", 2075, 9, 0, "iterable"],
"==",
"Const",
113,
19,
0,
null
],
[
"Throw",
2076,
1,
0,
"Call",
2076,
10,
0,
["Ident", 2076, 10, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 2076, 21, 0, "Expected iterable to be an Object, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2076, 70, 0, "iterable"]
]
],
"IfStatement",
2075,
1,
0,
0,
[
"Call",
140,
146,
0,
["Ident", 140, 146, 0, "__isArray"],
0,
["Ident", 2077, 20, 0, "iterable"]
],
[
"Return",
2078,
1,
0,
"Call",
2078,
1,
0,
["Ident", 2078, 1, 0, "__arrayToIter"],
0,
["Ident", 2078, 21, 0, "iterable"]
],
"IfStatement",
2075,
1,
0,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
2079,
23,
0,
["Ident", 2079, 23, 0, "iterable"],
".",
"Const",
2079,
33,
0,
"iterator"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Return",
2080,
1,
0,
"Call",
2080,
1,
0,
[
"Binary",
2080,
1,
0,
["Ident", 2080, 1, 0, "iterable"],
".",
"Const",
2080,
14,
0,
"iterator"
],
0
],
"IfStatement",
2075,
1,
0,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
2081,
23,
0,
["Ident", 2081, 23, 0, "iterable"],
".",
"Const",
2081,
33,
0,
"next"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Return",
2082,
1,
0,
"Ident",
2082,
1,
0,
"iterable"
],
"Throw",
2084,
1,
0,
"Call",
2084,
10,
0,
["Ident", 2084, 10, 0, "Error"],
0,
[
"Binary",
573,
7,
0,
[
"Const",
2084,
17,
0,
"Expected iterable to be an Array or an Object with an 'iterator' function or an Object with a 'next' function, got "
],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2084, 142, 0, "iterable"]
]
],
type: "function",
dependencies: ["__arrayToIter", "__isArray", "__iter", "__typeof"]
},
__keys: {
helper: [
"IfExpression",
2253,
23,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
2253,
39,
0,
["Ident", 2253, 39, 0, "Object"],
".",
"Const",
2253,
47,
0,
"keys"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Binary",
2254,
1,
0,
["Ident", 2254, 1, 0, "Object"],
".",
"Const",
2254,
10,
0,
"keys"
],
"Func",
2256,
4,
0,
0,
[["Ident", 2256, 5, 0, "x"]],
["key", "keys"],
[],
"BlockStatement",
2257,
1,
0,
0,
[
"Binary",
2257,
1,
0,
["Ident", 2257, 8, 0, "keys"],
"=",
"Arr",
2257,
15,
0
],
[
"ForIn",
2258,
1,
0,
0,
["Ident", 2258, 8, 0, "key"],
["Ident", 2258, 15, 0, "x"],
"IfStatement",
1525,
1,
0,
0,
[
"Call",
611,
7,
0,
[
"Binary",
611,
7,
0,
["Ident", 611, 7, 0, "__owns"],
".",
"Const",
611,
7,
0,
"call"
],
0,
["Ident", 2258, 15, 0, "x"],
["Ident", 2258, 8, 0, "key"]
],
[
"Call",
2259,
1,
0,
[
"Binary",
2259,
1,
0,
["Ident", 2259, 1, 0, "keys"],
".",
"Const",
2259,
12,
0,
"push"
],
0,
["Ident", 2259, 17, 0, "key"]
]
],
[
"Return",
2260,
1,
0,
"Ident",
2260,
1,
0,
"keys"
]
],
type: "any",
dependencies: ["__keys", "__owns"]
},
__allkeys: {
helper: [
"Func",
2265,
28,
0,
0,
[["Ident", 2265, 29, 0, "x"]],
["key", "keys"],
[],
"BlockStatement",
2266,
1,
0,
0,
[
"Binary",
2266,
1,
0,
["Ident", 2266, 6, 0, "keys"],
"=",
"Arr",
2266,
13,
0
],
[
"ForIn",
2267,
1,
0,
0,
["Ident", 2267, 6, 0, "key"],
["Ident", 2267, 16, 0, "x"],
"Call",
2268,
1,
0,
[
"Binary",
2268,
1,
0,
["Ident", 2268, 1, 0, "keys"],
".",
"Const",
2268,
10,
0,
"push"
],
0,
["Ident", 2268, 15, 0, "key"]
],
[
"Return",
2269,
1,
0,
"Ident",
2269,
1,
0,
"keys"
]
],
type: {type: "generic", base: "functionBase", args: ["stringArray"]},
dependencies: ["__allkeys"]
},
__new: {
helper: [
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
["newCreators"],
[],
"BlockStatement",
2275,
1,
0,
0,
[
"Binary",
2275,
1,
0,
["Ident", 2275, 6, 0, "newCreators"],
"=",
"Arr",
2275,
21,
0
],
[
"Return",
2276,
4,
0,
"Func",
2276,
4,
0,
0,
[],
["creator", "func", "i", "length"],
[],
"BlockStatement",
2277,
1,
0,
0,
[
"IfStatement",
2277,
1,
0,
0,
[
"Binary",
2277,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"This",
2277,
24,
0
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
2278,
1,
0,
"Call",
2278,
12,
0,
["Ident", 2278, 12, 0, "Error"],
0,
[
"Binary",
573,
7,
0,
["Const", 2278, 19, 0, "Expected this to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["This", 2278, 65, 0]
]
]
],
[
"Binary",
2279,
1,
0,
["Ident", 2279, 8, 0, "length"],
"=",
"Binary",
2279,
17,
0,
["Arguments", 2279, 17, 0],
".",
"Const",
2279,
28,
0,
"length"
],
[
"Binary",
2280,
1,
0,
["Ident", 2280, 16, 0, "creator"],
"=",
"Binary",
2280,
26,
0,
["Ident", 2280, 26, 0, "newCreators"],
".",
"Ident",
2280,
40,
0,
"length"
],
[
"IfStatement",
2281,
1,
0,
0,
[
"Unary",
2281,
7,
0,
"!",
"Ident",
2281,
11,
0,
"creator"
],
[
"BlockStatement",
2282,
1,
0,
0,
[
"Binary",
2282,
1,
0,
["Ident", 2282, 10, 0, "func"],
"=",
"Arr",
2282,
17,
0,
["Const", 2282, 19, 0, "return new C("]
],
[
"For",
1231,
1,
0,
0,
[
"BlockExpression",
0,
0,
0,
[
"Binary",
1141,
38,
0,
["Ident", 2283, 10, 0, "i"],
"=",
"Const",
2283,
16,
0,
0
],
["Ident", 2283, 21, 0, "length"]
],
[
"Binary",
1167,
57,
0,
["Ident", 2283, 10, 0, "i"],
"<",
"Ident",
2283,
21,
0,
"length"
],
[
"Unary",
1179,
35,
0,
"++",
"Ident",
2283,
10,
0,
"i"
],
"BlockStatement",
2284,
1,
0,
0,
[
"IfStatement",
2284,
1,
0,
0,
[
"Binary",
724,
9,
0,
["Ident", 2284, 11, 0, "i"],
">",
"Const",
2284,
16,
0,
0
],
[
"Call",
2285,
1,
0,
[
"Binary",
2285,
1,
0,
["Ident", 2285, 1, 0, "func"],
".",
"Const",
2285,
16,
0,
"push"
],
0,
["Const", 2285, 21, 0, ", "]
]
],
[
"Call",
2286,
1,
0,
[
"Binary",
2286,
1,
0,
["Ident", 2286, 1, 0, "func"],
".",
"Const",
2286,
14,
0,
"push"
],
0,
["Const", 2286, 19, 0, "a["],
["Ident", 2286, 24, 0, "i"],
["Const", 2286, 28, 0, "]"]
]
],
[
"Call",
2287,
1,
0,
[
"Binary",
2287,
1,
0,
["Ident", 2287, 1, 0, "func"],
".",
"Const",
2287,
12,
0,
"push"
],
0,
["Const", 2287, 17, 0, ");"]
],
[
"Binary",
2288,
1,
0,
["Ident", 2288, 1, 0, "creator"],
"=",
"Call",
2288,
17,
0,
["Ident", 2288, 17, 0, "Function"],
0,
["Const", 2288, 27, 0, "C"],
["Const", 2288, 32, 0, "a"],
[
"Call",
2288,
36,
0,
[
"Binary",
2288,
36,
0,
["Ident", 2288, 36, 0, "func"],
".",
"Const",
2288,
42,
0,
"join"
],
0,
["Const", 2288, 47, 0, ""]
]
],
[
"Binary",
2289,
1,
0,
[
"Binary",
2289,
1,
0,
["Ident", 2289, 1, 0, "newCreators"],
".",
"Ident",
2289,
20,
0,
"length"
],
"=",
"Ident",
2289,
30,
0,
"creator"
]
]
],
[
"Return",
2290,
1,
0,
"Call",
2290,
1,
0,
["Ident", 2290, 1, 0, "creator"],
0,
["This", 2290, 13, 0],
["Arguments", 2290, 18, 0]
]
]
],
0
],
type: "function",
dependencies: ["__new", "__typeof"]
},
__instanceofsome: {
helper: [
"Func",
2292,
35,
0,
0,
[
["Ident", 2292, 36, 0, "value"],
["Ident", 2292, 42, 0, "array"]
],
[],
[],
"Return",
9,
9,
0,
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
["_arr", "_i", "item"],
[],
"BlockStatement",
0,
0,
0,
0,
[
"For",
1431,
13,
0,
0,
[
"BlockExpression",
0,
0,
0,
[
"Binary",
2293,
1,
0,
["Ident", 2293, 1, 0, "_arr"],
"=",
"Call",
1295,
22,
0,
["Ident", 1295, 22, 0, "__toArray"],
0,
["Ident", 2293, 19, 0, "array"]
],
[
"Binary",
1334,
26,
0,
["Ident", 2293, 1, 0, "_i"],
"=",
"Binary",
1334,
49,
0,
["Ident", 2293, 1, 0, "_arr"],
".",
"Const",
1334,
56,
0,
"length"
]
],
[
"Unary",
1335,
16,
0,
"--post",
"Ident",
2293,
1,
0,
"_i"
],
0,
"BlockStatement",
1417,
1,
0,
0,
[
"Binary",
1417,
1,
0,
["Ident", 2293, 11, 0, "item"],
"=",
"Binary",
1298,
75,
0,
["Ident", 2293, 1, 0, "_arr"],
".",
"Ident",
2293,
1,
0,
"_i"
],
[
"IfStatement",
990,
1,
0,
0,
[
"Binary",
2294,
1,
0,
["Ident", 2294, 1, 0, "value"],
"instanceof",
"Ident",
2294,
21,
0,
"item"
],
[
"Return",
991,
1,
0,
"Const",
991,
21,
0,
true
]
]
],
[
"Return",
992,
57,
0,
"Const",
992,
64,
0,
false
]
],
0
],
type: {type: "generic", base: "functionBase", args: ["boolean"]},
dependencies: ["__instanceofsome", "__toArray"]
},
__getInstanceof: {
helper: [
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
[],
[],
"BlockStatement",
2297,
1,
0,
0,
[
"Func",
2297,
1,
0,
["Ident", 2297, 6, 0, "isAny"],
[],
[],
[],
"Return",
2297,
19,
0,
"Const",
2297,
19,
0,
true
],
[
"Func",
2298,
1,
0,
["Ident", 2298, 6, 0, "isStr"],
[["Ident", 2298, 17, 0, "x"]],
[],
[],
"Return",
128,
7,
0,
"Binary",
128,
7,
0,
[
"Unary",
128,
7,
0,
"typeof",
"Ident",
2298,
17,
0,
"x"
],
"===",
"Const",
128,
25,
0,
"string"
],
[
"Func",
2299,
1,
0,
["Ident", 2299, 6, 0, "isNum"],
[["Ident", 2299, 17, 0, "x"]],
[],
[],
"Return",
131,
7,
0,
"Binary",
131,
7,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
2299,
17,
0,
"x"
],
"===",
"Const",
131,
25,
0,
"number"
],
[
"Func",
2300,
1,
0,
["Ident", 2300, 6, 0, "isFunc"],
[["Ident", 2300, 18, 0, "x"]],
[],
[],
"Return",
137,
7,
0,
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
2300,
18,
0,
"x"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Func",
2301,
1,
0,
["Ident", 2301, 6, 0, "isBool"],
[["Ident", 2301, 18, 0, "x"]],
[],
[],
"Return",
134,
7,
0,
"Binary",
134,
7,
0,
[
"Unary",
134,
7,
0,
"typeof",
"Ident",
2301,
18,
0,
"x"
],
"===",
"Const",
134,
25,
0,
"boolean"
],
[
"Return",
2302,
4,
0,
"Func",
2302,
4,
0,
0,
[["Ident", 2302, 5, 0, "ctor"]],
[],
[],
"IfStatement",
2303,
1,
0,
0,
[
"Binary",
2303,
7,
0,
["Ident", 2303, 11, 0, "ctor"],
"==",
"Const",
113,
19,
0,
null
],
[
"Return",
2304,
1,
0,
"Ident",
2304,
1,
0,
"isAny"
],
"Switch",
2306,
1,
0,
0,
["Ident", 2306, 13, 0, "ctor"],
2307,
11,
null,
["Ident", 2307, 11, 0, "String"],
[
"Return",
2307,
19,
0,
"Ident",
2307,
19,
0,
"isStr"
],
2308,
11,
null,
["Ident", 2308, 11, 0, "Number"],
[
"Return",
2308,
19,
0,
"Ident",
2308,
19,
0,
"isNum"
],
2309,
11,
null,
["Ident", 2309, 11, 0, "Function"],
[
"Return",
2309,
21,
0,
"Ident",
2309,
21,
0,
"isFunc"
],
2310,
11,
null,
["Ident", 2310, 11, 0, "Boolean"],
[
"Return",
2310,
20,
0,
"Ident",
2310,
20,
0,
"isBool"
],
2311,
11,
null,
["Ident", 2311, 11, 0, "Array"],
[
"Return",
2311,
18,
0,
"Ident",
2311,
18,
0,
"__isArray"
],
2312,
11,
null,
["Ident", 2312, 11, 0, "Object"],
[
"Return",
2312,
19,
0,
"Ident",
2312,
19,
0,
"__isObject"
],
[
"Return",
2313,
17,
0,
"Func",
2313,
17,
0,
0,
[["Ident", 2313, 17, 0, "_x"]],
[],
[],
"Return",
2313,
17,
0,
"Binary",
2313,
17,
0,
["Ident", 2313, 17, 0, "_x"],
"instanceof",
"Ident",
2313,
27,
0,
"ctor"
]
]
],
0
],
type: {
type: "generic",
base: "functionBase",
args: [{type: "generic", base: "functionBase", args: ["boolean"]}]
},
dependencies: ["__getInstanceof", "__isArray", "__isObject"]
},
__name: {
helper: [
"Func",
1855,
1,
0,
0,
[["Ident", 2315, 26, 0, "func"]],
[],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
2315,
26,
0,
"func"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected func to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2315, 26, 0, "func"]
]
]
],
[
"Return",
2315,
50,
0,
"Binary",
2315,
50,
0,
[
"Binary",
2315,
50,
0,
[
"Binary",
2315,
50,
0,
["Ident", 2315, 50, 0, "func"],
".",
"Const",
2315,
56,
0,
"displayName"
],
"||",
"Binary",
2315,
71,
0,
["Ident", 2315, 71, 0, "func"],
".",
"Const",
2315,
77,
0,
"name"
],
"||",
"Const",
2315,
85,
0,
""
]
],
type: {type: "generic", base: "functionBase", args: ["string"]},
dependencies: ["__name", "__typeof"]
},
__once: {
helper: [
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
[],
[],
"BlockStatement",
2318,
1,
0,
0,
[
"Func",
2318,
1,
0,
["Ident", 2318, 6, 0, "replacement"],
[],
[],
[],
"Throw",
2318,
23,
0,
"Call",
2318,
29,
0,
["Ident", 2318, 29, 0, "Error"],
0,
["Const", 2318, 36, 0, "Attempted to call function more than once"]
],
[
"Func",
2319,
1,
0,
["Ident", 2319, 6, 0, "doNothing"],
[],
[],
[]
],
[
"Return",
1855,
1,
0,
"Func",
1855,
1,
0,
0,
[
["Ident", 2320, 12, 0, "func"],
["Ident", 2320, 24, 0, "silentFail"]
],
[],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
2320,
12,
0,
"func"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected func to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2320, 12, 0, "func"]
]
]
],
[
"IfStatement",
1646,
13,
0,
0,
[
"Binary",
1646,
16,
0,
["Ident", 2320, 24, 0, "silentFail"],
"==",
"Const",
113,
19,
0,
null
],
[
"Binary",
1647,
1,
0,
["Ident", 2320, 24, 0, "silentFail"],
"=",
"Const",
1647,
20,
0,
false
],
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
620,
18,
0,
[
"Unary",
134,
7,
0,
"typeof",
"Ident",
2320,
24,
0,
"silentFail"
],
"!==",
"Const",
134,
25,
0,
"boolean"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected silentFail to be a Boolean, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2320, 24, 0, "silentFail"]
]
]
],
[
"Return",
2320,
53,
0,
"Func",
2320,
53,
0,
0,
[],
["f"],
[],
"BlockStatement",
2321,
1,
0,
0,
[
"Binary",
2321,
1,
0,
["Ident", 2321, 8, 0, "f"],
"=",
"Ident",
2321,
12,
0,
"func"
],
[
"Binary",
2322,
1,
0,
["Ident", 2322, 1, 0, "func"],
"=",
"IfExpression",
2322,
12,
0,
["Ident", 2322, 15, 0, "silentFail"],
["Ident", 2322, 32, 0, "doNothing"],
"Ident",
2322,
48,
0,
"replacement"
],
[
"Return",
2323,
1,
0,
"Call",
2323,
1,
0,
[
"Binary",
2323,
1,
0,
["Ident", 2323, 1, 0, "f"],
".",
"Const",
2323,
1,
0,
"apply"
],
0,
["This", 2323, 8, 0],
["Arguments", 2323, 17, 0]
]
]
]
],
0
],
type: {type: "generic", base: "functionBase", args: ["function"]},
dependencies: ["__once", "__toArray", "__typeof"]
},
__async: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 2425, 34, 0, "limit"],
["Ident", 2425, 51, 0, "length"],
["Ident", 2425, 69, 0, "hasResult"],
["Ident", 2425, 92, 0, "onValue"],
["Ident", 2425, 108, 0, "onComplete"]
],
["broken", "completed", "index", "result", "slotsUsed", "sync"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
2425,
34,
0,
"limit"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected limit to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2425, 34, 0, "limit"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
2425,
51,
0,
"length"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected length to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2425, 51, 0, "length"]
]
]
],
[
"IfStatement",
1646,
13,
0,
0,
[
"Binary",
1646,
16,
0,
["Ident", 2425, 69, 0, "hasResult"],
"==",
"Const",
113,
19,
0,
null
],
[
"Binary",
1647,
1,
0,
["Ident", 2425, 69, 0, "hasResult"],
"=",
"Const",
1647,
20,
0,
false
],
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
620,
18,
0,
[
"Unary",
134,
7,
0,
"typeof",
"Ident",
2425,
69,
0,
"hasResult"
],
"!==",
"Const",
134,
25,
0,
"boolean"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected hasResult to be a Boolean, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2425, 69, 0, "hasResult"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
2425,
92,
0,
"onValue"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected onValue to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2425, 92, 0, "onValue"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
2425,
108,
0,
"onComplete"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected onComplete to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2425, 108, 0, "onComplete"]
]
]
],
[
"IfStatement",
2426,
15,
0,
0,
["Ident", 2426, 18, 0, "hasResult"],
[
"Binary",
2426,
1,
0,
["Ident", 2426, 6, 0, "result"],
"=",
"Arr",
2426,
34,
0
],
"Binary",
2426,
1,
0,
["Ident", 2426, 6, 0, "result"],
"=",
"Const",
2426,
42,
0,
null
],
[
"IfStatement",
2427,
1,
0,
0,
[
"Binary",
2427,
5,
0,
["Ident", 2427, 5, 0, "length"],
"<=",
"Const",
2427,
17,
0,
0
],
[
"Return",
2428,
1,
0,
"Call",
2428,
11,
0,
["Ident", 2428, 11, 0, "onComplete"],
0,
["Const", 2428, 24, 0, null],
["Ident", 2428, 29, 0, "result"]
]
],
[
"IfStatement",
2429,
1,
0,
0,
[
"Binary",
2429,
5,
0,
[
"Binary",
2429,
5,
0,
["Ident", 2429, 5, 0, "limit"],
"<",
"Const",
2429,
15,
0,
1
],
"||",
"Binary",
43,
7,
0,
["Ident", 2429, 19, 0, "limit"],
"!==",
"Ident",
2429,
28,
0,
"limit"
],
[
"Binary",
2430,
1,
0,
["Ident", 2430, 1, 0, "limit"],
"=",
"Const",
2430,
13,
0,
1,
1
]
],
[
"Binary",
2432,
1,
0,
["Ident", 2432, 14, 0, "broken"],
"=",
"Const",
2432,
23,
0,
null
],
[
"Binary",
2433,
1,
0,
["Ident", 2433, 14, 0, "slotsUsed"],
"=",
"Const",
2433,
28,
0,
0
],
[
"Binary",
2434,
1,
0,
["Ident", 2434, 14, 0, "sync"],
"=",
"Const",
2434,
21,
0,
false
],
[
"Binary",
2435,
1,
0,
["Ident", 2435, 14, 0, "completed"],
"=",
"Const",
2435,
26,
0,
false
],
[
"Func",
2436,
1,
0,
["Ident", 2436, 6, 0, "onValueCallback"],
[
["Ident", 2436, 25, 0, "err"],
["Ident", 2436, 29, 0, "value"]
],
[],
[],
"BlockStatement",
2437,
1,
0,
0,
[
"IfStatement",
2437,
1,
0,
0,
["Ident", 2437, 7, 0, "completed"],
[
"Return",
2438,
1,
0,
"Const",
2438,
1,
0
]
],
[
"Unary",
2439,
1,
0,
"--",
"Ident",
2439,
1,
0,
"slotsUsed"
],
[
"IfStatement",
2440,
1,
0,
0,
[
"Binary",
2440,
7,
0,
[
"Binary",
49,
7,
0,
["Ident", 2440, 7, 0, "err"],
"!=",
"Const",
113,
19,
0,
null
],
"&&",
"Binary",
2440,
16,
0,
["Ident", 2440, 20, 0, "broken"],
"==",
"Const",
113,
19,
0,
null
],
[
"Binary",
2441,
1,
0,
["Ident", 2441, 1, 0, "broken"],
"=",
"Ident",
2441,
16,
0,
"err"
]
],
[
"IfStatement",
2442,
1,
0,
0,
[
"Binary",
2442,
7,
0,
[
"Binary",
2442,
7,
0,
["Ident", 2442, 7, 0, "hasResult"],
"&&",
"Binary",
2442,
22,
0,
["Ident", 2442, 26, 0, "broken"],
"==",
"Const",
113,
19,
0,
null
],
"&&",
"Binary",
57,
23,
0,
[
"Binary",
2442,
38,
0,
["Arguments", 2442, 38, 0],
".",
"Const",
2442,
49,
0,
"length"
],
">",
"Const",
2442,
59,
0,
1
],
[
"Call",
2443,
1,
0,
[
"Binary",
2443,
1,
0,
["Ident", 2443, 1, 0, "result"],
".",
"Const",
2443,
14,
0,
"push"
],
0,
["Ident", 2443, 19, 0, "value"]
]
],
[
"IfStatement",
2444,
1,
0,
0,
[
"Unary",
2444,
7,
0,
"!",
"Ident",
2444,
11,
0,
"sync"
],
[
"Call",
2445,
1,
0,
["Ident", 2445, 1, 0, "next"],
0
]
]
],
[
"Binary",
2446,
1,
0,
["Ident", 2446, 14, 0, "index"],
"=",
"Const",
2446,
22,
0,
-1
],
[
"Func",
2447,
1,
0,
["Ident", 2447, 6, 0, "next"],
[],
[],
[],
"BlockStatement",
2448,
1,
0,
0,
[
"For",
1071,
1,
0,
0,
0,
[
"Binary",
2448,
10,
0,
[
"Binary",
2448,
10,
0,
[
"Binary",
2448,
10,
0,
[
"Unary",
2448,
10,
0,
"!",
"Ident",
2448,
14,
0,
"completed"
],
"&&",
"Binary",
2448,
28,
0,
["Ident", 2448, 32, 0, "broken"],
"==",
"Const",
113,
19,
0,
null
],
"&&",
"Binary",
2448,
44,
0,
["Ident", 2448, 44, 0, "slotsUsed"],
"<",
"Ident",
2448,
58,
0,
"limit"
],
"&&",
"Binary",
2448,
68,
0,
[
"Unary",
862,
11,
0,
"++",
"Ident",
2448,
70,
0,
"index"
],
"<",
"Ident",
2448,
84,
0,
"length"
],
0,
"BlockStatement",
2449,
1,
0,
0,
[
"Unary",
2449,
1,
0,
"++",
"Ident",
2449,
1,
0,
"slotsUsed"
],
[
"Binary",
2450,
1,
0,
["Ident", 2450, 1, 0, "sync"],
"=",
"Const",
2450,
14,
0,
true
],
[
"Call",
2451,
1,
0,
["Ident", 2451, 1, 0, "onValue"],
0,
["Ident", 2451, 16, 0, "index"],
[
"Call",
2351,
11,
0,
["Ident", 2351, 11, 0, "__once"],
0,
["Ident", 2451, 29, 0, "onValueCallback"]
]
],
[
"Binary",
2452,
1,
0,
["Ident", 2452, 1, 0, "sync"],
"=",
"Const",
2452,
14,
0,
false
]
],
[
"IfStatement",
2453,
1,
0,
0,
[
"Binary",
2453,
7,
0,
[
"Unary",
2453,
7,
0,
"!",
"Ident",
2453,
11,
0,
"completed"
],
"&&",
"Binary",
2453,
27,
0,
[
"Binary",
49,
7,
0,
["Ident", 2453, 27, 0, "broken"],
"!=",
"Const",
113,
19,
0,
null
],
"||",
"Binary",
2453,
37,
0,
["Ident", 2453, 37, 0, "slotsUsed"],
"===",
"Const",
2453,
52,
0,
0
],
[
"BlockStatement",
2454,
1,
0,
0,
[
"Binary",
2454,
1,
0,
["Ident", 2454, 1, 0, "completed"],
"=",
"Const",
2454,
19,
0,
true
],
[
"IfStatement",
2455,
1,
0,
0,
[
"Binary",
49,
7,
0,
["Ident", 2455, 9, 0, "broken"],
"!=",
"Const",
113,
19,
0,
null
],
[
"Call",
2456,
1,
0,
["Ident", 2456, 1, 0, "onComplete"],
0,
["Ident", 2456, 21, 0, "broken"]
],
"Call",
2458,
1,
0,
["Ident", 2458, 1, 0, "onComplete"],
0,
["Const", 2458, 21, 0, null],
["Ident", 2458, 26, 0, "result"]
]
]
]
],
[
"Call",
2459,
1,
0,
["Ident", 2459, 1, 0, "next"],
0
]
],
type: "function",
dependencies: ["__async", "__once", "__typeof"]
},
__asyncIter: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 2461, 39, 0, "limit"],
["Ident", 2461, 56, 0, "iterator"],
["Ident", 2461, 86, 0, "hasResult"],
["Ident", 2461, 109, 0, "onValue"],
["Ident", 2461, 125, 0, "onComplete"]
],
[
"broken",
"close",
"completed",
"index",
"iterStopped",
"result",
"slotsUsed",
"sync"
],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
2461,
39,
0,
"limit"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected limit to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2461, 39, 0, "limit"]
]
]
],
[
"IfStatement",
1728,
10,
0,
0,
[
"Binary",
1728,
13,
0,
[
"Binary",
143,
47,
0,
[
"Unary",
143,
47,
0,
"typeof",
"Ident",
2461,
56,
0,
"iterator"
],
"!==",
"Const",
143,
62,
0,
"object"
],
"||",
"Binary",
143,
72,
0,
["Ident", 2461, 56, 0, "iterator"],
"===",
"Const",
143,
78,
0,
null
],
[
"Throw",
1729,
1,
0,
"Call",
1729,
14,
0,
["Ident", 1729, 14, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected iterator to be an Object, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2461, 56, 0, "iterator"]
]
],
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
1727,
35,
0,
["Ident", 2461, 56, 0, "iterator"],
".",
"Const",
2461,
70,
0,
"next"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected iterator.next to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
[
"Binary",
1727,
35,
0,
["Ident", 2461, 56, 0, "iterator"],
".",
"Const",
2461,
70,
0,
"next"
]
]
]
],
[
"IfStatement",
1646,
13,
0,
0,
[
"Binary",
1646,
16,
0,
["Ident", 2461, 86, 0, "hasResult"],
"==",
"Const",
113,
19,
0,
null
],
[
"Binary",
1647,
1,
0,
["Ident", 2461, 86, 0, "hasResult"],
"=",
"Const",
1647,
20,
0,
false
],
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
620,
18,
0,
[
"Unary",
134,
7,
0,
"typeof",
"Ident",
2461,
86,
0,
"hasResult"
],
"!==",
"Const",
134,
25,
0,
"boolean"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected hasResult to be a Boolean, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2461, 86, 0, "hasResult"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
2461,
109,
0,
"onValue"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected onValue to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2461, 109, 0, "onValue"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
2461,
125,
0,
"onComplete"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected onComplete to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 2461, 125, 0, "onComplete"]
]
]
],
[
"IfStatement",
2462,
1,
0,
0,
[
"Binary",
2462,
5,
0,
[
"Binary",
2462,
5,
0,
["Ident", 2462, 5, 0, "limit"],
"<",
"Const",
2462,
15,
0,
1
],
"||",
"Binary",
43,
7,
0,
["Ident", 2462, 19, 0, "limit"],
"!==",
"Ident",
2462,
28,
0,
"limit"
],
[
"Binary",
2463,
1,
0,
["Ident", 2463, 1, 0, "limit"],
"=",
"Const",
2463,
13,
0,
1,
1
]
],
[
"Binary",
2464,
1,
0,
["Ident", 2464, 14, 0, "broken"],
"=",
"Const",
2464,
23,
0,
null
],
[
"Binary",
2465,
1,
0,
["Ident", 2465, 14, 0, "slotsUsed"],
"=",
"Const",
2465,
28,
0,
0
],
[
"Binary",
2466,
1,
0,
["Ident", 2466, 14, 0, "sync"],
"=",
"Const",
2466,
21,
0,
false
],
[
"IfStatement",
2467,
15,
0,
0,
["Ident", 2467, 18, 0, "hasResult"],
[
"Binary",
2467,
1,
0,
["Ident", 2467, 6, 0, "result"],
"=",
"Arr",
2467,
34,
0
],
"Binary",
2467,
1,
0,
["Ident", 2467, 6, 0, "result"],
"=",
"Const",
2467,
42,
0,
null
],
[
"Binary",
2468,
1,
0,
["Ident", 2468, 14, 0, "completed"],
"=",
"Const",
2468,
26,
0,
false
],
[
"Func",
2469,
1,
0,
["Ident", 2469, 6, 0, "onValueCallback"],
[
["Ident", 2469, 25, 0, "err"],
["Ident", 2469, 29, 0, "value"]
],
[],
[],
"BlockStatement",
2470,
1,
0,
0,
[
"IfStatement",
2470,
1,
0,
0,
["Ident", 2470, 7, 0, "completed"],
[
"Return",
2471,
1,
0,
"Const",
2471,
1,
0
]
],
[
"Unary",
2472,
1,
0,
"--",
"Ident",
2472,
1,
0,
"slotsUsed"
],
[
"IfStatement",
2473,
1,
0,
0,
[
"Binary",
2473,
7,
0,
[
"Binary",
49,
7,
0,
["Ident", 2473, 7, 0, "err"],
"!=",
"Const",
113,
19,
0,
null
],
"&&",
"Binary",
2473,
16,
0,
["Ident", 2473, 20, 0, "broken"],
"==",
"Const",
113,
19,
0,
null
],
[
"Binary",
2474,
1,
0,
["Ident", 2474, 1, 0, "broken"],
"=",
"Ident",
2474,
16,
0,
"err"
]
],
[
"IfStatement",
2475,
1,
0,
0,
[
"Binary",
2475,
7,
0,
[
"Binary",
2475,
7,
0,
["Ident", 2475, 7, 0, "hasResult"],
"&&",
"Binary",
2475,
22,
0,
["Ident", 2475, 26, 0, "broken"],
"==",
"Const",
113,
19,
0,
null
],
"&&",
"Binary",
57,
23,
0,
[
"Binary",
2475,
38,
0,
["Arguments", 2475, 38, 0],
".",
"Const",
2475,
49,
0,
"length"
],
">",
"Const",
2475,
59,
0,
1
],
[
"Call",
2476,
1,
0,
[
"Binary",
2476,
1,
0,
["Ident", 2476, 1, 0, "result"],
".",
"Const",
2476,
14,
0,
"push"
],
0,
["Ident", 2476, 19, 0, "value"]
]
],
[
"IfStatement",
2477,
1,
0,
0,
[
"Unary",
2477,
7,
0,
"!",
"Ident",
2477,
11,
0,
"sync"
],
[
"Call",
2478,
1,
0,
["Ident", 2478, 1, 0, "next"],
0
]
]
],
[
"Binary",
2479,
1,
0,
["Ident", 2479, 14, 0, "index"],
"=",
"Const",
2479,
22,
0,
-1
],
[
"Binary",
2480,
1,
0,
["Ident", 2480, 14, 0, "iterStopped"],
"=",
"Const",
2480,
29,
0,
false
],
[
"Binary",
2481,
1,
0,
["Ident", 2481, 14, 0, "close"],
"=",
"Func",
2481,
24,
0,
0,
[],
[],
[],
"BlockStatement",
2482,
1,
0,
0,
[
"Binary",
2482,
1,
0,
["Ident", 2482, 1, 0, "close"],
"=",
"Func",
2482,
15,
0,
0,
[],
[],
[]
],
[
"TryCatch",
2483,
1,
0,
0,
[
"Return",
2484,
1,
0,
"Call",
2484,
1,
0,
[
"Binary",
2484,
1,
0,
["Ident", 2484, 1, 0, "iterator"],
".",
"Const",
2484,
16,
0,
"close"
],
0
],
["Ident", 2485, 10, 0, "e"],
"Return",
2486,
1,
0,
"Const",
2486,
1,
0
]
],
[
"Func",
2487,
1,
0,
["Ident", 2487, 6, 0, "next"],
[],
["item"],
[],
"BlockStatement",
2488,
1,
0,
0,
[
"For",
1071,
1,
0,
0,
0,
[
"Binary",
2488,
10,
0,
[
"Binary",
2488,
10,
0,
[
"Binary",
2488,
10,
0,
[
"Unary",
2488,
10,
0,
"!",
"Ident",
2488,
14,
0,
"completed"
],
"&&",
"Binary",
2488,
28,
0,
["Ident", 2488, 32, 0, "broken"],
"==",
"Const",
113,
19,
0,
null
],
"&&",
"Binary",
2488,
44,
0,
["Ident", 2488, 44, 0, "slotsUsed"],
"<",
"Ident",
2488,
58,
0,
"limit"
],
"&&",
"Unary",
2488,
68,
0,
"!",
"Ident",
2488,
72,
0,
"iterStopped"
],
0,
"BlockStatement",
2489,
1,
0,
0,
[
"TryCatch",
2489,
1,
0,
0,
[
"Binary",
2490,
1,
0,
["Ident", 2490, 12, 0, "item"],
"=",
"Call",
2490,
19,
0,
[
"Binary",
2490,
19,
0,
["Ident", 2490, 19, 0, "iterator"],
".",
"Const",
2490,
29,
0,
"next"
],
0
],
["Ident", 2491, 12, 0, "e"],
"BlockStatement",
2492,
1,
0,
0,
[
"Binary",
2492,
1,
0,
["Ident", 2492, 1, 0, "broken"],
"=",
"Ident",
2492,
18,
0,
"e"
],
["Break", 2493, 1, 0]
],
[
"IfStatement",
2495,
1,
0,
0,
[
"Binary",
2495,
9,
0,
["Ident", 2495, 9, 0, "item"],
".",
"Const",
2495,
15,
0,
"done"
],
[
"BlockStatement",
2496,
1,
0,
0,
[
"Binary",
2496,
1,
0,
["Ident", 2496, 1, 0, "iterStopped"],
"=",
"Const",
2496,
24,
0,
true
],
["Break", 2497, 1, 0]
]
],
[
"Unary",
2499,
1,
0,
"++",
"Ident",
2499,
1,
0,
"slotsUsed"
],
[
"Binary",
2500,
1,
0,
["Ident", 2500, 1, 0, "sync"],
"=",
"Const",
2500,
14,
0,
true
],
[
"TryCatch",
2501,
1,
0,
0,
[
"Call",
2502,
1,
0,
["Ident", 2502, 1, 0, "onValue"],
0,
[
"Binary",
2502,
18,
0,
["Ident", 2502, 18, 0, "item"],
".",
"Const",
2502,
23,
0,
"value"
],
[
"Unary",
862,
11,
0,
"++",
"Ident",
2502,
31,
0,
"index"
],
[
"Call",
2351,
11,
0,
["Ident", 2351, 11, 0, "__once"],
0,
["Ident", 2502, 50, 0, "onValueCallback"]
]
],
["Ident", 2503, 12, 0, "e"],
"BlockStatement",
2504,
1,
0,
0,
[
"Call",
2504,
1,
0,
["Ident", 2504, 1, 0, "close"],
0
],
[
"Throw",
2505,
1,
0,
"Ident",
2505,
14,
0,
"e"
]
],
[
"Binary",
2506,
1,
0,
["Ident", 2506, 1, 0, "sync"],
"=",
"Const",
2506,
14,
0,
false
]
],
[
"IfStatement",
2507,
1,
0,
0,
[
"Binary",
2507,
7,
0,
[
"Unary",
2507,
7,
0,
"!",
"Ident",
2507,
11,
0,
"completed"
],
"&&",
"Binary",
2507,
27,
0,
[
"Binary",
49,
7,
0,
["Ident", 2507, 27, 0, "broken"],
"!=",
"Const",
113,
19,
0,
null
],
"||",
"Binary",
2507,
37,
0,
["Ident", 2507, 37, 0, "slotsUsed"],
"===",
"Const",
2507,
52,
0,
0
],
[
"BlockStatement",
2508,
1,
0,
0,
[
"Binary",
2508,
1,
0,
["Ident", 2508, 1, 0, "completed"],
"=",
"Const",
2508,
19,
0,
true
],
[
"Call",
2509,
1,
0,
["Ident", 2509, 1, 0, "close"],
0
],
[
"IfStatement",
2510,
1,
0,
0,
[
"Binary",
49,
7,
0,
["Ident", 2510, 9, 0, "broken"],
"!=",
"Const",
113,
19,
0,
null
],
[
"Call",
2511,
1,
0,
["Ident", 2511, 1, 0, "onComplete"],
0,
["Ident", 2511, 21, 0, "broken"]
],
"Call",
2513,
1,
0,
["Ident", 2513, 1, 0, "onComplete"],
0,
["Const", 2513, 21, 0, null],
["Ident", 2513, 26, 0, "result"]
]
]
]
],
[
"Call",
2514,
1,
0,
["Ident", 2514, 1, 0, "next"],
0
]
],
type: {type: "generic", base: "functionBase", args: ["undefined"]},
dependencies: ["__asyncIter", "__once", "__typeof"]
},
__is: {
helper: [
"IfExpression",
3154,
21,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
3154,
37,
0,
["Ident", 3154, 37, 0, "Object"],
".",
"Const",
3154,
45,
0,
"is"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Binary",
3155,
1,
0,
["Ident", 3155, 1, 0, "Object"],
".",
"Const",
3155,
10,
0,
"is"
],
"Func",
3157,
4,
0,
0,
[
["Ident", 3157, 5, 0, "x"],
["Ident", 3157, 7, 0, "y"]
],
[],
[],
"IfStatement",
3158,
1,
0,
0,
[
"Binary",
3158,
7,
0,
["Ident", 3158, 7, 0, "x"],
"===",
"Ident",
3158,
12,
0,
"y"
],
[
"Return",
3159,
1,
0,
"Binary",
3159,
1,
0,
[
"Binary",
43,
7,
0,
["Ident", 3159, 1, 0, "x"],
"!==",
"Const",
3159,
12,
0,
0
],
"||",
"Binary",
3159,
18,
0,
[
"Binary",
3159,
18,
0,
["Const", 3159, 18, 0, 1],
"/",
"Ident",
3159,
22,
0,
"x"
],
"===",
"Binary",
3159,
27,
0,
["Const", 3159, 28, 0, 1],
"/",
"Ident",
3159,
32,
0,
"y"
],
"Return",
3161,
1,
0,
"Binary",
3161,
1,
0,
[
"Binary",
43,
7,
0,
["Ident", 3161, 1, 0, "x"],
"!==",
"Ident",
3161,
11,
0,
"x"
],
"&&",
"Binary",
43,
7,
0,
["Ident", 3161, 17, 0, "y"],
"!==",
"Ident",
3161,
22,
0,
"y"
],
type: "any",
dependencies: ["__is"]
},
__bind: {
helper: [
"Func",
3201,
25,
0,
0,
[
["Ident", 3201, 26, 0, "parent"],
["Ident", 3201, 33, 0, "child"]
],
["func"],
[],
"BlockStatement",
3202,
1,
0,
0,
[
"IfStatement",
3202,
1,
0,
0,
[
"Binary",
3202,
5,
0,
["Ident", 3202, 9, 0, "parent"],
"==",
"Const",
113,
19,
0,
null
],
[
"Throw",
3203,
1,
0,
"Call",
3203,
10,
0,
["Ident", 3203, 10, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 3203, 21, 0, "Expected parent to be an object, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3203, 68, 0, "parent"]
]
]
],
[
"Binary",
3204,
1,
0,
["Ident", 3204, 6, 0, "func"],
"=",
"Binary",
3204,
13,
0,
["Ident", 3204, 13, 0, "parent"],
".",
"Ident",
3204,
21,
0,
"child"
],
[
"IfStatement",
3205,
1,
0,
0,
[
"Binary",
3205,
5,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3205,
22,
0,
"func"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
3206,
1,
0,
"Call",
3206,
10,
0,
["Ident", 3206, 10, 0, "Error"],
0,
[
"Binary",
573,
7,
0,
[
"Binary",
573,
7,
0,
["Const", 3206, 17, 0, "Trying to bind child '"],
"+",
"Call",
3206,
42,
0,
["Ident", 3206, 42, 0, "String"],
0,
["Ident", 3206, 49, 0, "child"]
],
"+",
"Const",
3206,
17,
0,
"' which is not a function"
]
]
],
[
"Return",
3207,
4,
0,
"Func",
3207,
4,
0,
0,
[],
[],
[],
"Return",
3207,
7,
0,
"Call",
3207,
7,
0,
[
"Binary",
3207,
7,
0,
["Ident", 3207, 7, 0, "func"],
".",
"Const",
3207,
7,
0,
"apply"
],
0,
["Ident", 3207, 14, 0, "parent"],
["Arguments", 3207, 25, 0]
]
],
type: {type: "generic", base: "functionBase", args: ["function"]},
dependencies: ["__bind", "__toArray", "__typeof"]
},
__defProp: {
helper: [
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
["defineGetter", "defineSetter", "fallback", "lookupGetter", "lookupSetter", "supportsAccessors"],
[],
"BlockStatement",
3210,
1,
0,
0,
[
"Binary",
3210,
1,
0,
["Ident", 3210, 6, 0, "fallback"],
"=",
"Binary",
3210,
17,
0,
["Ident", 3210, 17, 0, "Object"],
".",
"Const",
3210,
25,
0,
"defineProperty"
],
[
"IfStatement",
3211,
1,
0,
0,
[
"Binary",
3211,
5,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3211,
18,
0,
"fallback"
],
"===",
"Const",
137,
25,
0,
"function"
],
"&&",
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
["o"],
[],
"TryCatch",
3212,
1,
0,
0,
[
"BlockStatement",
3213,
1,
0,
0,
[
"Binary",
3213,
1,
0,
["Ident", 3213, 12, 0, "o"],
"=",
"Obj",
3213,
16,
0
],
[
"Call",
3214,
1,
0,
["Ident", 3214, 1, 0, "fallback"],
0,
["Ident", 3214, 18, 0, "o"],
["Const", 3214, 22, 0, "sentinel"],
["Obj", 3214, 31, 0]
],
[
"Return",
3215,
1,
0,
"Binary",
3215,
1,
0,
["Const", 3215, 19, 0, "sentinel"],
"in",
"Ident",
3215,
1,
0,
"o"
]
],
["Ident", 3216, 12, 0, "e"],
"Return",
3217,
1,
0,
"Const",
3217,
1,
0,
false
],
0
],
[
"Return",
3218,
1,
0,
"Ident",
3218,
1,
0,
"fallback"
],
"BlockStatement",
3220,
1,
0,
0,
[
"Binary",
3220,
1,
0,
["Ident", 3220, 8, 0, "supportsAccessors"],
"=",
"Call",
611,
7,
0,
[
"Binary",
611,
7,
0,
["Ident", 611, 7, 0, "__owns"],
".",
"Const",
611,
7,
0,
"call"
],
0,
[
"Binary",
3220,
29,
0,
["Ident", 3220, 29, 0, "Object"],
".",
"Const",
3220,
37,
0,
"prototype"
],
["Const", 3220, 56, 0, "__defineGetter__"]
],
[
"Binary",
3221,
1,
0,
["Ident", 3221, 8, 0, "lookupGetter"],
"=",
"Binary",
3221,
24,
0,
["Ident", 3221, 24, 0, "supportsAccessors"],
"&&",
"Binary",
3221,
47,
0,
[
"Binary",
3221,
47,
0,
["Ident", 3221, 47, 0, "Object"],
".",
"Const",
3221,
47,
0,
"prototype"
],
".",
"Const",
3221,
56,
0,
"__lookupGetter__"
],
[
"Binary",
3222,
1,
0,
["Ident", 3222, 8, 0, "lookupSetter"],
"=",
"Binary",
3222,
24,
0,
["Ident", 3222, 24, 0, "supportsAccessors"],
"&&",
"Binary",
3222,
47,
0,
[
"Binary",
3222,
47,
0,
["Ident", 3222, 47, 0, "Object"],
".",
"Const",
3222,
47,
0,
"prototype"
],
".",
"Const",
3222,
56,
0,
"__lookupSetter__"
],
[
"Binary",
3223,
1,
0,
["Ident", 3223, 8, 0, "defineGetter"],
"=",
"Binary",
3223,
24,
0,
["Ident", 3223, 24, 0, "supportsAccessors"],
"&&",
"Binary",
3223,
47,
0,
[
"Binary",
3223,
47,
0,
["Ident", 3223, 47, 0, "Object"],
".",
"Const",
3223,
47,
0,
"prototype"
],
".",
"Const",
3223,
56,
0,
"__defineGetter__"
],
[
"Binary",
3224,
1,
0,
["Ident", 3224, 8, 0, "defineSetter"],
"=",
"Binary",
3224,
24,
0,
["Ident", 3224, 24, 0, "supportsAccessors"],
"&&",
"Binary",
3224,
47,
0,
[
"Binary",
3224,
47,
0,
["Ident", 3224, 47, 0, "Object"],
".",
"Const",
3224,
47,
0,
"prototype"
],
".",
"Const",
3224,
56,
0,
"__defineSetter__"
],
[
"Return",
1855,
1,
0,
"Func",
1855,
1,
0,
0,
[
["Ident", 3225, 7, 0, "object"],
["Ident", 3225, 23, 0, "property"],
["Ident", 3225, 43, 0, "descriptor"]
],
["proto"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1690,
31,
0,
0,
[
"Binary",
3225,
6,
0,
[
"Binary",
626,
18,
0,
[
"Binary",
143,
47,
0,
[
"Unary",
143,
47,
0,
"typeof",
"Ident",
3225,
7,
0,
"object"
],
"!==",
"Const",
143,
62,
0,
"object"
],
"||",
"Binary",
43,
7,
0,
["Ident", 3225, 7, 0, "object"],
"===",
"Const",
143,
78,
0,
null
],
"&&",
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3225,
7,
0,
"object"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1691,
1,
0,
"Call",
1691,
14,
0,
["Ident", 1691, 14, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
[
"Const",
573,
7,
0,
"Expected object to be one of Object or Function, got "
],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3225, 7, 0, "object"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
616,
18,
0,
[
"Unary",
128,
7,
0,
"typeof",
"Ident",
3225,
23,
0,
"property"
],
"!==",
"Const",
128,
25,
0,
"string"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected property to be a String, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3225, 23, 0, "property"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
626,
18,
0,
[
"Binary",
143,
47,
0,
[
"Unary",
143,
47,
0,
"typeof",
"Ident",
3225,
43,
0,
"descriptor"
],
"!==",
"Const",
143,
62,
0,
"object"
],
"||",
"Binary",
43,
7,
0,
["Ident", 3225, 43, 0, "descriptor"],
"===",
"Const",
143,
78,
0,
null
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected descriptor to be an Object, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3225, 43, 0, "descriptor"]
]
]
],
[
"IfStatement",
3226,
1,
0,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3226,
22,
0,
"fallback"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"TryCatch",
3227,
1,
0,
0,
[
"Return",
3228,
1,
0,
"Call",
3228,
17,
0,
["Ident", 3228, 17, 0, "fallback"],
0,
["Ident", 3228, 27, 0, "object"],
["Ident", 3228, 34, 0, "property"],
["Ident", 3228, 44, 0, "descriptor"]
],
["Ident", 3229, 14, 0, "e"],
"Const",
3230,
1,
0
]
],
[
"IfStatement",
3232,
1,
0,
0,
[
"Call",
611,
7,
0,
[
"Binary",
611,
7,
0,
["Ident", 611, 7, 0, "__owns"],
".",
"Const",
611,
7,
0,
"call"
],
0,
["Ident", 3232, 9, 0, "descriptor"],
["Const", 3232, 30, 0, "value"]
],
[
"IfStatement",
3233,
1,
0,
0,
[
"Binary",
3233,
11,
0,
["Ident", 3233, 11, 0, "supportsAccessors"],
"&&",
"Call",
3233,
36,
0,
[
"Binary",
3233,
36,
0,
["Ident", 3233, 36, 0, "lookupGetter"],
".",
"Const",
3233,
36,
0,
"call"
],
0,
["Ident", 3233, 51, 0, "object"],
[
"Binary",
3233,
58,
0,
["Ident", 3233, 58, 0, "property"],
"||",
"Call",
3233,
70,
0,
[
"Binary",
3233,
70,
0,
["Ident", 3233, 70, 0, "lookupSetter"],
".",
"Const",
3233,
70,
0,
"call"
],
0,
["Ident", 3233, 86, 0, "object"],
["Ident", 3233, 93, 0, "property"]
]
],
[
"BlockStatement",
3234,
1,
0,
0,
[
"Binary",
3234,
1,
0,
["Ident", 3234, 14, 0, "proto"],
"=",
"Binary",
3234,
22,
0,
["Ident", 3234, 22, 0, "object"],
".",
"Const",
3234,
30,
0,
"__proto__"
],
[
"Binary",
3235,
1,
0,
[
"Binary",
3235,
1,
0,
["Ident", 3235, 1, 0, "object"],
".",
"Const",
3235,
18,
0,
"__proto__"
],
"=",
"Binary",
3235,
30,
0,
["Ident", 3235, 30, 0, "Object"],
".",
"Const",
3235,
38,
0,
"prototype"
],
[
"Unary",
3236,
1,
0,
"delete",
"Binary",
3236,
17,
0,
["Ident", 3236, 17, 0, "object"],
".",
"Ident",
3236,
25,
0,
"property"
],
[
"Binary",
3237,
1,
0,
[
"Binary",
3237,
1,
0,
["Ident", 3237, 1, 0, "object"],
".",
"Ident",
3237,
18,
0,
"property"
],
"=",
"Binary",
3237,
30,
0,
["Ident", 3237, 30, 0, "descriptor"],
".",
"Const",
3237,
42,
0,
"value"
],
[
"Binary",
3238,
1,
0,
[
"Binary",
3238,
1,
0,
["Ident", 3238, 1, 0, "object"],
".",
"Const",
3238,
18,
0,
"__proto__"
],
"=",
"Ident",
3238,
30,
0,
"proto"
]
],
"Binary",
3240,
1,
0,
[
"Binary",
3240,
1,
0,
["Ident", 3240, 1, 0, "object"],
".",
"Ident",
3240,
18,
0,
"property"
],
"=",
"Binary",
3240,
30,
0,
["Ident", 3240, 30, 0, "descriptor"],
".",
"Const",
3240,
42,
0,
"value"
],
"BlockStatement",
3242,
1,
0,
0,
[
"IfStatement",
3242,
1,
0,
0,
[
"Unary",
3242,
11,
0,
"!",
"Ident",
3242,
15,
0,
"supportsAccessors"
],
[
"Throw",
3243,
1,
0,
"Call",
3243,
16,
0,
["Ident", 3243, 16, 0, "Error"],
0,
[
"Const",
3243,
23,
0,
"Getters and setters cannot be defined on this Javascript engine"
]
]
],
[
"IfStatement",
3244,
1,
0,
0,
[
"Call",
611,
7,
0,
[
"Binary",
611,
7,
0,
["Ident", 611, 7, 0, "__owns"],
".",
"Const",
611,
7,
0,
"call"
],
0,
["Ident", 3244, 11, 0, "descriptor"],
["Const", 3244, 32, 0, "get"]
],
[
"Call",
3245,
1,
0,
[
"Binary",
3245,
1,
0,
["Ident", 3245, 1, 0, "defineGetter"],
".",
"Const",
3245,
1,
0,
"call"
],
0,
["Ident", 3245, 26, 0, "object"],
["Ident", 3245, 33, 0, "property"],
[
"Binary",
3245,
43,
0,
["Ident", 3245, 43, 0, "descriptor"],
".",
"Const",
3245,
55,
0,
"get"
]
]
],
[
"IfStatement",
3246,
1,
0,
0,
[
"Call",
611,
7,
0,
[
"Binary",
611,
7,
0,
["Ident", 611, 7, 0, "__owns"],
".",
"Const",
611,
7,
0,
"call"
],
0,
["Ident", 3246, 11, 0, "descriptor"],
["Const", 3246, 32, 0, "set"]
],
[
"Call",
3247,
1,
0,
[
"Binary",
3247,
1,
0,
["Ident", 3247, 1, 0, "defineSetter"],
".",
"Const",
3247,
1,
0,
"call"
],
0,
["Ident", 3247, 26, 0, "object"],
["Ident", 3247, 33, 0, "property"],
[
"Binary",
3247,
43,
0,
["Ident", 3247, 43, 0, "descriptor"],
".",
"Const",
3247,
55,
0,
"set"
]
]
]
],
[
"Return",
3248,
1,
0,
"Ident",
3248,
1,
0,
"object"
]
]
]
],
0
],
type: "any",
dependencies: ["__defProp", "__owns", "__typeof"]
},
__compose: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 3254, 29, 0, "left"],
["Ident", 3254, 40, 0, "right"]
],
[],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3254,
29,
0,
"left"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected left to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3254, 29, 0, "left"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3254,
40,
0,
"right"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected right to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3254, 40, 0, "right"]
]
]
],
[
"Return",
3255,
4,
0,
"Func",
3255,
4,
0,
0,
[],
[],
[],
"Return",
3255,
6,
0,
"Call",
3255,
6,
0,
[
"Binary",
3255,
6,
0,
["Ident", 3255, 6, 0, "left"],
".",
"Const",
3255,
6,
0,
"call"
],
0,
["This", 3255, 13, 0],
[
"Call",
3255,
18,
0,
[
"Binary",
3255,
18,
0,
["Ident", 3255, 18, 0, "right"],
".",
"Const",
3255,
18,
0,
"apply"
],
0,
["This", 3255, 26, 0],
["Arguments", 3255, 35, 0]
]
]
],
type: {type: "generic", base: "functionBase", args: ["function"]},
dependencies: ["__compose", "__toArray", "__typeof"]
},
__curry: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 3269, 27, 0, "numArgs"],
["Ident", 3269, 46, 0, "f"]
],
["currier"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
3269,
27,
0,
"numArgs"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected numArgs to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3269, 27, 0, "numArgs"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3269,
46,
0,
"f"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected f to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3269, 46, 0, "f"]
]
]
],
[
"IfStatement",
3270,
1,
0,
0,
[
"Binary",
724,
9,
0,
["Ident", 3270, 5, 0, "numArgs"],
">",
"Const",
3270,
17,
0,
1
],
[
"BlockStatement",
3271,
1,
0,
0,
[
"Binary",
3271,
1,
0,
["Ident", 3271, 8, 0, "currier"],
"=",
"Func",
3271,
16,
0,
0,
[["Ident", 3271, 17, 0, "args"]],
["ret"],
[],
"IfStatement",
3272,
1,
0,
0,
[
"Binary",
726,
9,
0,
[
"Call",
709,
11,
0,
["Ident", 709, 11, 0, "__num"],
0,
[
"Binary",
3272,
9,
0,
["Ident", 3272, 9, 0, "args"],
".",
"Const",
3272,
15,
0,
"length"
]
],
">=",
"Ident",
3272,
24,
0,
"numArgs"
],
[
"Return",
3273,
1,
0,
"Call",
3273,
1,
0,
[
"Binary",
3273,
1,
0,
["Ident", 3273, 1, 0, "f"],
".",
"Const",
3273,
11,
0,
"apply"
],
0,
["This", 3273, 17, 0],
["Ident", 3273, 22, 0, "args"]
],
"BlockStatement",
3275,
1,
0,
0,
[
"Binary",
3275,
1,
0,
["Ident", 3275, 12, 0, "ret"],
"=",
"Func",
3275,
16,
0,
0,
[],
[],
[],
"IfStatement",
3276,
1,
0,
0,
[
"Binary",
3276,
13,
0,
[
"Binary",
3276,
13,
0,
["Arguments", 3276, 13, 0],
".",
"Const",
3276,
24,
0,
"length"
],
"===",
"Const",
3276,
34,
0,
0
],
[
"Return",
3277,
1,
0,
"Ident",
3277,
1,
0,
"ret"
],
"Return",
3279,
1,
0,
"Call",
3279,
1,
0,
[
"Binary",
3279,
1,
0,
["Ident", 3279, 1, 0, "currier"],
".",
"Const",
3279,
1,
0,
"call"
],
0,
["This", 3279, 22, 0],
[
"Call",
3279,
27,
0,
[
"Binary",
3279,
27,
0,
["Ident", 3279, 27, 0, "args"],
".",
"Const",
3279,
33,
0,
"concat"
],
0,
[
"Call",
3279,
40,
0,
[
"Binary",
3279,
40,
0,
["Ident", 3279, 40, 0, "__slice"],
".",
"Const",
3279,
40,
0,
"call"
],
0,
["Arguments", 3279, 49, 0]
]
]
],
[
"Return",
3280,
1,
0,
"Ident",
3280,
1,
0,
"ret"
]
],
[
"Return",
3281,
1,
0,
"Call",
3281,
1,
0,
["Ident", 3281, 1, 0, "currier"],
0,
["Arr", 3281, 13, 0]
]
],
"Return",
3283,
1,
0,
"Ident",
3283,
1,
0,
"f"
]
],
type: {type: "generic", base: "functionBase", args: ["function"]},
dependencies: ["__curry", "__num", "__slice", "__typeof"]
},
__import: {
helper: [
"Func",
3297,
27,
0,
0,
[
["Ident", 3297, 28, 0, "dest"],
["Ident", 3297, 33, 0, "source"]
],
["k"],
[],
"BlockStatement",
3298,
1,
0,
0,
[
"ForIn",
3298,
1,
0,
0,
["Ident", 3298, 6, 0, "k"],
["Ident", 3298, 11, 0, "source"],
"IfStatement",
1525,
1,
0,
0,
[
"Call",
611,
7,
0,
[
"Binary",
611,
7,
0,
["Ident", 611, 7, 0, "__owns"],
".",
"Const",
611,
7,
0,
"call"
],
0,
["Ident", 3298, 11, 0, "source"],
["Ident", 3298, 6, 0, "k"]
],
[
"Binary",
3299,
1,
0,
[
"Binary",
3299,
1,
0,
["Ident", 3299, 1, 0, "dest"],
".",
"Ident",
3299,
10,
0,
"k"
],
"=",
"Binary",
3299,
15,
0,
["Ident", 3299, 15, 0, "source"],
".",
"Ident",
3299,
23,
0,
"k"
]
],
[
"Return",
3300,
1,
0,
"Ident",
3300,
1,
0,
"dest"
]
],
type: {type: "generic", base: "functionBase", args: ["object"]},
dependencies: ["__import", "__owns"]
},
WeakMap: {
helper: [
"IfExpression",
3349,
24,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
3349,
40,
0,
["Ident", 3349, 40, 0, "GLOBAL"],
".",
"Const",
3349,
48,
0,
"WeakMap"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Binary",
3349,
60,
0,
["Ident", 3349, 60, 0, "GLOBAL"],
".",
"Const",
3349,
68,
0,
"WeakMap"
],
"Binary",
2984,
10,
0,
["Ident", 3349, 86, 0, "WeakMap"],
"=",
"Call",
2946,
1,
0,
[
"Func",
2946,
1,
0,
0,
[],
["_WeakMap_prototype", "defProp", "isExtensible"],
[],
"BlockStatement",
2946,
1,
0,
0,
[
"Func",
2870,
29,
0,
["Ident", 3349, 86, 0, "WeakMap"],
[],
["_this"],
[],
"BlockStatement",
3357,
1,
0,
0,
[
"Binary",
3357,
1,
0,
["Ident", 3357, 1, 0, "_this"],
"=",
"IfExpression",
2869,
18,
0,
[
"Binary",
2869,
21,
0,
[
"Eval",
2869,
21,
0,
["Const", 2869, 27, 0, "this"]
],
"instanceof",
"Ident",
3349,
86,
0,
"WeakMap"
],
[
"Eval",
2869,
56,
0,
["Const", 2869, 62, 0, "this"]
],
"Call",
2869,
74,
0,
["Ident", 2869, 74, 0, "__create"],
0,
["Ident", 3349, 80, 0, "_WeakMap_prototype"]
],
[
"Binary",
3357,
1,
0,
[
"Binary",
3357,
1,
0,
["Ident", 3357, 1, 0, "_this"],
".",
"Const",
3357,
6,
0,
"_keys"
],
"=",
"Arr",
3357,
14,
0
],
[
"Binary",
3358,
1,
0,
[
"Binary",
3358,
1,
0,
["Ident", 3358, 1, 0, "_this"],
".",
"Const",
3358,
6,
0,
"_values"
],
"=",
"Arr",
3358,
16,
0
],
[
"Binary",
3360,
1,
0,
[
"Binary",
3360,
1,
0,
["Ident", 3360, 1, 0, "_this"],
".",
"Const",
3360,
6,
0,
"_chilly"
],
"=",
"Arr",
3360,
16,
0
],
[
"Binary",
3361,
1,
0,
[
"Binary",
3361,
1,
0,
["Ident", 3361, 1, 0, "_this"],
".",
"Const",
3361,
6,
0,
"_uid"
],
"=",
"Call",
3361,
13,
0,
["Ident", 3361, 13, 0, "createUid"],
0
],
[
"Return",
3357,
1,
0,
"Ident",
3357,
1,
0,
"_this"
]
],
[
"Binary",
2800,
20,
0,
["Ident", 3349, 80, 0, "_WeakMap_prototype"],
"=",
"Binary",
2800,
37,
0,
["Ident", 3349, 86, 0, "WeakMap"],
".",
"Const",
2800,
44,
0,
"prototype"
],
[
"Binary",
2812,
21,
0,
[
"Binary",
2812,
21,
0,
["Ident", 3349, 86, 0, "WeakMap"],
".",
"Const",
2812,
28,
0,
"displayName"
],
"=",
"Const",
3349,
80,
0,
"WeakMap"
],
[
"Func",
3350,
1,
0,
["Ident", 3350, 6, 0, "uidRand"],
[],
[],
[],
"Return",
3351,
1,
0,
"Call",
3351,
1,
0,
[
"Binary",
3351,
1,
0,
[
"Call",
3351,
1,
0,
[
"Binary",
3351,
1,
0,
[
"Call",
3351,
1,
0,
[
"Binary",
3351,
1,
0,
["Ident", 3351, 1, 0, "Math"],
".",
"Const",
3351,
10,
0,
"random"
],
0
],
".",
"Const",
3351,
19,
0,
"toString"
],
0,
["Const", 3351, 29, 0, 36]
],
".",
"Const",
3351,
33,
0,
"slice"
],
0,
["Const", 3351, 39, 0, 2]
],
[
"Func",
3352,
1,
0,
["Ident", 3352, 6, 0, "createUid"],
[],
[],
[],
"Return",
573,
7,
0,
"Binary",
573,
7,
0,
[
"Binary",
573,
7,
0,
[
"Binary",
573,
7,
0,
[
"Binary",
573,
7,
0,
[
"Binary",
573,
7,
0,
[
"Binary",
573,
7,
0,
[
"Call",
567,
11,
0,
["Ident", 567, 11, 0, "__strnum"],
0,
[
"Call",
3353,
8,
0,
["Ident", 3353, 8, 0, "uidRand"],
0
]
],
"+",
"Const",
3353,
5,
0,
"-"
],
"+",
"Call",
572,
11,
0,
["Ident", 572, 11, 0, "__strnum"],
0,
[
"Call",
3353,
22,
0,
[
"Binary",
3353,
22,
0,
[
"Call",
3353,
22,
0,
["Ident", 3353, 25, 0, "Date"],
1
],
".",
"Const",
3353,
33,
0,
"getTime"
],
0
]
],
"+",
"Const",
3353,
5,
0,
"-"
],
"+",
"Call",
572,
11,
0,
["Ident", 572, 11, 0, "__strnum"],
0,
[
"Call",
3353,
47,
0,
["Ident", 3353, 47, 0, "uidRand"],
0
]
],
"+",
"Const",
3353,
5,
0,
"-"
],
"+",
"Call",
572,
11,
0,
["Ident", 572, 11, 0, "__strnum"],
0,
[
"Call",
3353,
61,
0,
["Ident", 3353, 61, 0, "uidRand"],
0
]
],
[
"Binary",
3354,
1,
0,
["Ident", 3354, 6, 0, "isExtensible"],
"=",
"Binary",
3354,
22,
0,
[
"Binary",
3354,
22,
0,
["Ident", 3354, 22, 0, "Object"],
".",
"Const",
3354,
30,
0,
"isExtensible"
],
"||",
"Func",
3354,
48,
0,
0,
[],
[],
[],
"Return",
3354,
50,
0,
"Const",
3354,
50,
0,
true
],
[
"Func",
3363,
1,
0,
["Ident", 3363, 6, 0, "check"],
[["Ident", 3363, 13, 0, "key"]],
["chilly", "uid"],
[],
"BlockExpression",
3364,
1,
0,
[
"Binary",
3364,
1,
0,
["Ident", 3364, 8, 0, "uid"],
"=",
"Binary",
3364,
14,
0,
["This", 3364, 14, 0],
".",
"Const",
3364,
16,
0,
"_uid"
],
[
"IfExpression",
3365,
1,
0,
[
"Call",
611,
7,
0,
[
"Binary",
611,
7,
0,
["Ident", 611, 7, 0, "__owns"],
".",
"Const",
611,
7,
0,
"call"
],
0,
["Ident", 3365, 7, 0, "key"],
["Ident", 3365, 19, 0, "uid"]
],
[
"BlockExpression",
3366,
1,
0,
[
"Binary",
3366,
1,
0,
["Ident", 3366, 10, 0, "chilly"],
"=",
"Binary",
3366,
19,
0,
["This", 3366, 19, 0],
".",
"Const",
3366,
21,
0,
"_chilly"
],
[
"IfExpression",
3367,
1,
0,
[
"Binary",
3367,
9,
0,
[
"Call",
3367,
9,
0,
[
"Binary",
3367,
9,
0,
["Ident", 3367, 9, 0, "chilly"],
".",
"Const",
3367,
17,
0,
"indexOf"
],
0,
["Ident", 3367, 26, 0, "key"]
],
"===",
"Const",
3367,
33,
0,
-1
],
[
"BlockExpression",
3368,
1,
0,
[
"Call",
3368,
1,
0,
[
"Binary",
3368,
1,
0,
["Ident", 3368, 1, 0, "chilly"],
".",
"Const",
3368,
16,
0,
"push"
],
0,
["Ident", 3368, 21, 0, "key"]
],
[
"Call",
3369,
1,
0,
[
"Binary",
3369,
1,
0,
[
"Binary",
3369,
1,
0,
["This", 3369, 1, 0],
".",
"Const",
3369,
10,
0,
"_keys"
],
".",
"Const",
3369,
16,
0,
"push"
],
0,
["Ident", 3369, 21, 0, "key"]
],
[
"Call",
3370,
1,
0,
[
"Binary",
3370,
1,
0,
[
"Binary",
3370,
1,
0,
["This", 3370, 1, 0],
".",
"Const",
3370,
10,
0,
"_values"
],
".",
"Const",
3370,
18,
0,
"push"
],
0,
[
"Binary",
3370,
23,
0,
["Ident", 3370, 23, 0, "key"],
".",
"Ident",
3370,
27,
0,
"uid"
]
]
]
]
]
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3349, 80, 0, "_WeakMap_prototype"],
".",
"Const",
3372,
6,
0,
"get"
],
"=",
"Func",
3372,
10,
0,
0,
[["Ident", 3372, 11, 0, "key"]],
["_ref", "index"],
[],
"BlockStatement",
3373,
1,
0,
0,
[
"IfStatement",
3373,
1,
0,
0,
[
"Binary",
43,
7,
0,
[
"Call",
3373,
7,
0,
["Ident", 3373, 7, 0, "Object"],
0,
["Ident", 3373, 15, 0, "key"]
],
"!==",
"Ident",
3373,
22,
0,
"key"
],
[
"Throw",
3374,
1,
0,
"Call",
3374,
12,
0,
["Ident", 3374, 12, 0, "TypeError"],
0,
["Const", 3374, 23, 0, "Invalid value used as weak map key"]
]
],
[
"IfStatement",
3376,
1,
0,
0,
[
"Call",
3376,
7,
0,
["Ident", 3376, 7, 0, "isExtensible"],
0,
["Ident", 3376, 22, 0, "key"]
],
[
"IfStatement",
3377,
1,
0,
0,
[
"Call",
611,
7,
0,
[
"Binary",
611,
7,
0,
["Ident", 611, 7, 0, "__owns"],
".",
"Const",
611,
7,
0,
"call"
],
0,
["Ident", 3377, 1, 0, "key"],
[
"Binary",
3377,
1,
0,
["Ident", 3377, 1, 0, "_ref"],
"=",
"Binary",
3377,
12,
0,
["This", 3377, 12, 0],
".",
"Const",
3377,
13,
0,
"_uid"
]
],
[
"Return",
3377,
1,
0,
"Binary",
3377,
1,
0,
["Ident", 3377, 1, 0, "key"],
".",
"Ident",
3377,
1,
0,
"_ref"
]
],
"BlockStatement",
3379,
1,
0,
0,
[
"Call",
3379,
1,
0,
[
"Binary",
3379,
1,
0,
["Ident", 3379, 1, 0, "check"],
".",
"Const",
3379,
1,
0,
"call"
],
0,
["This", 3379, 14, 0],
["Ident", 3379, 19, 0, "key"]
],
[
"Binary",
3380,
1,
0,
["Ident", 3380, 10, 0, "index"],
"=",
"Call",
3380,
18,
0,
[
"Binary",
3380,
18,
0,
[
"Binary",
3380,
18,
0,
["This", 3380, 18, 0],
".",
"Const",
3380,
20,
0,
"_keys"
],
".",
"Const",
3380,
26,
0,
"indexOf"
],
0,
["Ident", 3380, 35, 0, "key"]
],
[
"IfStatement",
3381,
1,
0,
0,
[
"Binary",
3381,
9,
0,
["Ident", 3381, 9, 0, "index"],
"===",
"Const",
3381,
18,
0,
-1
],
[
"Return",
3382,
1,
0,
"Const",
3382,
1,
0
],
"Return",
3384,
1,
0,
"Binary",
3384,
1,
0,
[
"Binary",
3384,
1,
0,
["This", 3384, 1, 0],
".",
"Const",
3384,
10,
0,
"_values"
],
".",
"Ident",
3384,
18,
0,
"index"
]
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3349, 80, 0, "_WeakMap_prototype"],
".",
"Const",
3386,
6,
0,
"has"
],
"=",
"Func",
3386,
10,
0,
0,
[["Ident", 3386, 11, 0, "key"]],
[],
[],
"BlockStatement",
3387,
1,
0,
0,
[
"IfStatement",
3387,
1,
0,
0,
[
"Binary",
43,
7,
0,
[
"Call",
3387,
7,
0,
["Ident", 3387, 7, 0, "Object"],
0,
["Ident", 3387, 15, 0, "key"]
],
"!==",
"Ident",
3387,
22,
0,
"key"
],
[
"Throw",
3388,
1,
0,
"Call",
3388,
12,
0,
["Ident", 3388, 12, 0, "TypeError"],
0,
["Const", 3388, 23, 0, "Invalid value used as weak map key"]
]
],
[
"IfStatement",
3390,
1,
0,
0,
[
"Call",
3390,
7,
0,
["Ident", 3390, 7, 0, "isExtensible"],
0,
["Ident", 3390, 22, 0, "key"]
],
[
"Return",
611,
7,
0,
"Call",
611,
7,
0,
[
"Binary",
611,
7,
0,
["Ident", 611, 7, 0, "__owns"],
".",
"Const",
611,
7,
0,
"call"
],
0,
["Ident", 3391, 1, 0, "key"],
[
"Binary",
3391,
18,
0,
["This", 3391, 18, 0],
".",
"Const",
3391,
20,
0,
"_uid"
]
],
"BlockStatement",
3393,
1,
0,
0,
[
"Call",
3393,
1,
0,
[
"Binary",
3393,
1,
0,
["Ident", 3393, 1, 0, "check"],
".",
"Const",
3393,
1,
0,
"call"
],
0,
["This", 3393, 14, 0],
["Ident", 3393, 19, 0, "key"]
],
[
"Return",
43,
7,
0,
"Binary",
43,
7,
0,
[
"Call",
3394,
1,
0,
[
"Binary",
3394,
1,
0,
[
"Binary",
3394,
1,
0,
["This", 3394, 1, 0],
".",
"Const",
3394,
8,
0,
"_keys"
],
".",
"Const",
3394,
14,
0,
"indexOf"
],
0,
["Ident", 3394, 23, 0, "key"]
],
"!==",
"Const",
3394,
30,
0,
-1
]
]
],
[
"IfStatement",
3396,
17,
0,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
3396,
33,
0,
["Ident", 3396, 33, 0, "Object"],
".",
"Const",
3396,
41,
0,
"defineProperty"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Binary",
3396,
1,
0,
["Ident", 3396, 6, 0, "defProp"],
"=",
"Binary",
3396,
61,
0,
["Ident", 3396, 61, 0, "Object"],
".",
"Const",
3396,
69,
0,
"defineProperty"
],
"Binary",
3396,
1,
0,
["Ident", 3396, 6, 0, "defProp"],
"=",
"Func",
3396,
91,
0,
0,
[
["Ident", 3396, 92, 0, "o"],
["Ident", 3396, 94, 0, "k"],
["Ident", 3396, 97, 0, "d"]
],
[],
[],
"Binary",
3396,
104,
0,
[
"Binary",
3396,
104,
0,
["Ident", 3396, 104, 0, "o"],
".",
"Ident",
3396,
107,
0,
"k"
],
"=",
"Binary",
3396,
112,
0,
["Ident", 3396, 112, 0, "d"],
".",
"Const",
3396,
115,
0,
"value"
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3349, 80, 0, "_WeakMap_prototype"],
".",
"Const",
3397,
6,
0,
"set"
],
"=",
"Func",
3397,
10,
0,
0,
[
["Ident", 3397, 11, 0, "key"],
["Ident", 3397, 15, 0, "value"]
],
["index", "keys"],
[],
"BlockStatement",
3398,
1,
0,
0,
[
"IfStatement",
3398,
1,
0,
0,
[
"Binary",
43,
7,
0,
[
"Call",
3398,
7,
0,
["Ident", 3398, 7, 0, "Object"],
0,
["Ident", 3398, 15, 0, "key"]
],
"!==",
"Ident",
3398,
22,
0,
"key"
],
[
"Throw",
3399,
1,
0,
"Call",
3399,
12,
0,
["Ident", 3399, 12, 0, "TypeError"],
0,
["Const", 3399, 23, 0, "Invalid value used as weak map key"]
]
],
[
"IfStatement",
3401,
1,
0,
0,
[
"Call",
3401,
7,
0,
["Ident", 3401, 7, 0, "isExtensible"],
0,
["Ident", 3401, 22, 0, "key"]
],
[
"Call",
3402,
1,
0,
["Ident", 3402, 1, 0, "defProp"],
0,
["Ident", 3402, 16, 0, "key"],
[
"Binary",
3402,
20,
0,
["This", 3402, 20, 0],
".",
"Const",
3402,
22,
0,
"_uid"
],
[
"Obj",
3402,
27,
0,
3403,
10,
null,
"configurable",
["Const", 3403, 9, 0, true],
3404,
10,
null,
"writable",
["Const", 3404, 9, 0, true],
3405,
10,
null,
"enumerable",
["Const", 3405, 9, 0, false],
3406,
9,
null,
"value",
["Ident", 3406, 9, 0, "value"]
]
],
"BlockStatement",
3409,
1,
0,
0,
[
"Call",
3409,
1,
0,
[
"Binary",
3409,
1,
0,
["Ident", 3409, 1, 0, "check"],
".",
"Const",
3409,
1,
0,
"call"
],
0,
["This", 3409, 14, 0],
["Ident", 3409, 19, 0, "key"]
],
[
"Binary",
3410,
1,
0,
["Ident", 3410, 10, 0, "keys"],
"=",
"Binary",
3410,
17,
0,
["This", 3410, 17, 0],
".",
"Const",
3410,
19,
0,
"_keys"
],
[
"Binary",
3411,
1,
0,
["Ident", 3411, 18, 0, "index"],
"=",
"Call",
3411,
26,
0,
[
"Binary",
3411,
26,
0,
["Ident", 3411, 26, 0, "keys"],
".",
"Const",
3411,
32,
0,
"indexOf"
],
0,
["Ident", 3411, 41, 0, "key"]
],
[
"IfStatement",
3412,
1,
0,
0,
[
"Binary",
3412,
9,
0,
["Ident", 3412, 9, 0, "index"],
"===",
"Const",
3412,
18,
0,
-1
],
[
"BlockStatement",
3413,
1,
0,
0,
[
"Binary",
3413,
1,
0,
["Ident", 3413, 1, 0, "index"],
"=",
"Binary",
3413,
17,
0,
["Ident", 3413, 17, 0, "keys"],
".",
"Const",
3413,
23,
0,
"length"
],
[
"Binary",
3414,
1,
0,
[
"Binary",
3414,
1,
0,
["Ident", 3414, 1, 0, "keys"],
".",
"Ident",
3414,
14,
0,
"index"
],
"=",
"Ident",
3414,
23,
0,
"key"
]
]
],
[
"Binary",
3415,
1,
0,
[
"Binary",
3415,
1,
0,
[
"Binary",
3415,
1,
0,
["This", 3415, 1, 0],
".",
"Const",
3415,
8,
0,
"_values"
],
".",
"Ident",
3415,
16,
0,
"index"
],
"=",
"Ident",
3415,
25,
0,
"value"
]
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3349, 80, 0, "_WeakMap_prototype"],
".",
"Const",
3417,
6,
0,
"delete"
],
"=",
"Func",
3417,
13,
0,
0,
[["Ident", 3417, 14, 0, "key"]],
["index", "keys"],
[],
"BlockStatement",
3418,
1,
0,
0,
[
"IfStatement",
3418,
1,
0,
0,
[
"Binary",
43,
7,
0,
[
"Call",
3418,
7,
0,
["Ident", 3418, 7, 0, "Object"],
0,
["Ident", 3418, 15, 0, "key"]
],
"!==",
"Ident",
3418,
22,
0,
"key"
],
[
"Throw",
3419,
1,
0,
"Call",
3419,
12,
0,
["Ident", 3419, 12, 0, "TypeError"],
0,
["Const", 3419, 23, 0, "Invalid value used as weak map key"]
]
],
[
"IfStatement",
3421,
1,
0,
0,
[
"Call",
3421,
7,
0,
["Ident", 3421, 7, 0, "isExtensible"],
0,
["Ident", 3421, 22, 0, "key"]
],
[
"Unary",
3422,
1,
0,
"delete",
"Binary",
3422,
13,
0,
["Ident", 3422, 13, 0, "key"],
".",
"Binary",
3422,
18,
0,
["This", 3422, 18, 0],
".",
"Const",
3422,
19,
0,
"_uid"
],
"BlockStatement",
3424,
1,
0,
0,
[
"Call",
3424,
1,
0,
[
"Binary",
3424,
1,
0,
["Ident", 3424, 1, 0, "check"],
".",
"Const",
3424,
1,
0,
"call"
],
0,
["This", 3424, 14, 0],
["Ident", 3424, 19, 0, "key"]
],
[
"Binary",
3425,
1,
0,
["Ident", 3425, 10, 0, "keys"],
"=",
"Binary",
3425,
17,
0,
["This", 3425, 17, 0],
".",
"Const",
3425,
19,
0,
"_keys"
],
[
"Binary",
3426,
1,
0,
["Ident", 3426, 18, 0, "index"],
"=",
"Call",
3426,
26,
0,
[
"Binary",
3426,
26,
0,
["Ident", 3426, 26, 0, "keys"],
".",
"Const",
3426,
32,
0,
"indexOf"
],
0,
["Ident", 3426, 41, 0, "key"]
],
[
"IfStatement",
3427,
1,
0,
0,
[
"Binary",
43,
7,
0,
["Ident", 3427, 9, 0, "index"],
"!==",
"Const",
3427,
18,
0,
-1
],
[
"BlockStatement",
3428,
1,
0,
0,
[
"Call",
3428,
1,
0,
[
"Binary",
3428,
1,
0,
["Ident", 3428, 1, 0, "keys"],
".",
"Const",
3428,
14,
0,
"splice"
],
0,
["Ident", 3428, 21, 0, "index"],
["Const", 3428, 28, 0, 1]
],
[
"Call",
3429,
1,
0,
[
"Binary",
3429,
1,
0,
[
"Binary",
3429,
1,
0,
["This", 3429, 1, 0],
".",
"Const",
3429,
10,
0,
"_values"
],
".",
"Const",
3429,
18,
0,
"splice"
],
0,
["Ident", 3429, 25, 0, "index"],
["Const", 3429, 32, 0, 1]
]
]
]
]
],
[
"Return",
2948,
1,
0,
"Ident",
3349,
86,
0,
"WeakMap"
]
],
0
],
type: "any",
dependencies: ["__create", "__owns", "__strnum", "GLOBAL", "WeakMap"]
},
__indexOfIdentical: {
helper: [
"Func",
3431,
39,
0,
0,
[
["Ident", 3431, 40, 0, "array"],
["Ident", 3431, 46, 0, "item"]
],
["_arr", "check", "i", "inf"],
[],
"BlockStatement",
3432,
1,
0,
0,
[
"IfStatement",
3432,
1,
0,
0,
[
"Binary",
3432,
5,
0,
[
"Unary",
3432,
5,
0,
"typeof",
"Ident",
3432,
12,
0,
"item"
],
"===",
"Const",
3432,
22,
0,
"number"
],
[
"IfStatement",
3433,
1,
0,
0,
[
"Binary",
43,
7,
0,
["Ident", 3433, 7, 0, "item"],
"!==",
"Ident",
3433,
7,
0,
"item"
],
[
"BlockStatement",
3434,
1,
0,
0,
[
"For",
1455,
1,
0,
0,
[
"BlockExpression",
0,
0,
0,
[
"Binary",
3434,
1,
0,
["Ident", 3434, 1, 0, "_arr"],
"=",
"Call",
1295,
22,
0,
["Ident", 1295, 22, 0, "__toArray"],
0,
["Ident", 3434, 22, 0, "array"]
],
[
"Binary",
1334,
26,
0,
["Ident", 3434, 17, 0, "i"],
"=",
"Binary",
1334,
49,
0,
["Ident", 3434, 1, 0, "_arr"],
".",
"Const",
1334,
56,
0,
"length"
]
],
[
"Unary",
1335,
16,
0,
"--post",
"Ident",
3434,
17,
0,
"i"
],
0,
"BlockStatement",
1417,
1,
0,
0,
[
"Binary",
1417,
1,
0,
["Ident", 3434, 10, 0, "check"],
"=",
"Binary",
1298,
75,
0,
["Ident", 3434, 1, 0, "_arr"],
".",
"Ident",
3434,
17,
0,
"i"
],
[
"IfStatement",
3435,
1,
0,
0,
[
"Binary",
43,
7,
0,
["Ident", 3435, 11, 0, "check"],
"!==",
"Ident",
3435,
11,
0,
"check"
],
[
"Return",
3436,
1,
0,
"Ident",
3436,
17,
0,
"i"
]
]
],
[
"Return",
3437,
1,
0,
"Const",
3437,
13,
0,
-1
]
],
"IfStatement",
3433,
1,
0,
0,
[
"Binary",
3438,
12,
0,
["Ident", 3438, 12, 0, "item"],
"===",
"Const",
3438,
21,
0,
0
],
[
"BlockStatement",
3439,
1,
0,
0,
[
"Binary",
3439,
1,
0,
["Ident", 3439, 10, 0, "inf"],
"=",
"Binary",
3439,
16,
0,
["Const", 3439, 17, 0, 1],
"/",
"Ident",
3439,
21,
0,
"item"
],
[
"For",
1455,
1,
0,
0,
[
"BlockExpression",
0,
0,
0,
[
"Binary",
3440,
1,
0,
["Ident", 3440, 1, 0, "_arr"],
"=",
"Call",
1295,
22,
0,
["Ident", 1295, 22, 0, "__toArray"],
0,
["Ident", 3440, 22, 0, "array"]
],
[
"Binary",
1334,
26,
0,
["Ident", 3440, 17, 0, "i"],
"=",
"Binary",
1334,
49,
0,
["Ident", 3440, 1, 0, "_arr"],
".",
"Const",
1334,
56,
0,
"length"
]
],
[
"Unary",
1335,
16,
0,
"--post",
"Ident",
3440,
17,
0,
"i"
],
0,
"BlockStatement",
1417,
1,
0,
0,
[
"Binary",
1417,
1,
0,
["Ident", 3440, 10, 0, "check"],
"=",
"Binary",
1298,
75,
0,
["Ident", 3440, 1, 0, "_arr"],
".",
"Ident",
3440,
17,
0,
"i"
],
[
"IfStatement",
3441,
1,
0,
0,
[
"Binary",
3441,
11,
0,
[
"Binary",
3441,
11,
0,
["Ident", 3441, 11, 0, "check"],
"===",
"Const",
3441,
21,
0,
0
],
"&&",
"Binary",
3441,
26,
0,
[
"Binary",
3441,
26,
0,
["Const", 3441, 27, 0, 1],
"/",
"Ident",
3441,
31,
0,
"check"
],
"===",
"Ident",
3441,
40,
0,
"inf"
],
[
"Return",
3442,
1,
0,
"Ident",
3442,
17,
0,
"i"
]
]
],
[
"Return",
3443,
1,
0,
"Const",
3443,
13,
0,
-1
]
]
]
],
[
"Return",
3444,
1,
0,
"Call",
3444,
1,
0,
[
"Binary",
3444,
1,
0,
["Ident", 3444, 1, 0, "array"],
".",
"Const",
3444,
9,
0,
"indexOf"
],
0,
["Ident", 3444, 18, 0, "item"]
]
],
type: "function",
dependencies: ["__indexOfIdentical", "__toArray"]
},
Map: {
helper: [
"IfExpression",
3446,
20,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
3446,
36,
0,
["Ident", 3446, 36, 0, "GLOBAL"],
".",
"Const",
3446,
44,
0,
"Map"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Binary",
3446,
52,
0,
["Ident", 3446, 52, 0, "GLOBAL"],
".",
"Const",
3446,
60,
0,
"Map"
],
"Binary",
2984,
10,
0,
["Ident", 3446, 74, 0, "Map"],
"=",
"Call",
2946,
1,
0,
[
"Func",
2946,
1,
0,
0,
[],
["_Map_prototype"],
[],
"BlockStatement",
2946,
1,
0,
0,
[
"Func",
2870,
29,
0,
["Ident", 3446, 74, 0, "Map"],
[["Ident", 3447, 19, 0, "iterable"]],
["_item", "_iter", "_this", "x"],
[],
"BlockStatement",
3448,
1,
0,
0,
[
"Binary",
3448,
1,
0,
["Ident", 3448, 1, 0, "_this"],
"=",
"IfExpression",
2869,
18,
0,
[
"Binary",
2869,
21,
0,
[
"Eval",
2869,
21,
0,
["Const", 2869, 27, 0, "this"]
],
"instanceof",
"Ident",
3446,
74,
0,
"Map"
],
[
"Eval",
2869,
56,
0,
["Const", 2869, 62, 0, "this"]
],
"Call",
2869,
74,
0,
["Ident", 2869, 74, 0, "__create"],
0,
["Ident", 3446, 68, 0, "_Map_prototype"]
],
[
"Binary",
3448,
1,
0,
[
"Binary",
3448,
1,
0,
["Ident", 3448, 1, 0, "_this"],
".",
"Const",
3448,
6,
0,
"_keys"
],
"=",
"Arr",
3448,
14,
0
],
[
"Binary",
3449,
1,
0,
[
"Binary",
3449,
1,
0,
["Ident", 3449, 1, 0, "_this"],
".",
"Const",
3449,
6,
0,
"_values"
],
"=",
"Arr",
3449,
16,
0
],
[
"IfStatement",
3450,
1,
0,
0,
[
"Binary",
49,
7,
0,
["Ident", 3450, 7, 0, "iterable"],
"!=",
"Const",
113,
19,
0,
null
],
[
"TryFinally",
2166,
8,
0,
0,
[
"For",
2162,
1,
0,
0,
[
"Binary",
3451,
1,
0,
["Ident", 3451, 1, 0, "_iter"],
"=",
"Call",
2089,
30,
0,
["Ident", 2089, 30, 0, "__iter"],
0,
["Ident", 3451, 17, 0, "iterable"]
],
["Const", 2162, 19, 0, true],
0,
"BlockStatement",
2129,
1,
0,
0,
[
"Binary",
2099,
1,
0,
["Ident", 3451, 1, 0, "_item"],
"=",
"Call",
2099,
18,
0,
[
"Binary",
2099,
18,
0,
["Ident", 3451, 1, 0, "_iter"],
".",
"Const",
2099,
29,
0,
"next"
],
0
],
[
"IfStatement",
2100,
1,
0,
0,
[
"Binary",
2100,
9,
0,
["Ident", 3451, 1, 0, "_item"],
".",
"Const",
2100,
16,
0,
"done"
],
["Break", 2101, 1, 0]
],
[
"Binary",
2102,
1,
0,
["Ident", 3451, 10, 0, "x"],
"=",
"Binary",
2102,
19,
0,
["Ident", 3451, 1, 0, "_item"],
".",
"Const",
2102,
26,
0,
"value"
],
[
"Call",
3452,
1,
0,
[
"Binary",
3452,
1,
0,
["Ident", 3452, 1, 0, "_this"],
".",
"Const",
3452,
10,
0,
"set"
],
0,
[
"Binary",
3452,
14,
0,
["Ident", 3452, 14, 0, "x"],
".",
"Const",
3452,
16,
0,
0
],
[
"Binary",
3452,
19,
0,
["Ident", 3452, 19, 0, "x"],
".",
"Const",
3452,
22,
0,
1
]
]
],
"TryCatch",
2169,
1,
0,
0,
[
"Call",
2170,
1,
0,
[
"Binary",
2170,
1,
0,
["Ident", 3451, 1, 0, "_iter"],
".",
"Const",
2170,
19,
0,
"close"
],
0
],
["Ident", 3451, 1, 0, "_e"],
"Const",
2172,
1,
0
]
],
[
"Return",
3448,
1,
0,
"Ident",
3448,
1,
0,
"_this"
]
],
[
"Binary",
2800,
20,
0,
["Ident", 3446, 68, 0, "_Map_prototype"],
"=",
"Binary",
2800,
37,
0,
["Ident", 3446, 74, 0, "Map"],
".",
"Const",
2800,
44,
0,
"prototype"
],
[
"Binary",
2812,
21,
0,
[
"Binary",
2812,
21,
0,
["Ident", 3446, 74, 0, "Map"],
".",
"Const",
2812,
28,
0,
"displayName"
],
"=",
"Const",
3446,
68,
0,
"Map"
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3446, 68, 0, "_Map_prototype"],
".",
"Const",
3454,
6,
0,
"get"
],
"=",
"Func",
3454,
10,
0,
0,
[["Ident", 3454, 11, 0, "key"]],
["index"],
[],
"BlockStatement",
3455,
1,
0,
0,
[
"Binary",
3455,
1,
0,
["Ident", 3455, 8, 0, "index"],
"=",
"Call",
3455,
16,
0,
["Ident", 3455, 16, 0, "__indexOfIdentical"],
0,
[
"Binary",
3455,
38,
0,
["This", 3455, 38, 0],
".",
"Const",
3455,
39,
0,
"_keys"
],
["Ident", 3455, 45, 0, "key"]
],
[
"IfStatement",
3456,
1,
0,
0,
[
"Binary",
3456,
7,
0,
["Ident", 3456, 7, 0, "index"],
"===",
"Const",
3456,
16,
0,
-1
],
[
"Return",
3457,
1,
0,
"Const",
3457,
1,
0
],
"Return",
3459,
1,
0,
"Binary",
3459,
1,
0,
[
"Binary",
3459,
1,
0,
["This", 3459, 1, 0],
".",
"Const",
3459,
8,
0,
"_values"
],
".",
"Ident",
3459,
16,
0,
"index"
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3446, 68, 0, "_Map_prototype"],
".",
"Const",
3461,
6,
0,
"has"
],
"=",
"Func",
3461,
10,
0,
0,
[["Ident", 3461, 11, 0, "key"]],
[],
[],
"Return",
43,
7,
0,
"Binary",
43,
7,
0,
[
"Call",
3462,
1,
0,
["Ident", 3462, 1, 0, "__indexOfIdentical"],
0,
[
"Binary",
3462,
26,
0,
["This", 3462, 26, 0],
".",
"Const",
3462,
27,
0,
"_keys"
],
["Ident", 3462, 33, 0, "key"]
],
"!==",
"Const",
3462,
41,
0,
-1
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3446, 68, 0, "_Map_prototype"],
".",
"Const",
3464,
6,
0,
"set"
],
"=",
"Func",
3464,
10,
0,
0,
[
["Ident", 3464, 11, 0, "key"],
["Ident", 3464, 15, 0, "value"]
],
["index", "keys"],
[],
"BlockExpression",
3465,
1,
0,
[
"Binary",
3465,
1,
0,
["Ident", 3465, 8, 0, "keys"],
"=",
"Binary",
3465,
15,
0,
["This", 3465, 15, 0],
".",
"Const",
3465,
17,
0,
"_keys"
],
[
"Binary",
3466,
1,
0,
["Ident", 3466, 16, 0, "index"],
"=",
"Call",
3466,
24,
0,
["Ident", 3466, 24, 0, "__indexOfIdentical"],
0,
["Ident", 3466, 46, 0, "keys"],
["Ident", 3466, 51, 0, "key"]
],
[
"IfExpression",
3467,
1,
0,
[
"Binary",
3467,
7,
0,
["Ident", 3467, 7, 0, "index"],
"===",
"Const",
3467,
16,
0,
-1
],
[
"BlockExpression",
3468,
1,
0,
[
"Binary",
3468,
1,
0,
["Ident", 3468, 1, 0, "index"],
"=",
"Binary",
3468,
15,
0,
["Ident", 3468, 15, 0, "keys"],
".",
"Const",
3468,
21,
0,
"length"
],
[
"Binary",
3469,
1,
0,
[
"Binary",
3469,
1,
0,
["Ident", 3469, 1, 0, "keys"],
".",
"Ident",
3469,
12,
0,
"index"
],
"=",
"Ident",
3469,
21,
0,
"key"
]
]
],
[
"Binary",
3470,
1,
0,
[
"Binary",
3470,
1,
0,
[
"Binary",
3470,
1,
0,
["This", 3470, 1, 0],
".",
"Const",
3470,
6,
0,
"_values"
],
".",
"Ident",
3470,
14,
0,
"index"
],
"=",
"Ident",
3470,
23,
0,
"value"
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3446, 68, 0, "_Map_prototype"],
".",
"Const",
3472,
6,
0,
"delete"
],
"=",
"Func",
3472,
13,
0,
0,
[["Ident", 3472, 14, 0, "key"]],
["index", "keys"],
[],
"BlockStatement",
3473,
1,
0,
0,
[
"Binary",
3473,
1,
0,
["Ident", 3473, 8, 0, "keys"],
"=",
"Binary",
3473,
15,
0,
["This", 3473, 15, 0],
".",
"Const",
3473,
17,
0,
"_keys"
],
[
"Binary",
3474,
1,
0,
["Ident", 3474, 8, 0, "index"],
"=",
"Call",
3474,
16,
0,
["Ident", 3474, 16, 0, "__indexOfIdentical"],
0,
["Ident", 3474, 38, 0, "keys"],
["Ident", 3474, 43, 0, "key"]
],
[
"IfStatement",
3475,
1,
0,
0,
[
"Binary",
3475,
7,
0,
["Ident", 3475, 7, 0, "index"],
"===",
"Const",
3475,
16,
0,
-1
],
[
"Return",
3476,
1,
0,
"Const",
3476,
1,
0,
false
],
"BlockStatement",
3478,
1,
0,
0,
[
"Call",
3478,
1,
0,
[
"Binary",
3478,
1,
0,
["Ident", 3478, 1, 0, "keys"],
".",
"Const",
3478,
12,
0,
"splice"
],
0,
["Ident", 3478, 19, 0, "index"],
["Const", 3478, 26, 0, 1]
],
[
"Return",
3479,
1,
0,
"Call",
3479,
1,
0,
[
"Binary",
3479,
1,
0,
[
"Binary",
3479,
1,
0,
["This", 3479, 1, 0],
".",
"Const",
3479,
8,
0,
"_values"
],
".",
"Const",
3479,
16,
0,
"splice"
],
0,
["Ident", 3479, 23, 0, "index"],
["Const", 3479, 30, 0, 1]
]
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3446, 68, 0, "_Map_prototype"],
".",
"Const",
3481,
6,
0,
"keys"
],
"=",
"Func",
3481,
11,
0,
0,
[],
[
"_arr",
"_e",
"_i",
"_send",
"_state",
"_step",
"_this",
"_throw",
"key"
],
[],
"BlockStatement",
3482,
1,
0,
0,
[
"Binary",
3482,
1,
0,
["Ident", 3482, 1, 0, "_this"],
"=",
"This",
3482,
1,
0
],
[
"Binary",
3481,
11,
0,
["Ident", 3481, 11, 0, "_state"],
"=",
"Const",
3481,
11,
0,
0
],
[
"Func",
3481,
11,
0,
["Ident", 3481, 11, 0, "_close"],
[],
[],
[],
"Binary",
3481,
11,
0,
["Ident", 3481, 11, 0, "_state"],
"=",
"Const",
3481,
11,
0,
3
],
[
"Func",
3481,
11,
0,
["Ident", 3481, 11, 0, "_step"],
[["Ident", 3481, 11, 0, "_received"]],
[],
[],
"For",
3481,
11,
0,
0,
0,
["Const", 3481, 11, 0, true],
0,
"Switch",
3481,
11,
0,
0,
["Ident", 3481, 11, 0, "_state"],
0,
0,
null,
["Const", 0, 0, 0, 0],
[
"BlockStatement",
0,
0,
0,
0,
[
"Binary",
3482,
1,
0,
["Ident", 3482, 1, 0, "_arr"],
"=",
"Call",
1295,
22,
0,
["Ident", 1295, 22, 0, "__toArray"],
0,
[
"Binary",
3482,
15,
0,
["Ident", 3482, 15, 0, "_this"],
".",
"Const",
3482,
17,
0,
"_keys"
]
],
[
"Binary",
1334,
26,
0,
["Ident", 3482, 1, 0, "_i"],
"=",
"Binary",
1334,
49,
0,
["Ident", 3482, 1, 0, "_arr"],
".",
"Const",
1334,
56,
0,
"length"
],
[
"Unary",
1455,
1,
0,
"++",
"Ident",
3481,
11,
0,
"_state"
]
],
1335,
16,
null,
["Const", 1335, 16, 0, 1],
[
"BlockStatement",
1335,
16,
0,
0,
[
"Binary",
1335,
16,
0,
["Ident", 3481, 11, 0, "_state"],
"=",
"IfExpression",
1335,
16,
0,
[
"Unary",
1335,
16,
0,
"--post",
"Ident",
3482,
1,
0,
"_i"
],
["Const", 1335, 16, 0, 2],
"Const",
1335,
16,
0,
3
],
["Break", 1335, 16, 0]
],
1417,
1,
null,
["Const", 1417, 1, 0, 2],
[
"BlockStatement",
1417,
1,
0,
0,
[
"Binary",
1417,
1,
0,
["Ident", 3482, 8, 0, "key"],
"=",
"Binary",
1298,
75,
0,
["Ident", 3482, 1, 0, "_arr"],
".",
"Ident",
3482,
1,
0,
"_i"
],
[
"Binary",
3483,
1,
0,
["Ident", 3481, 11, 0, "_state"],
"=",
"Const",
3483,
1,
0,
1
],
[
"Return",
3483,
1,
0,
"Obj",
3483,
1,
0,
3483,
1,
null,
"done",
["Const", 3483, 1, 0, false],
3483,
1,
null,
"value",
["Ident", 3483, 12, 0, "key"]
]
],
3481,
11,
null,
["Const", 3481, 11, 0, 3],
[
"Return",
3481,
11,
0,
"Obj",
3481,
11,
0,
3481,
11,
null,
"done",
["Const", 3481, 11, 0, true],
3481,
11,
null,
"value",
["Const", 3481, 11, 0]
],
[
"Throw",
3481,
11,
0,
"Call",
3481,
11,
0,
["Ident", 3481, 11, 0, "Error"],
0,
[
"Binary",
3481,
11,
0,
["Const", 3481, 11, 0, "Unknown state: "],
"+",
"Ident",
3481,
11,
0,
"_state"
]
]
],
[
"Func",
3481,
11,
0,
["Ident", 3481, 11, 0, "_throw"],
[["Ident", 3481, 11, 0, "_e"]],
[],
[],
"BlockStatement",
3481,
11,
0,
0,
[
"Call",
3481,
11,
0,
["Ident", 3481, 11, 0, "_close"],
0
],
[
"Throw",
3481,
11,
0,
"Ident",
3481,
11,
0,
"_e"
]
],
[
"Func",
3481,
11,
0,
["Ident", 3481, 11, 0, "_send"],
[["Ident", 3481, 11, 0, "_received"]],
[],
[],
"TryCatch",
3481,
11,
0,
0,
[
"Return",
3481,
11,
0,
"Call",
3481,
11,
0,
["Ident", 3481, 11, 0, "_step"],
0,
["Ident", 3481, 11, 0, "_received"]
],
["Ident", 3481, 11, 0, "_e"],
"Call",
3481,
11,
0,
["Ident", 3481, 11, 0, "_throw"],
0,
["Ident", 3481, 11, 0, "_e"]
],
[
"Return",
3481,
11,
0,
"Obj",
3481,
11,
0,
3481,
11,
null,
"close",
["Ident", 3481, 11, 0, "_close"],
3481,
11,
null,
"iterator",
[
"Func",
3481,
11,
0,
0,
[],
[],
[],
"Return",
3481,
11,
0,
"This",
3481,
11,
0
],
3481,
11,
null,
"next",
[
"Func",
3481,
11,
0,
0,
[],
[],
[],
"Return",
3481,
11,
0,
"Call",
3481,
11,
0,
["Ident", 3481, 11, 0, "_send"],
0,
["Const", 3481, 11, 0]
],
3481,
11,
null,
"send",
["Ident", 3481, 11, 0, "_send"],
3481,
11,
null,
"throw",
[
"Func",
3481,
11,
0,
0,
[["Ident", 3481, 11, 0, "_e"]],
[],
[],
"BlockStatement",
3481,
11,
0,
0,
[
"Call",
3481,
11,
0,
["Ident", 3481, 11, 0, "_throw"],
0,
["Ident", 3481, 11, 0, "_e"]
],
[
"Return",
3481,
11,
0,
"Call",
3481,
11,
0,
["Ident", 3481, 11, 0, "_send"],
0,
["Const", 3481, 11, 0]
]
]
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3446, 68, 0, "_Map_prototype"],
".",
"Const",
3485,
6,
0,
"values"
],
"=",
"Func",
3485,
13,
0,
0,
[],
[
"_arr",
"_e",
"_i",
"_send",
"_state",
"_step",
"_this",
"_throw",
"value"
],
[],
"BlockStatement",
3486,
1,
0,
0,
[
"Binary",
3486,
1,
0,
["Ident", 3486, 1, 0, "_this"],
"=",
"This",
3486,
1,
0
],
[
"Binary",
3485,
13,
0,
["Ident", 3485, 13, 0, "_state"],
"=",
"Const",
3485,
13,
0,
0
],
[
"Func",
3485,
13,
0,
["Ident", 3485, 13, 0, "_close"],
[],
[],
[],
"Binary",
3485,
13,
0,
["Ident", 3485, 13, 0, "_state"],
"=",
"Const",
3485,
13,
0,
3
],
[
"Func",
3485,
13,
0,
["Ident", 3485, 13, 0, "_step"],
[["Ident", 3485, 13, 0, "_received"]],
[],
[],
"For",
3485,
13,
0,
0,
0,
["Const", 3485, 13, 0, true],
0,
"Switch",
3485,
13,
0,
0,
["Ident", 3485, 13, 0, "_state"],
0,
0,
null,
["Const", 0, 0, 0, 0],
[
"BlockStatement",
0,
0,
0,
0,
[
"Binary",
3486,
1,
0,
["Ident", 3486, 1, 0, "_arr"],
"=",
"Call",
1295,
22,
0,
["Ident", 1295, 22, 0, "__toArray"],
0,
[
"Binary",
3486,
17,
0,
["Ident", 3486, 17, 0, "_this"],
".",
"Const",
3486,
19,
0,
"_values"
]
],
[
"Binary",
1334,
26,
0,
["Ident", 3486, 1, 0, "_i"],
"=",
"Binary",
1334,
49,
0,
["Ident", 3486, 1, 0, "_arr"],
".",
"Const",
1334,
56,
0,
"length"
],
[
"Unary",
1455,
1,
0,
"++",
"Ident",
3485,
13,
0,
"_state"
]
],
1335,
16,
null,
["Const", 1335, 16, 0, 1],
[
"BlockStatement",
1335,
16,
0,
0,
[
"Binary",
1335,
16,
0,
["Ident", 3485, 13, 0, "_state"],
"=",
"IfExpression",
1335,
16,
0,
[
"Unary",
1335,
16,
0,
"--post",
"Ident",
3486,
1,
0,
"_i"
],
["Const", 1335, 16, 0, 2],
"Const",
1335,
16,
0,
3
],
["Break", 1335, 16, 0]
],
1417,
1,
null,
["Const", 1417, 1, 0, 2],
[
"BlockStatement",
1417,
1,
0,
0,
[
"Binary",
1417,
1,
0,
["Ident", 3486, 8, 0, "value"],
"=",
"Binary",
1298,
75,
0,
["Ident", 3486, 1, 0, "_arr"],
".",
"Ident",
3486,
1,
0,
"_i"
],
[
"Binary",
3487,
1,
0,
["Ident", 3485, 13, 0, "_state"],
"=",
"Const",
3487,
1,
0,
1
],
[
"Return",
3487,
1,
0,
"Obj",
3487,
1,
0,
3487,
1,
null,
"done",
["Const", 3487, 1, 0, false],
3487,
1,
null,
"value",
["Ident", 3487, 12, 0, "value"]
]
],
3485,
13,
null,
["Const", 3485, 13, 0, 3],
[
"Return",
3485,
13,
0,
"Obj",
3485,
13,
0,
3485,
13,
null,
"done",
["Const", 3485, 13, 0, true],
3485,
13,
null,
"value",
["Const", 3485, 13, 0]
],
[
"Throw",
3485,
13,
0,
"Call",
3485,
13,
0,
["Ident", 3485, 13, 0, "Error"],
0,
[
"Binary",
3485,
13,
0,
["Const", 3485, 13, 0, "Unknown state: "],
"+",
"Ident",
3485,
13,
0,
"_state"
]
]
],
[
"Func",
3485,
13,
0,
["Ident", 3485, 13, 0, "_throw"],
[["Ident", 3485, 13, 0, "_e"]],
[],
[],
"BlockStatement",
3485,
13,
0,
0,
[
"Call",
3485,
13,
0,
["Ident", 3485, 13, 0, "_close"],
0
],
[
"Throw",
3485,
13,
0,
"Ident",
3485,
13,
0,
"_e"
]
],
[
"Func",
3485,
13,
0,
["Ident", 3485, 13, 0, "_send"],
[["Ident", 3485, 13, 0, "_received"]],
[],
[],
"TryCatch",
3485,
13,
0,
0,
[
"Return",
3485,
13,
0,
"Call",
3485,
13,
0,
["Ident", 3485, 13, 0, "_step"],
0,
["Ident", 3485, 13, 0, "_received"]
],
["Ident", 3485, 13, 0, "_e"],
"Call",
3485,
13,
0,
["Ident", 3485, 13, 0, "_throw"],
0,
["Ident", 3485, 13, 0, "_e"]
],
[
"Return",
3485,
13,
0,
"Obj",
3485,
13,
0,
3485,
13,
null,
"close",
["Ident", 3485, 13, 0, "_close"],
3485,
13,
null,
"iterator",
[
"Func",
3485,
13,
0,
0,
[],
[],
[],
"Return",
3485,
13,
0,
"This",
3485,
13,
0
],
3485,
13,
null,
"next",
[
"Func",
3485,
13,
0,
0,
[],
[],
[],
"Return",
3485,
13,
0,
"Call",
3485,
13,
0,
["Ident", 3485, 13, 0, "_send"],
0,
["Const", 3485, 13, 0]
],
3485,
13,
null,
"send",
["Ident", 3485, 13, 0, "_send"],
3485,
13,
null,
"throw",
[
"Func",
3485,
13,
0,
0,
[["Ident", 3485, 13, 0, "_e"]],
[],
[],
"BlockStatement",
3485,
13,
0,
0,
[
"Call",
3485,
13,
0,
["Ident", 3485, 13, 0, "_throw"],
0,
["Ident", 3485, 13, 0, "_e"]
],
[
"Return",
3485,
13,
0,
"Call",
3485,
13,
0,
["Ident", 3485, 13, 0, "_send"],
0,
["Const", 3485, 13, 0]
]
]
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3446, 68, 0, "_Map_prototype"],
".",
"Const",
3489,
6,
0,
"items"
],
"=",
"Func",
3489,
12,
0,
0,
[],
[
"_arr",
"_e",
"_send",
"_state",
"_step",
"_this",
"_throw",
"i",
"key",
"values"
],
[],
"BlockStatement",
3490,
1,
0,
0,
[
"Binary",
3490,
1,
0,
["Ident", 3490, 1, 0, "_this"],
"=",
"This",
3490,
1,
0
],
[
"Binary",
3489,
12,
0,
["Ident", 3489, 12, 0, "_state"],
"=",
"Const",
3489,
12,
0,
0
],
[
"Func",
3489,
12,
0,
["Ident", 3489, 12, 0, "_close"],
[],
[],
[],
"Binary",
3489,
12,
0,
["Ident", 3489, 12, 0, "_state"],
"=",
"Const",
3489,
12,
0,
3
],
[
"Func",
3489,
12,
0,
["Ident", 3489, 12, 0, "_step"],
[["Ident", 3489, 12, 0, "_received"]],
[],
[],
"For",
3489,
12,
0,
0,
0,
["Const", 3489, 12, 0, true],
0,
"Switch",
3489,
12,
0,
0,
["Ident", 3489, 12, 0, "_state"],
3490,
1,
null,
["Const", 3490, 1, 0, 0],
[
"BlockStatement",
3490,
1,
0,
0,
[
"Binary",
3490,
1,
0,
["Ident", 3490, 8, 0, "values"],
"=",
"Binary",
3490,
17,
0,
["Ident", 3490, 17, 0, "_this"],
".",
"Const",
3490,
19,
0,
"_values"
],
[
"Binary",
3491,
1,
0,
["Ident", 3491, 1, 0, "_arr"],
"=",
"Call",
1295,
22,
0,
["Ident", 1295, 22, 0, "__toArray"],
0,
[
"Binary",
3491,
18,
0,
["Ident", 3491, 18, 0, "_this"],
".",
"Const",
3491,
20,
0,
"_keys"
]
],
[
"Binary",
1334,
26,
0,
["Ident", 3491, 13, 0, "i"],
"=",
"Binary",
1334,
49,
0,
["Ident", 3491, 1, 0, "_arr"],
".",
"Const",
1334,
56,
0,
"length"
],
[
"Unary",
1455,
1,
0,
"++",
"Ident",
3489,
12,
0,
"_state"
]
],
1335,
16,
null,
["Const", 1335, 16, 0, 1],
[
"BlockStatement",
1335,
16,
0,
0,
[
"Binary",
1335,
16,
0,
["Ident", 3489, 12, 0, "_state"],
"=",
"IfExpression",
1335,
16,
0,
[
"Unary",
1335,
16,
0,
"--post",
"Ident",
3491,
13,
0,
"i"
],
["Const", 1335, 16, 0, 2],
"Const",
1335,
16,
0,
3
],
["Break", 1335, 16, 0]
],
1417,
1,
null,
["Const", 1417, 1, 0, 2],
[
"BlockStatement",
1417,
1,
0,
0,
[
"Binary",
1417,
1,
0,
["Ident", 3491, 8, 0, "key"],
"=",
"Binary",
1298,
75,
0,
["Ident", 3491, 1, 0, "_arr"],
".",
"Ident",
3491,
13,
0,
"i"
],
[
"Binary",
3492,
1,
0,
["Ident", 3489, 12, 0, "_state"],
"=",
"Const",
3492,
1,
0,
1
],
[
"Return",
3492,
1,
0,
"Obj",
3492,
1,
0,
3492,
1,
null,
"done",
["Const", 3492, 1, 0, false],
3492,
1,
null,
"value",
[
"Arr",
3492,
12,
0,
["Ident", 3492, 14, 0, "key"],
[
"Binary",
3492,
18,
0,
["Ident", 3492, 18, 0, "values"],
".",
"Ident",
3492,
26,
0,
"i"
]
]
]
],
3489,
12,
null,
["Const", 3489, 12, 0, 3],
[
"Return",
3489,
12,
0,
"Obj",
3489,
12,
0,
3489,
12,
null,
"done",
["Const", 3489, 12, 0, true],
3489,
12,
null,
"value",
["Const", 3489, 12, 0]
],
[
"Throw",
3489,
12,
0,
"Call",
3489,
12,
0,
["Ident", 3489, 12, 0, "Error"],
0,
[
"Binary",
3489,
12,
0,
["Const", 3489, 12, 0, "Unknown state: "],
"+",
"Ident",
3489,
12,
0,
"_state"
]
]
],
[
"Func",
3489,
12,
0,
["Ident", 3489, 12, 0, "_throw"],
[["Ident", 3489, 12, 0, "_e"]],
[],
[],
"BlockStatement",
3489,
12,
0,
0,
[
"Call",
3489,
12,
0,
["Ident", 3489, 12, 0, "_close"],
0
],
[
"Throw",
3489,
12,
0,
"Ident",
3489,
12,
0,
"_e"
]
],
[
"Func",
3489,
12,
0,
["Ident", 3489, 12, 0, "_send"],
[["Ident", 3489, 12, 0, "_received"]],
[],
[],
"TryCatch",
3489,
12,
0,
0,
[
"Return",
3489,
12,
0,
"Call",
3489,
12,
0,
["Ident", 3489, 12, 0, "_step"],
0,
["Ident", 3489, 12, 0, "_received"]
],
["Ident", 3489, 12, 0, "_e"],
"Call",
3489,
12,
0,
["Ident", 3489, 12, 0, "_throw"],
0,
["Ident", 3489, 12, 0, "_e"]
],
[
"Return",
3489,
12,
0,
"Obj",
3489,
12,
0,
3489,
12,
null,
"close",
["Ident", 3489, 12, 0, "_close"],
3489,
12,
null,
"iterator",
[
"Func",
3489,
12,
0,
0,
[],
[],
[],
"Return",
3489,
12,
0,
"This",
3489,
12,
0
],
3489,
12,
null,
"next",
[
"Func",
3489,
12,
0,
0,
[],
[],
[],
"Return",
3489,
12,
0,
"Call",
3489,
12,
0,
["Ident", 3489, 12, 0, "_send"],
0,
["Const", 3489, 12, 0]
],
3489,
12,
null,
"send",
["Ident", 3489, 12, 0, "_send"],
3489,
12,
null,
"throw",
[
"Func",
3489,
12,
0,
0,
[["Ident", 3489, 12, 0, "_e"]],
[],
[],
"BlockStatement",
3489,
12,
0,
0,
[
"Call",
3489,
12,
0,
["Ident", 3489, 12, 0, "_throw"],
0,
["Ident", 3489, 12, 0, "_e"]
],
[
"Return",
3489,
12,
0,
"Call",
3489,
12,
0,
["Ident", 3489, 12, 0, "_send"],
0,
["Const", 3489, 12, 0]
]
]
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3446, 68, 0, "_Map_prototype"],
".",
"Const",
3493,
6,
0,
"iterator"
],
"=",
"Binary",
3493,
17,
0,
[
"Binary",
3493,
17,
0,
["Ident", 3493, 17, 0, "Map"],
".",
"Const",
3493,
17,
0,
"prototype"
],
".",
"Const",
3493,
23,
0,
"items"
],
[
"Return",
2948,
1,
0,
"Ident",
3446,
74,
0,
"Map"
]
],
0
],
type: "any",
dependencies: ["__create", "__indexOfIdentical", "__iter", "__toArray", "GLOBAL", "Map"]
},
Set: {
helper: [
"IfExpression",
3495,
20,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
3495,
36,
0,
["Ident", 3495, 36, 0, "GLOBAL"],
".",
"Const",
3495,
44,
0,
"Set"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Binary",
3495,
52,
0,
["Ident", 3495, 52, 0, "GLOBAL"],
".",
"Const",
3495,
60,
0,
"Set"
],
"Binary",
2984,
10,
0,
["Ident", 3495, 74, 0, "Set"],
"=",
"Call",
2946,
1,
0,
[
"Func",
2946,
1,
0,
0,
[],
["_Set_prototype"],
[],
"BlockStatement",
2946,
1,
0,
0,
[
"Func",
2870,
29,
0,
["Ident", 3495, 74, 0, "Set"],
[["Ident", 3496, 19, 0, "iterable"]],
["_item", "_iter", "_this", "item"],
[],
"BlockStatement",
3497,
1,
0,
0,
[
"Binary",
3497,
1,
0,
["Ident", 3497, 1, 0, "_this"],
"=",
"IfExpression",
2869,
18,
0,
[
"Binary",
2869,
21,
0,
[
"Eval",
2869,
21,
0,
["Const", 2869, 27, 0, "this"]
],
"instanceof",
"Ident",
3495,
74,
0,
"Set"
],
[
"Eval",
2869,
56,
0,
["Const", 2869, 62, 0, "this"]
],
"Call",
2869,
74,
0,
["Ident", 2869, 74, 0, "__create"],
0,
["Ident", 3495, 68, 0, "_Set_prototype"]
],
[
"Binary",
3497,
1,
0,
[
"Binary",
3497,
1,
0,
["Ident", 3497, 1, 0, "_this"],
".",
"Const",
3497,
6,
0,
"_items"
],
"=",
"Arr",
3497,
15,
0
],
[
"IfStatement",
3498,
1,
0,
0,
[
"Binary",
49,
7,
0,
["Ident", 3498, 7, 0, "iterable"],
"!=",
"Const",
113,
19,
0,
null
],
[
"TryFinally",
2166,
8,
0,
0,
[
"For",
2162,
1,
0,
0,
[
"Binary",
3499,
1,
0,
["Ident", 3499, 1, 0, "_iter"],
"=",
"Call",
2089,
30,
0,
["Ident", 2089, 30, 0, "__iter"],
0,
["Ident", 3499, 20, 0, "iterable"]
],
["Const", 2162, 19, 0, true],
0,
"BlockStatement",
2129,
1,
0,
0,
[
"Binary",
2099,
1,
0,
["Ident", 3499, 1, 0, "_item"],
"=",
"Call",
2099,
18,
0,
[
"Binary",
2099,
18,
0,
["Ident", 3499, 1, 0, "_iter"],
".",
"Const",
2099,
29,
0,
"next"
],
0
],
[
"IfStatement",
2100,
1,
0,
0,
[
"Binary",
2100,
9,
0,
["Ident", 3499, 1, 0, "_item"],
".",
"Const",
2100,
16,
0,
"done"
],
["Break", 2101, 1, 0]
],
[
"Binary",
2102,
1,
0,
["Ident", 3499, 10, 0, "item"],
"=",
"Binary",
2102,
19,
0,
["Ident", 3499, 1, 0, "_item"],
".",
"Const",
2102,
26,
0,
"value"
],
[
"Call",
3500,
1,
0,
[
"Binary",
3500,
1,
0,
["Ident", 3500, 1, 0, "_this"],
".",
"Const",
3500,
10,
0,
"add"
],
0,
["Ident", 3500, 14, 0, "item"]
]
],
"TryCatch",
2169,
1,
0,
0,
[
"Call",
2170,
1,
0,
[
"Binary",
2170,
1,
0,
["Ident", 3499, 1, 0, "_iter"],
".",
"Const",
2170,
19,
0,
"close"
],
0
],
["Ident", 3499, 1, 0, "_e"],
"Const",
2172,
1,
0
]
],
[
"Return",
3497,
1,
0,
"Ident",
3497,
1,
0,
"_this"
]
],
[
"Binary",
2800,
20,
0,
["Ident", 3495, 68, 0, "_Set_prototype"],
"=",
"Binary",
2800,
37,
0,
["Ident", 3495, 74, 0, "Set"],
".",
"Const",
2800,
44,
0,
"prototype"
],
[
"Binary",
2812,
21,
0,
[
"Binary",
2812,
21,
0,
["Ident", 3495, 74, 0, "Set"],
".",
"Const",
2812,
28,
0,
"displayName"
],
"=",
"Const",
3495,
68,
0,
"Set"
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3495, 68, 0, "_Set_prototype"],
".",
"Const",
3502,
6,
0,
"has"
],
"=",
"Func",
3502,
10,
0,
0,
[["Ident", 3502, 11, 0, "item"]],
[],
[],
"Return",
43,
7,
0,
"Binary",
43,
7,
0,
[
"Call",
3503,
1,
0,
["Ident", 3503, 1, 0, "__indexOfIdentical"],
0,
[
"Binary",
3503,
26,
0,
["This", 3503, 26, 0],
".",
"Const",
3503,
27,
0,
"_items"
],
["Ident", 3503, 34, 0, "item"]
],
"!==",
"Const",
3503,
43,
0,
-1
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3495, 68, 0, "_Set_prototype"],
".",
"Const",
3504,
6,
0,
"add"
],
"=",
"Func",
3504,
10,
0,
0,
[["Ident", 3504, 11, 0, "item"]],
["items"],
[],
"BlockExpression",
3505,
1,
0,
[
"Binary",
3505,
1,
0,
["Ident", 3505, 8, 0, "items"],
"=",
"Binary",
3505,
16,
0,
["This", 3505, 16, 0],
".",
"Const",
3505,
18,
0,
"_items"
],
[
"IfExpression",
3506,
1,
0,
[
"Binary",
3506,
7,
0,
[
"Call",
3506,
7,
0,
["Ident", 3506, 7, 0, "__indexOfIdentical"],
0,
["Ident", 3506, 29, 0, "items"],
["Ident", 3506, 35, 0, "item"]
],
"===",
"Const",
3506,
44,
0,
-1
],
[
"Call",
3507,
1,
0,
[
"Binary",
3507,
1,
0,
["Ident", 3507, 1, 0, "items"],
".",
"Const",
3507,
13,
0,
"push"
],
0,
["Ident", 3507, 18, 0, "item"]
]
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3495, 68, 0, "_Set_prototype"],
".",
"Const",
3508,
6,
0,
"delete"
],
"=",
"Func",
3508,
13,
0,
0,
[["Ident", 3508, 14, 0, "item"]],
["index", "items"],
[],
"BlockExpression",
3509,
1,
0,
[
"Binary",
3509,
1,
0,
["Ident", 3509, 8, 0, "items"],
"=",
"Binary",
3509,
16,
0,
["This", 3509, 16, 0],
".",
"Const",
3509,
18,
0,
"_items"
],
[
"Binary",
3510,
1,
0,
["Ident", 3510, 8, 0, "index"],
"=",
"Call",
3510,
16,
0,
["Ident", 3510, 16, 0, "__indexOfIdentical"],
0,
["Ident", 3510, 38, 0, "items"],
["Ident", 3510, 44, 0, "item"]
],
[
"IfExpression",
3511,
1,
0,
[
"Binary",
43,
7,
0,
["Ident", 3511, 7, 0, "index"],
"!==",
"Const",
3511,
16,
0,
-1
],
[
"BlockExpression",
3512,
1,
0,
[
"Call",
3512,
1,
0,
[
"Binary",
3512,
1,
0,
["Ident", 3512, 1, 0, "items"],
".",
"Const",
3512,
13,
0,
"splice"
],
0,
["Ident", 3512, 20, 0, "index"],
["Const", 3512, 27, 0, 1]
],
["Const", 3513, 1, 0, true]
],
"Const",
3515,
1,
0,
false
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3495, 68, 0, "_Set_prototype"],
".",
"Const",
3516,
6,
0,
"values"
],
"=",
"Func",
3516,
13,
0,
0,
[],
[
"_arr",
"_e",
"_i",
"_send",
"_state",
"_step",
"_this",
"_throw",
"item"
],
[],
"BlockStatement",
3517,
1,
0,
0,
[
"Binary",
3517,
1,
0,
["Ident", 3517, 1, 0, "_this"],
"=",
"This",
3517,
1,
0
],
[
"Binary",
3516,
13,
0,
["Ident", 3516, 13, 0, "_state"],
"=",
"Const",
3516,
13,
0,
0
],
[
"Func",
3516,
13,
0,
["Ident", 3516, 13, 0, "_close"],
[],
[],
[],
"Binary",
3516,
13,
0,
["Ident", 3516, 13, 0, "_state"],
"=",
"Const",
3516,
13,
0,
3
],
[
"Func",
3516,
13,
0,
["Ident", 3516, 13, 0, "_step"],
[["Ident", 3516, 13, 0, "_received"]],
[],
[],
"For",
3516,
13,
0,
0,
0,
["Const", 3516, 13, 0, true],
0,
"Switch",
3516,
13,
0,
0,
["Ident", 3516, 13, 0, "_state"],
0,
0,
null,
["Const", 0, 0, 0, 0],
[
"BlockStatement",
0,
0,
0,
0,
[
"Binary",
3517,
1,
0,
["Ident", 3517, 1, 0, "_arr"],
"=",
"Call",
1295,
22,
0,
["Ident", 1295, 22, 0, "__toArray"],
0,
[
"Binary",
3517,
16,
0,
["Ident", 3517, 16, 0, "_this"],
".",
"Const",
3517,
18,
0,
"_items"
]
],
[
"Binary",
1334,
26,
0,
["Ident", 3517, 1, 0, "_i"],
"=",
"Binary",
1334,
49,
0,
["Ident", 3517, 1, 0, "_arr"],
".",
"Const",
1334,
56,
0,
"length"
],
[
"Unary",
1455,
1,
0,
"++",
"Ident",
3516,
13,
0,
"_state"
]
],
1335,
16,
null,
["Const", 1335, 16, 0, 1],
[
"BlockStatement",
1335,
16,
0,
0,
[
"Binary",
1335,
16,
0,
["Ident", 3516, 13, 0, "_state"],
"=",
"IfExpression",
1335,
16,
0,
[
"Unary",
1335,
16,
0,
"--post",
"Ident",
3517,
1,
0,
"_i"
],
["Const", 1335, 16, 0, 2],
"Const",
1335,
16,
0,
3
],
["Break", 1335, 16, 0]
],
1417,
1,
null,
["Const", 1417, 1, 0, 2],
[
"BlockStatement",
1417,
1,
0,
0,
[
"Binary",
1417,
1,
0,
["Ident", 3517, 8, 0, "item"],
"=",
"Binary",
1298,
75,
0,
["Ident", 3517, 1, 0, "_arr"],
".",
"Ident",
3517,
1,
0,
"_i"
],
[
"Binary",
3518,
1,
0,
["Ident", 3516, 13, 0, "_state"],
"=",
"Const",
3518,
1,
0,
1
],
[
"Return",
3518,
1,
0,
"Obj",
3518,
1,
0,
3518,
1,
null,
"done",
["Const", 3518, 1, 0, false],
3518,
1,
null,
"value",
["Ident", 3518, 12, 0, "item"]
]
],
3516,
13,
null,
["Const", 3516, 13, 0, 3],
[
"Return",
3516,
13,
0,
"Obj",
3516,
13,
0,
3516,
13,
null,
"done",
["Const", 3516, 13, 0, true],
3516,
13,
null,
"value",
["Const", 3516, 13, 0]
],
[
"Throw",
3516,
13,
0,
"Call",
3516,
13,
0,
["Ident", 3516, 13, 0, "Error"],
0,
[
"Binary",
3516,
13,
0,
["Const", 3516, 13, 0, "Unknown state: "],
"+",
"Ident",
3516,
13,
0,
"_state"
]
]
],
[
"Func",
3516,
13,
0,
["Ident", 3516, 13, 0, "_throw"],
[["Ident", 3516, 13, 0, "_e"]],
[],
[],
"BlockStatement",
3516,
13,
0,
0,
[
"Call",
3516,
13,
0,
["Ident", 3516, 13, 0, "_close"],
0
],
[
"Throw",
3516,
13,
0,
"Ident",
3516,
13,
0,
"_e"
]
],
[
"Func",
3516,
13,
0,
["Ident", 3516, 13, 0, "_send"],
[["Ident", 3516, 13, 0, "_received"]],
[],
[],
"TryCatch",
3516,
13,
0,
0,
[
"Return",
3516,
13,
0,
"Call",
3516,
13,
0,
["Ident", 3516, 13, 0, "_step"],
0,
["Ident", 3516, 13, 0, "_received"]
],
["Ident", 3516, 13, 0, "_e"],
"Call",
3516,
13,
0,
["Ident", 3516, 13, 0, "_throw"],
0,
["Ident", 3516, 13, 0, "_e"]
],
[
"Return",
3516,
13,
0,
"Obj",
3516,
13,
0,
3516,
13,
null,
"close",
["Ident", 3516, 13, 0, "_close"],
3516,
13,
null,
"iterator",
[
"Func",
3516,
13,
0,
0,
[],
[],
[],
"Return",
3516,
13,
0,
"This",
3516,
13,
0
],
3516,
13,
null,
"next",
[
"Func",
3516,
13,
0,
0,
[],
[],
[],
"Return",
3516,
13,
0,
"Call",
3516,
13,
0,
["Ident", 3516, 13, 0, "_send"],
0,
["Const", 3516, 13, 0]
],
3516,
13,
null,
"send",
["Ident", 3516, 13, 0, "_send"],
3516,
13,
null,
"throw",
[
"Func",
3516,
13,
0,
0,
[["Ident", 3516, 13, 0, "_e"]],
[],
[],
"BlockStatement",
3516,
13,
0,
0,
[
"Call",
3516,
13,
0,
["Ident", 3516, 13, 0, "_throw"],
0,
["Ident", 3516, 13, 0, "_e"]
],
[
"Return",
3516,
13,
0,
"Call",
3516,
13,
0,
["Ident", 3516, 13, 0, "_send"],
0,
["Const", 3516, 13, 0]
]
]
]
],
[
"Binary",
2935,
25,
0,
[
"Binary",
2935,
25,
0,
["Ident", 3495, 68, 0, "_Set_prototype"],
".",
"Const",
3519,
6,
0,
"iterator"
],
"=",
"Binary",
3519,
17,
0,
[
"Binary",
3519,
17,
0,
["Ident", 3519, 17, 0, "Set"],
".",
"Const",
3519,
17,
0,
"prototype"
],
".",
"Const",
3519,
23,
0,
"values"
],
[
"Return",
2948,
1,
0,
"Ident",
3495,
74,
0,
"Set"
]
],
0
],
type: "any",
dependencies: ["__create", "__indexOfIdentical", "__iter", "__toArray", "GLOBAL", "Set"]
},
setImmediate: {
helper: [
"IfExpression",
3584,
30,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
3584,
46,
0,
["Ident", 3584, 46, 0, "GLOBAL"],
".",
"Const",
3584,
54,
0,
"setImmediate"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Binary",
3585,
1,
0,
["Ident", 3585, 1, 0, "GLOBAL"],
".",
"Const",
3585,
10,
0,
"setImmediate"
],
"IfExpression",
3584,
30,
0,
[
"Binary",
3586,
8,
0,
[
"Binary",
3586,
8,
0,
[
"Unary",
117,
9,
0,
"typeof",
"Ident",
3586,
21,
0,
"process"
],
"!==",
"Const",
117,
27,
0,
"undefined"
],
"&&",
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
3586,
46,
0,
["Ident", 3586, 46, 0, "process"],
".",
"Const",
3586,
55,
0,
"nextTick"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
["nextTick"],
[],
"BlockStatement",
3588,
1,
0,
0,
[
"Binary",
3588,
1,
0,
["Ident", 3588, 8, 0, "nextTick"],
"=",
"Binary",
3588,
20,
0,
["Ident", 3588, 20, 0, "process"],
".",
"Const",
3588,
29,
0,
"nextTick"
],
[
"Return",
1855,
1,
0,
"Func",
1855,
1,
0,
0,
[["Ident", 3589, 7, 0, "func"]],
["args"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3589,
7,
0,
"func"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected func to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3589, 7, 0, "func"]
]
]
],
[
"Binary",
1834,
1,
0,
["Ident", 3589, 22, 0, "args"],
"=",
"Call",
1834,
23,
0,
[
"Binary",
1834,
23,
0,
["Ident", 1834, 23, 0, "__slice"],
".",
"Const",
1834,
23,
0,
"call"
],
0,
["Arguments", 1834, 33, 0],
["Const", 0, 0, 0, 1]
],
[
"IfStatement",
3590,
1,
0,
0,
[
"Binary",
3590,
9,
0,
["Ident", 3590, 9, 0, "args"],
".",
"Const",
3590,
15,
0,
"length"
],
[
"Return",
3591,
1,
0,
"Call",
3591,
1,
0,
["Ident", 3591, 1, 0, "nextTick"],
0,
[
"Func",
3591,
20,
0,
0,
[],
[],
[],
"Call",
3591,
23,
0,
[
"Binary",
3591,
23,
0,
["Ident", 3591, 23, 0, "func"],
".",
"Const",
3591,
23,
0,
"apply"
],
0,
["Const", 3591, 23, 0],
[
"Call",
3591,
32,
0,
["Ident", 3591, 32, 0, "__toArray"],
0,
["Ident", 3591, 32, 0, "args"]
]
]
],
"Return",
3593,
1,
0,
"Call",
3593,
1,
0,
["Ident", 3593, 1, 0, "nextTick"],
0,
["Ident", 3593, 19, 0, "func"]
]
]
],
0
],
"Func",
1855,
1,
0,
0,
[["Ident", 3595, 5, 0, "func"]],
["args"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3595,
5,
0,
"func"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected func to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3595, 5, 0, "func"]
]
]
],
[
"Binary",
1834,
1,
0,
["Ident", 3595, 20, 0, "args"],
"=",
"Call",
1834,
23,
0,
[
"Binary",
1834,
23,
0,
["Ident", 1834, 23, 0, "__slice"],
".",
"Const",
1834,
23,
0,
"call"
],
0,
["Arguments", 1834, 33, 0],
["Const", 0, 0, 0, 1]
],
[
"IfStatement",
3596,
1,
0,
0,
[
"Binary",
3596,
7,
0,
["Ident", 3596, 7, 0, "args"],
".",
"Const",
3596,
13,
0,
"length"
],
[
"Return",
3597,
1,
0,
"Call",
3597,
1,
0,
["Ident", 3597, 1, 0, "setTimeout"],
0,
[
"Func",
3597,
20,
0,
0,
[],
[],
[],
"Call",
3597,
23,
0,
[
"Binary",
3597,
23,
0,
["Ident", 3597, 23, 0, "func"],
".",
"Const",
3597,
23,
0,
"apply"
],
0,
["Const", 3597, 23, 0],
[
"Call",
3597,
32,
0,
["Ident", 3597, 32, 0, "__toArray"],
0,
["Ident", 3597, 32, 0, "args"]
]
],
["Const", 3597, 39, 0, 0]
],
"Return",
3599,
1,
0,
"Call",
3599,
1,
0,
["Ident", 3599, 1, 0, "setTimeout"],
0,
["Ident", 3599, 19, 0, "func"],
["Const", 3599, 25, 0, 0]
]
],
type: "any",
dependencies: ["__slice", "__toArray", "__typeof", "GLOBAL", "setImmediate"]
},
__defer: {
helper: [
"Call",
9,
9,
0,
[
"Func",
9,
12,
0,
0,
[],
[],
[],
"BlockStatement",
3602,
1,
0,
0,
[
"Func",
3602,
1,
0,
["Ident", 3602, 6, 0, "__defer"],
[],
["deferred", "isError", "value"],
[],
"BlockStatement",
3603,
1,
0,
0,
[
"Binary",
3603,
1,
0,
["Ident", 3603, 16, 0, "isError"],
"=",
"Const",
3603,
27,
0,
false
],
[
"Binary",
3604,
1,
0,
["Ident", 3604, 16, 0, "value"],
"=",
"Const",
3604,
24,
0,
null
],
[
"Binary",
3606,
1,
0,
["Ident", 3606, 16, 0, "deferred"],
"=",
"Arr",
3606,
41,
0
],
[
"Func",
3607,
1,
0,
["Ident", 3607, 8, 0, "complete"],
[
["Ident", 3607, 18, 0, "newIsError"],
["Ident", 3607, 31, 0, "newValue"]
],
["funcs"],
[],
"IfExpression",
3608,
1,
0,
["Ident", 3608, 9, 0, "deferred"],
[
"BlockExpression",
3609,
1,
0,
[
"Binary",
3609,
1,
0,
["Ident", 3609, 12, 0, "funcs"],
"=",
"Ident",
3609,
29,
0,
"deferred"
],
[
"Binary",
3610,
1,
0,
["Ident", 3610, 1, 0, "deferred"],
"=",
"Const",
3610,
20,
0,
null
],
[
"Binary",
3611,
1,
0,
["Ident", 3611, 1, 0, "isError"],
"=",
"Ident",
3611,
20,
0,
"newIsError"
],
[
"Binary",
3612,
1,
0,
["Ident", 3612, 1, 0, "value"],
"=",
"Ident",
3612,
17,
0,
"newValue"
],
[
"IfExpression",
3613,
1,
0,
[
"Binary",
3613,
11,
0,
["Ident", 3613, 11, 0, "funcs"],
".",
"Const",
3613,
18,
0,
"length"
],
[
"Call",
3614,
1,
0,
["Ident", 3614, 1, 0, "setImmediate"],
0,
[
"Func",
3614,
26,
0,
0,
[],
["_end", "i"],
[],
"For",
1231,
1,
0,
0,
[
"BlockExpression",
0,
0,
0,
[
"Binary",
1141,
38,
0,
["Ident", 3615, 16, 0, "i"],
"=",
"Const",
3615,
22,
0,
0
],
[
"Binary",
3615,
1,
0,
["Ident", 3615, 1, 0, "_end"],
"=",
"Binary",
3615,
27,
0,
["Ident", 3615, 27, 0, "funcs"],
".",
"Const",
3615,
34,
0,
"length"
]
],
[
"Binary",
1167,
57,
0,
["Ident", 3615, 16, 0, "i"],
"<",
"Ident",
3615,
1,
0,
"_end"
],
[
"Unary",
1179,
35,
0,
"++",
"Ident",
3615,
16,
0,
"i"
],
"Call",
3616,
1,
0,
[
"Binary",
3616,
1,
0,
["Ident", 3616, 1, 0, "funcs"],
".",
"Ident",
3616,
21,
0,
"i"
],
0
]
]
]
]
],
[
"Return",
3618,
1,
0,
"Obj",
3618,
1,
0,
3619,
7,
null,
"promise",
[
"Obj",
3619,
15,
0,
3620,
9,
null,
"then",
[
"Func",
3620,
16,
0,
0,
[
["Ident", 3620, 17, 0, "onFulfilled"],
["Ident", 3620, 30, 0, "onRejected"],
["Ident", 3620, 51, 0, "allowSync"]
],
["_ref", "fulfill", "promise", "reject"],
[],
"BlockStatement",
3621,
1,
0,
0,
[
"IfStatement",
3621,
1,
0,
0,
[
"Binary",
43,
7,
0,
["Ident", 3621, 13, 0, "allowSync"],
"!==",
"Const",
3621,
27,
0,
true
],
[
"Binary",
3622,
1,
0,
["Ident", 3622, 1, 0, "allowSync"],
"=",
"Const",
3622,
26,
0
]
],
[
"Binary",
247,
43,
0,
["Ident", 3623, 16, 0, "promise"],
"=",
"Binary",
247,
55,
0,
[
"Binary",
3623,
1,
0,
["Ident", 3623, 1, 0, "_ref"],
"=",
"Call",
3623,
43,
0,
["Ident", 3623, 43, 0, "__defer"],
0
],
".",
"Const",
0,
0,
0,
"promise"
],
[
"Binary",
247,
43,
0,
["Ident", 3623, 24, 0, "fulfill"],
"=",
"Binary",
247,
55,
0,
["Ident", 3623, 1, 0, "_ref"],
".",
"Const",
0,
0,
0,
"fulfill"
],
[
"Binary",
247,
43,
0,
["Ident", 3623, 33, 0, "reject"],
"=",
"Binary",
247,
55,
0,
["Ident", 3623, 1, 0, "_ref"],
".",
"Const",
0,
0,
0,
"reject"
],
[
"Func",
3624,
1,
0,
["Ident", 3624, 14, 0, "step"],
[],
["f", "result"],
[],
"TryCatch",
3624,
27,
0,
0,
[
"BlockStatement",
3625,
1,
0,
0,
[
"IfStatement",
3625,
20,
0,
0,
["Ident", 3625, 23, 0, "isError"],
[
"Binary",
3625,
1,
0,
["Ident", 3625, 16, 0, "f"],
"=",
"Ident",
3625,
37,
0,
"onRejected"
],
"Binary",
3625,
1,
0,
["Ident", 3625, 16, 0, "f"],
"=",
"Ident",
3625,
54,
0,
"onFulfilled"
],
[
"IfStatement",
3626,
1,
0,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3626,
28,
0,
"f"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"BlockStatement",
3627,
1,
0,
0,
[
"Binary",
3627,
1,
0,
["Ident", 3627, 18, 0, "result"],
"=",
"Call",
3627,
27,
0,
["Ident", 3627, 27, 0, "f"],
0,
["Ident", 3627, 30, 0, "value"]
],
[
"IfStatement",
3628,
1,
0,
0,
[
"Binary",
3628,
17,
0,
["Ident", 3628, 17, 0, "result"],
"&&",
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
3628,
41,
0,
["Ident", 3628, 41, 0, "result"],
".",
"Const",
3628,
49,
0,
"then"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"Call",
3629,
1,
0,
[
"Binary",
3629,
1,
0,
["Ident", 3629, 1, 0, "result"],
".",
"Const",
3629,
24,
0,
"then"
],
0,
["Ident", 3629, 29, 0, "fulfill"],
["Ident", 3629, 37, 0, "reject"],
["Ident", 3629, 45, 0, "allowSync"]
],
"Call",
3631,
1,
0,
["Ident", 3631, 1, 0, "fulfill"],
0,
["Ident", 3631, 25, 0, "result"]
]
],
"Call",
3633,
1,
0,
[
"IfExpression",
3633,
16,
0,
["Ident", 3633, 18, 0, "isError"],
["Ident", 3633, 32, 0, "reject"],
"Ident",
3633,
44,
0,
"fulfill"
],
0,
["Ident", 3633, 54, 0, "value"]
]
],
["Ident", 3634, 16, 0, "e"],
"Call",
3635,
1,
0,
["Ident", 3635, 1, 0, "reject"],
0,
["Ident", 3635, 20, 0, "e"]
],
[
"IfStatement",
3637,
1,
0,
0,
["Ident", 3637, 13, 0, "deferred"],
[
"Call",
3638,
1,
0,
[
"Binary",
3638,
1,
0,
["Ident", 3638, 1, 0, "deferred"],
".",
"Const",
3638,
22,
0,
"push"
],
0,
["Ident", 3638, 27, 0, "step"]
],
"IfStatement",
3637,
1,
0,
0,
["Ident", 3639, 18, 0, "allowSync"],
[
"Call",
3640,
1,
0,
["Ident", 3640, 1, 0, "step"],
0
],
"Call",
3642,
1,
0,
["Ident", 3642, 1, 0, "setImmediate"],
0,
["Ident", 3642, 27, 0, "step"]
],
[
"Return",
3643,
1,
0,
"Ident",
3643,
1,
0,
"promise"
]
],
3644,
9,
null,
"sync",
[
"Func",
3644,
16,
0,
0,
[],
["result", "state"],
[],
"BlockStatement",
3645,
1,
0,
0,
[
"Binary",
3645,
1,
0,
["Ident", 3645, 22, 0, "state"],
"=",
"Const",
3645,
31,
0,
0
],
[
"Binary",
3646,
1,
0,
["Ident", 3646, 22, 0, "result"],
"=",
"Const",
3646,
32,
0,
0
],
[
"Call",
3647,
1,
0,
[
"Binary",
3647,
1,
0,
["This", 3647, 1, 0],
".",
"Const",
3647,
12,
0,
"then"
],
0,
[
"Func",
3648,
14,
0,
0,
[["Ident", 3648, 15, 0, "ret"]],
[],
[],
"BlockStatement",
3649,
1,
0,
0,
[
"Binary",
3649,
1,
0,
["Ident", 3649, 1, 0, "state"],
"=",
"Const",
3649,
24,
0,
1
],
[
"Return",
3650,
1,
0,
"Binary",
3650,
1,
0,
["Ident", 3650, 1, 0, "result"],
"=",
"Ident",
3650,
24,
0,
"ret"
]
],
[
"Func",
3651,
14,
0,
0,
[["Ident", 3651, 15, 0, "err"]],
[],
[],
"BlockStatement",
3652,
1,
0,
0,
[
"Binary",
3652,
1,
0,
["Ident", 3652, 1, 0, "state"],
"=",
"Const",
3652,
24,
0,
2
],
[
"Return",
3653,
1,
0,
"Binary",
3653,
1,
0,
["Ident", 3653, 1, 0, "result"],
"=",
"Ident",
3653,
24,
0,
"err"
]
],
["Const", 3654, 13, 0, true]
],
[
"Switch",
3655,
1,
0,
0,
["Ident", 3655, 17, 0, "state"],
3656,
16,
null,
["Const", 3656, 16, 0, 0],
[
"Throw",
3657,
1,
0,
"Call",
3657,
18,
0,
["Ident", 3657, 18, 0, "Error"],
0,
["Const", 3657, 25, 0, "Promise did not execute synchronously"]
],
3658,
16,
null,
["Const", 3658, 16, 0, 1],
[
"Return",
3659,
1,
0,
"Ident",
3659,
19,
0,
"result"
],
3660,
16,
null,
["Const", 3660, 16, 0, 2],
[
"Throw",
3661,
1,
0,
"Ident",
3661,
18,
0,
"result"
],
[
"Throw",
3663,
1,
0,
"Call",
3663,
18,
0,
["Ident", 3663, 18, 0, "Error"],
0,
["Const", 3663, 25, 0, "Unknown state"]
]
]
]
],
3665,
7,
null,
"fulfill",
[
"Func",
3665,
14,
0,
0,
[["Ident", 3665, 15, 0, "value"]],
[],
[],
"Call",
3665,
25,
0,
["Ident", 3665, 25, 0, "complete"],
0,
["Const", 3665, 35, 0, false],
["Ident", 3665, 41, 0, "value"]
],
3666,
7,
null,
"reject",
[
"Func",
3666,
13,
0,
0,
[["Ident", 3666, 14, 0, "reason"]],
[],
[],
"Call",
3666,
25,
0,
["Ident", 3666, 25, 0, "complete"],
0,
["Const", 3666, 35, 0, true],
["Ident", 3666, 40, 0, "reason"]
]
]
],
[
"Binary",
3668,
1,
0,
[
"Binary",
3668,
1,
0,
["Ident", 3668, 1, 0, "__defer"],
".",
"Const",
3668,
11,
0,
"fulfilled"
],
"=",
"Func",
3668,
25,
0,
0,
[["Ident", 3668, 26, 0, "value"]],
["d"],
[],
"BlockStatement",
3669,
1,
0,
0,
[
"Binary",
3669,
1,
0,
["Ident", 3669, 8, 0, "d"],
"=",
"Call",
3669,
12,
0,
["Ident", 3669, 12, 0, "__defer"],
0
],
[
"Call",
3670,
1,
0,
[
"Binary",
3670,
1,
0,
["Ident", 3670, 1, 0, "d"],
".",
"Const",
3670,
7,
0,
"fulfill"
],
0,
["Ident", 3670, 15, 0, "value"]
],
[
"Return",
3671,
1,
0,
"Binary",
3671,
1,
0,
["Ident", 3671, 1, 0, "d"],
".",
"Const",
3671,
7,
0,
"promise"
]
],
[
"Binary",
3672,
1,
0,
[
"Binary",
3672,
1,
0,
["Ident", 3672, 1, 0, "__defer"],
".",
"Const",
3672,
11,
0,
"rejected"
],
"=",
"Func",
3672,
24,
0,
0,
[["Ident", 3672, 25, 0, "reason"]],
["d"],
[],
"BlockStatement",
3673,
1,
0,
0,
[
"Binary",
3673,
1,
0,
["Ident", 3673, 8, 0, "d"],
"=",
"Call",
3673,
12,
0,
["Ident", 3673, 12, 0, "__defer"],
0
],
[
"Call",
3674,
1,
0,
[
"Binary",
3674,
1,
0,
["Ident", 3674, 1, 0, "d"],
".",
"Const",
3674,
7,
0,
"reject"
],
0,
["Ident", 3674, 14, 0, "reason"]
],
[
"Return",
3675,
1,
0,
"Binary",
3675,
1,
0,
["Ident", 3675, 1, 0, "d"],
".",
"Const",
3675,
7,
0,
"promise"
]
],
[
"Return",
3676,
1,
0,
"Ident",
3676,
1,
0,
"__defer"
]
],
0
],
type: {
type: "generic",
base: "functionBase",
args: [{
type: "object",
pairs: {
fulfill: {type: "generic", base: "functionBase", args: ["undefined"]},
promise: {
type: "object",
pairs: {sync: "function", then: "function"}
},
reject: {type: "generic", base: "functionBase", args: ["undefined"]}
}
}]
},
dependencies: ["__defer", "setImmediate"]
},
__generatorToPromise: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 3678, 42, 0, "generator"],
["Ident", 3678, 83, 0, "allowSync"]
],
[],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1728,
10,
0,
0,
[
"Binary",
1728,
13,
0,
[
"Binary",
143,
47,
0,
[
"Unary",
143,
47,
0,
"typeof",
"Ident",
3678,
42,
0,
"generator"
],
"!==",
"Const",
143,
62,
0,
"object"
],
"||",
"Binary",
143,
72,
0,
["Ident", 3678, 42, 0, "generator"],
"===",
"Const",
143,
78,
0,
null
],
[
"Throw",
1729,
1,
0,
"Call",
1729,
14,
0,
["Ident", 1729, 14, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected generator to be an Object, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3678, 42, 0, "generator"]
]
],
"BlockStatement",
0,
0,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
1727,
35,
0,
["Ident", 3678, 42, 0, "generator"],
".",
"Const",
3678,
56,
0,
"send"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected generator.send to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
[
"Binary",
1727,
35,
0,
["Ident", 3678, 42, 0, "generator"],
".",
"Const",
3678,
56,
0,
"send"
]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
1727,
35,
0,
["Ident", 3678, 42, 0, "generator"],
".",
"Const",
3678,
68,
0,
"throw"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected generator.throw to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
[
"Binary",
1727,
35,
0,
["Ident", 3678, 42, 0, "generator"],
".",
"Const",
3678,
68,
0,
"throw"
]
]
]
]
],
[
"IfStatement",
1646,
13,
0,
0,
[
"Binary",
1646,
16,
0,
["Ident", 3678, 83, 0, "allowSync"],
"==",
"Const",
113,
19,
0,
null
],
[
"Binary",
1647,
1,
0,
["Ident", 3678, 83, 0, "allowSync"],
"=",
"Const",
1647,
20,
0,
false
],
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
620,
18,
0,
[
"Unary",
134,
7,
0,
"typeof",
"Ident",
3678,
83,
0,
"allowSync"
],
"!==",
"Const",
134,
25,
0,
"boolean"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected allowSync to be a Boolean, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3678, 83, 0, "allowSync"]
]
]
],
[
"Func",
3679,
1,
0,
["Ident", 3679, 6, 0, "continuer"],
[
["Ident", 3679, 17, 0, "verb"],
["Ident", 3679, 22, 0, "arg"]
],
["item"],
[],
"BlockStatement",
3680,
1,
0,
0,
[
"TryCatch",
3681,
1,
0,
0,
[
"Binary",
3682,
1,
0,
["Ident", 3682, 1, 0, "item"],
"=",
"Call",
3682,
14,
0,
[
"Binary",
3682,
14,
0,
["Ident", 3682, 14, 0, "generator"],
".",
"Ident",
3682,
25,
0,
"verb"
],
0,
["Ident", 3682, 31, 0, "arg"]
],
["Ident", 3683, 10, 0, "e"],
"Return",
3684,
1,
0,
"Call",
3684,
13,
0,
[
"Binary",
3684,
13,
0,
["Ident", 3684, 13, 0, "__defer"],
".",
"Const",
3684,
22,
0,
"rejected"
],
0,
["Ident", 3684, 31, 0, "e"]
],
[
"IfStatement",
3685,
1,
0,
0,
[
"Binary",
3685,
7,
0,
["Ident", 3685, 7, 0, "item"],
".",
"Const",
3685,
13,
0,
"done"
],
[
"Return",
3686,
1,
0,
"Call",
3686,
1,
0,
[
"Binary",
3686,
1,
0,
["Ident", 3686, 1, 0, "__defer"],
".",
"Const",
3686,
15,
0,
"fulfilled"
],
0,
[
"Binary",
3686,
25,
0,
["Ident", 3686, 25, 0, "item"],
".",
"Const",
3686,
30,
0,
"value"
]
],
"Return",
3688,
1,
0,
"Call",
3688,
1,
0,
[
"Binary",
3688,
1,
0,
[
"Binary",
3688,
1,
0,
["Ident", 3688, 1, 0, "item"],
".",
"Const",
3688,
12,
0,
"value"
],
".",
"Const",
3688,
18,
0,
"then"
],
0,
["Ident", 3688, 23, 0, "callback"],
["Ident", 3688, 32, 0, "errback"],
["Ident", 3688, 41, 0, "allowSync"]
]
],
[
"Func",
3689,
1,
0,
["Ident", 3689, 6, 0, "callback"],
[["Ident", 3689, 16, 0, "value"]],
[],
[],
"Return",
3689,
25,
0,
"Call",
3689,
25,
0,
["Ident", 3689, 25, 0, "continuer"],
0,
["Const", 3689, 37, 0, "send"],
["Ident", 3689, 42, 0, "value"]
],
[
"Func",
3690,
1,
0,
["Ident", 3690, 6, 0, "errback"],
[["Ident", 3690, 15, 0, "value"]],
[],
[],
"Return",
3690,
24,
0,
"Call",
3690,
24,
0,
["Ident", 3690, 24, 0, "continuer"],
0,
["Const", 3690, 36, 0, "throw"],
["Ident", 3690, 42, 0, "value"]
],
[
"Return",
3691,
1,
0,
"Call",
3691,
1,
0,
["Ident", 3691, 1, 0, "callback"],
0,
["Const", 3691, 12, 0]
]
],
type: "function",
dependencies: ["__defer", "__generatorToPromise", "__typeof"]
},
__promise: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 3692, 36, 0, "value"],
["Ident", 3692, 43, 0, "allowSync"]
],
["factory"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1646,
13,
0,
0,
[
"Binary",
1646,
16,
0,
["Ident", 3692, 43, 0, "allowSync"],
"==",
"Const",
113,
19,
0,
null
],
[
"Binary",
1647,
1,
0,
["Ident", 3692, 43, 0, "allowSync"],
"=",
"Const",
1647,
20,
0,
false
],
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
620,
18,
0,
[
"Unary",
134,
7,
0,
"typeof",
"Ident",
3692,
43,
0,
"allowSync"
],
"!==",
"Const",
134,
25,
0,
"boolean"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected allowSync to be a Boolean, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3692, 43, 0, "allowSync"]
]
]
],
[
"IfStatement",
3693,
1,
0,
0,
[
"Binary",
137,
7,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3693,
18,
0,
"value"
],
"===",
"Const",
137,
25,
0,
"function"
],
[
"BlockStatement",
3694,
1,
0,
0,
[
"Binary",
3694,
1,
0,
["Ident", 3694, 8, 0, "factory"],
"=",
"Func",
3694,
16,
0,
0,
[],
[],
[],
"Return",
3694,
21,
0,
"Call",
3694,
21,
0,
["Ident", 3694, 21, 0, "__generatorToPromise"],
0,
[
"Call",
3694,
45,
0,
[
"Binary",
3694,
45,
0,
["Ident", 3694, 45, 0, "value"],
".",
"Const",
3694,
45,
0,
"apply"
],
0,
["This", 3694, 52, 0],
["Arguments", 3694, 61, 0]
]
],
[
"Binary",
3695,
1,
0,
[
"Binary",
3695,
1,
0,
["Ident", 3695, 1, 0, "factory"],
".",
"Const",
3695,
13,
0,
"sync"
],
"=",
"Func",
3695,
22,
0,
0,
[],
[],
[],
"Return",
3695,
24,
0,
"Call",
3695,
24,
0,
[
"Binary",
3695,
24,
0,
[
"Call",
3695,
24,
0,
["Ident", 3695, 24, 0, "__generatorToPromise"],
0,
[
"Call",
3695,
48,
0,
[
"Binary",
3695,
48,
0,
["Ident", 3695, 48, 0, "value"],
".",
"Const",
3695,
48,
0,
"apply"
],
0,
["This", 3695, 55, 0],
["Arguments", 3695, 64, 0]
],
["Const", 3695, 75, 0, true]
],
".",
"Const",
3695,
82,
0,
"sync"
],
0
],
[
"Return",
3696,
1,
0,
"Ident",
3696,
1,
0,
"factory"
]
],
"Return",
3698,
1,
0,
"Call",
3698,
1,
0,
["Ident", 3698, 1, 0, "__generatorToPromise"],
0,
["Ident", 3698, 28, 0, "value"],
["Ident", 3698, 34, 0, "allowSync"]
]
],
type: "function",
dependencies: ["__generatorToPromise", "__promise", "__toArray", "__typeof"]
},
__fromPromise: {
helper: [
"Func",
1855,
1,
0,
0,
[["Ident", 3736, 34, 0, "promise"]],
[],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1728,
10,
0,
0,
[
"Binary",
1728,
13,
0,
[
"Binary",
143,
47,
0,
[
"Unary",
143,
47,
0,
"typeof",
"Ident",
3736,
34,
0,
"promise"
],
"!==",
"Const",
143,
62,
0,
"object"
],
"||",
"Binary",
143,
72,
0,
["Ident", 3736, 34, 0, "promise"],
"===",
"Const",
143,
78,
0,
null
],
[
"Throw",
1729,
1,
0,
"Call",
1729,
14,
0,
["Ident", 1729, 14, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected promise to be an Object, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3736, 34, 0, "promise"]
]
],
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
1727,
35,
0,
["Ident", 3736, 34, 0, "promise"],
".",
"Const",
3736,
46,
0,
"then"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected promise.then to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
[
"Binary",
1727,
35,
0,
["Ident", 3736, 34, 0, "promise"],
".",
"Const",
3736,
46,
0,
"then"
]
]
]
],
[
"Return",
3736,
65,
0,
"Func",
3736,
65,
0,
0,
[["Ident", 3736, 66, 0, "callback"]],
[],
[],
"Call",
3737,
1,
0,
[
"Binary",
3737,
1,
0,
["Ident", 3737, 1, 0, "promise"],
".",
"Const",
3737,
11,
0,
"then"
],
0,
[
"Func",
3738,
6,
0,
0,
[["Ident", 3738, 7, 0, "value"]],
[],
[],
"Return",
3738,
16,
0,
"Call",
3738,
16,
0,
["Ident", 3738, 16, 0, "setImmediate"],
0,
["Ident", 3738, 31, 0, "callback"],
["Const", 3738, 40, 0, null],
["Ident", 3738, 46, 0, "value"]
],
[
"Func",
3739,
6,
0,
0,
[["Ident", 3739, 7, 0, "reason"]],
[],
[],
"Return",
3739,
17,
0,
"Call",
3739,
17,
0,
["Ident", 3739, 17, 0, "setImmediate"],
0,
["Ident", 3739, 32, 0, "callback"],
["Ident", 3739, 41, 0, "reason"]
]
]
],
type: {
type: "generic",
base: "functionBase",
args: [{type: "generic", base: "functionBase", args: ["undefined"]}]
},
dependencies: ["__fromPromise", "__typeof", "setImmediate"]
},
__toPromise: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 3746, 32, 0, "func"],
["Ident", 3746, 43, 0, "context"],
["Ident", 3746, 52, 0, "args"]
],
["d"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3746,
32,
0,
"func"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected func to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3746, 32, 0, "func"]
]
]
],
[
"Binary",
3747,
1,
0,
["Ident", 3747, 6, 0, "d"],
"=",
"Call",
3747,
10,
0,
["Ident", 3747, 10, 0, "__defer"],
0
],
[
"Call",
3748,
1,
0,
[
"Binary",
3748,
1,
0,
["Ident", 3748, 1, 0, "func"],
".",
"Const",
3748,
1,
0,
"apply"
],
0,
["Ident", 3748, 9, 0, "context"],
[
"Call",
3748,
1,
0,
[
"Binary",
3748,
1,
0,
[
"Call",
3748,
21,
0,
["Ident", 3748, 21, 0, "__toArray"],
0,
["Ident", 3748, 21, 0, "args"]
],
".",
"Const",
3748,
1,
0,
"concat"
],
0,
[
"Arr",
3748,
28,
0,
[
"Func",
3748,
28,
0,
0,
[
["Ident", 3748, 29, 0, "err"],
["Ident", 3748, 33, 0, "value"]
],
[],
[],
"IfExpression",
3749,
1,
0,
[
"Binary",
49,
7,
0,
["Ident", 3749, 7, 0, "err"],
"!=",
"Const",
113,
19,
0,
null
],
[
"Call",
3750,
1,
0,
[
"Binary",
3750,
1,
0,
["Ident", 3750, 1, 0, "d"],
".",
"Const",
3750,
9,
0,
"reject"
],
0,
["Ident", 3750, 16, 0, "err"]
],
"Call",
3752,
1,
0,
[
"Binary",
3752,
1,
0,
["Ident", 3752, 1, 0, "d"],
".",
"Const",
3752,
9,
0,
"fulfill"
],
0,
["Ident", 3752, 17, 0, "value"]
]
]
]
],
[
"Return",
3753,
1,
0,
"Binary",
3753,
1,
0,
["Ident", 3753, 1, 0, "d"],
".",
"Const",
3753,
5,
0,
"promise"
]
],
type: {
type: "generic",
base: "functionBase",
args: [{
type: "object",
pairs: {sync: "function", then: "function"}
}]
},
dependencies: ["__defer", "__toArray", "__toPromise", "__typeof"]
},
__generator: {
helper: [
"Func",
3783,
30,
0,
0,
[["Ident", 3783, 31, 0, "func"]],
[],
[],
"Return",
3783,
41,
0,
"Func",
3783,
41,
0,
0,
[],
["_this", "data"],
[],
"BlockStatement",
3784,
1,
0,
0,
[
"Binary",
3784,
1,
0,
["Ident", 3784, 1, 0, "_this"],
"=",
"This",
3784,
1,
0
],
[
"Binary",
3784,
1,
0,
["Ident", 3784, 14, 0, "data"],
"=",
"Arr",
3784,
32,
0,
["This", 3784, 34, 0],
[
"Call",
3784,
39,
0,
[
"Binary",
3784,
39,
0,
["Ident", 3784, 39, 0, "__slice"],
".",
"Const",
3784,
48,
0,
"call"
],
0,
["Arguments", 3784, 53, 0]
]
],
[
"Return",
3785,
1,
0,
"Obj",
3785,
1,
0,
3786,
5,
null,
"iterator",
[
"Func",
3786,
13,
0,
0,
[],
[],
[],
"Return",
3786,
18,
0,
"This",
3786,
18,
0
],
3787,
5,
null,
"send",
[
"Func",
3787,
9,
0,
0,
[],
["tmp"],
[],
"Return",
3788,
1,
0,
"Obj",
3788,
1,
0,
3789,
10,
null,
"done",
["Const", 3789, 9, 0, true],
3790,
9,
null,
"value",
[
"IfExpression",
3790,
15,
0,
["Ident", 3790, 18, 0, "data"],
[
"BlockExpression",
3791,
1,
0,
[
"Binary",
3791,
1,
0,
["Ident", 3791, 14, 0, "tmp"],
"=",
"Ident",
3791,
20,
0,
"data"
],
[
"Binary",
3792,
1,
0,
["Ident", 3792, 1, 0, "data"],
"=",
"Const",
3792,
18,
0,
null
],
[
"Call",
3793,
1,
0,
[
"Binary",
3793,
1,
0,
["Ident", 3793, 1, 0, "func"],
".",
"Const",
3793,
16,
0,
"apply"
],
0,
[
"Binary",
3793,
22,
0,
["Ident", 3793, 22, 0, "tmp"],
".",
"Const",
3793,
26,
0,
0
],
[
"Binary",
3793,
29,
0,
["Ident", 3793, 29, 0, "tmp"],
".",
"Const",
3793,
34,
0,
1
]
]
],
"Const",
3795,
1,
0
]
],
3797,
5,
null,
"next",
[
"Func",
3797,
9,
0,
0,
[],
[],
[],
"Return",
3797,
14,
0,
"Call",
3797,
14,
0,
[
"Binary",
3797,
14,
0,
["This", 3797, 14, 0],
".",
"Const",
3797,
16,
0,
"send"
],
0
],
3798,
5,
null,
"throw",
[
"Func",
3798,
10,
0,
0,
[["Ident", 3798, 11, 0, "err"]],
[],
[],
"BlockStatement",
3799,
1,
0,
0,
[
"Binary",
3799,
1,
0,
["Ident", 3799, 1, 0, "data"],
"=",
"Const",
3799,
14,
0,
null
],
[
"Throw",
3800,
1,
0,
"Ident",
3800,
12,
0,
"err"
]
]
]
],
type: {
type: "generic",
base: "functionBase",
args: [{
type: "generic",
base: "functionBase",
args: [{
type: "object",
pairs: {
iterator: "function",
next: "function",
send: {
type: "generic",
base: "functionBase",
args: [{type: "object", pairs: {done: "boolean"}}]
},
"throw": {type: "generic", base: "functionBase", args: ["none"]}
}
}]
}]
},
dependencies: ["__generator", "__slice"]
},
__somePromise: {
helper: [
"Func",
1855,
1,
0,
0,
[["Ident", 3803, 34, 0, "promises"]],
["defer", "i"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Unary",
624,
18,
0,
"!",
"Call",
140,
146,
0,
["Ident", 140, 146, 0, "__isArray"],
0,
["Ident", 3803, 34, 0, "promises"]
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected promises to be an Array, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3803, 34, 0, "promises"]
]
]
],
[
"Binary",
3804,
1,
0,
["Ident", 3804, 6, 0, "defer"],
"=",
"Call",
3804,
14,
0,
["Ident", 3804, 14, 0, "__defer"],
0
],
[
"Binary",
3805,
1,
0,
["Ident", 3805, 14, 0, "i"],
"=",
"Binary",
3805,
18,
0,
["Ident", 3805, 18, 0, "promises"],
".",
"Const",
3805,
28,
0,
"length"
],
[
"For",
1071,
1,
0,
0,
0,
[
"Unary",
3806,
8,
0,
"--post",
"Ident",
3806,
18,
0,
"i"
],
0,
"Call",
3807,
1,
0,
[
"Binary",
3807,
1,
0,
[
"Binary",
3807,
1,
0,
["Ident", 3807, 1, 0, "promises"],
".",
"Ident",
3807,
14,
0,
"i"
],
".",
"Const",
3807,
17,
0,
"then"
],
0,
[
"Binary",
3807,
22,
0,
["Ident", 3807, 22, 0, "defer"],
".",
"Const",
3807,
28,
0,
"fulfill"
],
[
"Binary",
3807,
36,
0,
["Ident", 3807, 36, 0, "defer"],
".",
"Const",
3807,
43,
0,
"reject"
]
],
[
"Return",
3808,
1,
0,
"Binary",
3808,
1,
0,
["Ident", 3808, 1, 0, "defer"],
".",
"Const",
3808,
9,
0,
"promise"
]
],
type: {
type: "generic",
base: "functionBase",
args: [{
type: "object",
pairs: {sync: "function", then: "function"}
}]
},
dependencies: ["__defer", "__isArray", "__somePromise", "__typeof"]
},
__everyPromise: {
helper: [
"Func",
1855,
1,
0,
0,
[["Ident", 3818, 35, 0, "promises"]],
[
"defer",
"i",
"isArray",
"k",
"remaining",
"result",
"v"
],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
626,
18,
0,
[
"Binary",
143,
47,
0,
[
"Unary",
143,
47,
0,
"typeof",
"Ident",
3818,
35,
0,
"promises"
],
"!==",
"Const",
143,
62,
0,
"object"
],
"||",
"Binary",
43,
7,
0,
["Ident", 3818, 35, 0, "promises"],
"===",
"Const",
143,
78,
0,
null
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected promises to be an Object, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3818, 35, 0, "promises"]
]
]
],
[
"Binary",
3819,
1,
0,
["Ident", 3819, 6, 0, "isArray"],
"=",
"Call",
140,
146,
0,
["Ident", 140, 146, 0, "__isArray"],
0,
["Ident", 3819, 27, 0, "promises"]
],
[
"Binary",
3820,
1,
0,
["Ident", 3820, 6, 0, "defer"],
"=",
"Call",
3820,
14,
0,
["Ident", 3820, 14, 0, "__defer"],
0
],
[
"IfStatement",
3821,
15,
0,
0,
["Ident", 3821, 18, 0, "isArray"],
[
"Binary",
3821,
1,
0,
["Ident", 3821, 6, 0, "result"],
"=",
"Arr",
3821,
32,
0
],
"Binary",
3821,
1,
0,
["Ident", 3821, 6, 0, "result"],
"=",
"Obj",
3821,
40,
0
],
[
"Binary",
3822,
1,
0,
["Ident", 3822, 14, 0, "remaining"],
"=",
"Const",
3822,
27,
0,
0
],
[
"Func",
3823,
1,
0,
["Ident", 3823, 6, 0, "handle"],
[
["Ident", 3823, 14, 0, "key"],
["Ident", 3823, 18, 0, "promise"]
],
[],
[],
"Return",
3824,
1,
0,
"Call",
3824,
1,
0,
[
"Binary",
3824,
1,
0,
["Ident", 3824, 1, 0, "promise"],
".",
"Const",
3824,
13,
0,
"then"
],
0,
[
"Func",
3825,
8,
0,
0,
[["Ident", 3825, 9, 0, "value"]],
[],
[],
"BlockExpression",
3826,
1,
0,
[
"Binary",
3826,
1,
0,
[
"Binary",
3826,
1,
0,
["Ident", 3826, 1, 0, "result"],
".",
"Ident",
3826,
16,
0,
"key"
],
"=",
"Ident",
3826,
23,
0,
"value"
],
[
"IfExpression",
3827,
1,
0,
[
"Binary",
3827,
11,
0,
[
"Unary",
864,
11,
0,
"--",
"Ident",
3827,
13,
0,
"remaining"
],
"===",
"Const",
3827,
32,
0,
0
],
[
"Call",
3828,
1,
0,
[
"Binary",
3828,
1,
0,
["Ident", 3828, 1, 0, "defer"],
".",
"Const",
3828,
17,
0,
"fulfill"
],
0,
["Ident", 3828, 25, 0, "result"]
]
]
],
[
"Binary",
3829,
7,
0,
["Ident", 3829, 7, 0, "defer"],
".",
"Const",
3829,
13,
0,
"reject"
]
],
[
"IfStatement",
3830,
1,
0,
0,
["Ident", 3830, 5, 0, "isArray"],
[
"BlockStatement",
3831,
1,
0,
0,
[
"Binary",
3831,
1,
0,
["Ident", 3831, 16, 0, "i"],
"=",
"Binary",
3831,
20,
0,
["Ident", 3831, 20, 0, "promises"],
".",
"Const",
3831,
30,
0,
"length"
],
[
"Binary",
3832,
1,
0,
["Ident", 3832, 1, 0, "remaining"],
"=",
"Ident",
3832,
17,
0,
"i"
],
[
"For",
1071,
1,
0,
0,
0,
[
"Unary",
3833,
10,
0,
"--post",
"Ident",
3833,
20,
0,
"i"
],
0,
"Call",
3834,
1,
0,
["Ident", 3834, 1, 0, "handle"],
0,
["Ident", 3834, 14, 0, "i"],
[
"Binary",
3834,
16,
0,
["Ident", 3834, 16, 0, "promises"],
".",
"Ident",
3834,
26,
0,
"i"
]
]
],
"ForIn",
3836,
1,
0,
0,
["Ident", 3836, 8, 0, "k"],
["Ident", 3836, 16, 0, "promises"],
"IfStatement",
1525,
1,
0,
0,
[
"Call",
611,
7,
0,
[
"Binary",
611,
7,
0,
["Ident", 611, 7, 0, "__owns"],
".",
"Const",
611,
7,
0,
"call"
],
0,
["Ident", 3836, 16, 0, "promises"],
["Ident", 3836, 8, 0, "k"]
],
[
"BlockStatement",
1503,
1,
0,
0,
[
"Binary",
1483,
52,
0,
["Ident", 3836, 11, 0, "v"],
"=",
"Binary",
1483,
65,
0,
["Ident", 3836, 16, 0, "promises"],
".",
"Ident",
3836,
8,
0,
"k"
],
[
"Unary",
862,
11,
0,
"++",
"Ident",
3837,
1,
0,
"remaining"
],
[
"Call",
3838,
1,
0,
["Ident", 3838, 1, 0, "handle"],
0,
["Ident", 3838, 14, 0, "k"],
["Ident", 3838, 16, 0, "v"]
]
]
],
[
"Return",
3839,
1,
0,
"Binary",
3839,
1,
0,
["Ident", 3839, 1, 0, "defer"],
".",
"Const",
3839,
9,
0,
"promise"
]
],
type: {
type: "generic",
base: "functionBase",
args: [{
type: "object",
pairs: {sync: "function", then: "function"}
}]
},
dependencies: ["__defer", "__everyPromise", "__isArray", "__owns", "__typeof"]
},
__delay: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 3849, 27, 0, "milliseconds"],
["Ident", 3849, 50, 0, "value"]
],
["defer"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
3849,
27,
0,
"milliseconds"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected milliseconds to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3849, 27, 0, "milliseconds"]
]
]
],
[
"IfStatement",
3850,
1,
0,
0,
[
"Binary",
690,
13,
0,
["Ident", 3850, 5, 0, "milliseconds"],
"<=",
"Const",
3850,
22,
0,
0
],
[
"Return",
3851,
1,
0,
"Call",
3851,
1,
0,
[
"Binary",
3851,
1,
0,
["Ident", 3851, 1, 0, "__defer"],
".",
"Const",
3851,
13,
0,
"fulfilled"
],
0,
["Ident", 3851, 23, 0, "value"]
],
"BlockStatement",
3853,
1,
0,
0,
[
"Binary",
3853,
1,
0,
["Ident", 3853, 8, 0, "defer"],
"=",
"Call",
3853,
16,
0,
["Ident", 3853, 16, 0, "__defer"],
0
],
[
"Call",
3854,
1,
0,
["Ident", 3854, 1, 0, "setTimeout"],
0,
[
"Func",
3854,
19,
0,
0,
[],
[],
[],
"Call",
3854,
22,
0,
[
"Binary",
3854,
22,
0,
["Ident", 3854, 22, 0, "defer"],
".",
"Const",
3854,
29,
0,
"fulfill"
],
0,
["Ident", 3854, 37, 0, "value"]
],
["Ident", 3854, 45, 0, "milliseconds"]
],
[
"Return",
3855,
1,
0,
"Binary",
3855,
1,
0,
["Ident", 3855, 1, 0, "defer"],
".",
"Const",
3855,
11,
0,
"promise"
]
]
],
type: "function",
dependencies: ["__defer", "__delay", "__typeof"]
},
__promiseLoop: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 3866, 41, 0, "limit"],
["Ident", 3866, 58, 0, "length"],
["Ident", 3866, 76, 0, "body"]
],
["defer", "done", "index", "result", "slotsUsed"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
3866,
41,
0,
"limit"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected limit to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3866, 41, 0, "limit"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
3866,
58,
0,
"length"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected length to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3866, 58, 0, "length"]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3866,
76,
0,
"body"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected body to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3866, 76, 0, "body"]
]
]
],
[
"IfStatement",
3867,
1,
0,
0,
[
"Binary",
3867,
5,
0,
[
"Binary",
3867,
5,
0,
["Ident", 3867, 5, 0, "limit"],
"<",
"Const",
3867,
15,
0,
1
],
"||",
"Binary",
43,
7,
0,
["Ident", 3867, 19, 0, "limit"],
"!==",
"Ident",
3867,
28,
0,
"limit"
],
[
"Binary",
3868,
1,
0,
["Ident", 3868, 1, 0, "limit"],
"=",
"Const",
3868,
13,
0,
1,
1
]
],
[
"Binary",
3870,
1,
0,
["Ident", 3870, 6, 0, "result"],
"=",
"Arr",
3870,
15,
0
],
[
"Binary",
3871,
1,
0,
["Ident", 3871, 14, 0, "done"],
"=",
"Const",
3871,
21,
0,
false
],
[
"Binary",
3872,
1,
0,
["Ident", 3872, 14, 0, "slotsUsed"],
"=",
"Const",
3872,
28,
0,
0
],
[
"Binary",
3873,
1,
0,
["Ident", 3873, 6, 0, "defer"],
"=",
"Call",
3873,
14,
0,
["Ident", 3873, 14, 0, "__defer"],
0
],
[
"Binary",
3874,
1,
0,
["Ident", 3874, 14, 0, "index"],
"=",
"Const",
3874,
23,
0,
0
],
[
"Func",
3875,
1,
0,
["Ident", 3875, 6, 0, "handle"],
[["Ident", 3875, 14, 0, "index"]],
[],
[],
"BlockStatement",
3876,
1,
0,
0,
[
"Unary",
862,
11,
0,
"++",
"Ident",
3876,
1,
0,
"slotsUsed"
],
[
"Return",
3877,
1,
0,
"Call",
3877,
1,
0,
[
"Binary",
3877,
1,
0,
[
"Call",
3877,
1,
0,
["Ident", 3877, 1, 0, "body"],
0,
["Ident", 3877, 10, 0, "index"]
],
".",
"Const",
3877,
17,
0,
"then"
],
0,
[
"Func",
3878,
8,
0,
0,
[["Ident", 3878, 9, 0, "value"]],
[],
[],
"BlockStatement",
3879,
1,
0,
0,
[
"Binary",
3879,
1,
0,
[
"Binary",
3879,
1,
0,
["Ident", 3879, 1, 0, "result"],
".",
"Ident",
3879,
16,
0,
"index"
],
"=",
"Ident",
3879,
25,
0,
"value"
],
[
"Unary",
864,
11,
0,
"--",
"Ident",
3880,
1,
0,
"slotsUsed"
],
[
"Return",
3881,
1,
0,
"Call",
3881,
1,
0,
["Ident", 3881, 1, 0, "flush"],
0
]
],
[
"Func",
3882,
8,
0,
0,
[["Ident", 3882, 9, 0, "reason"]],
[],
[],
"BlockStatement",
3883,
1,
0,
0,
[
"Binary",
3883,
1,
0,
["Ident", 3883, 1, 0, "done"],
"=",
"Const",
3883,
16,
0,
true
],
[
"Return",
3884,
1,
0,
"Call",
3884,
1,
0,
[
"Binary",
3884,
1,
0,
["Ident", 3884, 1, 0, "defer"],
".",
"Const",
3884,
15,
0,
"reject"
],
0,
["Ident", 3884, 22, 0, "reason"]
]
]
]
],
[
"Func",
3885,
1,
0,
["Ident", 3885, 6, 0, "flush"],
[],
[],
[],
"BlockStatement",
3886,
1,
0,
0,
[
"For",
1071,
1,
0,
0,
0,
[
"Binary",
3886,
10,
0,
[
"Binary",
3886,
10,
0,
[
"Unary",
3886,
10,
0,
"!",
"Ident",
3886,
14,
0,
"done"
],
"&&",
"Binary",
688,
13,
0,
["Ident", 3886, 23, 0, "slotsUsed"],
"<",
"Ident",
3886,
36,
0,
"limit"
],
"&&",
"Binary",
688,
13,
0,
["Ident", 3886, 46, 0, "index"],
"<",
"Ident",
3886,
54,
0,
"length"
],
[
"Unary",
862,
11,
0,
"++",
"Ident",
3886,
62,
0,
"index"
],
"Call",
3887,
1,
0,
["Ident", 3887, 1, 0, "handle"],
0,
["Ident", 3887, 14, 0, "index"]
],
[
"IfStatement",
3888,
1,
0,
0,
[
"Binary",
3888,
7,
0,
[
"Binary",
3888,
7,
0,
[
"Unary",
3888,
7,
0,
"!",
"Ident",
3888,
11,
0,
"done"
],
"&&",
"Binary",
726,
9,
0,
["Ident", 3888, 20, 0, "index"],
">=",
"Ident",
3888,
29,
0,
"length"
],
"&&",
"Binary",
3888,
40,
0,
["Ident", 3888, 40, 0, "slotsUsed"],
"===",
"Const",
3888,
55,
0,
0
],
[
"BlockStatement",
3889,
1,
0,
0,
[
"Binary",
3889,
1,
0,
["Ident", 3889, 1, 0, "done"],
"=",
"Const",
3889,
14,
0,
true
],
[
"Return",
3890,
1,
0,
"Call",
3890,
1,
0,
[
"Binary",
3890,
1,
0,
["Ident", 3890, 1, 0, "defer"],
".",
"Const",
3890,
13,
0,
"fulfill"
],
0,
["Ident", 3890, 21, 0, "result"]
]
]
]
],
[
"Call",
3891,
1,
0,
["Ident", 3891, 1, 0, "setImmediate"],
0,
["Ident", 3891, 17, 0, "flush"]
],
[
"Return",
3892,
1,
0,
"Binary",
3892,
1,
0,
["Ident", 3892, 1, 0, "defer"],
".",
"Const",
3892,
9,
0,
"promise"
]
],
type: {
type: "generic",
base: "functionBase",
args: [{
type: "object",
pairs: {sync: "function", then: "function"}
}]
},
dependencies: ["__defer", "__promiseLoop", "__typeof", "setImmediate"]
},
__promiseIter: {
helper: [
"Func",
1855,
1,
0,
0,
[
["Ident", 3894, 41, 0, "limit"],
["Ident", 3894, 58, 0, "iterator"],
["Ident", 3894, 88, 0, "body"]
],
["defer", "done", "index", "iterStopped", "result", "slotsUsed"],
[],
"BlockStatement",
1855,
1,
0,
0,
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
618,
18,
0,
[
"Unary",
131,
7,
0,
"typeof",
"Ident",
3894,
41,
0,
"limit"
],
"!==",
"Const",
131,
25,
0,
"number"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected limit to be a Number, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3894, 41, 0, "limit"]
]
]
],
[
"IfStatement",
1728,
10,
0,
0,
[
"Binary",
1728,
13,
0,
[
"Binary",
143,
47,
0,
[
"Unary",
143,
47,
0,
"typeof",
"Ident",
3894,
58,
0,
"iterator"
],
"!==",
"Const",
143,
62,
0,
"object"
],
"||",
"Binary",
143,
72,
0,
["Ident", 3894, 58, 0, "iterator"],
"===",
"Const",
143,
78,
0,
null
],
[
"Throw",
1729,
1,
0,
"Call",
1729,
14,
0,
["Ident", 1729, 14, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected iterator to be an Object, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3894, 58, 0, "iterator"]
]
],
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Binary",
1727,
35,
0,
["Ident", 3894, 58, 0, "iterator"],
".",
"Const",
3894,
72,
0,
"next"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected iterator.next to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
[
"Binary",
1727,
35,
0,
["Ident", 3894, 58, 0, "iterator"],
".",
"Const",
3894,
72,
0,
"next"
]
]
]
],
[
"IfStatement",
1639,
1,
0,
0,
[
"Binary",
622,
18,
0,
[
"Unary",
137,
7,
0,
"typeof",
"Ident",
3894,
88,
0,
"body"
],
"!==",
"Const",
137,
25,
0,
"function"
],
[
"Throw",
1640,
1,
0,
"Call",
1640,
18,
0,
["Ident", 1640, 18, 0, "TypeError"],
0,
[
"Binary",
573,
7,
0,
["Const", 573, 7, 0, "Expected body to be a Function, got "],
"+",
"Call",
486,
49,
0,
["Ident", 486, 49, 0, "__typeof"],
0,
["Ident", 3894, 88, 0, "body"]
]
]
],
[
"IfStatement",
3895,
1,
0,
0,
[
"Binary",
3895,
5,
0,
[
"Binary",
3895,
5,
0,
["Ident", 3895, 5, 0, "limit"],
"<",
"Const",
3895,
15,
0,
1
],
"||",
"Binary",
43,
7,
0,
["Ident", 3895, 19, 0, "limit"],
"!==",
"Ident",
3895,
28,
0,
"limit"
],
[
"Binary",
3896,
1,
0,
["Ident", 3896, 1, 0, "limit"],
"=",
"Const",
3896,
13,
0,
1,
1
]
],
[
"Binary",
3898,
1,
0,
["Ident", 3898, 6, 0, "result"],
"=",
"Arr",
3898,
15,
0
],
[
"Binary",
3899,
1,
0,
["Ident", 3899, 14, 0, "done"],
"=",
"Const",
3899,
21,
0,
false
],
[
"Binary",
3900,
1,
0,
["Ident", 3900, 14, 0, "slotsUsed"],
"=",
"Const",
3900,
28,
0,
0
],
[
"Binary",
3901,
1,
0,
["Ident", 3901, 6, 0, "defer"],
"=",
"Call",
3901,
14,
0,
["Ident", 3901, 14, 0, "__defer"],
0
],
[
"Binary",
3902,
1,
0,
["Ident", 3902, 14, 0, "index"],
"=",
"Const",
3902,
23,
0,
0
],
[
"Binary",
3903,
1,
0,
["Ident", 3903, 14, 0, "iterStopped"],
"=",
"Const",
3903,
29,
0,
false
],
[
"Func",
3904,
1,
0,
["Ident", 3904, 6, 0, "handle"],
[
["Ident", 3904, 14, 0, "item"],
["Ident", 3904, 19, 0, "index"]
],
[],
[],
"BlockStatement",
3905,
1,
0,
0,
[
"Unary",
862,
11,
0,
"++",
"Ident",
3905,
1,
0,
"slotsUsed"
],
[
"Return",
3906,
1,
0,
"Call",
3906,
1,
0,
[
"Binary",
3906,
1,
0,
[
"Call",
3906,
1,
0,
["Ident", 3906, 1, 0, "body"],
0,
["Ident", 3906, 10, 0, "item"],
["Ident", 3906, 15, 0, "index"]
],
".",
"Const",
3906,
23,
0,
"then"
],
0,
[
"Func",
3907,
8,
0,
0,
[["Ident", 3907, 9, 0, "value"]],
[],
[],
"BlockStatement",
3908,
1,
0,
0,
[
"Binary",
3908,
1,
0,
[
"Binary",
3908,
1,
0,
["Ident", 3908, 1, 0, "result"],
".",
"Ident",
3908,
16,
0,
"index"
],
"=",
"Ident",
3908,
25,
0,
"value"
],
[
"Unary",
864,
11,
0,
"--",
"Ident",
3909,
1,
0,
"slotsUsed"
],
[
"Return",
3910,
1,
0,
"Call",
3910,
1,
0,
["Ident", 3910, 1, 0, "flush"],
0
]
],
[
"Func",
3911,
8,
0,
0,
[["Ident", 3911, 9, 0, "reason"]],
[],
[],
"BlockStatement",
3912,
1,
0,
0,
[
"Binary",
3912,
1,
0,
["Ident", 3912, 1, 0, "done"],
"=",
"Const",
3912,
16,
0,
true
],
[
"Return",
3913,
1,
0,
"Call",
3913,
1,
0,
[
"Binary",
3913,
1,
0,
["Ident", 3913, 1, 0, "defer"],
".",
"Const",
3913,
15,
0,
"reject"
],
0,
["Ident", 3913, 22, 0, "reason"]
]
]
]
],
[
"Func",
3914,
1,
0,
["Ident", 3914, 6, 0, "flush"],
[],
["item"],
[],
"BlockStatement",
3915,
1,
0,
0,
[
"For",
1071,
1,
0,
0,
0,
[
"Binary",
3915,
10,
0,
[
"Binary",
3915,
10,
0,
[
"Unary",
3915,
10,
0,
"!",
"Ident",
3915,
14,
0,
"done"
],
"&&",
"Unary",
3915,
23,
0,
"!",
"Ident",
3915,
27,
0,
"iterStopped"
],
"&&",
"Binary",
688,
13,
0,
["Ident", 3915, 44, 0, "slotsUsed"],
"<",
"Ident",
3915,
57,
0,
"limit"
],
0,
"BlockStatement",
3916,
1,
0,
0,
[
"Binary",
3916,
1,
0,
["Ident", 3916, 18, 0, "item"],
"=",
"Const",
3916,
25,
0
],
[
"TryCatch",
3917,
1,
0,
0,
[
"Binary",
3918,
1,
0,
["Ident", 3918, 1, 0, "item"],
"=",
"Call",
3918,
16,
0,
[
"Binary",
3918,
16,
0,
["Ident", 3918, 16, 0, "iterator"],
".",
"Const",
3918,
26,
0,
"next"
],
0
],
["Ident", 3919, 12, 0, "e"],
"BlockStatement",
3920,
1,
0,
0,
[
"Binary",
3920,
1,
0,
["Ident", 3920, 1, 0, "done"],
"=",
"Const",
3920,
16,
0,
true
],
[
"Call",
3921,
1,
0,
[
"Binary",
3921,
1,
0,
["Ident", 3921, 1, 0, "defer"],
".",
"Const",
3921,
15,
0,
"reject"
],
0,
["Ident", 3921, 22, 0, "e"]
],
[
"Return",
3922,
1,
0,
"Const",
3922,
1,
0
]
],
[
"IfStatement",
3924,
1,
0,
0,
[
"Binary",
3924,
9,
0,
["Ident", 3924, 9, 0, "item"],
".",
"Const",
3924,
15,
0,
"done"
],
[
"BlockStatement",
3925,
1,
0,
0,
[
"Binary",
3925,
1,
0,
["Ident", 3925, 1, 0, "iterStopped"],
"=",
"Const",
3925,
24,
0,
true
],
["Break", 3926, 1, 0]
]
],
[
"Call",
3928,
1,
0,
["Ident", 3928, 1, 0, "handle"],
0,
[
"Binary",
3928,
14,
0,
["Ident", 3928, 14, 0, "item"],
".",
"Const",
3928,
19,
0,
"value"
],
[
"Unary",
3928,
25,
0,
"++post",
"Ident",
3928,
35,
0,
"index"
]
]
],
[
"IfStatement",
3930,
1,
0,
0,
[
"Binary",
3930,
7,
0,
[
"Binary",
3930,
7,
0,
[
"Unary",
3930,
7,
0,
"!",
"Ident",
3930,
11,
0,
"done"
],
"&&",
"Binary",
3930,
20,
0,
["Ident", 3930, 20, 0, "slotsUsed"],
"===",
"Const",
3930,
35,
0,
0
],
"&&",
"Ident",
3930,
40,
0,
"iterStopped"
],
[
"BlockStatement",
3931,
1,
0,
0,
[
"Binary",
3931,
1,
0,
["Ident", 3931, 1, 0, "done"],
"=",
"Const",
3931,
14,
0,
true
],
[
"Return",
3932,
1,
0,
"Call",
3932,
1,
0,
[
"Binary",
3932,
1,
0,
["Ident", 3932, 1, 0, "defer"],
".",
"Const",
3932,
13,
0,
"fulfill"
],
0,
["Ident", 3932, 21, 0, "result"]
]
]
]
],
[
"Call",
3933,
1,
0,
["Ident", 3933, 1, 0, "setImmediate"],
0,
["Ident", 3933, 17, 0, "flush"]
],
[
"Return",
3934,
1,
0,
"Binary",
3934,
1,
0,
["Ident", 3934, 1, 0, "defer"],
".",
"Const",
3934,
9,
0,
"promise"
]
],
type: {
type: "generic",
base: "functionBase",
args: [{
type: "object",
pairs: {sync: "function", then: "function"}
}]
},
dependencies: ["__defer", "__promiseIter", "__typeof", "setImmediate"]
}
},
assignOperator: [
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.assign(left,"=",right);};}.call(this));',
operators: ":=",
options: {type: "right"},
id: 30
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return __node("MacroAccess",303,9,1,303,{left:__wrap(setLeft),inverted:false,op:"and",right:__node("MacroAccess",303,25,30,303,{left:__wrap(left),op:":=",right:__wrap(right)},"expression",false,false)},"expression",false,false);});};}.call(this));',
operators: "and=",
id: 43
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return __node("MacroAccess",307,9,2,307,{left:__wrap(setLeft),inverted:false,op:"or",right:__node("MacroAccess",307,24,30,307,{left:__wrap(left),op:":=",right:__wrap(right)},"expression",false,false)},"expression",false,false);});};}.call(this));',
operators: "or=",
id: 44
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;if(this.canMutateLast(right)&&this.isIdentOrTmp(left)){return this.mutateLast(right||this.noop(),function(n){if(op==="~*="){return _this.assign(left,"*=",n);}else if(op==="~/="){return _this.assign(left,"/=",n);}else{return _this.assign(left,"%=",n);}},true);}else if(op==="~*="){return this.assign(left,"*=",right);}else if(op==="~/="){return this.assign(left,"/=",right);}else{return this.assign(left,"%=",right);}};}.call(this));',
operators: ["~*=", "~/=", "~%="],
options: {type: "number"},
id: 46
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return __node("MacroAccess",342,9,30,342,{left:__wrap(setLeft),op:":=",right:__node("MacroAccess",342,22,45,342,{left:__wrap(left),inverted:false,op:"~\\\\",right:__wrap(right)},"expression",false,false)},"expression",false,false);});};}.call(this));',
operators: "~\\=",
options: {type: "number"},
id: 47
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var left,op,right;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return __node("MacroAccess",396,9,30,396,{left:__wrap(setLeft),op:":=",right:__node("MacroAccess",396,22,50,396,{left:__wrap(left),inverted:false,op:"~^",right:__wrap(right)},"expression",false,false)},"expression",false,false);});};}.call(this));',
operators: "~^=",
options: {type: "number"},
id: 51
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right,value;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;if(this.isConst(right)){value=this.value(right);if(value===1){return this.unary("++",left);}else if(value===-1){return this.unary("--",left);}else if(typeof value==="number"&&!this.isType(left,"numeric")){return this.assign(left,"-=",this["const"](-value));}}if(this.isType(left,"numeric")){if(this.canMutateLast(right)&&this.isIdentOrTmp(left)){return this.mutateLast(right||this.noop(),function(n){if(!_this.isType(n,"numeric")){n=__node("MacroAccess",412,20,48,412,{op:"~+",node:__wrap(n)},"expression",false,false);}return _this.assign(left,"+=",n);},true);}else{if(!this.isType(right,"numeric")){right=__node("MacroAccess",416,22,48,416,{op:"~+",node:__wrap(right)},"expression",false,false);}return this.assign(left,"+=",right);}}else if(this.canMutateLast(right)&&this.isIdentOrTmp(left)){return this.mutateLast(right||this.noop(),function(n){return _this.assign(left,"-=",__node("MacroAccess",420,72,48,420,{op:"~-",node:__wrap(n)},"expression",false,false));},true);}else{return this.assign(left,"-=",__node("MacroAccess",422,31,48,422,{op:"~-",node:__wrap(right)},"expression",false,false));}};}.call(this));',
operators: "~+=",
options: {type: "number"},
id: 52
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right,value;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;if(this.isConst(right)){value=this.value(right);if(value===1){return this.unary("--",left);}else if(value===-1){return this.unary("++",left);}}if(this.canMutateLast(right)&&this.isIdentOrTmp(left)){return this.mutateLast(right||this.noop(),function(n){return _this.assign(left,"-=",n);},true);}else{return this.assign(left,"-=",right);}};}.call(this));',
operators: "~-=",
options: {type: "number"},
id: 53
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;if(this.canMutateLast(right)&&this.isIdentOrTmp(left)){return this.mutateLast(right||this.noop(),function(n){if(op==="~bitlshift="){return _this.assign(left,"<<=",n);}else if(op==="~bitrshift="){return _this.assign(left,">>=",n);}else{return _this.assign(left,">>>=",n);}},true);}else if(op==="~bitlshift="){return this.assign(left,"<<=",right);}else if(op==="~bitrshift="){return this.assign(left,">>=",right);}else{return this.assign(left,">>>=",right);}};}.call(this));',
operators: ["~bitlshift=", "~bitrshift=", "~biturshift="],
options: {type: "number"},
id: 55
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;if(this.canMutateLast(right)&&this.isIdentOrTmp(left)){return this.mutateLast(right||this.noop(),function(n){if(_this.hasType(left,"numeric")&&_this.hasType(n,"numeric")){n=__node("MacroAccess",465,18,29,465,{left:__node("Const",465,19,""),inverted:false,op:"~&",right:__node("Ident",465,24,"n")},"expression",false,false);}return _this.assign(left,"+=",n);},true);}else{if(this.hasType(left,"numeric")&&this.hasType(right,"numeric")){right=__node("MacroAccess",469,20,29,469,{left:__node("Const",469,21,""),inverted:false,op:"~&",right:__node("Ident",469,26,"right")},"expression",false,false);}return this.assign(left,"+=",right);}};}.call(this));',
operators: "~&=",
options: {type: "string"},
id: 56
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return __node("MacroAccess",529,9,30,529,{left:__wrap(setLeft),op:":=",right:__node("MacroAccess",529,22,60,529,{left:__wrap(left),inverted:false,op:"^",right:__wrap(right)},"expression",false,false)},"expression",false,false);});};}.call(this));',
operators: "^=",
options: {type: "number"},
id: 61
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return __node("MacroAccess",560,9,30,560,{left:__wrap(setLeft),op:":=",right:__node("MacroAccess",560,22,62,560,{left:__wrap(left),inverted:false,op:"\\\\",right:__wrap(right)},"expression",false,false)},"expression",false,false);});};}.call(this));',
operators: "\\=",
options: {type: "number"},
id: 66
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;if(this.isType(left,"string")){return __node("MacroAccess",577,9,56,577,{left:__wrap(left),op:"~&=",right:__node("MacroAccess",577,19,67,577,{left:__node("Const",577,20,""),inverted:false,op:"&",right:__wrap(right)},"expression",false,false)},"expression",false,false);}else{return this.maybeCacheAccess(left,function(setLeft,left){return __node("MacroAccess",580,11,30,580,{left:__wrap(setLeft),op:":=",right:__node("MacroAccess",580,24,67,580,{left:__wrap(left),inverted:false,op:"&",right:__wrap(right)},"expression",false,false)},"expression",false,false);});}};}.call(this));',
operators: "&=",
options: {type: "string"},
id: 68
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return _this.maybeCache(setLeft,function(setLeft,leftValue){return _this.maybeCache(right,function(setRight,right){return __node("MacroAccess",759,13,16,759,{macroName:"if",macroData:{test:__node("MacroAccess",759,16,10,759,{left:__wrap(setLeft),inverted:false,op:"~>",right:__wrap(setRight)},"expression",false,false),body:__node("MacroAccess",759,47,30,759,{left:__wrap(left),op:":=",right:__wrap(right)},"expression",false,false),elseIfs:[],elseBody:__wrap(leftValue)}},"expression",false,false);});});});};}.call(this));',
operators: "~min=",
id: 84
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return _this.maybeCache(setLeft,function(setLeft,leftValue){return _this.maybeCache(right,function(setRight,right){return __node("MacroAccess",765,13,16,765,{macroName:"if",macroData:{test:__node("MacroAccess",765,16,9,765,{left:__wrap(setLeft),inverted:false,op:"~<",right:__wrap(setRight)},"expression",false,false),body:__node("MacroAccess",765,47,30,765,{left:__wrap(left),op:":=",right:__wrap(right)},"expression",false,false),elseIfs:[],elseBody:__wrap(leftValue)}},"expression",false,false);});});});};}.call(this));',
operators: "~max=",
id: 85
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return _this.maybeCache(setLeft,function(setLeft,leftValue){return _this.maybeCache(right,function(setRight,right){return __node("MacroAccess",771,13,16,771,{macroName:"if",macroData:{test:__node("MacroAccess",771,16,77,771,{left:__wrap(setLeft),inverted:false,op:">",right:__wrap(setRight)},"expression",false,false),body:__node("MacroAccess",771,46,30,771,{left:__wrap(left),op:":=",right:__wrap(right)},"expression",false,false),elseIfs:[],elseBody:__wrap(leftValue)}},"expression",false,false);});});});};}.call(this));',
operators: "min=",
id: 86
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return _this.maybeCache(setLeft,function(setLeft,leftValue){return _this.maybeCache(right,function(setRight,right){return __node("MacroAccess",777,13,16,777,{macroName:"if",macroData:{test:__node("MacroAccess",777,16,76,777,{left:__wrap(setLeft),inverted:false,op:"<",right:__wrap(setRight)},"expression",false,false),body:__node("MacroAccess",777,46,30,777,{left:__wrap(left),op:":=",right:__wrap(right)},"expression",false,false),elseIfs:[],elseBody:__wrap(leftValue)}},"expression",false,false);});});});};}.call(this));',
operators: "max=",
id: 87
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return __node("MacroAccess",781,9,30,781,{left:__wrap(setLeft),op:":=",right:__node("MacroAccess",781,22,82,781,{left:__wrap(left),inverted:false,op:"xor",right:__wrap(right)},"expression",false,false)},"expression",false,false);});};}.call(this));',
operators: "xor=",
id: 88
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;return this.maybeCacheAccess(left,function(setLeft,left){return _this.maybeCache(setLeft,function(setLeft,leftValue){if(_this.position==="expression"){return __node("MacroAccess",787,13,16,787,{macroName:"if",macroData:{test:__node("MacroAccess",787,16,20,787,{op:"?",node:__wrap(setLeft)},"expression",false,false),body:__wrap(leftValue),elseIfs:[],elseBody:__node("MacroAccess",787,51,30,787,{left:__wrap(left),op:":=",right:__wrap(right)},"expression",false,false)}},"expression",false,false);}else{return __node("MacroAccess",789,12,17,789,{macroName:"if",macroData:{test:__node("MacroAccess",789,15,3,789,{op:"not",node:__node("MacroAccess",789,19,20,789,{op:"?",node:__wrap(setLeft)},"statement",false,false)},"statement",false,false),body:__node("MacroAccess",790,1,30,790,{left:__wrap(left),op:":=",right:__wrap(right)},"statement",false,false),elseIfs:[],elseBody:__wrap(leftValue)}},"statement",false,false);}});});};}.call(this));',
operators: "?=",
id: 89
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;if(this.canMutateLast(right)&&this.isIdentOrTmp(left)){return this.mutateLast(right||this.noop(),function(n){if(op==="~bitand="){return _this.assign(left,"&=",n);}else if(op==="~bitor="){return _this.assign(left,"|=",n);}else{return _this.assign(left,"^=",n);}},true);}else if(op==="~bitand="){return this.assign(left,"&=",right);}else if(op==="~bitor="){return this.assign(left,"|=",right);}else{return this.assign(left,"^=",right);}};}.call(this));',
operators: ["~bitand=", "~bitor=", "~bitxor="],
options: {type: "number"},
id: 93
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var _this,left,op,right;_this=this;left=macroData.left;op=macroData.op;right=macroData.right;if(this.isType(left,"number")){if(op==="*="){return __node("MacroAccess",856,11,46,856,{left:__wrap(left),op:"~*=",right:__node("MacroAccess",856,21,58,856,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="/="){return __node("MacroAccess",858,11,46,858,{left:__wrap(left),op:"~/=",right:__node("MacroAccess",858,21,58,858,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="%="){return __node("MacroAccess",860,11,46,860,{left:__wrap(left),op:"~%=",right:__node("MacroAccess",860,21,58,860,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="+="){return __node("MacroAccess",862,11,52,862,{left:__wrap(left),op:"~+=",right:__node("MacroAccess",862,21,58,862,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="-="){return __node("MacroAccess",864,11,53,864,{left:__wrap(left),op:"~-=",right:__node("MacroAccess",864,21,58,864,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="bitlshift="){return __node("MacroAccess",866,11,55,866,{left:__wrap(left),op:"~bitlshift=",right:__node("MacroAccess",866,29,58,866,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="bitrshift="){return __node("MacroAccess",868,11,55,868,{left:__wrap(left),op:"~bitrshift=",right:__node("MacroAccess",868,29,58,868,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="biturshift="){return __node("MacroAccess",870,11,55,870,{left:__wrap(left),op:"~biturshift=",right:__node("MacroAccess",870,30,58,870,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="bitand="){return __node("MacroAccess",872,11,93,872,{left:__wrap(left),op:"~bitand=",right:__node("MacroAccess",872,26,58,872,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="bitor="){return __node("MacroAccess",874,11,93,874,{left:__wrap(left),op:"~bitor=",right:__node("MacroAccess",874,25,58,874,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else if(op==="bitxor="){return __node("MacroAccess",876,11,93,876,{left:__wrap(left),op:"~bitxor=",right:__node("MacroAccess",876,26,58,876,{op:"+",node:__wrap(right)},"expression",false,false)},"expression",false,false);}else{return this.error("Unknown operator "+op);}}else{return this.maybeCacheAccess(left,function(setLeft,left){var action;if(op==="*="){action=__node("MacroAccess",882,13,62,882,{left:__wrap(left),inverted:false,op:"*",right:__wrap(right)},"expression",false,false);}else if(op==="/="){action=__node("MacroAccess",884,13,62,884,{left:__wrap(left),inverted:false,op:"/",right:__wrap(right)},"expression",false,false);}else if(op==="%="){action=__node("MacroAccess",886,13,62,886,{left:__wrap(left),inverted:false,op:"%",right:__wrap(right)},"expression",false,false);}else if(op==="+="){action=__node("MacroAccess",888,13,64,888,{left:__wrap(left),inverted:false,op:"+",right:__wrap(right)},"expression",false,false);}else if(op==="-="){action=__node("MacroAccess",890,13,64,890,{left:__wrap(left),inverted:false,op:"-",right:__wrap(right)},"expression",false,false);}else if(op==="bitlshift="){action=__node("MacroAccess",892,13,65,892,{left:__wrap(left),inverted:false,op:"bitlshift",right:__wrap(right)},"expression",false,false);}else if(op==="bitrshift="){action=__node("MacroAccess",894,13,65,894,{left:__wrap(left),inverted:false,op:"bitrshift",right:__wrap(right)},"expression",false,false);}else if(op==="biturshift="){action=__node("MacroAccess",896,13,65,896,{left:__wrap(left),inverted:false,op:"biturshift",right:__wrap(right)},"expression",false,false);}else if(op==="bitand="){action=__node("MacroAccess",898,13,94,898,{left:__wrap(left),inverted:false,op:"bitand",right:__wrap(right)},"expression",false,false);}else if(op==="bitor="){action=__node("MacroAccess",900,13,95,900,{left:__wrap(left),inverted:false,op:"bitor",right:__wrap(right)},"expression",false,false);}else if(op==="bitxor="){action=__node("MacroAccess",902,13,96,902,{left:__wrap(left),inverted:false,op:"bitxor",right:__wrap(right)},"expression",false,false);}else{action=_this.error("Unknown operator "+op);}return __node("MacroAccess",905,11,30,905,{left:__wrap(setLeft),op:":=",right:__wrap(action)},"expression",false,false);});}};}.call(this));',
operators: [
"*=",
"/=",
"%=",
"+=",
"-=",
"bitlshift=",
"bitrshift=",
"biturshift=",
"bitand=",
"bitor=",
"bitxor="
],
options: {type: "number"},
id: 101
}
],
defineSyntax: [
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var asType,ident,isMutable;isMutable=macroData.isMutable;ident=macroData.ident;asType=macroData.asType;if(this.isIdentOrTmp(ident)){return {type:"ident",isMutable:isMutable==="mutable",ident:ident,asType:asType};}else{return ident;}};}.call(this));',
options: {name: "DeclarableIdent"},
params: [
["ident", "isMutable", "many", "?", "const", "mutable"],
["ident", "ident", "ident", "Identifier"],
[
"ident",
"asType",
"many",
"?",
"sequence",
["const", "as"],
["this", "ident", "Type"]
]
],
id: 31
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var head,tail;head=macroData.head;tail=macroData.tail;return {type:"array",elements:[head].concat(tail)};};}.call(this));',
options: {name: "DeclarableArray"},
params: [
["const", "["],
[
"ident",
"head",
"choice",
["ident", "Declarable"],
["const", ""]
],
[
"ident",
"tail",
"many",
"*",
"sequence",
["const", ","],
[
"this",
"choice",
["ident", "Declarable"],
["const", ""]
]
],
["const", "]"]
],
id: 32
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var value;value=macroData.value;value=this.macroExpand1(value);return {key:this.name(value.ident),value:value};};}.call(this));',
options: {name: "DeclarableObjectSingularPair"},
params: [["ident", "value", "ident", "DeclarableIdent"]],
id: 33
},
{
options: {name: "DeclarableObjectDualPair"},
params: [[
"this",
"sequence",
["ident", "key", "ident", "ObjectKey"],
["const", ":"],
["ident", "value", "ident", "Declarable"]
]],
id: 34
},
{
options: {name: "DeclarableObjectPair"},
params: [[
"this",
"choice",
["ident", "DeclarableObjectDualPair"],
["ident", "DeclarableObjectSingularPair"]
]],
id: 35
},
{
code: 'return (function(){"use strict";return function(macroData,__wrap,__node){var head,tail;head=macroData.head;tail=macroData.tail;return {type:"object",pairs:[head].concat(tail)};};}.call(this));',
options: {name: "DeclarableObject"},
params: [
["const", "{"],
["ident", "head", "ident", "DeclarableObjectPair"],
[
"ident",
"tail",
"many",
"*",
"sequence",
["const", ","],
["this", "ident", "DeclarableObjectPair"]
],
["const", "}"]
],
id: 36
},
{
options: {name: "Declarable"},
params: [[
"this",
"choice",
["ident", "DeclarableArray"],
["ident", "DeclarableObject"],
["ident", "DeclarableIdent"]
]],
id: 37
}
],
call: [
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var body,func,macroData,macroName,ran,silentFail;macroName=macroFullData.macroName;macroData=macroFullData.macroData;func=macroData[0];silentFail=macroData[1];if(this.isFunc(func)){body=this.funcBody(func);ran=this.tmp("once",true,"boolean");func=this.rewrap(this.func(this.funcParams(func),__node("Block",2332,1,[__node("MacroAccess",2332,1,17,2332,{macroName:"if",macroData:{test:__wrap(ran),body:__node("MacroAccess",2333,1,17,2333,{macroName:"if",macroData:{test:__wrap(silentFail),body:__node("MacroAccess",2334,1,39,2334,{macroName:"return",macroData:{}},"statement",false,false),elseIfs:[],elseBody:__node("MacroAccess",2336,1,11,2336,{op:"throw",node:__node("Call",2336,18,__node("Ident",2336,18,"Error"),[__node("Const",2336,25,"Attempted to call function more than once")],false,false)},"statement",false,false)}},"statement",false,false),elseIfs:[],elseBody:__node("MacroAccess",2338,1,30,2338,{left:__wrap(ran),op:":=",right:__node("Const",2338,18,true)},"statement",false,false)}},"statement",false,false),__wrap(body)],null),this.funcIsAutoReturn(func),this.funcIsBound(func),this.funcIsCurried(func),this.funcAsType(func),this.funcIsGenerator(func),this.funcGeneric(func)));return __node("Block",2347,1,[__node("MacroAccess",2347,1,38,2347,{macroName:"let",macroData:{declarable:__node("MacroAccess",2347,10,37,2347,__node("MacroAccess",2347,10,31,2347,{isMutable:"mutable",ident:__wrap(ran)},"statement",false,false),"statement",false,false),value:__node("Const",2347,25,false)}},"statement",false,false),__wrap(func)],null);}else if(this.isConst(silentFail)&&!this.value(silentFail)){return __node("Call",2351,11,__node("Ident",2351,11,"__once"),[__wrap(func)],false,false);}else{return __node("Call",2353,11,__node("Ident",2353,11,"__once"),[__wrap(func),__wrap(silentFail)],false,false);}};}.call(this));',
names: "once!",
id: 124
},
{
code: 'return (function(){"use strict";var __slice;__slice=Array.prototype.slice;return function(macroFullData,__wrap,__node){var _this,head,macroData,macroName,tail;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;head=macroData[0];tail=__slice.call(arguments[0].macroData,1);if(tail.length===0){return __wrap(head);}else{return this.maybeCache(head,function(setHead,head){return __node("Block",3569,1,[__wrap(setHead),__wrap(tail),__wrap(head)],null);});}};}.call(this));',
names: "first!",
id: 154
},
{
code: 'return (function(){"use strict";var __num,__slice,__typeof;__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__slice=Array.prototype.slice;__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _ref,finish,macroData,macroName,start;macroName=macroFullData.macroName;macroData=macroFullData.macroData;start=__slice.call(arguments[0].macroData,0,-1);finish=(_ref=arguments[0].macroData)[__num(_ref.length)-1];if(start.length===0){return __wrap(finish);}else{return __node("Block",3581,1,[__wrap(start),__wrap(finish)],null);}};}.call(this));',
names: "last!",
id: 155
},
{
code: 'return (function(){"use strict";var __num,__typeof;__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _this,macroData,macroName,node;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData[0];if(__num(macroData.length)>1){this.error("fulfilled! only expects one argument");}return this.mutateLast(node||this.noop(),function(n){return __node("Call",3729,47,__node("Access",3729,47,__node("Ident",3729,47,"__defer"),__node("Const",3729,56,"fulfilled")),[__wrap(n)],false,false);},true);};}.call(this));',
names: "fulfilled!",
id: 158
},
{
code: 'return (function(){"use strict";var __num,__typeof;__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _this,macroData,macroName,node;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData[0];if(__num(macroData.length)>1){this.error("rejected! only expects one argument");}return this.mutateLast(node||this.noop(),function(n){return __node("Call",3734,47,__node("Access",3734,47,__node("Ident",3734,47,"__defer"),__node("Const",3734,56,"rejected")),[__wrap(n)],false,false);},true);};}.call(this));',
names: "rejected!",
id: 159
},
{
code: 'return (function(){"use strict";var __num,__typeof;__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var macroData,macroName,node;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData[0];if(__num(macroData.length)>1){this.error("from-promise! only expects one argument");}return __node("Call",3744,7,__node("Ident",3744,7,"__fromPromise"),[__wrap(node)],false,false);};}.call(this));',
names: "fromPromise!",
id: 160
},
{
code: 'return (function(){"use strict";var __num,__slice,__typeof;__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__slice=Array.prototype.slice;__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var _this,args,func,head,macroData,macroName,node,tail;_this=this;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData[0];if(__num(macroData.length)>1){this.error("to-promise! only expects one argument");}if(!this.isCall(node)){this.error("to-promise! call expression must be a call",node);}func=this.callFunc(node);args=this.callArgs(node);if(this.callIsNew(node)){args=this.array(args);return __node("Call",3765,9,__node("Ident",3765,9,"__toPromise"),[__node("Ident",3765,23,"__new"),__wrap(func),__wrap(args)],false,false);}else if(this.callIsApply(node)){if(args.length===0||!this.isSpread(args[0])){head=args[0];tail=this.array(__slice.call(args,1));return __node("Call",3770,11,__node("Ident",3770,11,"__toPromise"),[__wrap(func),__wrap(head),__wrap(tail)],false,false);}else{return this.maybeCache(this.array(args),function(setArgs,args){return __node("Call",3773,13,__node("Ident",3773,13,"__toPromise"),[__wrap(func),__node("Access",3773,33,__wrap(setArgs),__node("Const",3773,44,0)),__node("Call",3773,47,__node("Access",3773,47,__wrap(args),__node("Const",3773,54,"slice")),[__node("Const",3773,60,1)],false,false)],false,false);});}}else{args=this.array(args);if(this.isAccess(func)){return this.maybeCache(this.parent(func),function(setParent,parent){var child;child=_this.child(func);return __node("Call",3779,13,__node("Ident",3779,13,"__toPromise"),[__node("Access",3779,27,__wrap(setParent),__wrap(child)),__wrap(parent),__wrap(args)],false,false);});}else{return __node("Call",3781,11,__node("Ident",3781,11,"__toPromise"),[__wrap(func),__node("Const",3781,31,void 0),__wrap(args)],false,false);}}};}.call(this));',
options: {type: "promise"},
names: "toPromise!",
id: 161
},
{
code: 'return (function(){"use strict";var __num,__typeof;__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var macroData,macroName,node;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData[0];if(__num(macroData.length)>1){this.error("some-promise! only expects one argument");}if(!this.hasType(node,"array")){this.error("some-promise! should be used on an Array",node);}return __node("Call",3816,7,__node("Ident",3816,7,"__somePromise"),[__wrap(node)],false,false);};}.call(this));',
names: "somePromise!",
id: 162
},
{
code: 'return (function(){"use strict";var __num,__typeof;__num=function(num){if(typeof num!=="number"){throw TypeError("Expected a number, got "+__typeof(num));}else{return num;}};__typeof=(function(){var _toString;_toString=Object.prototype.toString;return function(o){if(o===void 0){return "Undefined";}else if(o===null){return "Null";}else{return o.constructor&&o.constructor.name||_toString.call(o).slice(8,-1);}};}());return function(macroFullData,__wrap,__node){var macroData,macroName,node;macroName=macroFullData.macroName;macroData=macroFullData.macroData;node=macroData[0];if(__num(macroData.length)>1){this.error("some-promise! only expects one argument");}if(!this.hasType(node,"array")&&!this.hasType(node,"object")){this.error("every-promise! should be used on an Array or Object",node);}return __node("Call",3847,7,__node("Ident",3847,7,"__everyPromise"),[__wrap(node)],false,false);};}.call(this));',
names: "everyPromise!",
id: 163
},
{
code: 'return (function(){"use strict";return function(macroFullData,__wrap,__node){var macroData,macroName,milliseconds,value;macroName=macroFullData.macroName;macroData=macroFullData.macroData;milliseconds=macroData[0];value=macroData[1];if(!this.hasType(milliseconds,"number")){this.error("delay! should take a number in milliseconds");}if(this.isConst(value)&&this.value(value)===void 0){return __node("Call",3862,9,__node("Ident",3862,9,"__delay"),[__wrap(milliseconds)],false,false);}else{return __node("Call",3864,9,__node("Ident",3864,9,"__delay"),[__wrap(milliseconds),__wrap(value)],false,false);}};}.call(this));',
names: "delay!",
id: 164
}
]
});
}(typeof module !== "undefined" && typeof require === "function" ? require : void 0));
if (typeof define === "function" && define.amd) {
define(function () { return GorillaScript; });
} else {
root.GorillaScript = GorillaScript;
}
}(this));