From 13cc30ac2c8ec09e65821e717ff9517b21c33217 Mon Sep 17 00:00:00 2001 From: NANKI Haruo Date: Sat, 13 Feb 2016 21:42:07 +0900 Subject: [PATCH] use estraverse. --- dist/browser/overload.js | 20945 ++++++++++++++++++--------------- dist/browser/overload.min.js | 830 +- lib/overload.js | 188 +- 3 files changed, 11568 insertions(+), 10395 deletions(-) diff --git a/dist/browser/overload.js b/dist/browser/overload.js index b3b901d..55c9412 100644 --- a/dist/browser/overload.js +++ b/dist/browser/overload.js @@ -4,6 +4,7 @@ var esprima = require('esprima'); var escodegen = require('escodegen'); +var estraverse = require('estraverse'); var funcNames = { '+': '__plus', @@ -49,129 +50,68 @@ var funcNames = { }; //The AST Walker And Transformer -function visit(statement, index, program) { - switch (statement.type) { - case 'VariableDeclaration': - statement.declarations.forEach(function (declaration, idx) { - visit(declaration.init, idx, program); - }); - break; - case 'BinaryExpression': - case 'LogicalExpression': - if (statement.operator && funcNames[statement.operator]) { - statement.type = 'CallExpression'; - statement.callee = { - 'type': 'MemberExpression', - 'computed': false, - 'object': statement.right, - 'property': { - 'type': 'Identifier', - 'name': funcNames[statement.operator] - } - }; - visit(statement.left, index, program); - visit(statement.right, index, program); - statement['arguments'] = [statement.left]; - } else { - visit(statement.left, index, program); - visit(statement.right, index, program); - } - break; - case 'ExpressionStatement': - visit(statement.expression, index, program); - break; - case 'CallExpression': - statement['arguments'].forEach(function (argument, idx) { - visit(argument, idx, program); - }); - visit(statement.callee, index, program); - break; - case 'AssignmentExpression': - if (statement.operator && funcNames[statement.operator]) { - statement.right = { - type: 'CallExpression', - callee: { - 'type': 'MemberExpression', - 'computed': false, - 'object': statement.left, - 'property': { - 'type': 'Identifier', - 'name': funcNames[statement.operator] - } - }, - arguments: [statement.right] - }; - statement.operator = '='; - - visit(statement.left, index, program); - visit(statement.right.arguments[0], index, program); - } else { - visit(statement.right, index, program); - } - break; - case 'UnaryExpression': - if (statement.operator && funcNames[statement.operator]) { - statement.type = 'CallExpression'; - statement.callee = { - 'type': 'MemberExpression', - 'computed': false, - 'object': statement.argument, - 'property': { - 'type': 'Identifier', - 'name': (statement.operator === '+' || statement.operator === '-') ? funcNames['u' + statement.operator] : funcNames[statement.operator] - } - }; - visit(statement.argument, index, program); - statement['arguments'] = []; - } else { - visit(statement.argument, index, program); - } - break; - case 'UpdateExpression': - if (statement.operator && funcNames[statement.operator]) { - statement.type = 'CallExpression'; - statement.callee = { - 'type': 'MemberExpression', - 'computed': false, - 'object': statement.argument, - 'property': { - 'type': 'Identifier', - 'name': funcNames[statement.operator] +var visitor = { + enter: function(node, parent) { + switch(node.type) { + case 'BinaryExpression': + case 'LogicalExpression': + if (node.operator && funcNames[node.operator]) { + return { + type: 'CallExpression', + callee: { + 'type': 'MemberExpression', + 'computed': false, + 'object': node.right, + 'property': { + 'type': 'Identifier', + 'name': funcNames[node.operator] + } + }, + arguments: [node.left] + }; + } + break; + case 'AssignmentExpression': + if (node.operator && funcNames[node.operator]) { + return { + type: 'AssignmentExpression', + left: node.left, + right: { + type: 'CallExpression', + callee: { + 'type': 'MemberExpression', + 'computed': false, + 'object': node.left, + 'property': { + 'type': 'Identifier', + 'name': funcNames[node.operator] + } + }, + arguments: [node.right] + }, + operator: '=' } - }; - visit(statement.argument, index, program); - statement['arguments'] = []; - } - break; - case 'FunctionDeclaration': - case 'FunctionExpression': - visit(statement.body, index, program); - break; - case 'BlockStatement': - statement.body.forEach(function (statement) { - visit(statement, index, program); - }); - break; - case 'ReturnStatement': - visit(statement.argument, index, program); - break; - case 'MemberExpression': - visit(statement.object, index, program); - break; - case 'SwitchStatement': - statement.cases.forEach(function(_case, idx){ - visit(_case, idx, program); - }); - break; - case 'SwitchCase': - statement.consequent.forEach(function(con, idx){ - visit(con, idx, program); - }); - break; - //We don't ned to transform following nodes! Phew! - case 'Literal': - case 'Identifier': - break; + } + break; + case 'UnaryExpression': + case 'UpdateExpression': + if (node.operator && funcNames[node.operator]) { + return { + type: 'CallExpression', + callee: { + 'type': 'MemberExpression', + 'computed': false, + 'object': node.argument, + 'property': { + 'type': 'Identifier', + 'name': (node.operator === '+' || node.operator === '-') ? funcNames['u' + node.operator] : funcNames[node.operator] + } + }, + arguments: [] + }; + } + break; + } } } @@ -199,9 +139,7 @@ module.exports = exports = function (func) { }; //Transform - program.body.forEach(function (statement, index) { - visit(statement, index, program); - }); + estraverse.replace(program, visitor) //Build new function args args.push(escodegen.generate(program, { @@ -360,6468 +298,5474 @@ cons.forEach(function (constructor) { exports.functionNames = funcNames; -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_61dd2044.js","/") -},{"1YiZ5S":25,"buffer":21,"escodegen":2,"esprima":20}],2:[function(require,module,exports){ +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_c102ede9.js","/") +},{"buffer":3,"escodegen":4,"esprima":24,"estraverse":25,"pBGvAp":29}],2:[function(require,module,exports){ (function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* - Copyright (C) 2012-2014 Yusuke Suzuki - Copyright (C) 2015 Ingvar Stepanyan - Copyright (C) 2014 Ivan Nikulin - Copyright (C) 2012-2013 Michael Ficarra - Copyright (C) 2012-2013 Mathias Bynens - Copyright (C) 2013 Irakli Gozalishvili - Copyright (C) 2012 Robert Gust-Bardon - Copyright (C) 2012 John Freeman - Copyright (C) 2011-2012 Ariya Hidayat - Copyright (C) 2012 Joost-Wim Boekesteijn - Copyright (C) 2012 Kris Kowal - Copyright (C) 2012 Arpad Borsos - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: +var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. +;(function (exports) { + 'use strict'; - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + var Arr = (typeof Uint8Array !== 'undefined') + ? Uint8Array + : Array -/*global exports:true, require:true, global:true*/ -(function () { - 'use strict'; + var PLUS = '+'.charCodeAt(0) + var SLASH = '/'.charCodeAt(0) + var NUMBER = '0'.charCodeAt(0) + var LOWER = 'a'.charCodeAt(0) + var UPPER = 'A'.charCodeAt(0) + var PLUS_URL_SAFE = '-'.charCodeAt(0) + var SLASH_URL_SAFE = '_'.charCodeAt(0) - var Syntax, - Precedence, - BinaryPrecedence, - SourceNode, - estraverse, - esutils, - isArray, - base, - indent, - json, - renumber, - hexadecimal, - quotes, - escapeless, - newline, - space, - parentheses, - semicolons, - safeConcatenation, - directive, - extra, - parse, - sourceMap, - sourceCode, - preserveBlankLines, - FORMAT_MINIFY, - FORMAT_DEFAULTS; + function decode (elt) { + var code = elt.charCodeAt(0) + if (code === PLUS || + code === PLUS_URL_SAFE) + return 62 // '+' + if (code === SLASH || + code === SLASH_URL_SAFE) + return 63 // '/' + if (code < NUMBER) + return -1 //no match + if (code < NUMBER + 10) + return code - NUMBER + 26 + 26 + if (code < UPPER + 26) + return code - UPPER + if (code < LOWER + 26) + return code - LOWER + 26 + } - estraverse = require('estraverse'); - esutils = require('esutils'); + function b64ToByteArray (b64) { + var i, j, l, tmp, placeHolders, arr - Syntax = estraverse.Syntax; + if (b64.length % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } - // Generation is done by generateExpression. - function isExpression(node) { - return CodeGenerator.Expression.hasOwnProperty(node.type); - } + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + var len = b64.length + placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - // Generation is done by generateStatement. - function isStatement(node) { - return CodeGenerator.Statement.hasOwnProperty(node.type); - } + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(b64.length * 3 / 4 - placeHolders) - Precedence = { - Sequence: 0, - Yield: 1, - Await: 1, - Assignment: 1, - Conditional: 2, - ArrowFunction: 2, - LogicalOR: 3, - LogicalAND: 4, - BitwiseOR: 5, - BitwiseXOR: 6, - BitwiseAND: 7, - Equality: 8, - Relational: 9, - BitwiseSHIFT: 10, - Additive: 11, - Multiplicative: 12, - Unary: 13, - Postfix: 14, - Call: 15, - New: 16, - TaggedTemplate: 17, - Member: 18, - Primary: 19 - }; + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? b64.length - 4 : b64.length - BinaryPrecedence = { - '||': Precedence.LogicalOR, - '&&': Precedence.LogicalAND, - '|': Precedence.BitwiseOR, - '^': Precedence.BitwiseXOR, - '&': Precedence.BitwiseAND, - '==': Precedence.Equality, - '!=': Precedence.Equality, - '===': Precedence.Equality, - '!==': Precedence.Equality, - 'is': Precedence.Equality, - 'isnt': Precedence.Equality, - '<': Precedence.Relational, - '>': Precedence.Relational, - '<=': Precedence.Relational, - '>=': Precedence.Relational, - 'in': Precedence.Relational, - 'instanceof': Precedence.Relational, - '<<': Precedence.BitwiseSHIFT, - '>>': Precedence.BitwiseSHIFT, - '>>>': Precedence.BitwiseSHIFT, - '+': Precedence.Additive, - '-': Precedence.Additive, - '*': Precedence.Multiplicative, - '%': Precedence.Multiplicative, - '/': Precedence.Multiplicative - }; + var L = 0 - //Flags - var F_ALLOW_IN = 1, - F_ALLOW_CALL = 1 << 1, - F_ALLOW_UNPARATH_NEW = 1 << 2, - F_FUNC_BODY = 1 << 3, - F_DIRECTIVE_CTX = 1 << 4, - F_SEMICOLON_OPT = 1 << 5; + function push (v) { + arr[L++] = v + } - //Expression flag sets - //NOTE: Flag order: - // F_ALLOW_IN - // F_ALLOW_CALL - // F_ALLOW_UNPARATH_NEW - var E_FTT = F_ALLOW_CALL | F_ALLOW_UNPARATH_NEW, - E_TTF = F_ALLOW_IN | F_ALLOW_CALL, - E_TTT = F_ALLOW_IN | F_ALLOW_CALL | F_ALLOW_UNPARATH_NEW, - E_TFF = F_ALLOW_IN, - E_FFT = F_ALLOW_UNPARATH_NEW, - E_TFT = F_ALLOW_IN | F_ALLOW_UNPARATH_NEW; + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) + push((tmp & 0xFF0000) >> 16) + push((tmp & 0xFF00) >> 8) + push(tmp & 0xFF) + } - //Statement flag sets - //NOTE: Flag order: - // F_ALLOW_IN - // F_FUNC_BODY - // F_DIRECTIVE_CTX - // F_SEMICOLON_OPT - var S_TFFF = F_ALLOW_IN, - S_TFFT = F_ALLOW_IN | F_SEMICOLON_OPT, - S_FFFF = 0x00, - S_TFTF = F_ALLOW_IN | F_DIRECTIVE_CTX, - S_TTFF = F_ALLOW_IN | F_FUNC_BODY; - - function getDefaultOptions() { - // default options - return { - indent: null, - base: null, - parse: null, - comment: false, - format: { - indent: { - style: ' ', - base: 0, - adjustMultilineComment: false - }, - newline: '\n', - space: ' ', - json: false, - renumber: false, - hexadecimal: false, - quotes: 'single', - escapeless: false, - compact: false, - parentheses: true, - semicolons: true, - safeConcatenation: false, - preserveBlankLines: false - }, - moz: { - comprehensionExpressionStartsWithAssignment: false, - starlessGenerator: false - }, - sourceMap: null, - sourceMapRoot: null, - sourceMapWithCode: false, - directive: false, - raw: true, - verbatim: null, - sourceCode: null - }; - } - - function stringRepeat(str, num) { - var result = ''; + if (placeHolders === 2) { + tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) + push(tmp & 0xFF) + } else if (placeHolders === 1) { + tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) + push((tmp >> 8) & 0xFF) + push(tmp & 0xFF) + } - for (num |= 0; num > 0; num >>>= 1, str += str) { - if (num & 1) { - result += str; - } - } + return arr + } - return result; - } + function uint8ToBase64 (uint8) { + var i, + extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes + output = "", + temp, length - isArray = Array.isArray; - if (!isArray) { - isArray = function isArray(array) { - return Object.prototype.toString.call(array) === '[object Array]'; - }; - } + function encode (num) { + return lookup.charAt(num) + } - function hasLineTerminator(str) { - return (/[\r\n]/g).test(str); - } + function tripletToBase64 (num) { + return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) + } - function endsWithLineTerminator(str) { - var len = str.length; - return len && esutils.code.isLineTerminator(str.charCodeAt(len - 1)); - } + // go through the array every three bytes, we'll deal with trailing stuff later + for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { + temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output += tripletToBase64(temp) + } - function merge(target, override) { - var key; - for (key in override) { - if (override.hasOwnProperty(key)) { - target[key] = override[key]; - } - } - return target; - } + // pad the end with zeros, but make sure to not forget the extra bytes + switch (extraBytes) { + case 1: + temp = uint8[uint8.length - 1] + output += encode(temp >> 2) + output += encode((temp << 4) & 0x3F) + output += '==' + break + case 2: + temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) + output += encode(temp >> 10) + output += encode((temp >> 4) & 0x3F) + output += encode((temp << 2) & 0x3F) + output += '=' + break + } - function updateDeeply(target, override) { - var key, val; + return output + } - function isHashObject(target) { - return typeof target === 'object' && target instanceof Object && !(target instanceof RegExp); - } + exports.toByteArray = b64ToByteArray + exports.fromByteArray = uint8ToBase64 +}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) - for (key in override) { - if (override.hasOwnProperty(key)) { - val = override[key]; - if (isHashObject(val)) { - if (isHashObject(target[key])) { - updateDeeply(target[key], val); - } else { - target[key] = updateDeeply({}, val); - } - } else { - target[key] = val; - } - } - } - return target; - } +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/base64-js/lib/b64.js","/../node_modules/base64-js/lib") +},{"buffer":3,"pBGvAp":29}],3:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ - function generateNumber(value) { - var result, point, temp, exponent, pos; +var base64 = require('base64-js') +var ieee754 = require('ieee754') - if (value !== value) { - throw new Error('Numeric literal whose value is NaN'); - } - if (value < 0 || (value === 0 && 1 / value < 0)) { - throw new Error('Numeric literal whose value is negative'); - } +exports.Buffer = Buffer +exports.SlowBuffer = Buffer +exports.INSPECT_MAX_BYTES = 50 +Buffer.poolSize = 8192 - if (value === 1 / 0) { - return json ? 'null' : renumber ? '1e400' : '1e+400'; - } +/** + * If `Buffer._useTypedArrays`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (compatible down to IE6) + */ +Buffer._useTypedArrays = (function () { + // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+, + // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding + // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support + // because we need to be able to add all the node Buffer API methods. This is an issue + // in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438 + try { + var buf = new ArrayBuffer(0) + var arr = new Uint8Array(buf) + arr.foo = function () { return 42 } + return 42 === arr.foo() && + typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray` + } catch (e) { + return false + } +})() - result = '' + value; - if (!renumber || result.length < 3) { - return result; - } +/** + * Class: Buffer + * ============= + * + * The Buffer constructor returns instances of `Uint8Array` that are augmented + * with function properties for all the node `Buffer` API functions. We use + * `Uint8Array` so that square bracket notation works as expected -- it returns + * a single octet. + * + * By augmenting the instances, we can avoid modifying the `Uint8Array` + * prototype. + */ +function Buffer (subject, encoding, noZero) { + if (!(this instanceof Buffer)) + return new Buffer(subject, encoding, noZero) - point = result.indexOf('.'); - if (!json && result.charCodeAt(0) === 0x30 /* 0 */ && point === 1) { - point = 0; - result = result.slice(1); - } - temp = result; - result = result.replace('e+', 'e'); - exponent = 0; - if ((pos = temp.indexOf('e')) > 0) { - exponent = +temp.slice(pos + 1); - temp = temp.slice(0, pos); - } - if (point >= 0) { - exponent -= temp.length - point - 1; - temp = +(temp.slice(0, point) + temp.slice(point + 1)) + ''; - } - pos = 0; - while (temp.charCodeAt(temp.length + pos - 1) === 0x30 /* 0 */) { - --pos; - } - if (pos !== 0) { - exponent -= pos; - temp = temp.slice(0, pos); - } - if (exponent !== 0) { - temp += 'e' + exponent; - } - if ((temp.length < result.length || - (hexadecimal && value > 1e12 && Math.floor(value) === value && (temp = '0x' + value.toString(16)).length < result.length)) && - +temp === value) { - result = temp; - } + var type = typeof subject - return result; + // Workaround: node's base64 implementation allows for non-padded strings + // while base64-js does not. + if (encoding === 'base64' && type === 'string') { + subject = stringtrim(subject) + while (subject.length % 4 !== 0) { + subject = subject + '=' } + } - // Generate valid RegExp expression. - // This function is based on https://github.com/Constellation/iv Engine - - function escapeRegExpCharacter(ch, previousIsBackslash) { - // not handling '\' and handling \u2028 or \u2029 to unicode escape sequence - if ((ch & ~1) === 0x2028) { - return (previousIsBackslash ? 'u' : '\\u') + ((ch === 0x2028) ? '2028' : '2029'); - } else if (ch === 10 || ch === 13) { // \n, \r - return (previousIsBackslash ? '' : '\\') + ((ch === 10) ? 'n' : 'r'); - } - return String.fromCharCode(ch); - } + // Find the length + var length + if (type === 'number') + length = coerce(subject) + else if (type === 'string') + length = Buffer.byteLength(subject, encoding) + else if (type === 'object') + length = coerce(subject.length) // assume that object is array-like + else + throw new Error('First argument needs to be a number, array or string.') - function generateRegExp(reg) { - var match, result, flags, i, iz, ch, characterInBrack, previousIsBackslash; + var buf + if (Buffer._useTypedArrays) { + // Preferred: Return an augmented `Uint8Array` instance for best performance + buf = Buffer._augment(new Uint8Array(length)) + } else { + // Fallback: Return THIS instance of Buffer (created by `new`) + buf = this + buf.length = length + buf._isBuffer = true + } - result = reg.toString(); + var i + if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') { + // Speed optimization -- use set if we're copying from a typed array + buf._set(subject) + } else if (isArrayish(subject)) { + // Treat array-ish objects as a byte array + for (i = 0; i < length; i++) { + if (Buffer.isBuffer(subject)) + buf[i] = subject.readUInt8(i) + else + buf[i] = subject[i] + } + } else if (type === 'string') { + buf.write(subject, 0, encoding) + } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) { + for (i = 0; i < length; i++) { + buf[i] = 0 + } + } - if (reg.source) { - // extract flag from toString result - match = result.match(/\/([^/]*)$/); - if (!match) { - return result; - } + return buf +} - flags = match[1]; - result = ''; +// STATIC METHODS +// ============== - characterInBrack = false; - previousIsBackslash = false; - for (i = 0, iz = reg.source.length; i < iz; ++i) { - ch = reg.source.charCodeAt(i); +Buffer.isEncoding = function (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'binary': + case 'base64': + case 'raw': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} - if (!previousIsBackslash) { - if (characterInBrack) { - if (ch === 93) { // ] - characterInBrack = false; - } - } else { - if (ch === 47) { // / - result += '\\'; - } else if (ch === 91) { // [ - characterInBrack = true; - } - } - result += escapeRegExpCharacter(ch, previousIsBackslash); - previousIsBackslash = ch === 92; // \ - } else { - // if new RegExp("\\\n') is provided, create /\n/ - result += escapeRegExpCharacter(ch, previousIsBackslash); - // prevent like /\\[/]/ - previousIsBackslash = false; - } - } +Buffer.isBuffer = function (b) { + return !!(b !== null && b !== undefined && b._isBuffer) +} - return '/' + result + '/' + flags; - } +Buffer.byteLength = function (str, encoding) { + var ret + str = str + '' + switch (encoding || 'utf8') { + case 'hex': + ret = str.length / 2 + break + case 'utf8': + case 'utf-8': + ret = utf8ToBytes(str).length + break + case 'ascii': + case 'binary': + case 'raw': + ret = str.length + break + case 'base64': + ret = base64ToBytes(str).length + break + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + ret = str.length * 2 + break + default: + throw new Error('Unknown encoding') + } + return ret +} - return result; - } +Buffer.concat = function (list, totalLength) { + assert(isArray(list), 'Usage: Buffer.concat(list, [totalLength])\n' + + 'list should be an Array.') - function escapeAllowedCharacter(code, next) { - var hex; + if (list.length === 0) { + return new Buffer(0) + } else if (list.length === 1) { + return list[0] + } - if (code === 0x08 /* \b */) { - return '\\b'; - } + var i + if (typeof totalLength !== 'number') { + totalLength = 0 + for (i = 0; i < list.length; i++) { + totalLength += list[i].length + } + } - if (code === 0x0C /* \f */) { - return '\\f'; - } + var buf = new Buffer(totalLength) + var pos = 0 + for (i = 0; i < list.length; i++) { + var item = list[i] + item.copy(buf, pos) + pos += item.length + } + return buf +} - if (code === 0x09 /* \t */) { - return '\\t'; - } +// BUFFER INSTANCE METHODS +// ======================= - hex = code.toString(16).toUpperCase(); - if (json || code > 0xFF) { - return '\\u' + '0000'.slice(hex.length) + hex; - } else if (code === 0x0000 && !esutils.code.isDecimalDigit(next)) { - return '\\0'; - } else if (code === 0x000B /* \v */) { // '\v' - return '\\x0B'; - } else { - return '\\x' + '00'.slice(hex.length) + hex; - } +function _hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining } + } - function escapeDisallowedCharacter(code) { - if (code === 0x5C /* \ */) { - return '\\\\'; - } + // must be an even number of digits + var strLen = string.length + assert(strLen % 2 === 0, 'Invalid hex string') - if (code === 0x0A /* \n */) { - return '\\n'; - } + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; i++) { + var byte = parseInt(string.substr(i * 2, 2), 16) + assert(!isNaN(byte), 'Invalid hex string') + buf[offset + i] = byte + } + Buffer._charsWritten = i * 2 + return i +} - if (code === 0x0D /* \r */) { - return '\\r'; - } +function _utf8Write (buf, string, offset, length) { + var charsWritten = Buffer._charsWritten = + blitBuffer(utf8ToBytes(string), buf, offset, length) + return charsWritten +} - if (code === 0x2028) { - return '\\u2028'; - } +function _asciiWrite (buf, string, offset, length) { + var charsWritten = Buffer._charsWritten = + blitBuffer(asciiToBytes(string), buf, offset, length) + return charsWritten +} - if (code === 0x2029) { - return '\\u2029'; - } +function _binaryWrite (buf, string, offset, length) { + return _asciiWrite(buf, string, offset, length) +} - throw new Error('Incorrectly classified character'); - } +function _base64Write (buf, string, offset, length) { + var charsWritten = Buffer._charsWritten = + blitBuffer(base64ToBytes(string), buf, offset, length) + return charsWritten +} - function escapeDirective(str) { - var i, iz, code, quote; +function _utf16leWrite (buf, string, offset, length) { + var charsWritten = Buffer._charsWritten = + blitBuffer(utf16leToBytes(string), buf, offset, length) + return charsWritten +} - quote = quotes === 'double' ? '"' : '\''; - for (i = 0, iz = str.length; i < iz; ++i) { - code = str.charCodeAt(i); - if (code === 0x27 /* ' */) { - quote = '"'; - break; - } else if (code === 0x22 /* " */) { - quote = '\''; - break; - } else if (code === 0x5C /* \ */) { - ++i; - } - } +Buffer.prototype.write = function (string, offset, length, encoding) { + // Support both (string, offset, length, encoding) + // and the legacy (string, encoding, offset, length) + if (isFinite(offset)) { + if (!isFinite(length)) { + encoding = length + length = undefined + } + } else { // legacy + var swap = encoding + encoding = offset + offset = length + length = swap + } - return quote + str + quote; + offset = Number(offset) || 0 + var remaining = this.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining } + } + encoding = String(encoding || 'utf8').toLowerCase() - function escapeString(str) { - var result = '', i, len, code, singleQuotes = 0, doubleQuotes = 0, single, quote; + var ret + switch (encoding) { + case 'hex': + ret = _hexWrite(this, string, offset, length) + break + case 'utf8': + case 'utf-8': + ret = _utf8Write(this, string, offset, length) + break + case 'ascii': + ret = _asciiWrite(this, string, offset, length) + break + case 'binary': + ret = _binaryWrite(this, string, offset, length) + break + case 'base64': + ret = _base64Write(this, string, offset, length) + break + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + ret = _utf16leWrite(this, string, offset, length) + break + default: + throw new Error('Unknown encoding') + } + return ret +} - for (i = 0, len = str.length; i < len; ++i) { - code = str.charCodeAt(i); - if (code === 0x27 /* ' */) { - ++singleQuotes; - } else if (code === 0x22 /* " */) { - ++doubleQuotes; - } else if (code === 0x2F /* / */ && json) { - result += '\\'; - } else if (esutils.code.isLineTerminator(code) || code === 0x5C /* \ */) { - result += escapeDisallowedCharacter(code); - continue; - } else if ((json && code < 0x20 /* SP */) || !(json || escapeless || (code >= 0x20 /* SP */ && code <= 0x7E /* ~ */))) { - result += escapeAllowedCharacter(code, str.charCodeAt(i + 1)); - continue; - } - result += String.fromCharCode(code); - } +Buffer.prototype.toString = function (encoding, start, end) { + var self = this - single = !(quotes === 'double' || (quotes === 'auto' && doubleQuotes < singleQuotes)); - quote = single ? '\'' : '"'; + encoding = String(encoding || 'utf8').toLowerCase() + start = Number(start) || 0 + end = (end !== undefined) + ? Number(end) + : end = self.length - if (!(single ? singleQuotes : doubleQuotes)) { - return quote + result + quote; - } + // Fastpath empty strings + if (end === start) + return '' - str = result; - result = quote; + var ret + switch (encoding) { + case 'hex': + ret = _hexSlice(self, start, end) + break + case 'utf8': + case 'utf-8': + ret = _utf8Slice(self, start, end) + break + case 'ascii': + ret = _asciiSlice(self, start, end) + break + case 'binary': + ret = _binarySlice(self, start, end) + break + case 'base64': + ret = _base64Slice(self, start, end) + break + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + ret = _utf16leSlice(self, start, end) + break + default: + throw new Error('Unknown encoding') + } + return ret +} - for (i = 0, len = str.length; i < len; ++i) { - code = str.charCodeAt(i); - if ((code === 0x27 /* ' */ && single) || (code === 0x22 /* " */ && !single)) { - result += '\\'; - } - result += String.fromCharCode(code); - } +Buffer.prototype.toJSON = function () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} - return result + quote; - } +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function (target, target_start, start, end) { + var source = this - /** - * flatten an array to a string, where the array can contain - * either strings or nested arrays - */ - function flattenToString(arr) { - var i, iz, elem, result = ''; - for (i = 0, iz = arr.length; i < iz; ++i) { - elem = arr[i]; - result += isArray(elem) ? flattenToString(elem) : elem; - } - return result; - } + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (!target_start) target_start = 0 - /** - * convert generated to a SourceNode when source maps are enabled. - */ - function toSourceNodeWhenNeeded(generated, node) { - if (!sourceMap) { - // with no source maps, generated is either an - // array or a string. if an array, flatten it. - // if a string, just return it - if (isArray(generated)) { - return flattenToString(generated); - } else { - return generated; - } - } - if (node == null) { - if (generated instanceof SourceNode) { - return generated; - } else { - node = {}; - } - } - if (node.loc == null) { - return new SourceNode(null, null, sourceMap, generated, node.name || null); - } - return new SourceNode(node.loc.start.line, node.loc.start.column, (sourceMap === true ? node.loc.source || null : sourceMap), generated, node.name || null); - } + // Copy 0 bytes; we're done + if (end === start) return + if (target.length === 0 || source.length === 0) return - function noEmptySpace() { - return (space) ? space : ' '; - } + // Fatal error conditions + assert(end >= start, 'sourceEnd < sourceStart') + assert(target_start >= 0 && target_start < target.length, + 'targetStart out of bounds') + assert(start >= 0 && start < source.length, 'sourceStart out of bounds') + assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds') - function join(left, right) { - var leftSource, - rightSource, - leftCharCode, - rightCharCode; + // Are we oob? + if (end > this.length) + end = this.length + if (target.length - target_start < end - start) + end = target.length - target_start + start - leftSource = toSourceNodeWhenNeeded(left).toString(); - if (leftSource.length === 0) { - return [right]; - } + var len = end - start - rightSource = toSourceNodeWhenNeeded(right).toString(); - if (rightSource.length === 0) { - return [left]; - } + if (len < 100 || !Buffer._useTypedArrays) { + for (var i = 0; i < len; i++) + target[i + target_start] = this[i + start] + } else { + target._set(this.subarray(start, start + len), target_start) + } +} - leftCharCode = leftSource.charCodeAt(leftSource.length - 1); - rightCharCode = rightSource.charCodeAt(0); +function _base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} - if ((leftCharCode === 0x2B /* + */ || leftCharCode === 0x2D /* - */) && leftCharCode === rightCharCode || - esutils.code.isIdentifierPart(leftCharCode) && esutils.code.isIdentifierPart(rightCharCode) || - leftCharCode === 0x2F /* / */ && rightCharCode === 0x69 /* i */) { // infix word operators all start with `i` - return [left, noEmptySpace(), right]; - } else if (esutils.code.isWhiteSpace(leftCharCode) || esutils.code.isLineTerminator(leftCharCode) || - esutils.code.isWhiteSpace(rightCharCode) || esutils.code.isLineTerminator(rightCharCode)) { - return [left, right]; - } - return [left, space, right]; +function _utf8Slice (buf, start, end) { + var res = '' + var tmp = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + if (buf[i] <= 0x7F) { + res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) + tmp = '' + } else { + tmp += '%' + buf[i].toString(16) } + } - function addIndent(stmt) { - return [base, stmt]; - } - - function withIndent(fn) { - var previousBase; - previousBase = base; - base += indent; - fn(base); - base = previousBase; - } + return res + decodeUtf8Char(tmp) +} - function calculateSpaces(str) { - var i; - for (i = str.length - 1; i >= 0; --i) { - if (esutils.code.isLineTerminator(str.charCodeAt(i))) { - break; - } - } - return (str.length - 1) - i; - } +function _asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) - function adjustMultilineComment(value, specialBase) { - var array, i, len, line, j, spaces, previousBase, sn; + for (var i = start; i < end; i++) + ret += String.fromCharCode(buf[i]) + return ret +} - array = value.split(/\r\n|[\r\n]/); - spaces = Number.MAX_VALUE; +function _binarySlice (buf, start, end) { + return _asciiSlice(buf, start, end) +} - // first line doesn't have indentation - for (i = 1, len = array.length; i < len; ++i) { - line = array[i]; - j = 0; - while (j < line.length && esutils.code.isWhiteSpace(line.charCodeAt(j))) { - ++j; - } - if (spaces > j) { - spaces = j; - } - } +function _hexSlice (buf, start, end) { + var len = buf.length - if (typeof specialBase !== 'undefined') { - // pattern like - // { - // var t = 20; /* - // * this is comment - // */ - // } - previousBase = base; - if (array[1][spaces] === '*') { - specialBase += ' '; - } - base = specialBase; - } else { - if (spaces & 1) { - // /* - // * - // */ - // If spaces are odd number, above pattern is considered. - // We waste 1 space. - --spaces; - } - previousBase = base; - } + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len - for (i = 1, len = array.length; i < len; ++i) { - sn = toSourceNodeWhenNeeded(addIndent(array[i].slice(spaces))); - array[i] = sourceMap ? sn.join('') : sn; - } + var out = '' + for (var i = start; i < end; i++) { + out += toHex(buf[i]) + } + return out +} - base = previousBase; +function _utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i+1] * 256) + } + return res +} - return array.join('\n'); - } +Buffer.prototype.slice = function (start, end) { + var len = this.length + start = clamp(start, len, 0) + end = clamp(end, len, len) - function generateComment(comment, specialBase) { - if (comment.type === 'Line') { - if (endsWithLineTerminator(comment.value)) { - return '//' + comment.value; - } else { - // Always use LineTerminator - var result = '//' + comment.value; - if (!preserveBlankLines) { - result += '\n'; - } - return result; - } - } - if (extra.format.indent.adjustMultilineComment && /[\n\r]/.test(comment.value)) { - return adjustMultilineComment('/*' + comment.value + '*/', specialBase); - } - return '/*' + comment.value + '*/'; + if (Buffer._useTypedArrays) { + return Buffer._augment(this.subarray(start, end)) + } else { + var sliceLen = end - start + var newBuf = new Buffer(sliceLen, undefined, true) + for (var i = 0; i < sliceLen; i++) { + newBuf[i] = this[i + start] } + return newBuf + } +} - function addComments(stmt, result) { - var i, len, comment, save, tailingToStatement, specialBase, fragment, - extRange, range, prevRange, prefix, infix, suffix, count; +// `get` will be removed in Node 0.13+ +Buffer.prototype.get = function (offset) { + console.log('.get() is deprecated. Access using array indexes instead.') + return this.readUInt8(offset) +} - if (stmt.leadingComments && stmt.leadingComments.length > 0) { - save = result; +// `set` will be removed in Node 0.13+ +Buffer.prototype.set = function (v, offset) { + console.log('.set() is deprecated. Access using array indexes instead.') + return this.writeUInt8(v, offset) +} - if (preserveBlankLines) { - comment = stmt.leadingComments[0]; - result = []; +Buffer.prototype.readUInt8 = function (offset, noAssert) { + if (!noAssert) { + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset < this.length, 'Trying to read beyond buffer length') + } - extRange = comment.extendedRange; - range = comment.range; + if (offset >= this.length) + return - prefix = sourceCode.substring(extRange[0], range[0]); - count = (prefix.match(/\n/g) || []).length; - if (count > 0) { - result.push(stringRepeat('\n', count)); - result.push(addIndent(generateComment(comment))); - } else { - result.push(prefix); - result.push(generateComment(comment)); - } + return this[offset] +} - prevRange = range; +function _readUInt16 (buf, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') + } - for (i = 1, len = stmt.leadingComments.length; i < len; i++) { - comment = stmt.leadingComments[i]; - range = comment.range; + var len = buf.length + if (offset >= len) + return - infix = sourceCode.substring(prevRange[1], range[0]); - count = (infix.match(/\n/g) || []).length; - result.push(stringRepeat('\n', count)); - result.push(addIndent(generateComment(comment))); + var val + if (littleEndian) { + val = buf[offset] + if (offset + 1 < len) + val |= buf[offset + 1] << 8 + } else { + val = buf[offset] << 8 + if (offset + 1 < len) + val |= buf[offset + 1] + } + return val +} - prevRange = range; - } +Buffer.prototype.readUInt16LE = function (offset, noAssert) { + return _readUInt16(this, offset, true, noAssert) +} - suffix = sourceCode.substring(range[1], extRange[1]); - count = (suffix.match(/\n/g) || []).length; - result.push(stringRepeat('\n', count)); - } else { - comment = stmt.leadingComments[0]; - result = []; - if (safeConcatenation && stmt.type === Syntax.Program && stmt.body.length === 0) { - result.push('\n'); - } - result.push(generateComment(comment)); - if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { - result.push('\n'); - } +Buffer.prototype.readUInt16BE = function (offset, noAssert) { + return _readUInt16(this, offset, false, noAssert) +} - for (i = 1, len = stmt.leadingComments.length; i < len; ++i) { - comment = stmt.leadingComments[i]; - fragment = [generateComment(comment)]; - if (!endsWithLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { - fragment.push('\n'); - } - result.push(addIndent(fragment)); - } - } +function _readUInt32 (buf, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') + } - result.push(addIndent(save)); - } + var len = buf.length + if (offset >= len) + return - if (stmt.trailingComments) { + var val + if (littleEndian) { + if (offset + 2 < len) + val = buf[offset + 2] << 16 + if (offset + 1 < len) + val |= buf[offset + 1] << 8 + val |= buf[offset] + if (offset + 3 < len) + val = val + (buf[offset + 3] << 24 >>> 0) + } else { + if (offset + 1 < len) + val = buf[offset + 1] << 16 + if (offset + 2 < len) + val |= buf[offset + 2] << 8 + if (offset + 3 < len) + val |= buf[offset + 3] + val = val + (buf[offset] << 24 >>> 0) + } + return val +} - if (preserveBlankLines) { - comment = stmt.trailingComments[0]; - extRange = comment.extendedRange; - range = comment.range; +Buffer.prototype.readUInt32LE = function (offset, noAssert) { + return _readUInt32(this, offset, true, noAssert) +} - prefix = sourceCode.substring(extRange[0], range[0]); - count = (prefix.match(/\n/g) || []).length; +Buffer.prototype.readUInt32BE = function (offset, noAssert) { + return _readUInt32(this, offset, false, noAssert) +} - if (count > 0) { - result.push(stringRepeat('\n', count)); - result.push(addIndent(generateComment(comment))); - } else { - result.push(prefix); - result.push(generateComment(comment)); - } - } else { - tailingToStatement = !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString()); - specialBase = stringRepeat(' ', calculateSpaces(toSourceNodeWhenNeeded([base, result, indent]).toString())); - for (i = 0, len = stmt.trailingComments.length; i < len; ++i) { - comment = stmt.trailingComments[i]; - if (tailingToStatement) { - // We assume target like following script - // - // var t = 20; /** - // * This is comment of t - // */ - if (i === 0) { - // first case - result = [result, indent]; - } else { - result = [result, specialBase]; - } - result.push(generateComment(comment, specialBase)); - } else { - result = [result, addIndent(generateComment(comment))]; - } - if (i !== len - 1 && !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { - result = [result, '\n']; - } - } - } - } +Buffer.prototype.readInt8 = function (offset, noAssert) { + if (!noAssert) { + assert(offset !== undefined && offset !== null, + 'missing offset') + assert(offset < this.length, 'Trying to read beyond buffer length') + } - return result; - } + if (offset >= this.length) + return - function generateBlankLines(start, end, result) { - var j, newlineCount = 0; + var neg = this[offset] & 0x80 + if (neg) + return (0xff - this[offset] + 1) * -1 + else + return this[offset] +} - for (j = start; j < end; j++) { - if (sourceCode[j] === '\n') { - newlineCount++; - } - } +function _readInt16 (buf, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') + } - for (j = 1; j < newlineCount; j++) { - result.push(newline); - } - } + var len = buf.length + if (offset >= len) + return - function parenthesize(text, current, should) { - if (current < should) { - return ['(', text, ')']; - } - return text; - } + var val = _readUInt16(buf, offset, littleEndian, true) + var neg = val & 0x8000 + if (neg) + return (0xffff - val + 1) * -1 + else + return val +} - function generateVerbatimString(string) { - var i, iz, result; - result = string.split(/\r\n|\n/); - for (i = 1, iz = result.length; i < iz; i++) { - result[i] = newline + base + result[i]; - } - return result; - } +Buffer.prototype.readInt16LE = function (offset, noAssert) { + return _readInt16(this, offset, true, noAssert) +} - function generateVerbatim(expr, precedence) { - var verbatim, result, prec; - verbatim = expr[extra.verbatim]; +Buffer.prototype.readInt16BE = function (offset, noAssert) { + return _readInt16(this, offset, false, noAssert) +} - if (typeof verbatim === 'string') { - result = parenthesize(generateVerbatimString(verbatim), Precedence.Sequence, precedence); - } else { - // verbatim is object - result = generateVerbatimString(verbatim.content); - prec = (verbatim.precedence != null) ? verbatim.precedence : Precedence.Sequence; - result = parenthesize(result, prec, precedence); - } +function _readInt32 (buf, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') + } - return toSourceNodeWhenNeeded(result, expr); - } + var len = buf.length + if (offset >= len) + return - function CodeGenerator() { - } + var val = _readUInt32(buf, offset, littleEndian, true) + var neg = val & 0x80000000 + if (neg) + return (0xffffffff - val + 1) * -1 + else + return val +} - // Helpers. +Buffer.prototype.readInt32LE = function (offset, noAssert) { + return _readInt32(this, offset, true, noAssert) +} - CodeGenerator.prototype.maybeBlock = function(stmt, flags) { - var result, noLeadingComment, that = this; +Buffer.prototype.readInt32BE = function (offset, noAssert) { + return _readInt32(this, offset, false, noAssert) +} - noLeadingComment = !extra.comment || !stmt.leadingComments; +function _readFloat (buf, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') + } - if (stmt.type === Syntax.BlockStatement && noLeadingComment) { - return [space, this.generateStatement(stmt, flags)]; - } + return ieee754.read(buf, offset, littleEndian, 23, 4) +} - if (stmt.type === Syntax.EmptyStatement && noLeadingComment) { - return ';'; - } +Buffer.prototype.readFloatLE = function (offset, noAssert) { + return _readFloat(this, offset, true, noAssert) +} - withIndent(function () { - result = [ - newline, - addIndent(that.generateStatement(stmt, flags)) - ]; - }); +Buffer.prototype.readFloatBE = function (offset, noAssert) { + return _readFloat(this, offset, false, noAssert) +} - return result; - }; +function _readDouble (buf, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset + 7 < buf.length, 'Trying to read beyond buffer length') + } - CodeGenerator.prototype.maybeBlockSuffix = function (stmt, result) { - var ends = endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString()); - if (stmt.type === Syntax.BlockStatement && (!extra.comment || !stmt.leadingComments) && !ends) { - return [result, space]; - } - if (ends) { - return [result, base]; - } - return [result, newline, base]; - }; + return ieee754.read(buf, offset, littleEndian, 52, 8) +} - function generateIdentifier(node) { - return toSourceNodeWhenNeeded(node.name, node); - } +Buffer.prototype.readDoubleLE = function (offset, noAssert) { + return _readDouble(this, offset, true, noAssert) +} - function generateAsyncPrefix(node, spaceRequired) { - return node.async ? 'async' + (spaceRequired ? noEmptySpace() : space) : ''; - } +Buffer.prototype.readDoubleBE = function (offset, noAssert) { + return _readDouble(this, offset, false, noAssert) +} - function generateStarSuffix(node) { - var isGenerator = node.generator && !extra.moz.starlessGenerator; - return isGenerator ? '*' + space : ''; - } +Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { + if (!noAssert) { + assert(value !== undefined && value !== null, 'missing value') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset < this.length, 'trying to write beyond buffer length') + verifuint(value, 0xff) + } - function generateMethodPrefix(prop) { - var func = prop.value; - if (func.async) { - return generateAsyncPrefix(func, !prop.computed); - } else { - // avoid space before method name - return generateStarSuffix(func) ? '*' : ''; - } - } + if (offset >= this.length) return - CodeGenerator.prototype.generatePattern = function (node, precedence, flags) { - if (node.type === Syntax.Identifier) { - return generateIdentifier(node); - } - return this.generateExpression(node, precedence, flags); - }; + this[offset] = value +} - CodeGenerator.prototype.generateFunctionParams = function (node) { - var i, iz, result, hasDefault; +function _writeUInt16 (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(value !== undefined && value !== null, 'missing value') + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset + 1 < buf.length, 'trying to write beyond buffer length') + verifuint(value, 0xffff) + } - hasDefault = false; + var len = buf.length + if (offset >= len) + return - if (node.type === Syntax.ArrowFunctionExpression && - !node.rest && (!node.defaults || node.defaults.length === 0) && - node.params.length === 1 && node.params[0].type === Syntax.Identifier) { - // arg => { } case - result = [generateAsyncPrefix(node, true), generateIdentifier(node.params[0])]; - } else { - result = node.type === Syntax.ArrowFunctionExpression ? [generateAsyncPrefix(node, false)] : []; - result.push('('); - if (node.defaults) { - hasDefault = true; - } - for (i = 0, iz = node.params.length; i < iz; ++i) { - if (hasDefault && node.defaults[i]) { - // Handle default values. - result.push(this.generateAssignment(node.params[i], node.defaults[i], '=', Precedence.Assignment, E_TTT)); - } else { - result.push(this.generatePattern(node.params[i], Precedence.Assignment, E_TTT)); - } - if (i + 1 < iz) { - result.push(',' + space); - } - } + for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) { + buf[offset + i] = + (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } +} - if (node.rest) { - if (node.params.length) { - result.push(',' + space); - } - result.push('...'); - result.push(generateIdentifier(node.rest)); - } +Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) { + _writeUInt16(this, value, offset, true, noAssert) +} - result.push(')'); - } +Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) { + _writeUInt16(this, value, offset, false, noAssert) +} - return result; - }; +function _writeUInt32 (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(value !== undefined && value !== null, 'missing value') + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset + 3 < buf.length, 'trying to write beyond buffer length') + verifuint(value, 0xffffffff) + } - CodeGenerator.prototype.generateFunctionBody = function (node) { - var result, expr; + var len = buf.length + if (offset >= len) + return - result = this.generateFunctionParams(node); + for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) { + buf[offset + i] = + (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } +} - if (node.type === Syntax.ArrowFunctionExpression) { - result.push(space); - result.push('=>'); - } +Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) { + _writeUInt32(this, value, offset, true, noAssert) +} - if (node.expression) { - result.push(space); - expr = this.generateExpression(node.body, Precedence.Assignment, E_TTT); - if (expr.toString().charAt(0) === '{') { - expr = ['(', expr, ')']; - } - result.push(expr); - } else { - result.push(this.maybeBlock(node.body, S_TTFF)); - } +Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) { + _writeUInt32(this, value, offset, false, noAssert) +} - return result; - }; +Buffer.prototype.writeInt8 = function (value, offset, noAssert) { + if (!noAssert) { + assert(value !== undefined && value !== null, 'missing value') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset < this.length, 'Trying to write beyond buffer length') + verifsint(value, 0x7f, -0x80) + } - CodeGenerator.prototype.generateIterationForStatement = function (operator, stmt, flags) { - var result = ['for' + space + '('], that = this; - withIndent(function () { - if (stmt.left.type === Syntax.VariableDeclaration) { - withIndent(function () { - result.push(stmt.left.kind + noEmptySpace()); - result.push(that.generateStatement(stmt.left.declarations[0], S_FFFF)); - }); - } else { - result.push(that.generateExpression(stmt.left, Precedence.Call, E_TTT)); - } + if (offset >= this.length) + return - result = join(result, operator); - result = [join( - result, - that.generateExpression(stmt.right, Precedence.Sequence, E_TTT) - ), ')']; - }); - result.push(this.maybeBlock(stmt.body, flags)); - return result; - }; + if (value >= 0) + this.writeUInt8(value, offset, noAssert) + else + this.writeUInt8(0xff + value + 1, offset, noAssert) +} - CodeGenerator.prototype.generatePropertyKey = function (expr, computed) { - var result = []; +function _writeInt16 (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(value !== undefined && value !== null, 'missing value') + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset + 1 < buf.length, 'Trying to write beyond buffer length') + verifsint(value, 0x7fff, -0x8000) + } - if (computed) { - result.push('['); - } + var len = buf.length + if (offset >= len) + return - result.push(this.generateExpression(expr, Precedence.Sequence, E_TTT)); - if (computed) { - result.push(']'); - } + if (value >= 0) + _writeUInt16(buf, value, offset, littleEndian, noAssert) + else + _writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert) +} - return result; - }; +Buffer.prototype.writeInt16LE = function (value, offset, noAssert) { + _writeInt16(this, value, offset, true, noAssert) +} - CodeGenerator.prototype.generateAssignment = function (left, right, operator, precedence, flags) { - if (Precedence.Assignment < precedence) { - flags |= F_ALLOW_IN; - } +Buffer.prototype.writeInt16BE = function (value, offset, noAssert) { + _writeInt16(this, value, offset, false, noAssert) +} - return parenthesize( - [ - this.generateExpression(left, Precedence.Call, flags), - space + operator + space, - this.generateExpression(right, Precedence.Assignment, flags) - ], - Precedence.Assignment, - precedence - ); - }; +function _writeInt32 (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(value !== undefined && value !== null, 'missing value') + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') + verifsint(value, 0x7fffffff, -0x80000000) + } - CodeGenerator.prototype.semicolon = function (flags) { - if (!semicolons && flags & F_SEMICOLON_OPT) { - return ''; - } - return ';'; - }; + var len = buf.length + if (offset >= len) + return - // Statements. + if (value >= 0) + _writeUInt32(buf, value, offset, littleEndian, noAssert) + else + _writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert) +} - CodeGenerator.Statement = { +Buffer.prototype.writeInt32LE = function (value, offset, noAssert) { + _writeInt32(this, value, offset, true, noAssert) +} - BlockStatement: function (stmt, flags) { - var range, content, result = ['{', newline], that = this; +Buffer.prototype.writeInt32BE = function (value, offset, noAssert) { + _writeInt32(this, value, offset, false, noAssert) +} - withIndent(function () { - // handle functions without any code - if (stmt.body.length === 0 && preserveBlankLines) { - range = stmt.range; - if (range[1] - range[0] > 2) { - content = sourceCode.substring(range[0] + 1, range[1] - 1); - if (content[0] === '\n') { - result = ['{']; - } - result.push(content); - } - } +function _writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(value !== undefined && value !== null, 'missing value') + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') + verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38) + } - var i, iz, fragment, bodyFlags; - bodyFlags = S_TFFF; - if (flags & F_FUNC_BODY) { - bodyFlags |= F_DIRECTIVE_CTX; - } + var len = buf.length + if (offset >= len) + return - for (i = 0, iz = stmt.body.length; i < iz; ++i) { - if (preserveBlankLines) { - // handle spaces before the first line - if (i === 0) { - if (stmt.body[0].leadingComments) { - range = stmt.body[0].leadingComments[0].extendedRange; - content = sourceCode.substring(range[0], range[1]); - if (content[0] === '\n') { - result = ['{']; - } - } - if (!stmt.body[0].leadingComments) { - generateBlankLines(stmt.range[0], stmt.body[0].range[0], result); - } - } + ieee754.write(buf, value, offset, littleEndian, 23, 4) +} - // handle spaces between lines - if (i > 0) { - if (!stmt.body[i - 1].trailingComments && !stmt.body[i].leadingComments) { - generateBlankLines(stmt.body[i - 1].range[1], stmt.body[i].range[0], result); - } - } - } +Buffer.prototype.writeFloatLE = function (value, offset, noAssert) { + _writeFloat(this, value, offset, true, noAssert) +} - if (i === iz - 1) { - bodyFlags |= F_SEMICOLON_OPT; - } +Buffer.prototype.writeFloatBE = function (value, offset, noAssert) { + _writeFloat(this, value, offset, false, noAssert) +} - if (stmt.body[i].leadingComments && preserveBlankLines) { - fragment = that.generateStatement(stmt.body[i], bodyFlags); - } else { - fragment = addIndent(that.generateStatement(stmt.body[i], bodyFlags)); - } +function _writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + assert(value !== undefined && value !== null, 'missing value') + assert(typeof littleEndian === 'boolean', 'missing or invalid endian') + assert(offset !== undefined && offset !== null, 'missing offset') + assert(offset + 7 < buf.length, + 'Trying to write beyond buffer length') + verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308) + } - result.push(fragment); - if (!endsWithLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { - if (preserveBlankLines && i < iz - 1) { - // don't add a new line if there are leading coments - // in the next statement - if (!stmt.body[i + 1].leadingComments) { - result.push(newline); - } - } else { - result.push(newline); - } - } + var len = buf.length + if (offset >= len) + return - if (preserveBlankLines) { - // handle spaces after the last line - if (i === iz - 1) { - if (!stmt.body[i].trailingComments) { - generateBlankLines(stmt.body[i].range[1], stmt.range[1], result); - } - } - } - } - }); + ieee754.write(buf, value, offset, littleEndian, 52, 8) +} - result.push(addIndent('}')); - return result; - }, +Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) { + _writeDouble(this, value, offset, true, noAssert) +} - BreakStatement: function (stmt, flags) { - if (stmt.label) { - return 'break ' + stmt.label.name + this.semicolon(flags); - } - return 'break' + this.semicolon(flags); - }, +Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) { + _writeDouble(this, value, offset, false, noAssert) +} - ContinueStatement: function (stmt, flags) { - if (stmt.label) { - return 'continue ' + stmt.label.name + this.semicolon(flags); - } - return 'continue' + this.semicolon(flags); - }, +// fill(value, start=0, end=buffer.length) +Buffer.prototype.fill = function (value, start, end) { + if (!value) value = 0 + if (!start) start = 0 + if (!end) end = this.length - ClassBody: function (stmt, flags) { - var result = [ '{', newline], that = this; + if (typeof value === 'string') { + value = value.charCodeAt(0) + } - withIndent(function (indent) { - var i, iz; + assert(typeof value === 'number' && !isNaN(value), 'value is not a number') + assert(end >= start, 'end < start') - for (i = 0, iz = stmt.body.length; i < iz; ++i) { - result.push(indent); - result.push(that.generateExpression(stmt.body[i], Precedence.Sequence, E_TTT)); - if (i + 1 < iz) { - result.push(newline); - } - } - }); + // Fill 0 bytes; we're done + if (end === start) return + if (this.length === 0) return - if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { - result.push(newline); - } - result.push(base); - result.push('}'); - return result; - }, + assert(start >= 0 && start < this.length, 'start out of bounds') + assert(end >= 0 && end <= this.length, 'end out of bounds') - ClassDeclaration: function (stmt, flags) { - var result, fragment; - result = ['class ' + stmt.id.name]; - if (stmt.superClass) { - fragment = join('extends', this.generateExpression(stmt.superClass, Precedence.Assignment, E_TTT)); - result = join(result, fragment); - } - result.push(space); - result.push(this.generateStatement(stmt.body, S_TFFT)); - return result; - }, + for (var i = start; i < end; i++) { + this[i] = value + } +} - DirectiveStatement: function (stmt, flags) { - if (extra.raw && stmt.raw) { - return stmt.raw + this.semicolon(flags); - } - return escapeDirective(stmt.directive) + this.semicolon(flags); - }, +Buffer.prototype.inspect = function () { + var out = [] + var len = this.length + for (var i = 0; i < len; i++) { + out[i] = toHex(this[i]) + if (i === exports.INSPECT_MAX_BYTES) { + out[i + 1] = '...' + break + } + } + return '' +} - DoWhileStatement: function (stmt, flags) { - // Because `do 42 while (cond)` is Syntax Error. We need semicolon. - var result = join('do', this.maybeBlock(stmt.body, S_TFFF)); - result = this.maybeBlockSuffix(stmt.body, result); - return join(result, [ - 'while' + space + '(', - this.generateExpression(stmt.test, Precedence.Sequence, E_TTT), - ')' + this.semicolon(flags) - ]); - }, +/** + * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. + * Added in Node 0.12. Only available in browsers that support ArrayBuffer. + */ +Buffer.prototype.toArrayBuffer = function () { + if (typeof Uint8Array !== 'undefined') { + if (Buffer._useTypedArrays) { + return (new Buffer(this)).buffer + } else { + var buf = new Uint8Array(this.length) + for (var i = 0, len = buf.length; i < len; i += 1) + buf[i] = this[i] + return buf.buffer + } + } else { + throw new Error('Buffer.toArrayBuffer not supported in this browser') + } +} - CatchClause: function (stmt, flags) { - var result, that = this; - withIndent(function () { - var guard; +// HELPER FUNCTIONS +// ================ - result = [ - 'catch' + space + '(', - that.generateExpression(stmt.param, Precedence.Sequence, E_TTT), - ')' - ]; +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} - if (stmt.guard) { - guard = that.generateExpression(stmt.guard, Precedence.Sequence, E_TTT); - result.splice(2, 0, ' if ', guard); - } - }); - result.push(this.maybeBlock(stmt.body, S_TFFF)); - return result; - }, +var BP = Buffer.prototype - DebuggerStatement: function (stmt, flags) { - return 'debugger' + this.semicolon(flags); - }, +/** + * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods + */ +Buffer._augment = function (arr) { + arr._isBuffer = true - EmptyStatement: function (stmt, flags) { - return ';'; - }, + // save reference to original Uint8Array get/set methods before overwriting + arr._get = arr.get + arr._set = arr.set - ExportDeclaration: function (stmt, flags) { - var result = [ 'export' ], bodyFlags, that = this; + // deprecated, will be removed in node 0.13+ + arr.get = BP.get + arr.set = BP.set - bodyFlags = (flags & F_SEMICOLON_OPT) ? S_TFFT : S_TFFF; + arr.write = BP.write + arr.toString = BP.toString + arr.toLocaleString = BP.toString + arr.toJSON = BP.toJSON + arr.copy = BP.copy + arr.slice = BP.slice + arr.readUInt8 = BP.readUInt8 + arr.readUInt16LE = BP.readUInt16LE + arr.readUInt16BE = BP.readUInt16BE + arr.readUInt32LE = BP.readUInt32LE + arr.readUInt32BE = BP.readUInt32BE + arr.readInt8 = BP.readInt8 + arr.readInt16LE = BP.readInt16LE + arr.readInt16BE = BP.readInt16BE + arr.readInt32LE = BP.readInt32LE + arr.readInt32BE = BP.readInt32BE + arr.readFloatLE = BP.readFloatLE + arr.readFloatBE = BP.readFloatBE + arr.readDoubleLE = BP.readDoubleLE + arr.readDoubleBE = BP.readDoubleBE + arr.writeUInt8 = BP.writeUInt8 + arr.writeUInt16LE = BP.writeUInt16LE + arr.writeUInt16BE = BP.writeUInt16BE + arr.writeUInt32LE = BP.writeUInt32LE + arr.writeUInt32BE = BP.writeUInt32BE + arr.writeInt8 = BP.writeInt8 + arr.writeInt16LE = BP.writeInt16LE + arr.writeInt16BE = BP.writeInt16BE + arr.writeInt32LE = BP.writeInt32LE + arr.writeInt32BE = BP.writeInt32BE + arr.writeFloatLE = BP.writeFloatLE + arr.writeFloatBE = BP.writeFloatBE + arr.writeDoubleLE = BP.writeDoubleLE + arr.writeDoubleBE = BP.writeDoubleBE + arr.fill = BP.fill + arr.inspect = BP.inspect + arr.toArrayBuffer = BP.toArrayBuffer - // export default HoistableDeclaration[Default] - // export default AssignmentExpression[In] ; - if (stmt['default']) { - result = join(result, 'default'); - if (isStatement(stmt.declaration)) { - result = join(result, this.generateStatement(stmt.declaration, bodyFlags)); - } else { - result = join(result, this.generateExpression(stmt.declaration, Precedence.Assignment, E_TTT) + this.semicolon(flags)); - } - return result; - } + return arr +} - // export VariableStatement - // export Declaration[Default] - if (stmt.declaration) { - return join(result, this.generateStatement(stmt.declaration, bodyFlags)); - } +// slice(start, end) +function clamp (index, len, defaultValue) { + if (typeof index !== 'number') return defaultValue + index = ~~index; // Coerce to integer. + if (index >= len) return len + if (index >= 0) return index + index += len + if (index >= 0) return index + return 0 +} - // export * FromClause ; - // export ExportClause[NoReference] FromClause ; - // export ExportClause ; - if (stmt.specifiers) { - if (stmt.specifiers.length === 0) { - result = join(result, '{' + space + '}'); - } else if (stmt.specifiers[0].type === Syntax.ExportBatchSpecifier) { - result = join(result, this.generateExpression(stmt.specifiers[0], Precedence.Sequence, E_TTT)); - } else { - result = join(result, '{'); - withIndent(function (indent) { - var i, iz; - result.push(newline); - for (i = 0, iz = stmt.specifiers.length; i < iz; ++i) { - result.push(indent); - result.push(that.generateExpression(stmt.specifiers[i], Precedence.Sequence, E_TTT)); - if (i + 1 < iz) { - result.push(',' + newline); - } - } - }); - if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { - result.push(newline); - } - result.push(base + '}'); - } +function coerce (length) { + // Coerce length to a number (possibly NaN), round up + // in case it's fractional (e.g. 123.456) then do a + // double negate to coerce a NaN to 0. Easy, right? + length = ~~Math.ceil(+length) + return length < 0 ? 0 : length +} - if (stmt.source) { - result = join(result, [ - 'from' + space, - // ModuleSpecifier - this.generateExpression(stmt.source, Precedence.Sequence, E_TTT), - this.semicolon(flags) - ]); - } else { - result.push(this.semicolon(flags)); - } - } - return result; - }, +function isArray (subject) { + return (Array.isArray || function (subject) { + return Object.prototype.toString.call(subject) === '[object Array]' + })(subject) +} - ExpressionStatement: function (stmt, flags) { - var result, fragment; +function isArrayish (subject) { + return isArray(subject) || Buffer.isBuffer(subject) || + subject && typeof subject === 'object' && + typeof subject.length === 'number' +} - function isClassPrefixed(fragment) { - var code; - if (fragment.slice(0, 5) !== 'class') { - return false; - } - code = fragment.charCodeAt(5); - return code === 0x7B /* '{' */ || esutils.code.isWhiteSpace(code) || esutils.code.isLineTerminator(code); - } +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} - function isFunctionPrefixed(fragment) { - var code; - if (fragment.slice(0, 8) !== 'function') { - return false; - } - code = fragment.charCodeAt(8); - return code === 0x28 /* '(' */ || esutils.code.isWhiteSpace(code) || code === 0x2A /* '*' */ || esutils.code.isLineTerminator(code); - } +function utf8ToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; i++) { + var b = str.charCodeAt(i) + if (b <= 0x7F) + byteArray.push(str.charCodeAt(i)) + else { + var start = i + if (b >= 0xD800 && b <= 0xDFFF) i++ + var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%') + for (var j = 0; j < h.length; j++) + byteArray.push(parseInt(h[j], 16)) + } + } + return byteArray +} - function isAsyncPrefixed(fragment) { - var code, i, iz; - if (fragment.slice(0, 5) !== 'async') { - return false; - } - if (!esutils.code.isWhiteSpace(fragment.charCodeAt(5))) { - return false; - } - for (i = 6, iz = fragment.length; i < iz; ++i) { - if (!esutils.code.isWhiteSpace(fragment.charCodeAt(i))) { - break; - } - } - if (i === iz) { - return false; - } - if (fragment.slice(i, i + 8) !== 'function') { - return false; - } - code = fragment.charCodeAt(i + 8); - return code === 0x28 /* '(' */ || esutils.code.isWhiteSpace(code) || code === 0x2A /* '*' */ || esutils.code.isLineTerminator(code); - } +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; i++) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} - result = [this.generateExpression(stmt.expression, Precedence.Sequence, E_TTT)]; - // 12.4 '{', 'function', 'class' is not allowed in this position. - // wrap expression with parentheses - fragment = toSourceNodeWhenNeeded(result).toString(); - if (fragment.charCodeAt(0) === 0x7B /* '{' */ || // ObjectExpression - isClassPrefixed(fragment) || - isFunctionPrefixed(fragment) || - isAsyncPrefixed(fragment) || - (directive && (flags & F_DIRECTIVE_CTX) && stmt.expression.type === Syntax.Literal && typeof stmt.expression.value === 'string')) { - result = ['(', result, ')' + this.semicolon(flags)]; - } else { - result.push(this.semicolon(flags)); - } - return result; - }, +function utf16leToBytes (str) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; i++) { + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } - ImportDeclaration: function (stmt, flags) { - // ES6: 15.2.1 valid import declarations: - // - import ImportClause FromClause ; - // - import ModuleSpecifier ; - var result, cursor, that = this; + return byteArray +} - // If no ImportClause is present, - // this should be `import ModuleSpecifier` so skip `from` - // ModuleSpecifier is StringLiteral. - if (stmt.specifiers.length === 0) { - // import ModuleSpecifier ; - return [ - 'import', - space, - // ModuleSpecifier - this.generateExpression(stmt.source, Precedence.Sequence, E_TTT), - this.semicolon(flags) - ]; - } +function base64ToBytes (str) { + return base64.toByteArray(str) +} - // import ImportClause FromClause ; - result = [ - 'import' - ]; - cursor = 0; +function blitBuffer (src, dst, offset, length) { + var pos + for (var i = 0; i < length; i++) { + if ((i + offset >= dst.length) || (i >= src.length)) + break + dst[i + offset] = src[i] + } + return i +} - // ImportedBinding - if (stmt.specifiers[cursor].type === Syntax.ImportDefaultSpecifier) { - result = join(result, [ - this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT) - ]); - ++cursor; - } +function decodeUtf8Char (str) { + try { + return decodeURIComponent(str) + } catch (err) { + return String.fromCharCode(0xFFFD) // UTF 8 invalid char + } +} - if (stmt.specifiers[cursor]) { - if (cursor !== 0) { - result.push(','); - } +/* + * We have to make sure that the value is a valid integer. This means that it + * is non-negative. It has no fractional component and that it does not + * exceed the maximum allowed value. + */ +function verifuint (value, max) { + assert(typeof value === 'number', 'cannot write a non-number as a number') + assert(value >= 0, 'specified a negative value for writing an unsigned value') + assert(value <= max, 'value is larger than maximum value for type') + assert(Math.floor(value) === value, 'value has a fractional component') +} - if (stmt.specifiers[cursor].type === Syntax.ImportNamespaceSpecifier) { - // NameSpaceImport - result = join(result, [ - space, - this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT) - ]); - } else { - // NamedImports - result.push(space + '{'); +function verifsint (value, max, min) { + assert(typeof value === 'number', 'cannot write a non-number as a number') + assert(value <= max, 'value larger than maximum allowed value') + assert(value >= min, 'value smaller than minimum allowed value') + assert(Math.floor(value) === value, 'value has a fractional component') +} - if ((stmt.specifiers.length - cursor) === 1) { - // import { ... } from "..."; - result.push(space); - result.push(this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT)); - result.push(space + '}' + space); - } else { - // import { - // ..., - // ..., - // } from "..."; - withIndent(function (indent) { - var i, iz; - result.push(newline); - for (i = cursor, iz = stmt.specifiers.length; i < iz; ++i) { - result.push(indent); - result.push(that.generateExpression(stmt.specifiers[i], Precedence.Sequence, E_TTT)); - if (i + 1 < iz) { - result.push(',' + newline); - } - } - }); - if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { - result.push(newline); - } - result.push(base + '}' + space); - } - } - } +function verifIEEE754 (value, max, min) { + assert(typeof value === 'number', 'cannot write a non-number as a number') + assert(value <= max, 'value larger than maximum allowed value') + assert(value >= min, 'value smaller than minimum allowed value') +} - result = join(result, [ - 'from' + space, - // ModuleSpecifier - this.generateExpression(stmt.source, Precedence.Sequence, E_TTT), - this.semicolon(flags) - ]); - return result; - }, +function assert (test, message) { + if (!test) throw new Error(message || 'Failed assertion') +} - VariableDeclarator: function (stmt, flags) { - var itemFlags = (flags & F_ALLOW_IN) ? E_TTT : E_FTT; - if (stmt.init) { - return [ - this.generateExpression(stmt.id, Precedence.Assignment, itemFlags), - space, - '=', - space, - this.generateExpression(stmt.init, Precedence.Assignment, itemFlags) - ]; - } - return this.generatePattern(stmt.id, Precedence.Assignment, itemFlags); - }, +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/buffer/index.js","/../node_modules/buffer") +},{"base64-js":2,"buffer":3,"ieee754":27,"pBGvAp":29}],4:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* + Copyright (C) 2012-2014 Yusuke Suzuki + Copyright (C) 2015 Ingvar Stepanyan + Copyright (C) 2014 Ivan Nikulin + Copyright (C) 2012-2013 Michael Ficarra + Copyright (C) 2012-2013 Mathias Bynens + Copyright (C) 2013 Irakli Gozalishvili + Copyright (C) 2012 Robert Gust-Bardon + Copyright (C) 2012 John Freeman + Copyright (C) 2011-2012 Ariya Hidayat + Copyright (C) 2012 Joost-Wim Boekesteijn + Copyright (C) 2012 Kris Kowal + Copyright (C) 2012 Arpad Borsos - VariableDeclaration: function (stmt, flags) { - // VariableDeclarator is typed as Statement, - // but joined with comma (not LineTerminator). - // So if comment is attached to target node, we should specialize. - var result, i, iz, node, bodyFlags, that = this; + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - result = [ stmt.kind ]; + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - bodyFlags = (flags & F_ALLOW_IN) ? S_TFFF : S_FFFF; + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ - function block() { - node = stmt.declarations[0]; - if (extra.comment && node.leadingComments) { - result.push('\n'); - result.push(addIndent(that.generateStatement(node, bodyFlags))); - } else { - result.push(noEmptySpace()); - result.push(that.generateStatement(node, bodyFlags)); - } +/*global exports:true, require:true, global:true*/ +(function () { + 'use strict'; - for (i = 1, iz = stmt.declarations.length; i < iz; ++i) { - node = stmt.declarations[i]; - if (extra.comment && node.leadingComments) { - result.push(',' + newline); - result.push(addIndent(that.generateStatement(node, bodyFlags))); - } else { - result.push(',' + space); - result.push(that.generateStatement(node, bodyFlags)); - } - } - } + var Syntax, + Precedence, + BinaryPrecedence, + SourceNode, + estraverse, + esutils, + isArray, + base, + indent, + json, + renumber, + hexadecimal, + quotes, + escapeless, + newline, + space, + parentheses, + semicolons, + safeConcatenation, + directive, + extra, + parse, + sourceMap, + sourceCode, + preserveBlankLines, + FORMAT_MINIFY, + FORMAT_DEFAULTS; - if (stmt.declarations.length > 1) { - withIndent(block); - } else { - block(); - } + estraverse = require('estraverse'); + esutils = require('esutils'); - result.push(this.semicolon(flags)); + Syntax = estraverse.Syntax; - return result; - }, + // Generation is done by generateExpression. + function isExpression(node) { + return CodeGenerator.Expression.hasOwnProperty(node.type); + } - ThrowStatement: function (stmt, flags) { - return [join( - 'throw', - this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT) - ), this.semicolon(flags)]; - }, + // Generation is done by generateStatement. + function isStatement(node) { + return CodeGenerator.Statement.hasOwnProperty(node.type); + } - TryStatement: function (stmt, flags) { - var result, i, iz, guardedHandlers; + Precedence = { + Sequence: 0, + Yield: 1, + Await: 1, + Assignment: 1, + Conditional: 2, + ArrowFunction: 2, + LogicalOR: 3, + LogicalAND: 4, + BitwiseOR: 5, + BitwiseXOR: 6, + BitwiseAND: 7, + Equality: 8, + Relational: 9, + BitwiseSHIFT: 10, + Additive: 11, + Multiplicative: 12, + Unary: 13, + Postfix: 14, + Call: 15, + New: 16, + TaggedTemplate: 17, + Member: 18, + Primary: 19 + }; - result = ['try', this.maybeBlock(stmt.block, S_TFFF)]; - result = this.maybeBlockSuffix(stmt.block, result); + BinaryPrecedence = { + '||': Precedence.LogicalOR, + '&&': Precedence.LogicalAND, + '|': Precedence.BitwiseOR, + '^': Precedence.BitwiseXOR, + '&': Precedence.BitwiseAND, + '==': Precedence.Equality, + '!=': Precedence.Equality, + '===': Precedence.Equality, + '!==': Precedence.Equality, + 'is': Precedence.Equality, + 'isnt': Precedence.Equality, + '<': Precedence.Relational, + '>': Precedence.Relational, + '<=': Precedence.Relational, + '>=': Precedence.Relational, + 'in': Precedence.Relational, + 'instanceof': Precedence.Relational, + '<<': Precedence.BitwiseSHIFT, + '>>': Precedence.BitwiseSHIFT, + '>>>': Precedence.BitwiseSHIFT, + '+': Precedence.Additive, + '-': Precedence.Additive, + '*': Precedence.Multiplicative, + '%': Precedence.Multiplicative, + '/': Precedence.Multiplicative + }; - if (stmt.handlers) { - // old interface - for (i = 0, iz = stmt.handlers.length; i < iz; ++i) { - result = join(result, this.generateStatement(stmt.handlers[i], S_TFFF)); - if (stmt.finalizer || i + 1 !== iz) { - result = this.maybeBlockSuffix(stmt.handlers[i].body, result); - } - } - } else { - guardedHandlers = stmt.guardedHandlers || []; + //Flags + var F_ALLOW_IN = 1, + F_ALLOW_CALL = 1 << 1, + F_ALLOW_UNPARATH_NEW = 1 << 2, + F_FUNC_BODY = 1 << 3, + F_DIRECTIVE_CTX = 1 << 4, + F_SEMICOLON_OPT = 1 << 5; - for (i = 0, iz = guardedHandlers.length; i < iz; ++i) { - result = join(result, this.generateStatement(guardedHandlers[i], S_TFFF)); - if (stmt.finalizer || i + 1 !== iz) { - result = this.maybeBlockSuffix(guardedHandlers[i].body, result); - } - } + //Expression flag sets + //NOTE: Flag order: + // F_ALLOW_IN + // F_ALLOW_CALL + // F_ALLOW_UNPARATH_NEW + var E_FTT = F_ALLOW_CALL | F_ALLOW_UNPARATH_NEW, + E_TTF = F_ALLOW_IN | F_ALLOW_CALL, + E_TTT = F_ALLOW_IN | F_ALLOW_CALL | F_ALLOW_UNPARATH_NEW, + E_TFF = F_ALLOW_IN, + E_FFT = F_ALLOW_UNPARATH_NEW, + E_TFT = F_ALLOW_IN | F_ALLOW_UNPARATH_NEW; - // new interface - if (stmt.handler) { - if (isArray(stmt.handler)) { - for (i = 0, iz = stmt.handler.length; i < iz; ++i) { - result = join(result, this.generateStatement(stmt.handler[i], S_TFFF)); - if (stmt.finalizer || i + 1 !== iz) { - result = this.maybeBlockSuffix(stmt.handler[i].body, result); - } - } - } else { - result = join(result, this.generateStatement(stmt.handler, S_TFFF)); - if (stmt.finalizer) { - result = this.maybeBlockSuffix(stmt.handler.body, result); - } - } - } - } - if (stmt.finalizer) { - result = join(result, ['finally', this.maybeBlock(stmt.finalizer, S_TFFF)]); - } - return result; - }, + //Statement flag sets + //NOTE: Flag order: + // F_ALLOW_IN + // F_FUNC_BODY + // F_DIRECTIVE_CTX + // F_SEMICOLON_OPT + var S_TFFF = F_ALLOW_IN, + S_TFFT = F_ALLOW_IN | F_SEMICOLON_OPT, + S_FFFF = 0x00, + S_TFTF = F_ALLOW_IN | F_DIRECTIVE_CTX, + S_TTFF = F_ALLOW_IN | F_FUNC_BODY; - SwitchStatement: function (stmt, flags) { - var result, fragment, i, iz, bodyFlags, that = this; - withIndent(function () { - result = [ - 'switch' + space + '(', - that.generateExpression(stmt.discriminant, Precedence.Sequence, E_TTT), - ')' + space + '{' + newline - ]; - }); - if (stmt.cases) { - bodyFlags = S_TFFF; - for (i = 0, iz = stmt.cases.length; i < iz; ++i) { - if (i === iz - 1) { - bodyFlags |= F_SEMICOLON_OPT; - } - fragment = addIndent(this.generateStatement(stmt.cases[i], bodyFlags)); - result.push(fragment); - if (!endsWithLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { - result.push(newline); - } - } + function getDefaultOptions() { + // default options + return { + indent: null, + base: null, + parse: null, + comment: false, + format: { + indent: { + style: ' ', + base: 0, + adjustMultilineComment: false + }, + newline: '\n', + space: ' ', + json: false, + renumber: false, + hexadecimal: false, + quotes: 'single', + escapeless: false, + compact: false, + parentheses: true, + semicolons: true, + safeConcatenation: false, + preserveBlankLines: false + }, + moz: { + comprehensionExpressionStartsWithAssignment: false, + starlessGenerator: false + }, + sourceMap: null, + sourceMapRoot: null, + sourceMapWithCode: false, + directive: false, + raw: true, + verbatim: null, + sourceCode: null + }; + } + + function stringRepeat(str, num) { + var result = ''; + + for (num |= 0; num > 0; num >>>= 1, str += str) { + if (num & 1) { + result += str; } - result.push(addIndent('}')); - return result; - }, + } - SwitchCase: function (stmt, flags) { - var result, fragment, i, iz, bodyFlags, that = this; - withIndent(function () { - if (stmt.test) { - result = [ - join('case', that.generateExpression(stmt.test, Precedence.Sequence, E_TTT)), - ':' - ]; - } else { - result = ['default:']; - } + return result; + } - i = 0; - iz = stmt.consequent.length; - if (iz && stmt.consequent[0].type === Syntax.BlockStatement) { - fragment = that.maybeBlock(stmt.consequent[0], S_TFFF); - result.push(fragment); - i = 1; - } + isArray = Array.isArray; + if (!isArray) { + isArray = function isArray(array) { + return Object.prototype.toString.call(array) === '[object Array]'; + }; + } - if (i !== iz && !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { - result.push(newline); - } + function hasLineTerminator(str) { + return (/[\r\n]/g).test(str); + } - bodyFlags = S_TFFF; - for (; i < iz; ++i) { - if (i === iz - 1 && flags & F_SEMICOLON_OPT) { - bodyFlags |= F_SEMICOLON_OPT; - } - fragment = addIndent(that.generateStatement(stmt.consequent[i], bodyFlags)); - result.push(fragment); - if (i + 1 !== iz && !endsWithLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { - result.push(newline); - } - } - }); - return result; - }, + function endsWithLineTerminator(str) { + var len = str.length; + return len && esutils.code.isLineTerminator(str.charCodeAt(len - 1)); + } - IfStatement: function (stmt, flags) { - var result, bodyFlags, semicolonOptional, that = this; - withIndent(function () { - result = [ - 'if' + space + '(', - that.generateExpression(stmt.test, Precedence.Sequence, E_TTT), - ')' - ]; - }); - semicolonOptional = flags & F_SEMICOLON_OPT; - bodyFlags = S_TFFF; - if (semicolonOptional) { - bodyFlags |= F_SEMICOLON_OPT; - } - if (stmt.alternate) { - result.push(this.maybeBlock(stmt.consequent, S_TFFF)); - result = this.maybeBlockSuffix(stmt.consequent, result); - if (stmt.alternate.type === Syntax.IfStatement) { - result = join(result, ['else ', this.generateStatement(stmt.alternate, bodyFlags)]); - } else { - result = join(result, join('else', this.maybeBlock(stmt.alternate, bodyFlags))); - } - } else { - result.push(this.maybeBlock(stmt.consequent, bodyFlags)); + function merge(target, override) { + var key; + for (key in override) { + if (override.hasOwnProperty(key)) { + target[key] = override[key]; } - return result; - }, + } + return target; + } - ForStatement: function (stmt, flags) { - var result, that = this; - withIndent(function () { - result = ['for' + space + '(']; - if (stmt.init) { - if (stmt.init.type === Syntax.VariableDeclaration) { - result.push(that.generateStatement(stmt.init, S_FFFF)); - } else { - // F_ALLOW_IN becomes false. - result.push(that.generateExpression(stmt.init, Precedence.Sequence, E_FTT)); - result.push(';'); - } - } else { - result.push(';'); - } + function updateDeeply(target, override) { + var key, val; - if (stmt.test) { - result.push(space); - result.push(that.generateExpression(stmt.test, Precedence.Sequence, E_TTT)); - result.push(';'); - } else { - result.push(';'); - } + function isHashObject(target) { + return typeof target === 'object' && target instanceof Object && !(target instanceof RegExp); + } - if (stmt.update) { - result.push(space); - result.push(that.generateExpression(stmt.update, Precedence.Sequence, E_TTT)); - result.push(')'); + for (key in override) { + if (override.hasOwnProperty(key)) { + val = override[key]; + if (isHashObject(val)) { + if (isHashObject(target[key])) { + updateDeeply(target[key], val); + } else { + target[key] = updateDeeply({}, val); + } } else { - result.push(')'); + target[key] = val; } - }); - - result.push(this.maybeBlock(stmt.body, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF)); - return result; - }, + } + } + return target; + } - ForInStatement: function (stmt, flags) { - return this.generateIterationForStatement('in', stmt, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF); - }, + function generateNumber(value) { + var result, point, temp, exponent, pos; - ForOfStatement: function (stmt, flags) { - return this.generateIterationForStatement('of', stmt, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF); - }, + if (value !== value) { + throw new Error('Numeric literal whose value is NaN'); + } + if (value < 0 || (value === 0 && 1 / value < 0)) { + throw new Error('Numeric literal whose value is negative'); + } - LabeledStatement: function (stmt, flags) { - return [stmt.label.name + ':', this.maybeBlock(stmt.body, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF)]; - }, + if (value === 1 / 0) { + return json ? 'null' : renumber ? '1e400' : '1e+400'; + } - Program: function (stmt, flags) { - var result, fragment, i, iz, bodyFlags; - iz = stmt.body.length; - result = [safeConcatenation && iz > 0 ? '\n' : '']; - bodyFlags = S_TFTF; - for (i = 0; i < iz; ++i) { - if (!safeConcatenation && i === iz - 1) { - bodyFlags |= F_SEMICOLON_OPT; - } + result = '' + value; + if (!renumber || result.length < 3) { + return result; + } - if (preserveBlankLines) { - // handle spaces before the first line - if (i === 0) { - if (!stmt.body[0].leadingComments) { - generateBlankLines(stmt.range[0], stmt.body[i].range[0], result); - } - } + point = result.indexOf('.'); + if (!json && result.charCodeAt(0) === 0x30 /* 0 */ && point === 1) { + point = 0; + result = result.slice(1); + } + temp = result; + result = result.replace('e+', 'e'); + exponent = 0; + if ((pos = temp.indexOf('e')) > 0) { + exponent = +temp.slice(pos + 1); + temp = temp.slice(0, pos); + } + if (point >= 0) { + exponent -= temp.length - point - 1; + temp = +(temp.slice(0, point) + temp.slice(point + 1)) + ''; + } + pos = 0; + while (temp.charCodeAt(temp.length + pos - 1) === 0x30 /* 0 */) { + --pos; + } + if (pos !== 0) { + exponent -= pos; + temp = temp.slice(0, pos); + } + if (exponent !== 0) { + temp += 'e' + exponent; + } + if ((temp.length < result.length || + (hexadecimal && value > 1e12 && Math.floor(value) === value && (temp = '0x' + value.toString(16)).length < result.length)) && + +temp === value) { + result = temp; + } - // handle spaces between lines - if (i > 0) { - if (!stmt.body[i - 1].trailingComments && !stmt.body[i].leadingComments) { - generateBlankLines(stmt.body[i - 1].range[1], stmt.body[i].range[0], result); - } - } - } + return result; + } - fragment = addIndent(this.generateStatement(stmt.body[i], bodyFlags)); - result.push(fragment); - if (i + 1 < iz && !endsWithLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { - if (preserveBlankLines) { - if (!stmt.body[i + 1].leadingComments) { - result.push(newline); + // Generate valid RegExp expression. + // This function is based on https://github.com/Constellation/iv Engine + + function escapeRegExpCharacter(ch, previousIsBackslash) { + // not handling '\' and handling \u2028 or \u2029 to unicode escape sequence + if ((ch & ~1) === 0x2028) { + return (previousIsBackslash ? 'u' : '\\u') + ((ch === 0x2028) ? '2028' : '2029'); + } else if (ch === 10 || ch === 13) { // \n, \r + return (previousIsBackslash ? '' : '\\') + ((ch === 10) ? 'n' : 'r'); + } + return String.fromCharCode(ch); + } + + function generateRegExp(reg) { + var match, result, flags, i, iz, ch, characterInBrack, previousIsBackslash; + + result = reg.toString(); + + if (reg.source) { + // extract flag from toString result + match = result.match(/\/([^/]*)$/); + if (!match) { + return result; + } + + flags = match[1]; + result = ''; + + characterInBrack = false; + previousIsBackslash = false; + for (i = 0, iz = reg.source.length; i < iz; ++i) { + ch = reg.source.charCodeAt(i); + + if (!previousIsBackslash) { + if (characterInBrack) { + if (ch === 93) { // ] + characterInBrack = false; } } else { - result.push(newline); - } - } - - if (preserveBlankLines) { - // handle spaces after the last line - if (i === iz - 1) { - if (!stmt.body[i].trailingComments) { - generateBlankLines(stmt.body[i].range[1], stmt.range[1], result); + if (ch === 47) { // / + result += '\\'; + } else if (ch === 91) { // [ + characterInBrack = true; } } + result += escapeRegExpCharacter(ch, previousIsBackslash); + previousIsBackslash = ch === 92; // \ + } else { + // if new RegExp("\\\n') is provided, create /\n/ + result += escapeRegExpCharacter(ch, previousIsBackslash); + // prevent like /\\[/]/ + previousIsBackslash = false; } } - return result; - }, - FunctionDeclaration: function (stmt, flags) { - return [ - generateAsyncPrefix(stmt, true), - 'function', - generateStarSuffix(stmt) || noEmptySpace(), - generateIdentifier(stmt.id), - this.generateFunctionBody(stmt) - ]; - }, + return '/' + result + '/' + flags; + } - ReturnStatement: function (stmt, flags) { - if (stmt.argument) { - return [join( - 'return', - this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT) - ), this.semicolon(flags)]; - } - return ['return' + this.semicolon(flags)]; - }, + return result; + } - WhileStatement: function (stmt, flags) { - var result, that = this; - withIndent(function () { - result = [ - 'while' + space + '(', - that.generateExpression(stmt.test, Precedence.Sequence, E_TTT), - ')' - ]; - }); - result.push(this.maybeBlock(stmt.body, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF)); - return result; - }, + function escapeAllowedCharacter(code, next) { + var hex; - WithStatement: function (stmt, flags) { - var result, that = this; - withIndent(function () { - result = [ - 'with' + space + '(', - that.generateExpression(stmt.object, Precedence.Sequence, E_TTT), - ')' - ]; - }); - result.push(this.maybeBlock(stmt.body, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF)); - return result; + if (code === 0x08 /* \b */) { + return '\\b'; } - }; + if (code === 0x0C /* \f */) { + return '\\f'; + } - merge(CodeGenerator.prototype, CodeGenerator.Statement); + if (code === 0x09 /* \t */) { + return '\\t'; + } - // Expressions. + hex = code.toString(16).toUpperCase(); + if (json || code > 0xFF) { + return '\\u' + '0000'.slice(hex.length) + hex; + } else if (code === 0x0000 && !esutils.code.isDecimalDigit(next)) { + return '\\0'; + } else if (code === 0x000B /* \v */) { // '\v' + return '\\x0B'; + } else { + return '\\x' + '00'.slice(hex.length) + hex; + } + } - CodeGenerator.Expression = { + function escapeDisallowedCharacter(code) { + if (code === 0x5C /* \ */) { + return '\\\\'; + } - SequenceExpression: function (expr, precedence, flags) { - var result, i, iz; - if (Precedence.Sequence < precedence) { - flags |= F_ALLOW_IN; - } - result = []; - for (i = 0, iz = expr.expressions.length; i < iz; ++i) { - result.push(this.generateExpression(expr.expressions[i], Precedence.Assignment, flags)); - if (i + 1 < iz) { - result.push(',' + space); - } - } - return parenthesize(result, Precedence.Sequence, precedence); - }, + if (code === 0x0A /* \n */) { + return '\\n'; + } - AssignmentExpression: function (expr, precedence, flags) { - return this.generateAssignment(expr.left, expr.right, expr.operator, precedence, flags); - }, + if (code === 0x0D /* \r */) { + return '\\r'; + } - ArrowFunctionExpression: function (expr, precedence, flags) { - return parenthesize(this.generateFunctionBody(expr), Precedence.ArrowFunction, precedence); - }, + if (code === 0x2028) { + return '\\u2028'; + } - ConditionalExpression: function (expr, precedence, flags) { - if (Precedence.Conditional < precedence) { - flags |= F_ALLOW_IN; - } - return parenthesize( - [ - this.generateExpression(expr.test, Precedence.LogicalOR, flags), - space + '?' + space, - this.generateExpression(expr.consequent, Precedence.Assignment, flags), - space + ':' + space, - this.generateExpression(expr.alternate, Precedence.Assignment, flags) - ], - Precedence.Conditional, - precedence - ); - }, + if (code === 0x2029) { + return '\\u2029'; + } - LogicalExpression: function (expr, precedence, flags) { - return this.BinaryExpression(expr, precedence, flags); - }, + throw new Error('Incorrectly classified character'); + } - BinaryExpression: function (expr, precedence, flags) { - var result, currentPrecedence, fragment, leftSource; - currentPrecedence = BinaryPrecedence[expr.operator]; + function escapeDirective(str) { + var i, iz, code, quote; - if (currentPrecedence < precedence) { - flags |= F_ALLOW_IN; + quote = quotes === 'double' ? '"' : '\''; + for (i = 0, iz = str.length; i < iz; ++i) { + code = str.charCodeAt(i); + if (code === 0x27 /* ' */) { + quote = '"'; + break; + } else if (code === 0x22 /* " */) { + quote = '\''; + break; + } else if (code === 0x5C /* \ */) { + ++i; } + } - fragment = this.generateExpression(expr.left, currentPrecedence, flags); + return quote + str + quote; + } - leftSource = fragment.toString(); + function escapeString(str) { + var result = '', i, len, code, singleQuotes = 0, doubleQuotes = 0, single, quote; - if (leftSource.charCodeAt(leftSource.length - 1) === 0x2F /* / */ && esutils.code.isIdentifierPart(expr.operator.charCodeAt(0))) { - result = [fragment, noEmptySpace(), expr.operator]; - } else { - result = join(fragment, expr.operator); + for (i = 0, len = str.length; i < len; ++i) { + code = str.charCodeAt(i); + if (code === 0x27 /* ' */) { + ++singleQuotes; + } else if (code === 0x22 /* " */) { + ++doubleQuotes; + } else if (code === 0x2F /* / */ && json) { + result += '\\'; + } else if (esutils.code.isLineTerminator(code) || code === 0x5C /* \ */) { + result += escapeDisallowedCharacter(code); + continue; + } else if (!esutils.code.isIdentifierPartES5(code) && (json && code < 0x20 /* SP */ || !json && !escapeless && (code < 0x20 /* SP */ || code > 0x7E /* ~ */))) { + result += escapeAllowedCharacter(code, str.charCodeAt(i + 1)); + continue; } + result += String.fromCharCode(code); + } - fragment = this.generateExpression(expr.right, currentPrecedence + 1, flags); - - if (expr.operator === '/' && fragment.toString().charAt(0) === '/' || - expr.operator.slice(-1) === '<' && fragment.toString().slice(0, 3) === '!--') { - // If '/' concats with '/' or `<` concats with `!--`, it is interpreted as comment start - result.push(noEmptySpace()); - result.push(fragment); - } else { - result = join(result, fragment); - } + single = !(quotes === 'double' || (quotes === 'auto' && doubleQuotes < singleQuotes)); + quote = single ? '\'' : '"'; - if (expr.operator === 'in' && !(flags & F_ALLOW_IN)) { - return ['(', result, ')']; - } - return parenthesize(result, currentPrecedence, precedence); - }, + if (!(single ? singleQuotes : doubleQuotes)) { + return quote + result + quote; + } - CallExpression: function (expr, precedence, flags) { - var result, i, iz; - // F_ALLOW_UNPARATH_NEW becomes false. - result = [this.generateExpression(expr.callee, Precedence.Call, E_TTF)]; - result.push('('); - for (i = 0, iz = expr['arguments'].length; i < iz; ++i) { - result.push(this.generateExpression(expr['arguments'][i], Precedence.Assignment, E_TTT)); - if (i + 1 < iz) { - result.push(',' + space); - } - } - result.push(')'); + str = result; + result = quote; - if (!(flags & F_ALLOW_CALL)) { - return ['(', result, ')']; + for (i = 0, len = str.length; i < len; ++i) { + code = str.charCodeAt(i); + if ((code === 0x27 /* ' */ && single) || (code === 0x22 /* " */ && !single)) { + result += '\\'; } - return parenthesize(result, Precedence.Call, precedence); - }, - - NewExpression: function (expr, precedence, flags) { - var result, length, i, iz, itemFlags; - length = expr['arguments'].length; + result += String.fromCharCode(code); + } - // F_ALLOW_CALL becomes false. - // F_ALLOW_UNPARATH_NEW may become false. - itemFlags = (flags & F_ALLOW_UNPARATH_NEW && !parentheses && length === 0) ? E_TFT : E_TFF; + return result + quote; + } - result = join( - 'new', - this.generateExpression(expr.callee, Precedence.New, itemFlags) - ); + /** + * flatten an array to a string, where the array can contain + * either strings or nested arrays + */ + function flattenToString(arr) { + var i, iz, elem, result = ''; + for (i = 0, iz = arr.length; i < iz; ++i) { + elem = arr[i]; + result += isArray(elem) ? flattenToString(elem) : elem; + } + return result; + } - if (!(flags & F_ALLOW_UNPARATH_NEW) || parentheses || length > 0) { - result.push('('); - for (i = 0, iz = length; i < iz; ++i) { - result.push(this.generateExpression(expr['arguments'][i], Precedence.Assignment, E_TTT)); - if (i + 1 < iz) { - result.push(',' + space); - } - } - result.push(')'); + /** + * convert generated to a SourceNode when source maps are enabled. + */ + function toSourceNodeWhenNeeded(generated, node) { + if (!sourceMap) { + // with no source maps, generated is either an + // array or a string. if an array, flatten it. + // if a string, just return it + if (isArray(generated)) { + return flattenToString(generated); + } else { + return generated; + } + } + if (node == null) { + if (generated instanceof SourceNode) { + return generated; + } else { + node = {}; } + } + if (node.loc == null) { + return new SourceNode(null, null, sourceMap, generated, node.name || null); + } + return new SourceNode(node.loc.start.line, node.loc.start.column, (sourceMap === true ? node.loc.source || null : sourceMap), generated, node.name || null); + } - return parenthesize(result, Precedence.New, precedence); - }, + function noEmptySpace() { + return (space) ? space : ' '; + } - MemberExpression: function (expr, precedence, flags) { - var result, fragment; + function join(left, right) { + var leftSource, + rightSource, + leftCharCode, + rightCharCode; - // F_ALLOW_UNPARATH_NEW becomes false. - result = [this.generateExpression(expr.object, Precedence.Call, (flags & F_ALLOW_CALL) ? E_TTF : E_TFF)]; + leftSource = toSourceNodeWhenNeeded(left).toString(); + if (leftSource.length === 0) { + return [right]; + } - if (expr.computed) { - result.push('['); - result.push(this.generateExpression(expr.property, Precedence.Sequence, flags & F_ALLOW_CALL ? E_TTT : E_TFT)); - result.push(']'); - } else { - if (expr.object.type === Syntax.Literal && typeof expr.object.value === 'number') { - fragment = toSourceNodeWhenNeeded(result).toString(); - // When the following conditions are all true, - // 1. No floating point - // 2. Don't have exponents - // 3. The last character is a decimal digit - // 4. Not hexadecimal OR octal number literal - // we should add a floating point. - if ( - fragment.indexOf('.') < 0 && - !/[eExX]/.test(fragment) && - esutils.code.isDecimalDigit(fragment.charCodeAt(fragment.length - 1)) && - !(fragment.length >= 2 && fragment.charCodeAt(0) === 48) // '0' - ) { - result.push('.'); - } - } - result.push('.'); - result.push(generateIdentifier(expr.property)); - } + rightSource = toSourceNodeWhenNeeded(right).toString(); + if (rightSource.length === 0) { + return [left]; + } - return parenthesize(result, Precedence.Member, precedence); - }, + leftCharCode = leftSource.charCodeAt(leftSource.length - 1); + rightCharCode = rightSource.charCodeAt(0); - UnaryExpression: function (expr, precedence, flags) { - var result, fragment, rightCharCode, leftSource, leftCharCode; - fragment = this.generateExpression(expr.argument, Precedence.Unary, E_TTT); + if ((leftCharCode === 0x2B /* + */ || leftCharCode === 0x2D /* - */) && leftCharCode === rightCharCode || + esutils.code.isIdentifierPartES5(leftCharCode) && esutils.code.isIdentifierPartES5(rightCharCode) || + leftCharCode === 0x2F /* / */ && rightCharCode === 0x69 /* i */) { // infix word operators all start with `i` + return [left, noEmptySpace(), right]; + } else if (esutils.code.isWhiteSpace(leftCharCode) || esutils.code.isLineTerminator(leftCharCode) || + esutils.code.isWhiteSpace(rightCharCode) || esutils.code.isLineTerminator(rightCharCode)) { + return [left, right]; + } + return [left, space, right]; + } - if (space === '') { - result = join(expr.operator, fragment); - } else { - result = [expr.operator]; - if (expr.operator.length > 2) { - // delete, void, typeof - // get `typeof []`, not `typeof[]` - result = join(result, fragment); - } else { - // Prevent inserting spaces between operator and argument if it is unnecessary - // like, `!cond` - leftSource = toSourceNodeWhenNeeded(result).toString(); - leftCharCode = leftSource.charCodeAt(leftSource.length - 1); - rightCharCode = fragment.toString().charCodeAt(0); + function addIndent(stmt) { + return [base, stmt]; + } - if (((leftCharCode === 0x2B /* + */ || leftCharCode === 0x2D /* - */) && leftCharCode === rightCharCode) || - (esutils.code.isIdentifierPart(leftCharCode) && esutils.code.isIdentifierPart(rightCharCode))) { - result.push(noEmptySpace()); - result.push(fragment); - } else { - result.push(fragment); - } - } - } - return parenthesize(result, Precedence.Unary, precedence); - }, + function withIndent(fn) { + var previousBase; + previousBase = base; + base += indent; + fn(base); + base = previousBase; + } - YieldExpression: function (expr, precedence, flags) { - var result; - if (expr.delegate) { - result = 'yield*'; - } else { - result = 'yield'; - } - if (expr.argument) { - result = join( - result, - this.generateExpression(expr.argument, Precedence.Yield, E_TTT) - ); + function calculateSpaces(str) { + var i; + for (i = str.length - 1; i >= 0; --i) { + if (esutils.code.isLineTerminator(str.charCodeAt(i))) { + break; } - return parenthesize(result, Precedence.Yield, precedence); - }, + } + return (str.length - 1) - i; + } - AwaitExpression: function (expr, precedence, flags) { - var result = join( - expr.delegate ? 'await*' : 'await', - this.generateExpression(expr.argument, Precedence.Await, E_TTT) - ); - return parenthesize(result, Precedence.Await, precedence); - }, + function adjustMultilineComment(value, specialBase) { + var array, i, len, line, j, spaces, previousBase, sn; - UpdateExpression: function (expr, precedence, flags) { - if (expr.prefix) { - return parenthesize( - [ - expr.operator, - this.generateExpression(expr.argument, Precedence.Unary, E_TTT) - ], - Precedence.Unary, - precedence - ); + array = value.split(/\r\n|[\r\n]/); + spaces = Number.MAX_VALUE; + + // first line doesn't have indentation + for (i = 1, len = array.length; i < len; ++i) { + line = array[i]; + j = 0; + while (j < line.length && esutils.code.isWhiteSpace(line.charCodeAt(j))) { + ++j; } - return parenthesize( - [ - this.generateExpression(expr.argument, Precedence.Postfix, E_TTT), - expr.operator - ], - Precedence.Postfix, - precedence - ); - }, + if (spaces > j) { + spaces = j; + } + } - FunctionExpression: function (expr, precedence, flags) { - var result = [ - generateAsyncPrefix(expr, true), - 'function' - ]; - if (expr.id) { - result.push(generateStarSuffix(expr) || noEmptySpace()); - result.push(generateIdentifier(expr.id)); - } else { - result.push(generateStarSuffix(expr) || space); + if (typeof specialBase !== 'undefined') { + // pattern like + // { + // var t = 20; /* + // * this is comment + // */ + // } + previousBase = base; + if (array[1][spaces] === '*') { + specialBase += ' '; } - result.push(this.generateFunctionBody(expr)); - return result; - }, + base = specialBase; + } else { + if (spaces & 1) { + // /* + // * + // */ + // If spaces are odd number, above pattern is considered. + // We waste 1 space. + --spaces; + } + previousBase = base; + } - ExportBatchSpecifier: function (expr, precedence, flags) { - return '*'; - }, + for (i = 1, len = array.length; i < len; ++i) { + sn = toSourceNodeWhenNeeded(addIndent(array[i].slice(spaces))); + array[i] = sourceMap ? sn.join('') : sn; + } - ArrayPattern: function (expr, precedence, flags) { - return this.ArrayExpression(expr, precedence, flags); - }, + base = previousBase; - ArrayExpression: function (expr, precedence, flags) { - var result, multiline, that = this; - if (!expr.elements.length) { - return '[]'; - } - multiline = expr.elements.length > 1; - result = ['[', multiline ? newline : '']; - withIndent(function (indent) { - var i, iz; - for (i = 0, iz = expr.elements.length; i < iz; ++i) { - if (!expr.elements[i]) { - if (multiline) { - result.push(indent); - } - if (i + 1 === iz) { - result.push(','); - } - } else { - result.push(multiline ? indent : ''); - result.push(that.generateExpression(expr.elements[i], Precedence.Assignment, E_TTT)); - } - if (i + 1 < iz) { - result.push(',' + (multiline ? newline : space)); - } + return array.join('\n'); + } + + function generateComment(comment, specialBase) { + if (comment.type === 'Line') { + if (endsWithLineTerminator(comment.value)) { + return '//' + comment.value; + } else { + // Always use LineTerminator + var result = '//' + comment.value; + if (!preserveBlankLines) { + result += '\n'; } - }); - if (multiline && !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { - result.push(newline); + return result; } - result.push(multiline ? base : ''); - result.push(']'); - return result; - }, + } + if (extra.format.indent.adjustMultilineComment && /[\n\r]/.test(comment.value)) { + return adjustMultilineComment('/*' + comment.value + '*/', specialBase); + } + return '/*' + comment.value + '*/'; + } - ClassExpression: function (expr, precedence, flags) { - var result, fragment; - result = ['class']; - if (expr.id) { - result = join(result, this.generateExpression(expr.id, Precedence.Sequence, E_TTT)); - } - if (expr.superClass) { - fragment = join('extends', this.generateExpression(expr.superClass, Precedence.Assignment, E_TTT)); - result = join(result, fragment); - } - result.push(space); - result.push(this.generateStatement(expr.body, S_TFFT)); - return result; - }, + function addComments(stmt, result) { + var i, len, comment, save, tailingToStatement, specialBase, fragment, + extRange, range, prevRange, prefix, infix, suffix, count; - MethodDefinition: function (expr, precedence, flags) { - var result, fragment; - if (expr['static']) { - result = ['static' + space]; - } else { + if (stmt.leadingComments && stmt.leadingComments.length > 0) { + save = result; + + if (preserveBlankLines) { + comment = stmt.leadingComments[0]; result = []; - } - if (expr.kind === 'get' || expr.kind === 'set') { - fragment = [ - join(expr.kind, this.generatePropertyKey(expr.key, expr.computed)), - this.generateFunctionBody(expr.value) - ]; - } else { - fragment = [ - generateMethodPrefix(expr), - this.generatePropertyKey(expr.key, expr.computed), - this.generateFunctionBody(expr.value) - ]; - } - return join(result, fragment); - }, - Property: function (expr, precedence, flags) { - if (expr.kind === 'get' || expr.kind === 'set') { - return [ - expr.kind, noEmptySpace(), - this.generatePropertyKey(expr.key, expr.computed), - this.generateFunctionBody(expr.value) - ]; - } + extRange = comment.extendedRange; + range = comment.range; - if (expr.shorthand) { - return this.generatePropertyKey(expr.key, expr.computed); - } + prefix = sourceCode.substring(extRange[0], range[0]); + count = (prefix.match(/\n/g) || []).length; + if (count > 0) { + result.push(stringRepeat('\n', count)); + result.push(addIndent(generateComment(comment))); + } else { + result.push(prefix); + result.push(generateComment(comment)); + } - if (expr.method) { - return [ - generateMethodPrefix(expr), - this.generatePropertyKey(expr.key, expr.computed), - this.generateFunctionBody(expr.value) - ]; - } + prevRange = range; - return [ - this.generatePropertyKey(expr.key, expr.computed), - ':' + space, - this.generateExpression(expr.value, Precedence.Assignment, E_TTT) - ]; - }, + for (i = 1, len = stmt.leadingComments.length; i < len; i++) { + comment = stmt.leadingComments[i]; + range = comment.range; - ObjectExpression: function (expr, precedence, flags) { - var multiline, result, fragment, that = this; + infix = sourceCode.substring(prevRange[1], range[0]); + count = (infix.match(/\n/g) || []).length; + result.push(stringRepeat('\n', count)); + result.push(addIndent(generateComment(comment))); - if (!expr.properties.length) { - return '{}'; - } - multiline = expr.properties.length > 1; + prevRange = range; + } - withIndent(function () { - fragment = that.generateExpression(expr.properties[0], Precedence.Sequence, E_TTT); - }); + suffix = sourceCode.substring(range[1], extRange[1]); + count = (suffix.match(/\n/g) || []).length; + result.push(stringRepeat('\n', count)); + } else { + comment = stmt.leadingComments[0]; + result = []; + if (safeConcatenation && stmt.type === Syntax.Program && stmt.body.length === 0) { + result.push('\n'); + } + result.push(generateComment(comment)); + if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { + result.push('\n'); + } - if (!multiline) { - // issues 4 - // Do not transform from - // dejavu.Class.declare({ - // method2: function () {} - // }); - // to - // dejavu.Class.declare({method2: function () { - // }}); - if (!hasLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { - return [ '{', space, fragment, space, '}' ]; + for (i = 1, len = stmt.leadingComments.length; i < len; ++i) { + comment = stmt.leadingComments[i]; + fragment = [generateComment(comment)]; + if (!endsWithLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { + fragment.push('\n'); + } + result.push(addIndent(fragment)); } } - withIndent(function (indent) { - var i, iz; - result = [ '{', newline, indent, fragment ]; + result.push(addIndent(save)); + } - if (multiline) { - result.push(',' + newline); - for (i = 1, iz = expr.properties.length; i < iz; ++i) { - result.push(indent); - result.push(that.generateExpression(expr.properties[i], Precedence.Sequence, E_TTT)); - if (i + 1 < iz) { - result.push(',' + newline); - } - } - } - }); + if (stmt.trailingComments) { - if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { - result.push(newline); - } - result.push(base); - result.push('}'); - return result; - }, + if (preserveBlankLines) { + comment = stmt.trailingComments[0]; + extRange = comment.extendedRange; + range = comment.range; - ObjectPattern: function (expr, precedence, flags) { - var result, i, iz, multiline, property, that = this; - if (!expr.properties.length) { - return '{}'; - } + prefix = sourceCode.substring(extRange[0], range[0]); + count = (prefix.match(/\n/g) || []).length; - multiline = false; - if (expr.properties.length === 1) { - property = expr.properties[0]; - if (property.value.type !== Syntax.Identifier) { - multiline = true; + if (count > 0) { + result.push(stringRepeat('\n', count)); + result.push(addIndent(generateComment(comment))); + } else { + result.push(prefix); + result.push(generateComment(comment)); } } else { - for (i = 0, iz = expr.properties.length; i < iz; ++i) { - property = expr.properties[i]; - if (!property.shorthand) { - multiline = true; - break; + tailingToStatement = !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString()); + specialBase = stringRepeat(' ', calculateSpaces(toSourceNodeWhenNeeded([base, result, indent]).toString())); + for (i = 0, len = stmt.trailingComments.length; i < len; ++i) { + comment = stmt.trailingComments[i]; + if (tailingToStatement) { + // We assume target like following script + // + // var t = 20; /** + // * This is comment of t + // */ + if (i === 0) { + // first case + result = [result, indent]; + } else { + result = [result, specialBase]; + } + result.push(generateComment(comment, specialBase)); + } else { + result = [result, addIndent(generateComment(comment))]; } - } - } - result = ['{', multiline ? newline : '' ]; - - withIndent(function (indent) { - var i, iz; - for (i = 0, iz = expr.properties.length; i < iz; ++i) { - result.push(multiline ? indent : ''); - result.push(that.generateExpression(expr.properties[i], Precedence.Sequence, E_TTT)); - if (i + 1 < iz) { - result.push(',' + (multiline ? newline : space)); + if (i !== len - 1 && !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { + result = [result, '\n']; } } - }); - - if (multiline && !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { - result.push(newline); } - result.push(multiline ? base : ''); - result.push('}'); - return result; - }, - - ThisExpression: function (expr, precedence, flags) { - return 'this'; - }, + } - Identifier: function (expr, precedence, flags) { - return generateIdentifier(expr); - }, + return result; + } - ImportDefaultSpecifier: function (expr, precedence, flags) { - return generateIdentifier(expr.id); - }, + function generateBlankLines(start, end, result) { + var j, newlineCount = 0; - ImportNamespaceSpecifier: function (expr, precedence, flags) { - var result = ['*']; - if (expr.id) { - result.push(space + 'as' + noEmptySpace() + generateIdentifier(expr.id)); + for (j = start; j < end; j++) { + if (sourceCode[j] === '\n') { + newlineCount++; } - return result; - }, + } - ImportSpecifier: function (expr, precedence, flags) { - return this.ExportSpecifier(expr, precedence, flags); - }, + for (j = 1; j < newlineCount; j++) { + result.push(newline); + } + } - ExportSpecifier: function (expr, precedence, flags) { - var result = [ expr.id.name ]; - if (expr.name) { - result.push(noEmptySpace() + 'as' + noEmptySpace() + generateIdentifier(expr.name)); - } - return result; - }, + function parenthesize(text, current, should) { + if (current < should) { + return ['(', text, ')']; + } + return text; + } - Literal: function (expr, precedence, flags) { - var raw; - if (expr.hasOwnProperty('raw') && parse && extra.raw) { - try { - raw = parse(expr.raw).body[0].expression; - if (raw.type === Syntax.Literal) { - if (raw.value === expr.value) { - return expr.raw; - } - } - } catch (e) { - // not use raw property - } - } + function generateVerbatimString(string) { + var i, iz, result; + result = string.split(/\r\n|\n/); + for (i = 1, iz = result.length; i < iz; i++) { + result[i] = newline + base + result[i]; + } + return result; + } - if (expr.value === null) { - return 'null'; - } + function generateVerbatim(expr, precedence) { + var verbatim, result, prec; + verbatim = expr[extra.verbatim]; - if (typeof expr.value === 'string') { - return escapeString(expr.value); - } + if (typeof verbatim === 'string') { + result = parenthesize(generateVerbatimString(verbatim), Precedence.Sequence, precedence); + } else { + // verbatim is object + result = generateVerbatimString(verbatim.content); + prec = (verbatim.precedence != null) ? verbatim.precedence : Precedence.Sequence; + result = parenthesize(result, prec, precedence); + } - if (typeof expr.value === 'number') { - return generateNumber(expr.value); - } + return toSourceNodeWhenNeeded(result, expr); + } - if (typeof expr.value === 'boolean') { - return expr.value ? 'true' : 'false'; - } + function CodeGenerator() { + } - return generateRegExp(expr.value); - }, + // Helpers. - GeneratorExpression: function (expr, precedence, flags) { - return this.ComprehensionExpression(expr, precedence, flags); - }, + CodeGenerator.prototype.maybeBlock = function(stmt, flags) { + var result, noLeadingComment, that = this; - ComprehensionExpression: function (expr, precedence, flags) { - // GeneratorExpression should be parenthesized with (...), ComprehensionExpression with [...] - // Due to https://bugzilla.mozilla.org/show_bug.cgi?id=883468 position of expr.body can differ in Spidermonkey and ES6 + noLeadingComment = !extra.comment || !stmt.leadingComments; - var result, i, iz, fragment, that = this; - result = (expr.type === Syntax.GeneratorExpression) ? ['('] : ['[']; + if (stmt.type === Syntax.BlockStatement && noLeadingComment) { + return [space, this.generateStatement(stmt, flags)]; + } - if (extra.moz.comprehensionExpressionStartsWithAssignment) { - fragment = this.generateExpression(expr.body, Precedence.Assignment, E_TTT); - result.push(fragment); - } + if (stmt.type === Syntax.EmptyStatement && noLeadingComment) { + return ';'; + } - if (expr.blocks) { - withIndent(function () { - for (i = 0, iz = expr.blocks.length; i < iz; ++i) { - fragment = that.generateExpression(expr.blocks[i], Precedence.Sequence, E_TTT); - if (i > 0 || extra.moz.comprehensionExpressionStartsWithAssignment) { - result = join(result, fragment); - } else { - result.push(fragment); - } - } - }); - } + withIndent(function () { + result = [ + newline, + addIndent(that.generateStatement(stmt, flags)) + ]; + }); - if (expr.filter) { - result = join(result, 'if' + space); - fragment = this.generateExpression(expr.filter, Precedence.Sequence, E_TTT); - result = join(result, [ '(', fragment, ')' ]); - } + return result; + }; - if (!extra.moz.comprehensionExpressionStartsWithAssignment) { - fragment = this.generateExpression(expr.body, Precedence.Assignment, E_TTT); + CodeGenerator.prototype.maybeBlockSuffix = function (stmt, result) { + var ends = endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString()); + if (stmt.type === Syntax.BlockStatement && (!extra.comment || !stmt.leadingComments) && !ends) { + return [result, space]; + } + if (ends) { + return [result, base]; + } + return [result, newline, base]; + }; - result = join(result, fragment); - } + function generateIdentifier(node) { + return toSourceNodeWhenNeeded(node.name, node); + } - result.push((expr.type === Syntax.GeneratorExpression) ? ')' : ']'); - return result; - }, + function generateAsyncPrefix(node, spaceRequired) { + return node.async ? 'async' + (spaceRequired ? noEmptySpace() : space) : ''; + } - ComprehensionBlock: function (expr, precedence, flags) { - var fragment; - if (expr.left.type === Syntax.VariableDeclaration) { - fragment = [ - expr.left.kind, noEmptySpace(), - this.generateStatement(expr.left.declarations[0], S_FFFF) - ]; - } else { - fragment = this.generateExpression(expr.left, Precedence.Call, E_TTT); - } + function generateStarSuffix(node) { + var isGenerator = node.generator && !extra.moz.starlessGenerator; + return isGenerator ? '*' + space : ''; + } - fragment = join(fragment, expr.of ? 'of' : 'in'); - fragment = join(fragment, this.generateExpression(expr.right, Precedence.Sequence, E_TTT)); - - return [ 'for' + space + '(', fragment, ')' ]; - }, + function generateMethodPrefix(prop) { + var func = prop.value; + if (func.async) { + return generateAsyncPrefix(func, !prop.computed); + } else { + // avoid space before method name + return generateStarSuffix(func) ? '*' : ''; + } + } - SpreadElement: function (expr, precedence, flags) { - return [ - '...', - this.generateExpression(expr.argument, Precedence.Assignment, E_TTT) - ]; - }, + CodeGenerator.prototype.generatePattern = function (node, precedence, flags) { + if (node.type === Syntax.Identifier) { + return generateIdentifier(node); + } + return this.generateExpression(node, precedence, flags); + }; - TaggedTemplateExpression: function (expr, precedence, flags) { - var itemFlags = E_TTF; - if (!(flags & F_ALLOW_CALL)) { - itemFlags = E_TFF; - } - var result = [ - this.generateExpression(expr.tag, Precedence.Call, itemFlags), - this.generateExpression(expr.quasi, Precedence.Primary, E_FFT) - ]; - return parenthesize(result, Precedence.TaggedTemplate, precedence); - }, + CodeGenerator.prototype.generateFunctionParams = function (node) { + var i, iz, result, hasDefault; - TemplateElement: function (expr, precedence, flags) { - // Don't use "cooked". Since tagged template can use raw template - // representation. So if we do so, it breaks the script semantics. - return expr.value.raw; - }, + hasDefault = false; - TemplateLiteral: function (expr, precedence, flags) { - var result, i, iz; - result = [ '`' ]; - for (i = 0, iz = expr.quasis.length; i < iz; ++i) { - result.push(this.generateExpression(expr.quasis[i], Precedence.Primary, E_TTT)); + if (node.type === Syntax.ArrowFunctionExpression && + !node.rest && (!node.defaults || node.defaults.length === 0) && + node.params.length === 1 && node.params[0].type === Syntax.Identifier) { + // arg => { } case + result = [generateAsyncPrefix(node, true), generateIdentifier(node.params[0])]; + } else { + result = node.type === Syntax.ArrowFunctionExpression ? [generateAsyncPrefix(node, false)] : []; + result.push('('); + if (node.defaults) { + hasDefault = true; + } + for (i = 0, iz = node.params.length; i < iz; ++i) { + if (hasDefault && node.defaults[i]) { + // Handle default values. + result.push(this.generateAssignment(node.params[i], node.defaults[i], '=', Precedence.Assignment, E_TTT)); + } else { + result.push(this.generatePattern(node.params[i], Precedence.Assignment, E_TTT)); + } if (i + 1 < iz) { - result.push('${' + space); - result.push(this.generateExpression(expr.expressions[i], Precedence.Sequence, E_TTT)); - result.push(space + '}'); + result.push(',' + space); } } - result.push('`'); - return result; - }, - ModuleSpecifier: function (expr, precedence, flags) { - return this.Literal(expr, precedence, flags); + if (node.rest) { + if (node.params.length) { + result.push(',' + space); + } + result.push('...'); + result.push(generateIdentifier(node.rest)); + } + + result.push(')'); } + return result; }; - merge(CodeGenerator.prototype, CodeGenerator.Expression); - - CodeGenerator.prototype.generateExpression = function (expr, precedence, flags) { - var result, type; + CodeGenerator.prototype.generateFunctionBody = function (node) { + var result, expr; - type = expr.type || Syntax.Property; + result = this.generateFunctionParams(node); - if (extra.verbatim && expr.hasOwnProperty(extra.verbatim)) { - return generateVerbatim(expr, precedence); + if (node.type === Syntax.ArrowFunctionExpression) { + result.push(space); + result.push('=>'); } - result = this[type](expr, precedence, flags); - - - if (extra.comment) { - result = addComments(expr,result); + if (node.expression) { + result.push(space); + expr = this.generateExpression(node.body, Precedence.Assignment, E_TTT); + if (expr.toString().charAt(0) === '{') { + expr = ['(', expr, ')']; + } + result.push(expr); + } else { + result.push(this.maybeBlock(node.body, S_TTFF)); } - return toSourceNodeWhenNeeded(result, expr); + + return result; }; - CodeGenerator.prototype.generateStatement = function (stmt, flags) { - var result, - fragment; + CodeGenerator.prototype.generateIterationForStatement = function (operator, stmt, flags) { + var result = ['for' + space + '('], that = this; + withIndent(function () { + if (stmt.left.type === Syntax.VariableDeclaration) { + withIndent(function () { + result.push(stmt.left.kind + noEmptySpace()); + result.push(that.generateStatement(stmt.left.declarations[0], S_FFFF)); + }); + } else { + result.push(that.generateExpression(stmt.left, Precedence.Call, E_TTT)); + } - result = this[stmt.type](stmt, flags); + result = join(result, operator); + result = [join( + result, + that.generateExpression(stmt.right, Precedence.Sequence, E_TTT) + ), ')']; + }); + result.push(this.maybeBlock(stmt.body, flags)); + return result; + }; - // Attach comments + CodeGenerator.prototype.generatePropertyKey = function (expr, computed) { + var result = []; - if (extra.comment) { - result = addComments(stmt, result); + if (computed) { + result.push('['); } - fragment = toSourceNodeWhenNeeded(result).toString(); - if (stmt.type === Syntax.Program && !safeConcatenation && newline === '' && fragment.charAt(fragment.length - 1) === '\n') { - result = sourceMap ? toSourceNodeWhenNeeded(result).replaceRight(/\s+$/, '') : fragment.replace(/\s+$/, ''); + result.push(this.generateExpression(expr, Precedence.Sequence, E_TTT)); + if (computed) { + result.push(']'); } - return toSourceNodeWhenNeeded(result, stmt); + return result; }; - function generateInternal(node) { - var codegen; - - codegen = new CodeGenerator(); - if (isStatement(node)) { - return codegen.generateStatement(node, S_TFFF); - } - - if (isExpression(node)) { - return codegen.generateExpression(node, Precedence.Sequence, E_TTT); + CodeGenerator.prototype.generateAssignment = function (left, right, operator, precedence, flags) { + if (Precedence.Assignment < precedence) { + flags |= F_ALLOW_IN; } - throw new Error('Unknown node type: ' + node.type); - } - - function generate(node, options) { - var defaultOptions = getDefaultOptions(), result, pair; - - if (options != null) { - // Obsolete options - // - // `options.indent` - // `options.base` - // - // Instead of them, we can use `option.format.indent`. - if (typeof options.indent === 'string') { - defaultOptions.format.indent.style = options.indent; - } - if (typeof options.base === 'number') { - defaultOptions.format.indent.base = options.base; - } - options = updateDeeply(defaultOptions, options); - indent = options.format.indent.style; - if (typeof options.base === 'string') { - base = options.base; - } else { - base = stringRepeat(indent, options.format.indent.base); - } - } else { - options = defaultOptions; - indent = options.format.indent.style; - base = stringRepeat(indent, options.format.indent.base); - } - json = options.format.json; - renumber = options.format.renumber; - hexadecimal = json ? false : options.format.hexadecimal; - quotes = json ? 'double' : options.format.quotes; - escapeless = options.format.escapeless; - newline = options.format.newline; - space = options.format.space; - if (options.format.compact) { - newline = space = indent = base = ''; - } - parentheses = options.format.parentheses; - semicolons = options.format.semicolons; - safeConcatenation = options.format.safeConcatenation; - directive = options.directive; - parse = json ? null : options.parse; - sourceMap = options.sourceMap; - sourceCode = options.sourceCode; - preserveBlankLines = options.format.preserveBlankLines && sourceCode !== null; - extra = options; + return parenthesize( + [ + this.generateExpression(left, Precedence.Call, flags), + space + operator + space, + this.generateExpression(right, Precedence.Assignment, flags) + ], + Precedence.Assignment, + precedence + ); + }; - if (sourceMap) { - if (!exports.browser) { - // We assume environment is node.js - // And prevent from including source-map by browserify - SourceNode = require('source-map').SourceNode; - } else { - SourceNode = global.sourceMap.SourceNode; - } + CodeGenerator.prototype.semicolon = function (flags) { + if (!semicolons && flags & F_SEMICOLON_OPT) { + return ''; } + return ';'; + }; - result = generateInternal(node); - - if (!sourceMap) { - pair = {code: result.toString(), map: null}; - return options.sourceMapWithCode ? pair : pair.code; - } + // Statements. + CodeGenerator.Statement = { - pair = result.toStringWithSourceMap({ - file: options.file, - sourceRoot: options.sourceMapRoot - }); + BlockStatement: function (stmt, flags) { + var range, content, result = ['{', newline], that = this; - if (options.sourceContent) { - pair.map.setSourceContent(options.sourceMap, - options.sourceContent); - } - - if (options.sourceMapWithCode) { - return pair; - } + withIndent(function () { + // handle functions without any code + if (stmt.body.length === 0 && preserveBlankLines) { + range = stmt.range; + if (range[1] - range[0] > 2) { + content = sourceCode.substring(range[0] + 1, range[1] - 1); + if (content[0] === '\n') { + result = ['{']; + } + result.push(content); + } + } - return pair.map.toString(); - } + var i, iz, fragment, bodyFlags; + bodyFlags = S_TFFF; + if (flags & F_FUNC_BODY) { + bodyFlags |= F_DIRECTIVE_CTX; + } - FORMAT_MINIFY = { - indent: { - style: '', - base: 0 - }, - renumber: true, - hexadecimal: true, - quotes: 'auto', - escapeless: true, - compact: true, - parentheses: false, - semicolons: false - }; + for (i = 0, iz = stmt.body.length; i < iz; ++i) { + if (preserveBlankLines) { + // handle spaces before the first line + if (i === 0) { + if (stmt.body[0].leadingComments) { + range = stmt.body[0].leadingComments[0].extendedRange; + content = sourceCode.substring(range[0], range[1]); + if (content[0] === '\n') { + result = ['{']; + } + } + if (!stmt.body[0].leadingComments) { + generateBlankLines(stmt.range[0], stmt.body[0].range[0], result); + } + } - FORMAT_DEFAULTS = getDefaultOptions().format; + // handle spaces between lines + if (i > 0) { + if (!stmt.body[i - 1].trailingComments && !stmt.body[i].leadingComments) { + generateBlankLines(stmt.body[i - 1].range[1], stmt.body[i].range[0], result); + } + } + } - exports.version = require('./package.json').version; - exports.generate = generate; - exports.attachComments = estraverse.attachComments; - exports.Precedence = updateDeeply({}, Precedence); - exports.browser = false; - exports.FORMAT_MINIFY = FORMAT_MINIFY; - exports.FORMAT_DEFAULTS = FORMAT_DEFAULTS; -}()); -/* vim: set sw=4 ts=4 et tw=80 : */ + if (i === iz - 1) { + bodyFlags |= F_SEMICOLON_OPT; + } -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/escodegen.js","/../node_modules/escodegen") -},{"./package.json":19,"1YiZ5S":25,"buffer":21,"estraverse":3,"esutils":7,"source-map":8}],3:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* - Copyright (C) 2012-2013 Yusuke Suzuki - Copyright (C) 2012 Ariya Hidayat + if (stmt.body[i].leadingComments && preserveBlankLines) { + fragment = that.generateStatement(stmt.body[i], bodyFlags); + } else { + fragment = addIndent(that.generateStatement(stmt.body[i], bodyFlags)); + } - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + result.push(fragment); + if (!endsWithLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { + if (preserveBlankLines && i < iz - 1) { + // don't add a new line if there are leading coments + // in the next statement + if (!stmt.body[i + 1].leadingComments) { + result.push(newline); + } + } else { + result.push(newline); + } + } - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + if (preserveBlankLines) { + // handle spaces after the last line + if (i === iz - 1) { + if (!stmt.body[i].trailingComments) { + generateBlankLines(stmt.body[i].range[1], stmt.range[1], result); + } + } + } + } + }); - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/*jslint vars:false, bitwise:true*/ -/*jshint indent:4*/ -/*global exports:true, define:true*/ -(function (root, factory) { - 'use strict'; + result.push(addIndent('}')); + return result; + }, - // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, - // and plain browser loading, - if (typeof define === 'function' && define.amd) { - define(['exports'], factory); - } else if (typeof exports !== 'undefined') { - factory(exports); - } else { - factory((root.estraverse = {})); - } -}(this, function clone(exports) { - 'use strict'; + BreakStatement: function (stmt, flags) { + if (stmt.label) { + return 'break ' + stmt.label.name + this.semicolon(flags); + } + return 'break' + this.semicolon(flags); + }, - var Syntax, - isArray, - VisitorOption, - VisitorKeys, - objectCreate, - objectKeys, - BREAK, - SKIP, - REMOVE; + ContinueStatement: function (stmt, flags) { + if (stmt.label) { + return 'continue ' + stmt.label.name + this.semicolon(flags); + } + return 'continue' + this.semicolon(flags); + }, - function ignoreJSHintError() { } + ClassBody: function (stmt, flags) { + var result = [ '{', newline], that = this; - isArray = Array.isArray; - if (!isArray) { - isArray = function isArray(array) { - return Object.prototype.toString.call(array) === '[object Array]'; - }; - } + withIndent(function (indent) { + var i, iz; - function deepCopy(obj) { - var ret = {}, key, val; - for (key in obj) { - if (obj.hasOwnProperty(key)) { - val = obj[key]; - if (typeof val === 'object' && val !== null) { - ret[key] = deepCopy(val); - } else { - ret[key] = val; + for (i = 0, iz = stmt.body.length; i < iz; ++i) { + result.push(indent); + result.push(that.generateExpression(stmt.body[i], Precedence.Sequence, E_TTT)); + if (i + 1 < iz) { + result.push(newline); + } } - } - } - return ret; - } + }); - function shallowCopy(obj) { - var ret = {}, key; - for (key in obj) { - if (obj.hasOwnProperty(key)) { - ret[key] = obj[key]; + if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { + result.push(newline); } - } - return ret; - } - ignoreJSHintError(shallowCopy); - - // based on LLVM libc++ upper_bound / lower_bound - // MIT License - - function upperBound(array, func) { - var diff, len, i, current; + result.push(base); + result.push('}'); + return result; + }, - len = array.length; - i = 0; + ClassDeclaration: function (stmt, flags) { + var result, fragment; + result = ['class ' + stmt.id.name]; + if (stmt.superClass) { + fragment = join('extends', this.generateExpression(stmt.superClass, Precedence.Assignment, E_TTT)); + result = join(result, fragment); + } + result.push(space); + result.push(this.generateStatement(stmt.body, S_TFFT)); + return result; + }, - while (len) { - diff = len >>> 1; - current = i + diff; - if (func(array[current])) { - len = diff; - } else { - i = current + 1; - len -= diff + 1; + DirectiveStatement: function (stmt, flags) { + if (extra.raw && stmt.raw) { + return stmt.raw + this.semicolon(flags); } - } - return i; - } + return escapeDirective(stmt.directive) + this.semicolon(flags); + }, - function lowerBound(array, func) { - var diff, len, i, current; + DoWhileStatement: function (stmt, flags) { + // Because `do 42 while (cond)` is Syntax Error. We need semicolon. + var result = join('do', this.maybeBlock(stmt.body, S_TFFF)); + result = this.maybeBlockSuffix(stmt.body, result); + return join(result, [ + 'while' + space + '(', + this.generateExpression(stmt.test, Precedence.Sequence, E_TTT), + ')' + this.semicolon(flags) + ]); + }, - len = array.length; - i = 0; + CatchClause: function (stmt, flags) { + var result, that = this; + withIndent(function () { + var guard; - while (len) { - diff = len >>> 1; - current = i + diff; - if (func(array[current])) { - i = current + 1; - len -= diff + 1; - } else { - len = diff; - } - } - return i; - } - ignoreJSHintError(lowerBound); + result = [ + 'catch' + space + '(', + that.generateExpression(stmt.param, Precedence.Sequence, E_TTT), + ')' + ]; - objectCreate = Object.create || (function () { - function F() { } + if (stmt.guard) { + guard = that.generateExpression(stmt.guard, Precedence.Sequence, E_TTT); + result.splice(2, 0, ' if ', guard); + } + }); + result.push(this.maybeBlock(stmt.body, S_TFFF)); + return result; + }, - return function (o) { - F.prototype = o; - return new F(); - }; - })(); + DebuggerStatement: function (stmt, flags) { + return 'debugger' + this.semicolon(flags); + }, - objectKeys = Object.keys || function (o) { - var keys = [], key; - for (key in o) { - keys.push(key); - } - return keys; - }; + EmptyStatement: function (stmt, flags) { + return ';'; + }, - function extend(to, from) { - var keys = objectKeys(from), key, i, len; - for (i = 0, len = keys.length; i < len; i += 1) { - key = keys[i]; - to[key] = from[key]; - } - return to; - } + ExportDefaultDeclaration: function (stmt, flags) { + var result = [ 'export' ], bodyFlags; - Syntax = { - AssignmentExpression: 'AssignmentExpression', - ArrayExpression: 'ArrayExpression', - ArrayPattern: 'ArrayPattern', - ArrowFunctionExpression: 'ArrowFunctionExpression', - AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7. - BlockStatement: 'BlockStatement', - BinaryExpression: 'BinaryExpression', - BreakStatement: 'BreakStatement', - CallExpression: 'CallExpression', - CatchClause: 'CatchClause', - ClassBody: 'ClassBody', - ClassDeclaration: 'ClassDeclaration', - ClassExpression: 'ClassExpression', - ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7. - ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7. - ConditionalExpression: 'ConditionalExpression', - ContinueStatement: 'ContinueStatement', - DebuggerStatement: 'DebuggerStatement', - DirectiveStatement: 'DirectiveStatement', - DoWhileStatement: 'DoWhileStatement', - EmptyStatement: 'EmptyStatement', - ExportBatchSpecifier: 'ExportBatchSpecifier', - ExportDeclaration: 'ExportDeclaration', - ExportSpecifier: 'ExportSpecifier', - ExpressionStatement: 'ExpressionStatement', - ForStatement: 'ForStatement', - ForInStatement: 'ForInStatement', - ForOfStatement: 'ForOfStatement', - FunctionDeclaration: 'FunctionDeclaration', - FunctionExpression: 'FunctionExpression', - GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7. - Identifier: 'Identifier', - IfStatement: 'IfStatement', - ImportDeclaration: 'ImportDeclaration', - ImportDefaultSpecifier: 'ImportDefaultSpecifier', - ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', - ImportSpecifier: 'ImportSpecifier', - Literal: 'Literal', - LabeledStatement: 'LabeledStatement', - LogicalExpression: 'LogicalExpression', - MemberExpression: 'MemberExpression', - MethodDefinition: 'MethodDefinition', - ModuleSpecifier: 'ModuleSpecifier', - NewExpression: 'NewExpression', - ObjectExpression: 'ObjectExpression', - ObjectPattern: 'ObjectPattern', - Program: 'Program', - Property: 'Property', - ReturnStatement: 'ReturnStatement', - SequenceExpression: 'SequenceExpression', - SpreadElement: 'SpreadElement', - SwitchStatement: 'SwitchStatement', - SwitchCase: 'SwitchCase', - TaggedTemplateExpression: 'TaggedTemplateExpression', - TemplateElement: 'TemplateElement', - TemplateLiteral: 'TemplateLiteral', - ThisExpression: 'ThisExpression', - ThrowStatement: 'ThrowStatement', - TryStatement: 'TryStatement', - UnaryExpression: 'UnaryExpression', - UpdateExpression: 'UpdateExpression', - VariableDeclaration: 'VariableDeclaration', - VariableDeclarator: 'VariableDeclarator', - WhileStatement: 'WhileStatement', - WithStatement: 'WithStatement', - YieldExpression: 'YieldExpression' - }; + bodyFlags = (flags & F_SEMICOLON_OPT) ? S_TFFT : S_TFFF; - VisitorKeys = { - AssignmentExpression: ['left', 'right'], - ArrayExpression: ['elements'], - ArrayPattern: ['elements'], - ArrowFunctionExpression: ['params', 'defaults', 'rest', 'body'], - AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7. - BlockStatement: ['body'], - BinaryExpression: ['left', 'right'], - BreakStatement: ['label'], - CallExpression: ['callee', 'arguments'], - CatchClause: ['param', 'body'], - ClassBody: ['body'], - ClassDeclaration: ['id', 'body', 'superClass'], - ClassExpression: ['id', 'body', 'superClass'], - ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7. - ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7. - ConditionalExpression: ['test', 'consequent', 'alternate'], - ContinueStatement: ['label'], - DebuggerStatement: [], - DirectiveStatement: [], - DoWhileStatement: ['body', 'test'], - EmptyStatement: [], - ExportBatchSpecifier: [], - ExportDeclaration: ['declaration', 'specifiers', 'source'], - ExportSpecifier: ['id', 'name'], - ExpressionStatement: ['expression'], - ForStatement: ['init', 'test', 'update', 'body'], - ForInStatement: ['left', 'right', 'body'], - ForOfStatement: ['left', 'right', 'body'], - FunctionDeclaration: ['id', 'params', 'defaults', 'rest', 'body'], - FunctionExpression: ['id', 'params', 'defaults', 'rest', 'body'], - GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7. - Identifier: [], - IfStatement: ['test', 'consequent', 'alternate'], - ImportDeclaration: ['specifiers', 'source'], - ImportDefaultSpecifier: ['id'], - ImportNamespaceSpecifier: ['id'], - ImportSpecifier: ['id', 'name'], - Literal: [], - LabeledStatement: ['label', 'body'], - LogicalExpression: ['left', 'right'], - MemberExpression: ['object', 'property'], - MethodDefinition: ['key', 'value'], - ModuleSpecifier: [], - NewExpression: ['callee', 'arguments'], - ObjectExpression: ['properties'], - ObjectPattern: ['properties'], - Program: ['body'], - Property: ['key', 'value'], - ReturnStatement: ['argument'], - SequenceExpression: ['expressions'], - SpreadElement: ['argument'], - SwitchStatement: ['discriminant', 'cases'], - SwitchCase: ['test', 'consequent'], - TaggedTemplateExpression: ['tag', 'quasi'], - TemplateElement: [], - TemplateLiteral: ['quasis', 'expressions'], - ThisExpression: [], - ThrowStatement: ['argument'], - TryStatement: ['block', 'handlers', 'handler', 'guardedHandlers', 'finalizer'], - UnaryExpression: ['argument'], - UpdateExpression: ['argument'], - VariableDeclaration: ['declarations'], - VariableDeclarator: ['id', 'init'], - WhileStatement: ['test', 'body'], - WithStatement: ['object', 'body'], - YieldExpression: ['argument'] - }; + // export default HoistableDeclaration[Default] + // export default AssignmentExpression[In] ; + result = join(result, 'default'); + if (isStatement(stmt.declaration)) { + result = join(result, this.generateStatement(stmt.declaration, bodyFlags)); + } else { + result = join(result, this.generateExpression(stmt.declaration, Precedence.Assignment, E_TTT) + this.semicolon(flags)); + } + return result; + }, - // unique id - BREAK = {}; - SKIP = {}; - REMOVE = {}; + ExportNamedDeclaration: function (stmt, flags) { + var result = [ 'export' ], bodyFlags, that = this; - VisitorOption = { - Break: BREAK, - Skip: SKIP, - Remove: REMOVE - }; + bodyFlags = (flags & F_SEMICOLON_OPT) ? S_TFFT : S_TFFF; - function Reference(parent, key) { - this.parent = parent; - this.key = key; - } + // export VariableStatement + // export Declaration[Default] + if (stmt.declaration) { + return join(result, this.generateStatement(stmt.declaration, bodyFlags)); + } - Reference.prototype.replace = function replace(node) { - this.parent[this.key] = node; - }; + // export ExportClause[NoReference] FromClause ; + // export ExportClause ; + if (stmt.specifiers) { + if (stmt.specifiers.length === 0) { + result = join(result, '{' + space + '}'); + } else if (stmt.specifiers[0].type === Syntax.ExportBatchSpecifier) { + result = join(result, this.generateExpression(stmt.specifiers[0], Precedence.Sequence, E_TTT)); + } else { + result = join(result, '{'); + withIndent(function (indent) { + var i, iz; + result.push(newline); + for (i = 0, iz = stmt.specifiers.length; i < iz; ++i) { + result.push(indent); + result.push(that.generateExpression(stmt.specifiers[i], Precedence.Sequence, E_TTT)); + if (i + 1 < iz) { + result.push(',' + newline); + } + } + }); + if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { + result.push(newline); + } + result.push(base + '}'); + } - Reference.prototype.remove = function remove() { - if (isArray(this.parent)) { - this.parent.splice(this.key, 1); - return true; - } else { - this.replace(null); - return false; - } - }; + if (stmt.source) { + result = join(result, [ + 'from' + space, + // ModuleSpecifier + this.generateExpression(stmt.source, Precedence.Sequence, E_TTT), + this.semicolon(flags) + ]); + } else { + result.push(this.semicolon(flags)); + } + } + return result; + }, - function Element(node, path, wrap, ref) { - this.node = node; - this.path = path; - this.wrap = wrap; - this.ref = ref; - } + ExportAllDeclaration: function (stmt, flags) { + // export * FromClause ; + return [ + 'export' + space, + '*' + space, + 'from' + space, + // ModuleSpecifier + this.generateExpression(stmt.source, Precedence.Sequence, E_TTT), + this.semicolon(flags) + ]; + }, - function Controller() { } + ExpressionStatement: function (stmt, flags) { + var result, fragment; - // API: - // return property path array from root to current node - Controller.prototype.path = function path() { - var i, iz, j, jz, result, element; + function isClassPrefixed(fragment) { + var code; + if (fragment.slice(0, 5) !== 'class') { + return false; + } + code = fragment.charCodeAt(5); + return code === 0x7B /* '{' */ || esutils.code.isWhiteSpace(code) || esutils.code.isLineTerminator(code); + } - function addToPath(result, path) { - if (isArray(path)) { - for (j = 0, jz = path.length; j < jz; ++j) { - result.push(path[j]); + function isFunctionPrefixed(fragment) { + var code; + if (fragment.slice(0, 8) !== 'function') { + return false; } - } else { - result.push(path); + code = fragment.charCodeAt(8); + return code === 0x28 /* '(' */ || esutils.code.isWhiteSpace(code) || code === 0x2A /* '*' */ || esutils.code.isLineTerminator(code); } - } - // root node - if (!this.__current.path) { - return null; - } + function isAsyncPrefixed(fragment) { + var code, i, iz; + if (fragment.slice(0, 5) !== 'async') { + return false; + } + if (!esutils.code.isWhiteSpace(fragment.charCodeAt(5))) { + return false; + } + for (i = 6, iz = fragment.length; i < iz; ++i) { + if (!esutils.code.isWhiteSpace(fragment.charCodeAt(i))) { + break; + } + } + if (i === iz) { + return false; + } + if (fragment.slice(i, i + 8) !== 'function') { + return false; + } + code = fragment.charCodeAt(i + 8); + return code === 0x28 /* '(' */ || esutils.code.isWhiteSpace(code) || code === 0x2A /* '*' */ || esutils.code.isLineTerminator(code); + } - // first node is sentinel, second node is root element - result = []; - for (i = 2, iz = this.__leavelist.length; i < iz; ++i) { - element = this.__leavelist[i]; - addToPath(result, element.path); - } - addToPath(result, this.__current.path); - return result; - }; + result = [this.generateExpression(stmt.expression, Precedence.Sequence, E_TTT)]; + // 12.4 '{', 'function', 'class' is not allowed in this position. + // wrap expression with parentheses + fragment = toSourceNodeWhenNeeded(result).toString(); + if (fragment.charCodeAt(0) === 0x7B /* '{' */ || // ObjectExpression + isClassPrefixed(fragment) || + isFunctionPrefixed(fragment) || + isAsyncPrefixed(fragment) || + (directive && (flags & F_DIRECTIVE_CTX) && stmt.expression.type === Syntax.Literal && typeof stmt.expression.value === 'string')) { + result = ['(', result, ')' + this.semicolon(flags)]; + } else { + result.push(this.semicolon(flags)); + } + return result; + }, - // API: - // return type of current node - Controller.prototype.type = function () { - var node = this.current(); - return node.type || this.__current.wrap; - }; + ImportDeclaration: function (stmt, flags) { + // ES6: 15.2.1 valid import declarations: + // - import ImportClause FromClause ; + // - import ModuleSpecifier ; + var result, cursor, that = this; - // API: - // return array of parent elements - Controller.prototype.parents = function parents() { - var i, iz, result; + // If no ImportClause is present, + // this should be `import ModuleSpecifier` so skip `from` + // ModuleSpecifier is StringLiteral. + if (stmt.specifiers.length === 0) { + // import ModuleSpecifier ; + return [ + 'import', + space, + // ModuleSpecifier + this.generateExpression(stmt.source, Precedence.Sequence, E_TTT), + this.semicolon(flags) + ]; + } - // first node is sentinel - result = []; - for (i = 1, iz = this.__leavelist.length; i < iz; ++i) { - result.push(this.__leavelist[i].node); - } + // import ImportClause FromClause ; + result = [ + 'import' + ]; + cursor = 0; - return result; - }; + // ImportedBinding + if (stmt.specifiers[cursor].type === Syntax.ImportDefaultSpecifier) { + result = join(result, [ + this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT) + ]); + ++cursor; + } - // API: - // return current node - Controller.prototype.current = function current() { - return this.__current.node; - }; + if (stmt.specifiers[cursor]) { + if (cursor !== 0) { + result.push(','); + } - Controller.prototype.__execute = function __execute(callback, element) { - var previous, result; + if (stmt.specifiers[cursor].type === Syntax.ImportNamespaceSpecifier) { + // NameSpaceImport + result = join(result, [ + space, + this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT) + ]); + } else { + // NamedImports + result.push(space + '{'); - result = undefined; + if ((stmt.specifiers.length - cursor) === 1) { + // import { ... } from "..."; + result.push(space); + result.push(this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT)); + result.push(space + '}' + space); + } else { + // import { + // ..., + // ..., + // } from "..."; + withIndent(function (indent) { + var i, iz; + result.push(newline); + for (i = cursor, iz = stmt.specifiers.length; i < iz; ++i) { + result.push(indent); + result.push(that.generateExpression(stmt.specifiers[i], Precedence.Sequence, E_TTT)); + if (i + 1 < iz) { + result.push(',' + newline); + } + } + }); + if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { + result.push(newline); + } + result.push(base + '}' + space); + } + } + } - previous = this.__current; - this.__current = element; - this.__state = null; - if (callback) { - result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node); - } - this.__current = previous; + result = join(result, [ + 'from' + space, + // ModuleSpecifier + this.generateExpression(stmt.source, Precedence.Sequence, E_TTT), + this.semicolon(flags) + ]); + return result; + }, - return result; - }; + VariableDeclarator: function (stmt, flags) { + var itemFlags = (flags & F_ALLOW_IN) ? E_TTT : E_FTT; + if (stmt.init) { + return [ + this.generateExpression(stmt.id, Precedence.Assignment, itemFlags), + space, + '=', + space, + this.generateExpression(stmt.init, Precedence.Assignment, itemFlags) + ]; + } + return this.generatePattern(stmt.id, Precedence.Assignment, itemFlags); + }, - // API: - // notify control skip / break - Controller.prototype.notify = function notify(flag) { - this.__state = flag; - }; + VariableDeclaration: function (stmt, flags) { + // VariableDeclarator is typed as Statement, + // but joined with comma (not LineTerminator). + // So if comment is attached to target node, we should specialize. + var result, i, iz, node, bodyFlags, that = this; - // API: - // skip child nodes of current node - Controller.prototype.skip = function () { - this.notify(SKIP); - }; + result = [ stmt.kind ]; - // API: - // break traversals - Controller.prototype['break'] = function () { - this.notify(BREAK); - }; + bodyFlags = (flags & F_ALLOW_IN) ? S_TFFF : S_FFFF; - // API: - // remove node - Controller.prototype.remove = function () { - this.notify(REMOVE); - }; - - Controller.prototype.__initialize = function(root, visitor) { - this.visitor = visitor; - this.root = root; - this.__worklist = []; - this.__leavelist = []; - this.__current = null; - this.__state = null; - this.__fallback = visitor.fallback === 'iteration'; - this.__keys = VisitorKeys; - if (visitor.keys) { - this.__keys = extend(objectCreate(this.__keys), visitor.keys); - } - }; - - function isNode(node) { - if (node == null) { - return false; - } - return typeof node === 'object' && typeof node.type === 'string'; - } - - function isProperty(nodeType, key) { - return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key; - } - - Controller.prototype.traverse = function traverse(root, visitor) { - var worklist, - leavelist, - element, - node, - nodeType, - ret, - key, - current, - current2, - candidates, - candidate, - sentinel; - - this.__initialize(root, visitor); - - sentinel = {}; - - // reference - worklist = this.__worklist; - leavelist = this.__leavelist; - - // initialize - worklist.push(new Element(root, null, null, null)); - leavelist.push(new Element(null, null, null, null)); - - while (worklist.length) { - element = worklist.pop(); - - if (element === sentinel) { - element = leavelist.pop(); - - ret = this.__execute(visitor.leave, element); + function block() { + node = stmt.declarations[0]; + if (extra.comment && node.leadingComments) { + result.push('\n'); + result.push(addIndent(that.generateStatement(node, bodyFlags))); + } else { + result.push(noEmptySpace()); + result.push(that.generateStatement(node, bodyFlags)); + } - if (this.__state === BREAK || ret === BREAK) { - return; + for (i = 1, iz = stmt.declarations.length; i < iz; ++i) { + node = stmt.declarations[i]; + if (extra.comment && node.leadingComments) { + result.push(',' + newline); + result.push(addIndent(that.generateStatement(node, bodyFlags))); + } else { + result.push(',' + space); + result.push(that.generateStatement(node, bodyFlags)); + } } - continue; } - if (element.node) { + if (stmt.declarations.length > 1) { + withIndent(block); + } else { + block(); + } - ret = this.__execute(visitor.enter, element); + result.push(this.semicolon(flags)); - if (this.__state === BREAK || ret === BREAK) { - return; - } + return result; + }, - worklist.push(sentinel); - leavelist.push(element); + ThrowStatement: function (stmt, flags) { + return [join( + 'throw', + this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT) + ), this.semicolon(flags)]; + }, - if (this.__state === SKIP || ret === SKIP) { - continue; - } + TryStatement: function (stmt, flags) { + var result, i, iz, guardedHandlers; - node = element.node; - nodeType = element.wrap || node.type; - candidates = this.__keys[nodeType]; - if (!candidates) { - if (this.__fallback) { - candidates = objectKeys(node); - } else { - throw new Error('Unknown node type ' + nodeType + '.'); + result = ['try', this.maybeBlock(stmt.block, S_TFFF)]; + result = this.maybeBlockSuffix(stmt.block, result); + + if (stmt.handlers) { + // old interface + for (i = 0, iz = stmt.handlers.length; i < iz; ++i) { + result = join(result, this.generateStatement(stmt.handlers[i], S_TFFF)); + if (stmt.finalizer || i + 1 !== iz) { + result = this.maybeBlockSuffix(stmt.handlers[i].body, result); } } + } else { + guardedHandlers = stmt.guardedHandlers || []; - current = candidates.length; - while ((current -= 1) >= 0) { - key = candidates[current]; - candidate = node[key]; - if (!candidate) { - continue; + for (i = 0, iz = guardedHandlers.length; i < iz; ++i) { + result = join(result, this.generateStatement(guardedHandlers[i], S_TFFF)); + if (stmt.finalizer || i + 1 !== iz) { + result = this.maybeBlockSuffix(guardedHandlers[i].body, result); } + } - if (isArray(candidate)) { - current2 = candidate.length; - while ((current2 -= 1) >= 0) { - if (!candidate[current2]) { - continue; - } - if (isProperty(nodeType, candidates[current])) { - element = new Element(candidate[current2], [key, current2], 'Property', null); - } else if (isNode(candidate[current2])) { - element = new Element(candidate[current2], [key, current2], null, null); - } else { - continue; + // new interface + if (stmt.handler) { + if (isArray(stmt.handler)) { + for (i = 0, iz = stmt.handler.length; i < iz; ++i) { + result = join(result, this.generateStatement(stmt.handler[i], S_TFFF)); + if (stmt.finalizer || i + 1 !== iz) { + result = this.maybeBlockSuffix(stmt.handler[i].body, result); } - worklist.push(element); } - } else if (isNode(candidate)) { - worklist.push(new Element(candidate, key, null, null)); + } else { + result = join(result, this.generateStatement(stmt.handler, S_TFFF)); + if (stmt.finalizer) { + result = this.maybeBlockSuffix(stmt.handler.body, result); + } } } } - } - }; - - Controller.prototype.replace = function replace(root, visitor) { - function removeElem(element) { - var i, - key, - nextElem, - parent; - - if (element.ref.remove()) { - // When the reference is an element of an array. - key = element.ref.key; - parent = element.ref.parent; + if (stmt.finalizer) { + result = join(result, ['finally', this.maybeBlock(stmt.finalizer, S_TFFF)]); + } + return result; + }, - // If removed from array, then decrease following items' keys. - i = worklist.length; - while (i--) { - nextElem = worklist[i]; - if (nextElem.ref && nextElem.ref.parent === parent) { - if (nextElem.ref.key < key) { - break; - } - --nextElem.ref.key; + SwitchStatement: function (stmt, flags) { + var result, fragment, i, iz, bodyFlags, that = this; + withIndent(function () { + result = [ + 'switch' + space + '(', + that.generateExpression(stmt.discriminant, Precedence.Sequence, E_TTT), + ')' + space + '{' + newline + ]; + }); + if (stmt.cases) { + bodyFlags = S_TFFF; + for (i = 0, iz = stmt.cases.length; i < iz; ++i) { + if (i === iz - 1) { + bodyFlags |= F_SEMICOLON_OPT; + } + fragment = addIndent(this.generateStatement(stmt.cases[i], bodyFlags)); + result.push(fragment); + if (!endsWithLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { + result.push(newline); } } } - } + result.push(addIndent('}')); + return result; + }, - var worklist, - leavelist, - node, - nodeType, - target, - element, - current, - current2, - candidates, - candidate, - sentinel, - outer, - key; + SwitchCase: function (stmt, flags) { + var result, fragment, i, iz, bodyFlags, that = this; + withIndent(function () { + if (stmt.test) { + result = [ + join('case', that.generateExpression(stmt.test, Precedence.Sequence, E_TTT)), + ':' + ]; + } else { + result = ['default:']; + } - this.__initialize(root, visitor); + i = 0; + iz = stmt.consequent.length; + if (iz && stmt.consequent[0].type === Syntax.BlockStatement) { + fragment = that.maybeBlock(stmt.consequent[0], S_TFFF); + result.push(fragment); + i = 1; + } - sentinel = {}; + if (i !== iz && !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { + result.push(newline); + } - // reference - worklist = this.__worklist; - leavelist = this.__leavelist; - - // initialize - outer = { - root: root - }; - element = new Element(root, null, null, new Reference(outer, 'root')); - worklist.push(element); - leavelist.push(element); - - while (worklist.length) { - element = worklist.pop(); - - if (element === sentinel) { - element = leavelist.pop(); - - target = this.__execute(visitor.leave, element); + bodyFlags = S_TFFF; + for (; i < iz; ++i) { + if (i === iz - 1 && flags & F_SEMICOLON_OPT) { + bodyFlags |= F_SEMICOLON_OPT; + } + fragment = addIndent(that.generateStatement(stmt.consequent[i], bodyFlags)); + result.push(fragment); + if (i + 1 !== iz && !endsWithLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { + result.push(newline); + } + } + }); + return result; + }, - // node may be replaced with null, - // so distinguish between undefined and null in this place - if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) { - // replace - element.ref.replace(target); + IfStatement: function (stmt, flags) { + var result, bodyFlags, semicolonOptional, that = this; + withIndent(function () { + result = [ + 'if' + space + '(', + that.generateExpression(stmt.test, Precedence.Sequence, E_TTT), + ')' + ]; + }); + semicolonOptional = flags & F_SEMICOLON_OPT; + bodyFlags = S_TFFF; + if (semicolonOptional) { + bodyFlags |= F_SEMICOLON_OPT; + } + if (stmt.alternate) { + result.push(this.maybeBlock(stmt.consequent, S_TFFF)); + result = this.maybeBlockSuffix(stmt.consequent, result); + if (stmt.alternate.type === Syntax.IfStatement) { + result = join(result, ['else ', this.generateStatement(stmt.alternate, bodyFlags)]); + } else { + result = join(result, join('else', this.maybeBlock(stmt.alternate, bodyFlags))); } + } else { + result.push(this.maybeBlock(stmt.consequent, bodyFlags)); + } + return result; + }, - if (this.__state === REMOVE || target === REMOVE) { - removeElem(element); + ForStatement: function (stmt, flags) { + var result, that = this; + withIndent(function () { + result = ['for' + space + '(']; + if (stmt.init) { + if (stmt.init.type === Syntax.VariableDeclaration) { + result.push(that.generateStatement(stmt.init, S_FFFF)); + } else { + // F_ALLOW_IN becomes false. + result.push(that.generateExpression(stmt.init, Precedence.Sequence, E_FTT)); + result.push(';'); + } + } else { + result.push(';'); } - if (this.__state === BREAK || target === BREAK) { - return outer.root; + if (stmt.test) { + result.push(space); + result.push(that.generateExpression(stmt.test, Precedence.Sequence, E_TTT)); + result.push(';'); + } else { + result.push(';'); } - continue; - } - target = this.__execute(visitor.enter, element); + if (stmt.update) { + result.push(space); + result.push(that.generateExpression(stmt.update, Precedence.Sequence, E_TTT)); + result.push(')'); + } else { + result.push(')'); + } + }); - // node may be replaced with null, - // so distinguish between undefined and null in this place - if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) { - // replace - element.ref.replace(target); - element.node = target; - } + result.push(this.maybeBlock(stmt.body, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF)); + return result; + }, - if (this.__state === REMOVE || target === REMOVE) { - removeElem(element); - element.node = null; - } + ForInStatement: function (stmt, flags) { + return this.generateIterationForStatement('in', stmt, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF); + }, - if (this.__state === BREAK || target === BREAK) { - return outer.root; - } + ForOfStatement: function (stmt, flags) { + return this.generateIterationForStatement('of', stmt, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF); + }, - // node may be null - node = element.node; - if (!node) { - continue; - } + LabeledStatement: function (stmt, flags) { + return [stmt.label.name + ':', this.maybeBlock(stmt.body, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF)]; + }, - worklist.push(sentinel); - leavelist.push(element); + Program: function (stmt, flags) { + var result, fragment, i, iz, bodyFlags; + iz = stmt.body.length; + result = [safeConcatenation && iz > 0 ? '\n' : '']; + bodyFlags = S_TFTF; + for (i = 0; i < iz; ++i) { + if (!safeConcatenation && i === iz - 1) { + bodyFlags |= F_SEMICOLON_OPT; + } - if (this.__state === SKIP || target === SKIP) { - continue; - } + if (preserveBlankLines) { + // handle spaces before the first line + if (i === 0) { + if (!stmt.body[0].leadingComments) { + generateBlankLines(stmt.range[0], stmt.body[i].range[0], result); + } + } - nodeType = element.wrap || node.type; - candidates = this.__keys[nodeType]; - if (!candidates) { - if (this.__fallback) { - candidates = objectKeys(node); - } else { - throw new Error('Unknown node type ' + nodeType + '.'); + // handle spaces between lines + if (i > 0) { + if (!stmt.body[i - 1].trailingComments && !stmt.body[i].leadingComments) { + generateBlankLines(stmt.body[i - 1].range[1], stmt.body[i].range[0], result); + } + } } - } - current = candidates.length; - while ((current -= 1) >= 0) { - key = candidates[current]; - candidate = node[key]; - if (!candidate) { - continue; + fragment = addIndent(this.generateStatement(stmt.body[i], bodyFlags)); + result.push(fragment); + if (i + 1 < iz && !endsWithLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { + if (preserveBlankLines) { + if (!stmt.body[i + 1].leadingComments) { + result.push(newline); + } + } else { + result.push(newline); + } } - if (isArray(candidate)) { - current2 = candidate.length; - while ((current2 -= 1) >= 0) { - if (!candidate[current2]) { - continue; - } - if (isProperty(nodeType, candidates[current])) { - element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2)); - } else if (isNode(candidate[current2])) { - element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2)); - } else { - continue; + if (preserveBlankLines) { + // handle spaces after the last line + if (i === iz - 1) { + if (!stmt.body[i].trailingComments) { + generateBlankLines(stmt.body[i].range[1], stmt.range[1], result); } - worklist.push(element); } - } else if (isNode(candidate)) { - worklist.push(new Element(candidate, key, null, new Reference(node, key))); } } + return result; + }, + + FunctionDeclaration: function (stmt, flags) { + return [ + generateAsyncPrefix(stmt, true), + 'function', + generateStarSuffix(stmt) || noEmptySpace(), + stmt.id ? generateIdentifier(stmt.id) : '', + this.generateFunctionBody(stmt) + ]; + }, + + ReturnStatement: function (stmt, flags) { + if (stmt.argument) { + return [join( + 'return', + this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT) + ), this.semicolon(flags)]; + } + return ['return' + this.semicolon(flags)]; + }, + + WhileStatement: function (stmt, flags) { + var result, that = this; + withIndent(function () { + result = [ + 'while' + space + '(', + that.generateExpression(stmt.test, Precedence.Sequence, E_TTT), + ')' + ]; + }); + result.push(this.maybeBlock(stmt.body, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF)); + return result; + }, + + WithStatement: function (stmt, flags) { + var result, that = this; + withIndent(function () { + result = [ + 'with' + space + '(', + that.generateExpression(stmt.object, Precedence.Sequence, E_TTT), + ')' + ]; + }); + result.push(this.maybeBlock(stmt.body, flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF)); + return result; } - return outer.root; }; - function traverse(root, visitor) { - var controller = new Controller(); - return controller.traverse(root, visitor); - } + merge(CodeGenerator.prototype, CodeGenerator.Statement); - function replace(root, visitor) { - var controller = new Controller(); - return controller.replace(root, visitor); - } + // Expressions. - function extendCommentRange(comment, tokens) { - var target; - - target = upperBound(tokens, function search(token) { - return token.range[0] > comment.range[0]; - }); + CodeGenerator.Expression = { - comment.extendedRange = [comment.range[0], comment.range[1]]; + SequenceExpression: function (expr, precedence, flags) { + var result, i, iz; + if (Precedence.Sequence < precedence) { + flags |= F_ALLOW_IN; + } + result = []; + for (i = 0, iz = expr.expressions.length; i < iz; ++i) { + result.push(this.generateExpression(expr.expressions[i], Precedence.Assignment, flags)); + if (i + 1 < iz) { + result.push(',' + space); + } + } + return parenthesize(result, Precedence.Sequence, precedence); + }, - if (target !== tokens.length) { - comment.extendedRange[1] = tokens[target].range[0]; - } + AssignmentExpression: function (expr, precedence, flags) { + return this.generateAssignment(expr.left, expr.right, expr.operator, precedence, flags); + }, - target -= 1; - if (target >= 0) { - comment.extendedRange[0] = tokens[target].range[1]; - } + ArrowFunctionExpression: function (expr, precedence, flags) { + return parenthesize(this.generateFunctionBody(expr), Precedence.ArrowFunction, precedence); + }, - return comment; - } + ConditionalExpression: function (expr, precedence, flags) { + if (Precedence.Conditional < precedence) { + flags |= F_ALLOW_IN; + } + return parenthesize( + [ + this.generateExpression(expr.test, Precedence.LogicalOR, flags), + space + '?' + space, + this.generateExpression(expr.consequent, Precedence.Assignment, flags), + space + ':' + space, + this.generateExpression(expr.alternate, Precedence.Assignment, flags) + ], + Precedence.Conditional, + precedence + ); + }, - function attachComments(tree, providedComments, tokens) { - // At first, we should calculate extended comment ranges. - var comments = [], comment, len, i, cursor; + LogicalExpression: function (expr, precedence, flags) { + return this.BinaryExpression(expr, precedence, flags); + }, - if (!tree.range) { - throw new Error('attachComments needs range information'); - } + BinaryExpression: function (expr, precedence, flags) { + var result, currentPrecedence, fragment, leftSource; + currentPrecedence = BinaryPrecedence[expr.operator]; - // tokens array is empty, we attach comments to tree as 'leadingComments' - if (!tokens.length) { - if (providedComments.length) { - for (i = 0, len = providedComments.length; i < len; i += 1) { - comment = deepCopy(providedComments[i]); - comment.extendedRange = [0, tree.range[0]]; - comments.push(comment); - } - tree.leadingComments = comments; + if (currentPrecedence < precedence) { + flags |= F_ALLOW_IN; } - return tree; - } - for (i = 0, len = providedComments.length; i < len; i += 1) { - comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens)); - } + fragment = this.generateExpression(expr.left, currentPrecedence, flags); - // This is based on John Freeman's implementation. - cursor = 0; - traverse(tree, { - enter: function (node) { - var comment; + leftSource = fragment.toString(); - while (cursor < comments.length) { - comment = comments[cursor]; - if (comment.extendedRange[1] > node.range[0]) { - break; - } + if (leftSource.charCodeAt(leftSource.length - 1) === 0x2F /* / */ && esutils.code.isIdentifierPartES5(expr.operator.charCodeAt(0))) { + result = [fragment, noEmptySpace(), expr.operator]; + } else { + result = join(fragment, expr.operator); + } - if (comment.extendedRange[1] === node.range[0]) { - if (!node.leadingComments) { - node.leadingComments = []; - } - node.leadingComments.push(comment); - comments.splice(cursor, 1); - } else { - cursor += 1; - } - } + fragment = this.generateExpression(expr.right, currentPrecedence + 1, flags); - // already out of owned node - if (cursor === comments.length) { - return VisitorOption.Break; - } + if (expr.operator === '/' && fragment.toString().charAt(0) === '/' || + expr.operator.slice(-1) === '<' && fragment.toString().slice(0, 3) === '!--') { + // If '/' concats with '/' or `<` concats with `!--`, it is interpreted as comment start + result.push(noEmptySpace()); + result.push(fragment); + } else { + result = join(result, fragment); + } - if (comments[cursor].extendedRange[0] > node.range[1]) { - return VisitorOption.Skip; + if (expr.operator === 'in' && !(flags & F_ALLOW_IN)) { + return ['(', result, ')']; + } + return parenthesize(result, currentPrecedence, precedence); + }, + + CallExpression: function (expr, precedence, flags) { + var result, i, iz; + // F_ALLOW_UNPARATH_NEW becomes false. + result = [this.generateExpression(expr.callee, Precedence.Call, E_TTF)]; + result.push('('); + for (i = 0, iz = expr['arguments'].length; i < iz; ++i) { + result.push(this.generateExpression(expr['arguments'][i], Precedence.Assignment, E_TTT)); + if (i + 1 < iz) { + result.push(',' + space); } } - }); + result.push(')'); - cursor = 0; - traverse(tree, { - leave: function (node) { - var comment; + if (!(flags & F_ALLOW_CALL)) { + return ['(', result, ')']; + } + return parenthesize(result, Precedence.Call, precedence); + }, - while (cursor < comments.length) { - comment = comments[cursor]; - if (node.range[1] < comment.extendedRange[0]) { - break; - } + NewExpression: function (expr, precedence, flags) { + var result, length, i, iz, itemFlags; + length = expr['arguments'].length; - if (node.range[1] === comment.extendedRange[0]) { - if (!node.trailingComments) { - node.trailingComments = []; - } - node.trailingComments.push(comment); - comments.splice(cursor, 1); - } else { - cursor += 1; - } - } + // F_ALLOW_CALL becomes false. + // F_ALLOW_UNPARATH_NEW may become false. + itemFlags = (flags & F_ALLOW_UNPARATH_NEW && !parentheses && length === 0) ? E_TFT : E_TFF; - // already out of owned node - if (cursor === comments.length) { - return VisitorOption.Break; - } + result = join( + 'new', + this.generateExpression(expr.callee, Precedence.New, itemFlags) + ); - if (comments[cursor].extendedRange[0] > node.range[1]) { - return VisitorOption.Skip; + if (!(flags & F_ALLOW_UNPARATH_NEW) || parentheses || length > 0) { + result.push('('); + for (i = 0, iz = length; i < iz; ++i) { + result.push(this.generateExpression(expr['arguments'][i], Precedence.Assignment, E_TTT)); + if (i + 1 < iz) { + result.push(',' + space); + } } + result.push(')'); } - }); - return tree; - } + return parenthesize(result, Precedence.New, precedence); + }, - exports.version = '1.8.1-dev'; - exports.Syntax = Syntax; - exports.traverse = traverse; - exports.replace = replace; - exports.attachComments = attachComments; - exports.VisitorKeys = VisitorKeys; - exports.VisitorOption = VisitorOption; - exports.Controller = Controller; - exports.cloneEnvironment = function () { return clone({}); }; + MemberExpression: function (expr, precedence, flags) { + var result, fragment; - return exports; -})); -/* vim: set sw=4 ts=4 et tw=80 : */ + // F_ALLOW_UNPARATH_NEW becomes false. + result = [this.generateExpression(expr.object, Precedence.Call, (flags & F_ALLOW_CALL) ? E_TTF : E_TFF)]; -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/estraverse/estraverse.js","/../node_modules/escodegen/node_modules/estraverse") -},{"1YiZ5S":25,"buffer":21}],4:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* - Copyright (C) 2013 Yusuke Suzuki + if (expr.computed) { + result.push('['); + result.push(this.generateExpression(expr.property, Precedence.Sequence, flags & F_ALLOW_CALL ? E_TTT : E_TFT)); + result.push(']'); + } else { + if (expr.object.type === Syntax.Literal && typeof expr.object.value === 'number') { + fragment = toSourceNodeWhenNeeded(result).toString(); + // When the following conditions are all true, + // 1. No floating point + // 2. Don't have exponents + // 3. The last character is a decimal digit + // 4. Not hexadecimal OR octal number literal + // we should add a floating point. + if ( + fragment.indexOf('.') < 0 && + !/[eExX]/.test(fragment) && + esutils.code.isDecimalDigit(fragment.charCodeAt(fragment.length - 1)) && + !(fragment.length >= 2 && fragment.charCodeAt(0) === 48) // '0' + ) { + result.push('.'); + } + } + result.push('.'); + result.push(generateIdentifier(expr.property)); + } - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + return parenthesize(result, Precedence.Member, precedence); + }, - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + MetaProperty: function (expr, precedence, flags) { + var result; + result = []; + result.push(expr.meta); + result.push('.'); + result.push(expr.property); + return parenthesize(result, Precedence.Member, precedence); + }, - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -(function () { - 'use strict'; + UnaryExpression: function (expr, precedence, flags) { + var result, fragment, rightCharCode, leftSource, leftCharCode; + fragment = this.generateExpression(expr.argument, Precedence.Unary, E_TTT); - function isExpression(node) { - if (node == null) { return false; } - switch (node.type) { - case 'ArrayExpression': - case 'AssignmentExpression': - case 'BinaryExpression': - case 'CallExpression': - case 'ConditionalExpression': - case 'FunctionExpression': - case 'Identifier': - case 'Literal': - case 'LogicalExpression': - case 'MemberExpression': - case 'NewExpression': - case 'ObjectExpression': - case 'SequenceExpression': - case 'ThisExpression': - case 'UnaryExpression': - case 'UpdateExpression': - return true; - } - return false; - } + if (space === '') { + result = join(expr.operator, fragment); + } else { + result = [expr.operator]; + if (expr.operator.length > 2) { + // delete, void, typeof + // get `typeof []`, not `typeof[]` + result = join(result, fragment); + } else { + // Prevent inserting spaces between operator and argument if it is unnecessary + // like, `!cond` + leftSource = toSourceNodeWhenNeeded(result).toString(); + leftCharCode = leftSource.charCodeAt(leftSource.length - 1); + rightCharCode = fragment.toString().charCodeAt(0); - function isIterationStatement(node) { - if (node == null) { return false; } - switch (node.type) { - case 'DoWhileStatement': - case 'ForInStatement': - case 'ForStatement': - case 'WhileStatement': - return true; - } - return false; - } + if (((leftCharCode === 0x2B /* + */ || leftCharCode === 0x2D /* - */) && leftCharCode === rightCharCode) || + (esutils.code.isIdentifierPartES5(leftCharCode) && esutils.code.isIdentifierPartES5(rightCharCode))) { + result.push(noEmptySpace()); + result.push(fragment); + } else { + result.push(fragment); + } + } + } + return parenthesize(result, Precedence.Unary, precedence); + }, - function isStatement(node) { - if (node == null) { return false; } - switch (node.type) { - case 'BlockStatement': - case 'BreakStatement': - case 'ContinueStatement': - case 'DebuggerStatement': - case 'DoWhileStatement': - case 'EmptyStatement': - case 'ExpressionStatement': - case 'ForInStatement': - case 'ForStatement': - case 'IfStatement': - case 'LabeledStatement': - case 'ReturnStatement': - case 'SwitchStatement': - case 'ThrowStatement': - case 'TryStatement': - case 'VariableDeclaration': - case 'WhileStatement': - case 'WithStatement': - return true; - } - return false; - } + YieldExpression: function (expr, precedence, flags) { + var result; + if (expr.delegate) { + result = 'yield*'; + } else { + result = 'yield'; + } + if (expr.argument) { + result = join( + result, + this.generateExpression(expr.argument, Precedence.Yield, E_TTT) + ); + } + return parenthesize(result, Precedence.Yield, precedence); + }, - function isSourceElement(node) { - return isStatement(node) || node != null && node.type === 'FunctionDeclaration'; - } + AwaitExpression: function (expr, precedence, flags) { + var result = join( + expr.all ? 'await*' : 'await', + this.generateExpression(expr.argument, Precedence.Await, E_TTT) + ); + return parenthesize(result, Precedence.Await, precedence); + }, - function trailingStatement(node) { - switch (node.type) { - case 'IfStatement': - if (node.alternate != null) { - return node.alternate; + UpdateExpression: function (expr, precedence, flags) { + if (expr.prefix) { + return parenthesize( + [ + expr.operator, + this.generateExpression(expr.argument, Precedence.Unary, E_TTT) + ], + Precedence.Unary, + precedence + ); } - return node.consequent; + return parenthesize( + [ + this.generateExpression(expr.argument, Precedence.Postfix, E_TTT), + expr.operator + ], + Precedence.Postfix, + precedence + ); + }, - case 'LabeledStatement': - case 'ForStatement': - case 'ForInStatement': - case 'WhileStatement': - case 'WithStatement': - return node.body; - } - return null; - } + FunctionExpression: function (expr, precedence, flags) { + var result = [ + generateAsyncPrefix(expr, true), + 'function' + ]; + if (expr.id) { + result.push(generateStarSuffix(expr) || noEmptySpace()); + result.push(generateIdentifier(expr.id)); + } else { + result.push(generateStarSuffix(expr) || space); + } + result.push(this.generateFunctionBody(expr)); + return result; + }, - function isProblematicIfStatement(node) { - var current; + ArrayPattern: function (expr, precedence, flags) { + return this.ArrayExpression(expr, precedence, flags, true); + }, - if (node.type !== 'IfStatement') { - return false; - } - if (node.alternate == null) { - return false; - } - current = node.consequent; - do { - if (current.type === 'IfStatement') { - if (current.alternate == null) { - return true; + ArrayExpression: function (expr, precedence, flags, isPattern) { + var result, multiline, that = this; + if (!expr.elements.length) { + return '[]'; + } + multiline = isPattern ? false : expr.elements.length > 1; + result = ['[', multiline ? newline : '']; + withIndent(function (indent) { + var i, iz; + for (i = 0, iz = expr.elements.length; i < iz; ++i) { + if (!expr.elements[i]) { + if (multiline) { + result.push(indent); + } + if (i + 1 === iz) { + result.push(','); + } + } else { + result.push(multiline ? indent : ''); + result.push(that.generateExpression(expr.elements[i], Precedence.Assignment, E_TTT)); + } + if (i + 1 < iz) { + result.push(',' + (multiline ? newline : space)); + } } + }); + if (multiline && !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { + result.push(newline); } - current = trailingStatement(current); - } while (current); - - return false; - } - - module.exports = { - isExpression: isExpression, - isStatement: isStatement, - isIterationStatement: isIterationStatement, - isSourceElement: isSourceElement, - isProblematicIfStatement: isProblematicIfStatement, - - trailingStatement: trailingStatement - }; -}()); -/* vim: set sw=4 ts=4 et tw=80 : */ - -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/ast.js","/../node_modules/escodegen/node_modules/esutils/lib") -},{"1YiZ5S":25,"buffer":21}],5:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* - Copyright (C) 2013-2014 Yusuke Suzuki - Copyright (C) 2014 Ivan Nikulin + result.push(multiline ? base : ''); + result.push(']'); + return result; + }, - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + RestElement: function(expr, precedence, flags) { + return '...' + this.generatePattern(expr.argument); + }, - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + ClassExpression: function (expr, precedence, flags) { + var result, fragment; + result = ['class']; + if (expr.id) { + result = join(result, this.generateExpression(expr.id, Precedence.Sequence, E_TTT)); + } + if (expr.superClass) { + fragment = join('extends', this.generateExpression(expr.superClass, Precedence.Assignment, E_TTT)); + result = join(result, fragment); + } + result.push(space); + result.push(this.generateStatement(expr.body, S_TFFT)); + return result; + }, - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -(function () { - 'use strict'; + MethodDefinition: function (expr, precedence, flags) { + var result, fragment; + if (expr['static']) { + result = ['static' + space]; + } else { + result = []; + } + if (expr.kind === 'get' || expr.kind === 'set') { + fragment = [ + join(expr.kind, this.generatePropertyKey(expr.key, expr.computed)), + this.generateFunctionBody(expr.value) + ]; + } else { + fragment = [ + generateMethodPrefix(expr), + this.generatePropertyKey(expr.key, expr.computed), + this.generateFunctionBody(expr.value) + ]; + } + return join(result, fragment); + }, - var Regex, NON_ASCII_WHITESPACES; + Property: function (expr, precedence, flags) { + if (expr.kind === 'get' || expr.kind === 'set') { + return [ + expr.kind, noEmptySpace(), + this.generatePropertyKey(expr.key, expr.computed), + this.generateFunctionBody(expr.value) + ]; + } - // See `tools/generate-identifier-regex.js`. - Regex = { - NonAsciiIdentifierStart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]'), - NonAsciiIdentifierPart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]') - }; + if (expr.shorthand) { + return this.generatePropertyKey(expr.key, expr.computed); + } - function isDecimalDigit(ch) { - return (ch >= 48 && ch <= 57); // 0..9 - } + if (expr.method) { + return [ + generateMethodPrefix(expr), + this.generatePropertyKey(expr.key, expr.computed), + this.generateFunctionBody(expr.value) + ]; + } - function isHexDigit(ch) { - return isDecimalDigit(ch) || // 0..9 - (97 <= ch && ch <= 102) || // a..f - (65 <= ch && ch <= 70); // A..F - } + return [ + this.generatePropertyKey(expr.key, expr.computed), + ':' + space, + this.generateExpression(expr.value, Precedence.Assignment, E_TTT) + ]; + }, - function isOctalDigit(ch) { - return (ch >= 48 && ch <= 55); // 0..7 - } + ObjectExpression: function (expr, precedence, flags) { + var multiline, result, fragment, that = this; - // 7.2 White Space + if (!expr.properties.length) { + return '{}'; + } + multiline = expr.properties.length > 1; - NON_ASCII_WHITESPACES = [ - 0x1680, 0x180E, - 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, - 0x202F, 0x205F, - 0x3000, - 0xFEFF - ]; + withIndent(function () { + fragment = that.generateExpression(expr.properties[0], Precedence.Sequence, E_TTT); + }); - function isWhiteSpace(ch) { - return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || - (ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0); - } + if (!multiline) { + // issues 4 + // Do not transform from + // dejavu.Class.declare({ + // method2: function () {} + // }); + // to + // dejavu.Class.declare({method2: function () { + // }}); + if (!hasLineTerminator(toSourceNodeWhenNeeded(fragment).toString())) { + return [ '{', space, fragment, space, '}' ]; + } + } - // 7.3 Line Terminators + withIndent(function (indent) { + var i, iz; + result = [ '{', newline, indent, fragment ]; - function isLineTerminator(ch) { - return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029); - } + if (multiline) { + result.push(',' + newline); + for (i = 1, iz = expr.properties.length; i < iz; ++i) { + result.push(indent); + result.push(that.generateExpression(expr.properties[i], Precedence.Sequence, E_TTT)); + if (i + 1 < iz) { + result.push(',' + newline); + } + } + } + }); - // 7.6 Identifier Names and Identifiers + if (!endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { + result.push(newline); + } + result.push(base); + result.push('}'); + return result; + }, - function isIdentifierStart(ch) { - return (ch >= 97 && ch <= 122) || // a..z - (ch >= 65 && ch <= 90) || // A..Z - (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) - (ch === 92) || // \ (backslash) - ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))); - } + AssignmentPattern: function(expr, precedence, flags) { + return this.generateAssignment(expr.left, expr.right, expr.operator, precedence, flags); + }, - function isIdentifierPart(ch) { - return (ch >= 97 && ch <= 122) || // a..z - (ch >= 65 && ch <= 90) || // A..Z - (ch >= 48 && ch <= 57) || // 0..9 - (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) - (ch === 92) || // \ (backslash) - ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))); - } + ObjectPattern: function (expr, precedence, flags) { + var result, i, iz, multiline, property, that = this; + if (!expr.properties.length) { + return '{}'; + } - module.exports = { - isDecimalDigit: isDecimalDigit, - isHexDigit: isHexDigit, - isOctalDigit: isOctalDigit, - isWhiteSpace: isWhiteSpace, - isLineTerminator: isLineTerminator, - isIdentifierStart: isIdentifierStart, - isIdentifierPart: isIdentifierPart - }; -}()); -/* vim: set sw=4 ts=4 et tw=80 : */ + multiline = false; + if (expr.properties.length === 1) { + property = expr.properties[0]; + if (property.value.type !== Syntax.Identifier) { + multiline = true; + } + } else { + for (i = 0, iz = expr.properties.length; i < iz; ++i) { + property = expr.properties[i]; + if (!property.shorthand) { + multiline = true; + break; + } + } + } + result = ['{', multiline ? newline : '' ]; -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/code.js","/../node_modules/escodegen/node_modules/esutils/lib") -},{"1YiZ5S":25,"buffer":21}],6:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* - Copyright (C) 2013 Yusuke Suzuki + withIndent(function (indent) { + var i, iz; + for (i = 0, iz = expr.properties.length; i < iz; ++i) { + result.push(multiline ? indent : ''); + result.push(that.generateExpression(expr.properties[i], Precedence.Sequence, E_TTT)); + if (i + 1 < iz) { + result.push(',' + (multiline ? newline : space)); + } + } + }); - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + if (multiline && !endsWithLineTerminator(toSourceNodeWhenNeeded(result).toString())) { + result.push(newline); + } + result.push(multiline ? base : ''); + result.push('}'); + return result; + }, - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + ThisExpression: function (expr, precedence, flags) { + return 'this'; + }, - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + Super: function (expr, precedence, flags) { + return 'super'; + }, -(function () { - 'use strict'; + Identifier: function (expr, precedence, flags) { + return generateIdentifier(expr); + }, - var code = require('./code'); + ImportDefaultSpecifier: function (expr, precedence, flags) { + return generateIdentifier(expr.id || expr.local); + }, - function isStrictModeReservedWordES6(id) { - switch (id) { - case 'implements': - case 'interface': - case 'package': - case 'private': - case 'protected': - case 'public': - case 'static': - case 'let': - return true; - default: - return false; - } - } + ImportNamespaceSpecifier: function (expr, precedence, flags) { + var result = ['*']; + var id = expr.id || expr.local; + if (id) { + result.push(space + 'as' + noEmptySpace() + generateIdentifier(id)); + } + return result; + }, - function isKeywordES5(id, strict) { - // yield should not be treated as keyword under non-strict mode. - if (!strict && id === 'yield') { - return false; - } - return isKeywordES6(id, strict); - } + ImportSpecifier: function (expr, precedence, flags) { + var imported = expr.imported; + var result = [ imported.name ]; + var local = expr.local; + if (local && local.name !== imported.name) { + result.push(noEmptySpace() + 'as' + noEmptySpace() + generateIdentifier(local)); + } + return result; + }, - function isKeywordES6(id, strict) { - if (strict && isStrictModeReservedWordES6(id)) { - return true; - } + ExportSpecifier: function (expr, precedence, flags) { + var local = expr.local; + var result = [ local.name ]; + var exported = expr.exported; + if (exported && exported.name !== local.name) { + result.push(noEmptySpace() + 'as' + noEmptySpace() + generateIdentifier(exported)); + } + return result; + }, - switch (id.length) { - case 2: - return (id === 'if') || (id === 'in') || (id === 'do'); - case 3: - return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try'); - case 4: - return (id === 'this') || (id === 'else') || (id === 'case') || - (id === 'void') || (id === 'with') || (id === 'enum'); - case 5: - return (id === 'while') || (id === 'break') || (id === 'catch') || - (id === 'throw') || (id === 'const') || (id === 'yield') || - (id === 'class') || (id === 'super'); - case 6: - return (id === 'return') || (id === 'typeof') || (id === 'delete') || - (id === 'switch') || (id === 'export') || (id === 'import'); - case 7: - return (id === 'default') || (id === 'finally') || (id === 'extends'); - case 8: - return (id === 'function') || (id === 'continue') || (id === 'debugger'); - case 10: - return (id === 'instanceof'); - default: - return false; - } - } + Literal: function (expr, precedence, flags) { + var raw; + if (expr.hasOwnProperty('raw') && parse && extra.raw) { + try { + raw = parse(expr.raw).body[0].expression; + if (raw.type === Syntax.Literal) { + if (raw.value === expr.value) { + return expr.raw; + } + } + } catch (e) { + // not use raw property + } + } - function isReservedWordES5(id, strict) { - return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict); - } + if (expr.value === null) { + return 'null'; + } - function isReservedWordES6(id, strict) { - return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict); - } + if (typeof expr.value === 'string') { + return escapeString(expr.value); + } - function isRestrictedWord(id) { - return id === 'eval' || id === 'arguments'; - } + if (typeof expr.value === 'number') { + return generateNumber(expr.value); + } - function isIdentifierName(id) { - var i, iz, ch; + if (typeof expr.value === 'boolean') { + return expr.value ? 'true' : 'false'; + } - if (id.length === 0) { - return false; - } + return generateRegExp(expr.value); + }, - ch = id.charCodeAt(0); - if (!code.isIdentifierStart(ch) || ch === 92) { // \ (backslash) - return false; - } + GeneratorExpression: function (expr, precedence, flags) { + return this.ComprehensionExpression(expr, precedence, flags); + }, - for (i = 1, iz = id.length; i < iz; ++i) { - ch = id.charCodeAt(i); - if (!code.isIdentifierPart(ch) || ch === 92) { // \ (backslash) - return false; + ComprehensionExpression: function (expr, precedence, flags) { + // GeneratorExpression should be parenthesized with (...), ComprehensionExpression with [...] + // Due to https://bugzilla.mozilla.org/show_bug.cgi?id=883468 position of expr.body can differ in Spidermonkey and ES6 + + var result, i, iz, fragment, that = this; + result = (expr.type === Syntax.GeneratorExpression) ? ['('] : ['[']; + + if (extra.moz.comprehensionExpressionStartsWithAssignment) { + fragment = this.generateExpression(expr.body, Precedence.Assignment, E_TTT); + result.push(fragment); } - } - return true; - } - function isIdentifierES5(id, strict) { - return isIdentifierName(id) && !isReservedWordES5(id, strict); - } + if (expr.blocks) { + withIndent(function () { + for (i = 0, iz = expr.blocks.length; i < iz; ++i) { + fragment = that.generateExpression(expr.blocks[i], Precedence.Sequence, E_TTT); + if (i > 0 || extra.moz.comprehensionExpressionStartsWithAssignment) { + result = join(result, fragment); + } else { + result.push(fragment); + } + } + }); + } - function isIdentifierES6(id, strict) { - return isIdentifierName(id) && !isReservedWordES6(id, strict); - } + if (expr.filter) { + result = join(result, 'if' + space); + fragment = this.generateExpression(expr.filter, Precedence.Sequence, E_TTT); + result = join(result, [ '(', fragment, ')' ]); + } - module.exports = { - isKeywordES5: isKeywordES5, - isKeywordES6: isKeywordES6, - isReservedWordES5: isReservedWordES5, - isReservedWordES6: isReservedWordES6, - isRestrictedWord: isRestrictedWord, - isIdentifierName: isIdentifierName, - isIdentifierES5: isIdentifierES5, - isIdentifierES6: isIdentifierES6 - }; -}()); -/* vim: set sw=4 ts=4 et tw=80 : */ + if (!extra.moz.comprehensionExpressionStartsWithAssignment) { + fragment = this.generateExpression(expr.body, Precedence.Assignment, E_TTT); -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/keyword.js","/../node_modules/escodegen/node_modules/esutils/lib") -},{"./code":5,"1YiZ5S":25,"buffer":21}],7:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* - Copyright (C) 2013 Yusuke Suzuki + result = join(result, fragment); + } - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + result.push((expr.type === Syntax.GeneratorExpression) ? ')' : ']'); + return result; + }, - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + ComprehensionBlock: function (expr, precedence, flags) { + var fragment; + if (expr.left.type === Syntax.VariableDeclaration) { + fragment = [ + expr.left.kind, noEmptySpace(), + this.generateStatement(expr.left.declarations[0], S_FFFF) + ]; + } else { + fragment = this.generateExpression(expr.left, Precedence.Call, E_TTT); + } - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + fragment = join(fragment, expr.of ? 'of' : 'in'); + fragment = join(fragment, this.generateExpression(expr.right, Precedence.Sequence, E_TTT)); + return [ 'for' + space + '(', fragment, ')' ]; + }, -(function () { - 'use strict'; + SpreadElement: function (expr, precedence, flags) { + return [ + '...', + this.generateExpression(expr.argument, Precedence.Assignment, E_TTT) + ]; + }, - exports.ast = require('./ast'); - exports.code = require('./code'); - exports.keyword = require('./keyword'); -}()); -/* vim: set sw=4 ts=4 et tw=80 : */ + TaggedTemplateExpression: function (expr, precedence, flags) { + var itemFlags = E_TTF; + if (!(flags & F_ALLOW_CALL)) { + itemFlags = E_TFF; + } + var result = [ + this.generateExpression(expr.tag, Precedence.Call, itemFlags), + this.generateExpression(expr.quasi, Precedence.Primary, E_FFT) + ]; + return parenthesize(result, Precedence.TaggedTemplate, precedence); + }, -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/utils.js","/../node_modules/escodegen/node_modules/esutils/lib") -},{"./ast":4,"./code":5,"./keyword":6,"1YiZ5S":25,"buffer":21}],8:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* - * Copyright 2009-2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE.txt or: - * http://opensource.org/licenses/BSD-3-Clause - */ -exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator; -exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer; -exports.SourceNode = require('./source-map/source-node').SourceNode; + TemplateElement: function (expr, precedence, flags) { + // Don't use "cooked". Since tagged template can use raw template + // representation. So if we do so, it breaks the script semantics. + return expr.value.raw; + }, -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map.js","/../node_modules/escodegen/node_modules/source-map/lib") -},{"./source-map/source-map-consumer":14,"./source-map/source-map-generator":15,"./source-map/source-node":16,"1YiZ5S":25,"buffer":21}],9:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = require('amdefine')(module, require); -} -define(function (require, exports, module) { + TemplateLiteral: function (expr, precedence, flags) { + var result, i, iz; + result = [ '`' ]; + for (i = 0, iz = expr.quasis.length; i < iz; ++i) { + result.push(this.generateExpression(expr.quasis[i], Precedence.Primary, E_TTT)); + if (i + 1 < iz) { + result.push('${' + space); + result.push(this.generateExpression(expr.expressions[i], Precedence.Sequence, E_TTT)); + result.push(space + '}'); + } + } + result.push('`'); + return result; + }, - var util = require('./util'); + ModuleSpecifier: function (expr, precedence, flags) { + return this.Literal(expr, precedence, flags); + } - /** - * A data structure which is a combination of an array and a set. Adding a new - * member is O(1), testing for membership is O(1), and finding the index of an - * element is O(1). Removing elements from the set is not supported. Only - * strings are supported for membership. - */ - function ArraySet() { - this._array = []; - this._set = {}; - } + }; - /** - * Static method for creating ArraySet instances from an existing array. - */ - ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { - var set = new ArraySet(); - for (var i = 0, len = aArray.length; i < len; i++) { - set.add(aArray[i], aAllowDuplicates); - } - return set; - }; + merge(CodeGenerator.prototype, CodeGenerator.Expression); - /** - * Add the given string to this set. - * - * @param String aStr - */ - ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { - var isDuplicate = this.has(aStr); - var idx = this._array.length; - if (!isDuplicate || aAllowDuplicates) { - this._array.push(aStr); - } - if (!isDuplicate) { - this._set[util.toSetString(aStr)] = idx; - } - }; - - /** - * Is the given string a member of this set? - * - * @param String aStr - */ - ArraySet.prototype.has = function ArraySet_has(aStr) { - return Object.prototype.hasOwnProperty.call(this._set, - util.toSetString(aStr)); - }; + CodeGenerator.prototype.generateExpression = function (expr, precedence, flags) { + var result, type; - /** - * What is the index of the given string in the array? - * - * @param String aStr - */ - ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { - if (this.has(aStr)) { - return this._set[util.toSetString(aStr)]; - } - throw new Error('"' + aStr + '" is not in the set.'); - }; + type = expr.type || Syntax.Property; - /** - * What is the element at the given index? - * - * @param Number aIdx - */ - ArraySet.prototype.at = function ArraySet_at(aIdx) { - if (aIdx >= 0 && aIdx < this._array.length) { - return this._array[aIdx]; - } - throw new Error('No element indexed by ' + aIdx); - }; + if (extra.verbatim && expr.hasOwnProperty(extra.verbatim)) { + return generateVerbatim(expr, precedence); + } - /** - * Returns the array representation of this set (which has the proper indices - * indicated by indexOf). Note that this is a copy of the internal array used - * for storing the members so that no one can mess with internal state. - */ - ArraySet.prototype.toArray = function ArraySet_toArray() { - return this._array.slice(); - }; + result = this[type](expr, precedence, flags); - exports.ArraySet = ArraySet; -}); + if (extra.comment) { + result = addComments(expr, result); + } + return toSourceNodeWhenNeeded(result, expr); + }; -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/array-set.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") -},{"./util":17,"1YiZ5S":25,"amdefine":18,"buffer":21}],10:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - * - * Based on the Base 64 VLQ implementation in Closure Compiler: - * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java - * - * Copyright 2011 The Closure Compiler Authors. All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -if (typeof define !== 'function') { - var define = require('amdefine')(module, require); -} -define(function (require, exports, module) { + CodeGenerator.prototype.generateStatement = function (stmt, flags) { + var result, + fragment; - var base64 = require('./base64'); + result = this[stmt.type](stmt, flags); - // A single base 64 digit can contain 6 bits of data. For the base 64 variable - // length quantities we use in the source map spec, the first bit is the sign, - // the next four bits are the actual value, and the 6th bit is the - // continuation bit. The continuation bit tells us whether there are more - // digits in this value following this digit. - // - // Continuation - // | Sign - // | | - // V V - // 101011 + // Attach comments - var VLQ_BASE_SHIFT = 5; + if (extra.comment) { + result = addComments(stmt, result); + } - // binary: 100000 - var VLQ_BASE = 1 << VLQ_BASE_SHIFT; + fragment = toSourceNodeWhenNeeded(result).toString(); + if (stmt.type === Syntax.Program && !safeConcatenation && newline === '' && fragment.charAt(fragment.length - 1) === '\n') { + result = sourceMap ? toSourceNodeWhenNeeded(result).replaceRight(/\s+$/, '') : fragment.replace(/\s+$/, ''); + } - // binary: 011111 - var VLQ_BASE_MASK = VLQ_BASE - 1; + return toSourceNodeWhenNeeded(result, stmt); + }; - // binary: 100000 - var VLQ_CONTINUATION_BIT = VLQ_BASE; + function generateInternal(node) { + var codegen; - /** - * Converts from a two-complement value to a value where the sign bit is - * placed in the least significant bit. For example, as decimals: - * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) - * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) - */ - function toVLQSigned(aValue) { - return aValue < 0 - ? ((-aValue) << 1) + 1 - : (aValue << 1) + 0; - } + codegen = new CodeGenerator(); + if (isStatement(node)) { + return codegen.generateStatement(node, S_TFFF); + } - /** - * Converts to a two-complement value from a value where the sign bit is - * placed in the least significant bit. For example, as decimals: - * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 - * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 - */ - function fromVLQSigned(aValue) { - var isNegative = (aValue & 1) === 1; - var shifted = aValue >> 1; - return isNegative - ? -shifted - : shifted; - } + if (isExpression(node)) { + return codegen.generateExpression(node, Precedence.Sequence, E_TTT); + } - /** - * Returns the base 64 VLQ encoded value. - */ - exports.encode = function base64VLQ_encode(aValue) { - var encoded = ""; - var digit; + throw new Error('Unknown node type: ' + node.type); + } - var vlq = toVLQSigned(aValue); + function generate(node, options) { + var defaultOptions = getDefaultOptions(), result, pair; - do { - digit = vlq & VLQ_BASE_MASK; - vlq >>>= VLQ_BASE_SHIFT; - if (vlq > 0) { - // There are still more digits in this value, so we must make sure the - // continuation bit is marked. - digit |= VLQ_CONTINUATION_BIT; - } - encoded += base64.encode(digit); - } while (vlq > 0); + if (options != null) { + // Obsolete options + // + // `options.indent` + // `options.base` + // + // Instead of them, we can use `option.format.indent`. + if (typeof options.indent === 'string') { + defaultOptions.format.indent.style = options.indent; + } + if (typeof options.base === 'number') { + defaultOptions.format.indent.base = options.base; + } + options = updateDeeply(defaultOptions, options); + indent = options.format.indent.style; + if (typeof options.base === 'string') { + base = options.base; + } else { + base = stringRepeat(indent, options.format.indent.base); + } + } else { + options = defaultOptions; + indent = options.format.indent.style; + base = stringRepeat(indent, options.format.indent.base); + } + json = options.format.json; + renumber = options.format.renumber; + hexadecimal = json ? false : options.format.hexadecimal; + quotes = json ? 'double' : options.format.quotes; + escapeless = options.format.escapeless; + newline = options.format.newline; + space = options.format.space; + if (options.format.compact) { + newline = space = indent = base = ''; + } + parentheses = options.format.parentheses; + semicolons = options.format.semicolons; + safeConcatenation = options.format.safeConcatenation; + directive = options.directive; + parse = json ? null : options.parse; + sourceMap = options.sourceMap; + sourceCode = options.sourceCode; + preserveBlankLines = options.format.preserveBlankLines && sourceCode !== null; + extra = options; - return encoded; - }; + if (sourceMap) { + if (!exports.browser) { + // We assume environment is node.js + // And prevent from including source-map by browserify + SourceNode = require('source-map').SourceNode; + } else { + SourceNode = global.sourceMap.SourceNode; + } + } - /** - * Decodes the next base 64 VLQ value from the given string and returns the - * value and the rest of the string via the out parameter. - */ - exports.decode = function base64VLQ_decode(aStr, aOutParam) { - var i = 0; - var strLen = aStr.length; - var result = 0; - var shift = 0; - var continuation, digit; + result = generateInternal(node); - do { - if (i >= strLen) { - throw new Error("Expected more digits in base 64 VLQ value."); - } - digit = base64.decode(aStr.charAt(i++)); - continuation = !!(digit & VLQ_CONTINUATION_BIT); - digit &= VLQ_BASE_MASK; - result = result + (digit << shift); - shift += VLQ_BASE_SHIFT; - } while (continuation); - - aOutParam.value = fromVLQSigned(result); - aOutParam.rest = aStr.slice(i); - }; + if (!sourceMap) { + pair = {code: result.toString(), map: null}; + return options.sourceMapWithCode ? pair : pair.code; + } -}); -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/base64-vlq.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") -},{"./base64":11,"1YiZ5S":25,"amdefine":18,"buffer":21}],11:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = require('amdefine')(module, require); -} -define(function (require, exports, module) { + pair = result.toStringWithSourceMap({ + file: options.file, + sourceRoot: options.sourceMapRoot + }); - var charToIntMap = {}; - var intToCharMap = {}; + if (options.sourceContent) { + pair.map.setSourceContent(options.sourceMap, + options.sourceContent); + } - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' - .split('') - .forEach(function (ch, index) { - charToIntMap[ch] = index; - intToCharMap[index] = ch; - }); + if (options.sourceMapWithCode) { + return pair; + } - /** - * Encode an integer in the range of 0 to 63 to a single base 64 digit. - */ - exports.encode = function base64_encode(aNumber) { - if (aNumber in intToCharMap) { - return intToCharMap[aNumber]; + return pair.map.toString(); } - throw new TypeError("Must be between 0 and 63: " + aNumber); - }; - /** - * Decode a single base 64 digit to an integer. - */ - exports.decode = function base64_decode(aChar) { - if (aChar in charToIntMap) { - return charToIntMap[aChar]; - } - throw new TypeError("Not a valid base 64 digit: " + aChar); - }; + FORMAT_MINIFY = { + indent: { + style: '', + base: 0 + }, + renumber: true, + hexadecimal: true, + quotes: 'auto', + escapeless: true, + compact: true, + parentheses: false, + semicolons: false + }; -}); + FORMAT_DEFAULTS = getDefaultOptions().format; + + exports.version = require('./package.json').version; + exports.generate = generate; + exports.attachComments = estraverse.attachComments; + exports.Precedence = updateDeeply({}, Precedence); + exports.browser = false; + exports.FORMAT_MINIFY = FORMAT_MINIFY; + exports.FORMAT_DEFAULTS = FORMAT_DEFAULTS; +}()); +/* vim: set sw=4 ts=4 et tw=80 : */ -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/base64.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") -},{"1YiZ5S":25,"amdefine":18,"buffer":21}],12:[function(require,module,exports){ +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/escodegen.js","/../node_modules/escodegen") +},{"./package.json":23,"buffer":3,"estraverse":6,"esutils":10,"pBGvAp":29,"source-map":11}],5:[function(require,module,exports){ (function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause +/** vim: et:ts=4:sw=4:sts=4 + * @license amdefine 1.0.0 Copyright (c) 2011-2015, The Dojo Foundation All Rights Reserved. + * Available via the MIT or new BSD license. + * see: http://github.com/jrburke/amdefine for details */ -if (typeof define !== 'function') { - var define = require('amdefine')(module, require); -} -define(function (require, exports, module) { - /** - * Recursive implementation of binary search. - * - * @param aLow Indices here and lower do not contain the needle. - * @param aHigh Indices here and higher do not contain the needle. - * @param aNeedle The element being searched for. - * @param aHaystack The non-empty array being searched. - * @param aCompare Function which takes two elements and returns -1, 0, or 1. - */ - function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) { - // This function terminates when one of the following is true: - // - // 1. We find the exact element we are looking for. - // - // 2. We did not find the exact element, but we can return the index of - // the next closest element that is less than that element. - // - // 3. We did not find the exact element, and there is no next-closest - // element which is less than the one we are searching for, so we - // return -1. - var mid = Math.floor((aHigh - aLow) / 2) + aLow; - var cmp = aCompare(aNeedle, aHaystack[mid], true); - if (cmp === 0) { - // Found the element we are looking for. - return mid; - } - else if (cmp > 0) { - // aHaystack[mid] is greater than our needle. - if (aHigh - mid > 1) { - // The element is in the upper half. - return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare); - } - // We did not find an exact match, return the next closest one - // (termination case 2). - return mid; - } - else { - // aHaystack[mid] is less than our needle. - if (mid - aLow > 1) { - // The element is in the lower half. - return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare); - } - // The exact needle element was not found in this haystack. Determine if - // we are in termination case (2) or (3) and return the appropriate thing. - return aLow < 0 ? -1 : aLow; - } - } +/*jslint node: true */ +/*global module, process */ +'use strict'; - /** - * This is an implementation of binary search which will always try and return - * the index of next lowest value checked if there is no exact hit. This is - * because mappings between original and generated line/col pairs are single - * points, and there is an implicit region between each of them, so a miss - * just means that you aren't on the very start of a region. - * - * @param aNeedle The element you are looking for. - * @param aHaystack The array that is being searched. - * @param aCompare A function which takes the needle and an element in the - * array and returns -1, 0, or 1 depending on whether the needle is less - * than, equal to, or greater than the element, respectively. - */ - exports.search = function search(aNeedle, aHaystack, aCompare) { - if (aHaystack.length === 0) { - return -1; +/** + * Creates a define for node. + * @param {Object} module the "module" object that is defined by Node for the + * current module. + * @param {Function} [requireFn]. Node's require function for the current module. + * It only needs to be passed in Node versions before 0.5, when module.require + * did not exist. + * @returns {Function} a define function that is usable for the current node + * module. + */ +function amdefine(module, requireFn) { + 'use strict'; + var defineCache = {}, + loaderCache = {}, + alreadyCalled = false, + path = require('path'), + makeRequire, stringRequire; + + /** + * Trims the . and .. from an array of path segments. + * It will keep a leading path segment if a .. will become + * the first path segment, to help with module name lookups, + * which act like paths, but can be remapped. But the end result, + * all paths that use this function should look normalized. + * NOTE: this method MODIFIES the input array. + * @param {Array} ary the array of path segments. + */ + function trimDots(ary) { + var i, part; + for (i = 0; ary[i]; i+= 1) { + part = ary[i]; + if (part === '.') { + ary.splice(i, 1); + i -= 1; + } else if (part === '..') { + if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { + //End of the line. Keep at least one non-dot + //path segment at the front so it can be mapped + //correctly to disk. Otherwise, there is likely + //no path mapping for a path starting with '..'. + //This can still fail, but catches the most reasonable + //uses of .. + break; + } else if (i > 0) { + ary.splice(i - 1, 2); + i -= 2; + } + } + } } - return recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare) - }; -}); + function normalize(name, baseName) { + var baseParts; -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/binary-search.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") -},{"1YiZ5S":25,"amdefine":18,"buffer":21}],13:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2014 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = require('amdefine')(module, require); -} -define(function (require, exports, module) { + //Adjust any relative paths. + if (name && name.charAt(0) === '.') { + //If have a base name, try to normalize against it, + //otherwise, assume it is a top-level require that will + //be relative to baseUrl in the end. + if (baseName) { + baseParts = baseName.split('/'); + baseParts = baseParts.slice(0, baseParts.length - 1); + baseParts = baseParts.concat(name.split('/')); + trimDots(baseParts); + name = baseParts.join('/'); + } + } - var util = require('./util'); + return name; + } - /** - * Determine whether mappingB is after mappingA with respect to generated - * position. - */ - function generatedPositionAfter(mappingA, mappingB) { - // Optimized for most common case - var lineA = mappingA.generatedLine; - var lineB = mappingB.generatedLine; - var columnA = mappingA.generatedColumn; - var columnB = mappingB.generatedColumn; - return lineB > lineA || lineB == lineA && columnB >= columnA || - util.compareByGeneratedPositions(mappingA, mappingB) <= 0; - } - - /** - * A data structure to provide a sorted view of accumulated mappings in a - * performance conscious manner. It trades a neglibable overhead in general - * case for a large speedup in case of mappings being added in order. - */ - function MappingList() { - this._array = []; - this._sorted = true; - // Serves as infimum - this._last = {generatedLine: -1, generatedColumn: 0}; - } + /** + * Create the normalize() function passed to a loader plugin's + * normalize method. + */ + function makeNormalize(relName) { + return function (name) { + return normalize(name, relName); + }; + } - /** - * Iterate through internal items. This method takes the same arguments that - * `Array.prototype.forEach` takes. - * - * NOTE: The order of the mappings is NOT guaranteed. - */ - MappingList.prototype.unsortedForEach = - function MappingList_forEach(aCallback, aThisArg) { - this._array.forEach(aCallback, aThisArg); - }; + function makeLoad(id) { + function load(value) { + loaderCache[id] = value; + } - /** - * Add the given source mapping. - * - * @param Object aMapping - */ - MappingList.prototype.add = function MappingList_add(aMapping) { - var mapping; - if (generatedPositionAfter(this._last, aMapping)) { - this._last = aMapping; - this._array.push(aMapping); - } else { - this._sorted = false; - this._array.push(aMapping); - } - }; + load.fromText = function (id, text) { + //This one is difficult because the text can/probably uses + //define, and any relative paths and requires should be relative + //to that id was it would be found on disk. But this would require + //bootstrapping a module/require fairly deeply from node core. + //Not sure how best to go about that yet. + throw new Error('amdefine does not implement load.fromText'); + }; - /** - * Returns the flat, sorted array of mappings. The mappings are sorted by - * generated position. - * - * WARNING: This method returns internal data without copying, for - * performance. The return value must NOT be mutated, and should be treated as - * an immutable borrow. If you want to take ownership, you must make your own - * copy. - */ - MappingList.prototype.toArray = function MappingList_toArray() { - if (!this._sorted) { - this._array.sort(util.compareByGeneratedPositions); - this._sorted = true; + return load; } - return this._array; - }; - exports.MappingList = MappingList; + makeRequire = function (systemRequire, exports, module, relId) { + function amdRequire(deps, callback) { + if (typeof deps === 'string') { + //Synchronous, single module require('') + return stringRequire(systemRequire, exports, module, deps, relId); + } else { + //Array of dependencies with a callback. -}); + //Convert the dependencies to modules. + deps = deps.map(function (depName) { + return stringRequire(systemRequire, exports, module, depName, relId); + }); -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/mapping-list.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") -},{"./util":17,"1YiZ5S":25,"amdefine":18,"buffer":21}],14:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = require('amdefine')(module, require); -} -define(function (require, exports, module) { + //Wait for next tick to call back the require call. + if (callback) { + process.nextTick(function () { + callback.apply(null, deps); + }); + } + } + } - var util = require('./util'); - var binarySearch = require('./binary-search'); - var ArraySet = require('./array-set').ArraySet; - var base64VLQ = require('./base64-vlq'); + amdRequire.toUrl = function (filePath) { + if (filePath.indexOf('.') === 0) { + return normalize(filePath, path.dirname(module.filename)); + } else { + return filePath; + } + }; - /** - * A SourceMapConsumer instance represents a parsed source map which we can - * query for information about the original file positions by giving it a file - * position in the generated source. - * - * The only parameter is the raw source map (either as a JSON string, or - * already parsed to an object). According to the spec, source maps have the - * following attributes: - * - * - version: Which version of the source map spec this map is following. - * - sources: An array of URLs to the original source files. - * - names: An array of identifiers which can be referrenced by individual mappings. - * - sourceRoot: Optional. The URL root from which all sources are relative. - * - sourcesContent: Optional. An array of contents of the original source files. - * - mappings: A string of base64 VLQs which contain the actual mappings. - * - file: Optional. The generated file this source map is associated with. - * - * Here is an example source map, taken from the source map spec[0]: - * - * { - * version : 3, - * file: "out.js", - * sourceRoot : "", - * sources: ["foo.js", "bar.js"], - * names: ["src", "maps", "are", "fun"], - * mappings: "AA,AB;;ABCDE;" - * } - * - * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# - */ - function SourceMapConsumer(aSourceMap) { - var sourceMap = aSourceMap; - if (typeof aSourceMap === 'string') { - sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); - } + return amdRequire; + }; - var version = util.getArg(sourceMap, 'version'); - var sources = util.getArg(sourceMap, 'sources'); - // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which - // requires the array) to play nice here. - var names = util.getArg(sourceMap, 'names', []); - var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); - var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); - var mappings = util.getArg(sourceMap, 'mappings'); - var file = util.getArg(sourceMap, 'file', null); + //Favor explicit value, passed in if the module wants to support Node 0.4. + requireFn = requireFn || function req() { + return module.require.apply(module, arguments); + }; - // Once again, Sass deviates from the spec and supplies the version as a - // string rather than a number, so we use loose equality checking here. - if (version != this._version) { - throw new Error('Unsupported version: ' + version); - } + function runFactory(id, deps, factory) { + var r, e, m, result; - // Some source maps produce relative source paths like "./foo.js" instead of - // "foo.js". Normalize these first so that future comparisons will succeed. - // See bugzil.la/1090768. - sources = sources.map(util.normalize); + if (id) { + e = loaderCache[id] = {}; + m = { + id: id, + uri: __filename, + exports: e + }; + r = makeRequire(requireFn, e, m, id); + } else { + //Only support one define call per file + if (alreadyCalled) { + throw new Error('amdefine with no module ID cannot be called more than once per file.'); + } + alreadyCalled = true; - // Pass `true` below to allow duplicate names and sources. While source maps - // are intended to be compressed and deduplicated, the TypeScript compiler - // sometimes generates source maps with duplicates in them. See Github issue - // #72 and bugzil.la/889492. - this._names = ArraySet.fromArray(names, true); - this._sources = ArraySet.fromArray(sources, true); + //Use the real variables from node + //Use module.exports for exports, since + //the exports in here is amdefine exports. + e = module.exports; + m = module; + r = makeRequire(requireFn, e, m, module.id); + } - this.sourceRoot = sourceRoot; - this.sourcesContent = sourcesContent; - this._mappings = mappings; - this.file = file; - } + //If there are dependencies, they are strings, so need + //to convert them to dependency values. + if (deps) { + deps = deps.map(function (depName) { + return r(depName); + }); + } - /** - * Create a SourceMapConsumer from a SourceMapGenerator. - * - * @param SourceMapGenerator aSourceMap - * The source map that will be consumed. - * @returns SourceMapConsumer - */ - SourceMapConsumer.fromSourceMap = - function SourceMapConsumer_fromSourceMap(aSourceMap) { - var smc = Object.create(SourceMapConsumer.prototype); + //Call the factory with the right dependencies. + if (typeof factory === 'function') { + result = factory.apply(m.exports, deps); + } else { + result = factory; + } - smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); - smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); - smc.sourceRoot = aSourceMap._sourceRoot; - smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), - smc.sourceRoot); - smc.file = aSourceMap._file; + if (result !== undefined) { + m.exports = result; + if (id) { + loaderCache[id] = m.exports; + } + } + } - smc.__generatedMappings = aSourceMap._mappings.toArray().slice(); - smc.__originalMappings = aSourceMap._mappings.toArray().slice() - .sort(util.compareByOriginalPositions); + stringRequire = function (systemRequire, exports, module, id, relId) { + //Split the ID by a ! so that + var index = id.indexOf('!'), + originalId = id, + prefix, plugin; - return smc; - }; + if (index === -1) { + id = normalize(id, relId); - /** - * The version of the source mapping spec that we are consuming. - */ - SourceMapConsumer.prototype._version = 3; + //Straight module lookup. If it is one of the special dependencies, + //deal with it, otherwise, delegate to node. + if (id === 'require') { + return makeRequire(systemRequire, exports, module, relId); + } else if (id === 'exports') { + return exports; + } else if (id === 'module') { + return module; + } else if (loaderCache.hasOwnProperty(id)) { + return loaderCache[id]; + } else if (defineCache[id]) { + runFactory.apply(null, defineCache[id]); + return loaderCache[id]; + } else { + if(systemRequire) { + return systemRequire(originalId); + } else { + throw new Error('No module with ID: ' + id); + } + } + } else { + //There is a plugin in play. + prefix = id.substring(0, index); + id = id.substring(index + 1, id.length); - /** - * The list of original sources. - */ - Object.defineProperty(SourceMapConsumer.prototype, 'sources', { - get: function () { - return this._sources.toArray().map(function (s) { - return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s; - }, this); - } - }); + plugin = stringRequire(systemRequire, exports, module, prefix, relId); - // `__generatedMappings` and `__originalMappings` are arrays that hold the - // parsed mapping coordinates from the source map's "mappings" attribute. They - // are lazily instantiated, accessed via the `_generatedMappings` and - // `_originalMappings` getters respectively, and we only parse the mappings - // and create these arrays once queried for a source location. We jump through - // these hoops because there can be many thousands of mappings, and parsing - // them is expensive, so we only want to do it if we must. - // - // Each object in the arrays is of the form: - // - // { - // generatedLine: The line number in the generated code, - // generatedColumn: The column number in the generated code, - // source: The path to the original source file that generated this - // chunk of code, - // originalLine: The line number in the original source that - // corresponds to this chunk of generated code, - // originalColumn: The column number in the original source that - // corresponds to this chunk of generated code, - // name: The name of the original symbol which generated this chunk of - // code. - // } - // - // All properties except for `generatedLine` and `generatedColumn` can be - // `null`. - // - // `_generatedMappings` is ordered by the generated positions. - // - // `_originalMappings` is ordered by the original positions. + if (plugin.normalize) { + id = plugin.normalize(id, makeNormalize(relId)); + } else { + //Normalize the ID normally. + id = normalize(id, relId); + } - SourceMapConsumer.prototype.__generatedMappings = null; - Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { - get: function () { - if (!this.__generatedMappings) { - this.__generatedMappings = []; - this.__originalMappings = []; - this._parseMappings(this._mappings, this.sourceRoot); - } + if (loaderCache[id]) { + return loaderCache[id]; + } else { + plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {}); - return this.__generatedMappings; - } - }); + return loaderCache[id]; + } + } + }; - SourceMapConsumer.prototype.__originalMappings = null; - Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { - get: function () { - if (!this.__originalMappings) { - this.__generatedMappings = []; - this.__originalMappings = []; - this._parseMappings(this._mappings, this.sourceRoot); - } + //Create a define function specific to the module asking for amdefine. + function define(id, deps, factory) { + if (Array.isArray(id)) { + factory = deps; + deps = id; + id = undefined; + } else if (typeof id !== 'string') { + factory = id; + id = deps = undefined; + } - return this.__originalMappings; - } - }); + if (deps && !Array.isArray(deps)) { + factory = deps; + deps = undefined; + } - SourceMapConsumer.prototype._nextCharIsMappingSeparator = - function SourceMapConsumer_nextCharIsMappingSeparator(aStr) { - var c = aStr.charAt(0); - return c === ";" || c === ","; - }; + if (!deps) { + deps = ['require', 'exports', 'module']; + } - /** - * Parse the mappings in a string in to a data structure which we can easily - * query (the ordered arrays in the `this.__generatedMappings` and - * `this.__originalMappings` properties). - */ - SourceMapConsumer.prototype._parseMappings = - function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { - var generatedLine = 1; - var previousGeneratedColumn = 0; - var previousOriginalLine = 0; - var previousOriginalColumn = 0; - var previousSource = 0; - var previousName = 0; - var str = aStr; - var temp = {}; - var mapping; + //Set up properties for this module. If an ID, then use + //internal cache. If no ID, then use the external variables + //for this node module. + if (id) { + //Put the module in deep freeze until there is a + //require call for it. + defineCache[id] = [id, deps, factory]; + } else { + runFactory(id, deps, factory); + } + } - while (str.length > 0) { - if (str.charAt(0) === ';') { - generatedLine++; - str = str.slice(1); - previousGeneratedColumn = 0; + //define.require, which has access to all the values in the + //cache. Useful for AMD modules that all have IDs in the file, + //but need to finally export a value to node based on one of those + //IDs. + define.require = function (id) { + if (loaderCache[id]) { + return loaderCache[id]; } - else if (str.charAt(0) === ',') { - str = str.slice(1); + + if (defineCache[id]) { + runFactory.apply(null, defineCache[id]); + return loaderCache[id]; } - else { - mapping = {}; - mapping.generatedLine = generatedLine; + }; - // Generated column. - base64VLQ.decode(str, temp); - mapping.generatedColumn = previousGeneratedColumn + temp.value; - previousGeneratedColumn = mapping.generatedColumn; - str = temp.rest; + define.amd = {}; - if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) { - // Original source. - base64VLQ.decode(str, temp); - mapping.source = this._sources.at(previousSource + temp.value); - previousSource += temp.value; - str = temp.rest; - if (str.length === 0 || this._nextCharIsMappingSeparator(str)) { - throw new Error('Found a source, but no line and column'); - } + return define; +} - // Original line. - base64VLQ.decode(str, temp); - mapping.originalLine = previousOriginalLine + temp.value; - previousOriginalLine = mapping.originalLine; - // Lines are stored 0-based - mapping.originalLine += 1; - str = temp.rest; - if (str.length === 0 || this._nextCharIsMappingSeparator(str)) { - throw new Error('Found a source and line, but no column'); - } +module.exports = amdefine; - // Original column. - base64VLQ.decode(str, temp); - mapping.originalColumn = previousOriginalColumn + temp.value; - previousOriginalColumn = mapping.originalColumn; - str = temp.rest; +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/amdefine/amdefine.js","/../node_modules/escodegen/node_modules/amdefine") +},{"buffer":3,"pBGvAp":29,"path":28}],6:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* + Copyright (C) 2012-2013 Yusuke Suzuki + Copyright (C) 2012 Ariya Hidayat - if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) { - // Original name. - base64VLQ.decode(str, temp); - mapping.name = this._names.at(previousName + temp.value); - previousName += temp.value; - str = temp.rest; - } - } + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - this.__generatedMappings.push(mapping); - if (typeof mapping.originalLine === 'number') { - this.__originalMappings.push(mapping); - } - } - } + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - this.__generatedMappings.sort(util.compareByGeneratedPositions); - this.__originalMappings.sort(util.compareByOriginalPositions); - }; + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/*jslint vars:false, bitwise:true*/ +/*jshint indent:4*/ +/*global exports:true, define:true*/ +(function (root, factory) { + 'use strict'; - /** - * Find the mapping that best matches the hypothetical "needle" mapping that - * we are searching for in the given "haystack" of mappings. - */ - SourceMapConsumer.prototype._findMapping = - function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, - aColumnName, aComparator) { - // To return the position we are searching for, we must first find the - // mapping for the given position and then return the opposite position it - // points to. Because the mappings are sorted, we can use binary search to - // find the best mapping. - - if (aNeedle[aLineName] <= 0) { - throw new TypeError('Line must be greater than or equal to 1, got ' - + aNeedle[aLineName]); - } - if (aNeedle[aColumnName] < 0) { - throw new TypeError('Column must be greater than or equal to 0, got ' - + aNeedle[aColumnName]); - } + // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, + // and plain browser loading, + if (typeof define === 'function' && define.amd) { + define(['exports'], factory); + } else if (typeof exports !== 'undefined') { + factory(exports); + } else { + factory((root.estraverse = {})); + } +}(this, function clone(exports) { + 'use strict'; - return binarySearch.search(aNeedle, aMappings, aComparator); - }; + var Syntax, + isArray, + VisitorOption, + VisitorKeys, + objectCreate, + objectKeys, + BREAK, + SKIP, + REMOVE; - /** - * Compute the last column for each generated mapping. The last column is - * inclusive. - */ - SourceMapConsumer.prototype.computeColumnSpans = - function SourceMapConsumer_computeColumnSpans() { - for (var index = 0; index < this._generatedMappings.length; ++index) { - var mapping = this._generatedMappings[index]; + function ignoreJSHintError() { } - // Mappings do not contain a field for the last generated columnt. We - // can come up with an optimistic estimate, however, by assuming that - // mappings are contiguous (i.e. given two consecutive mappings, the - // first mapping ends where the second one starts). - if (index + 1 < this._generatedMappings.length) { - var nextMapping = this._generatedMappings[index + 1]; + isArray = Array.isArray; + if (!isArray) { + isArray = function isArray(array) { + return Object.prototype.toString.call(array) === '[object Array]'; + }; + } - if (mapping.generatedLine === nextMapping.generatedLine) { - mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1; - continue; - } + function deepCopy(obj) { + var ret = {}, key, val; + for (key in obj) { + if (obj.hasOwnProperty(key)) { + val = obj[key]; + if (typeof val === 'object' && val !== null) { + ret[key] = deepCopy(val); + } else { + ret[key] = val; + } + } } + return ret; + } - // The last mapping for each line spans the entire line. - mapping.lastGeneratedColumn = Infinity; - } - }; + function shallowCopy(obj) { + var ret = {}, key; + for (key in obj) { + if (obj.hasOwnProperty(key)) { + ret[key] = obj[key]; + } + } + return ret; + } + ignoreJSHintError(shallowCopy); - /** - * Returns the original source, line, and column information for the generated - * source's line and column positions provided. The only argument is an object - * with the following properties: - * - * - line: The line number in the generated source. - * - column: The column number in the generated source. - * - * and an object is returned with the following properties: - * - * - source: The original source file, or null. - * - line: The line number in the original source, or null. - * - column: The column number in the original source, or null. - * - name: The original identifier, or null. - */ - SourceMapConsumer.prototype.originalPositionFor = - function SourceMapConsumer_originalPositionFor(aArgs) { - var needle = { - generatedLine: util.getArg(aArgs, 'line'), - generatedColumn: util.getArg(aArgs, 'column') - }; + // based on LLVM libc++ upper_bound / lower_bound + // MIT License - var index = this._findMapping(needle, - this._generatedMappings, - "generatedLine", - "generatedColumn", - util.compareByGeneratedPositions); + function upperBound(array, func) { + var diff, len, i, current; - if (index >= 0) { - var mapping = this._generatedMappings[index]; + len = array.length; + i = 0; - if (mapping.generatedLine === needle.generatedLine) { - var source = util.getArg(mapping, 'source', null); - if (source != null && this.sourceRoot != null) { - source = util.join(this.sourceRoot, source); - } - return { - source: source, - line: util.getArg(mapping, 'originalLine', null), - column: util.getArg(mapping, 'originalColumn', null), - name: util.getArg(mapping, 'name', null) - }; + while (len) { + diff = len >>> 1; + current = i + diff; + if (func(array[current])) { + len = diff; + } else { + i = current + 1; + len -= diff + 1; + } } - } + return i; + } - return { - source: null, - line: null, - column: null, - name: null - }; - }; + function lowerBound(array, func) { + var diff, len, i, current; - /** - * Returns the original source content. The only argument is the url of the - * original source file. Returns null if no original source content is - * availible. - */ - SourceMapConsumer.prototype.sourceContentFor = - function SourceMapConsumer_sourceContentFor(aSource) { - if (!this.sourcesContent) { - return null; - } + len = array.length; + i = 0; - if (this.sourceRoot != null) { - aSource = util.relative(this.sourceRoot, aSource); - } + while (len) { + diff = len >>> 1; + current = i + diff; + if (func(array[current])) { + i = current + 1; + len -= diff + 1; + } else { + len = diff; + } + } + return i; + } + ignoreJSHintError(lowerBound); - if (this._sources.has(aSource)) { - return this.sourcesContent[this._sources.indexOf(aSource)]; - } + objectCreate = Object.create || (function () { + function F() { } - var url; - if (this.sourceRoot != null - && (url = util.urlParse(this.sourceRoot))) { - // XXX: file:// URIs and absolute paths lead to unexpected behavior for - // many users. We can help them out when they expect file:// URIs to - // behave like it would if they were running a local HTTP server. See - // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. - var fileUriAbsPath = aSource.replace(/^file:\/\//, ""); - if (url.scheme == "file" - && this._sources.has(fileUriAbsPath)) { - return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] - } + return function (o) { + F.prototype = o; + return new F(); + }; + })(); - if ((!url.path || url.path == "/") - && this._sources.has("/" + aSource)) { - return this.sourcesContent[this._sources.indexOf("/" + aSource)]; + objectKeys = Object.keys || function (o) { + var keys = [], key; + for (key in o) { + keys.push(key); } - } - - throw new Error('"' + aSource + '" is not in the SourceMap.'); + return keys; }; - /** - * Returns the generated line and column information for the original source, - * line, and column positions provided. The only argument is an object with - * the following properties: - * - * - source: The filename of the original source. - * - line: The line number in the original source. - * - column: The column number in the original source. - * - * and an object is returned with the following properties: - * - * - line: The line number in the generated source, or null. - * - column: The column number in the generated source, or null. - */ - SourceMapConsumer.prototype.generatedPositionFor = - function SourceMapConsumer_generatedPositionFor(aArgs) { - var needle = { - source: util.getArg(aArgs, 'source'), - originalLine: util.getArg(aArgs, 'line'), - originalColumn: util.getArg(aArgs, 'column') - }; - - if (this.sourceRoot != null) { - needle.source = util.relative(this.sourceRoot, needle.source); - } - - var index = this._findMapping(needle, - this._originalMappings, - "originalLine", - "originalColumn", - util.compareByOriginalPositions); - - if (index >= 0) { - var mapping = this._originalMappings[index]; + function extend(to, from) { + var keys = objectKeys(from), key, i, len; + for (i = 0, len = keys.length; i < len; i += 1) { + key = keys[i]; + to[key] = from[key]; + } + return to; + } - return { - line: util.getArg(mapping, 'generatedLine', null), - column: util.getArg(mapping, 'generatedColumn', null), - lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) - }; - } + Syntax = { + AssignmentExpression: 'AssignmentExpression', + ArrayExpression: 'ArrayExpression', + ArrayPattern: 'ArrayPattern', + ArrowFunctionExpression: 'ArrowFunctionExpression', + AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7. + BlockStatement: 'BlockStatement', + BinaryExpression: 'BinaryExpression', + BreakStatement: 'BreakStatement', + CallExpression: 'CallExpression', + CatchClause: 'CatchClause', + ClassBody: 'ClassBody', + ClassDeclaration: 'ClassDeclaration', + ClassExpression: 'ClassExpression', + ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7. + ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7. + ConditionalExpression: 'ConditionalExpression', + ContinueStatement: 'ContinueStatement', + DebuggerStatement: 'DebuggerStatement', + DirectiveStatement: 'DirectiveStatement', + DoWhileStatement: 'DoWhileStatement', + EmptyStatement: 'EmptyStatement', + ExportBatchSpecifier: 'ExportBatchSpecifier', + ExportDeclaration: 'ExportDeclaration', + ExportSpecifier: 'ExportSpecifier', + ExpressionStatement: 'ExpressionStatement', + ForStatement: 'ForStatement', + ForInStatement: 'ForInStatement', + ForOfStatement: 'ForOfStatement', + FunctionDeclaration: 'FunctionDeclaration', + FunctionExpression: 'FunctionExpression', + GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7. + Identifier: 'Identifier', + IfStatement: 'IfStatement', + ImportDeclaration: 'ImportDeclaration', + ImportDefaultSpecifier: 'ImportDefaultSpecifier', + ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', + ImportSpecifier: 'ImportSpecifier', + Literal: 'Literal', + LabeledStatement: 'LabeledStatement', + LogicalExpression: 'LogicalExpression', + MemberExpression: 'MemberExpression', + MethodDefinition: 'MethodDefinition', + ModuleSpecifier: 'ModuleSpecifier', + NewExpression: 'NewExpression', + ObjectExpression: 'ObjectExpression', + ObjectPattern: 'ObjectPattern', + Program: 'Program', + Property: 'Property', + ReturnStatement: 'ReturnStatement', + SequenceExpression: 'SequenceExpression', + SpreadElement: 'SpreadElement', + SwitchStatement: 'SwitchStatement', + SwitchCase: 'SwitchCase', + TaggedTemplateExpression: 'TaggedTemplateExpression', + TemplateElement: 'TemplateElement', + TemplateLiteral: 'TemplateLiteral', + ThisExpression: 'ThisExpression', + ThrowStatement: 'ThrowStatement', + TryStatement: 'TryStatement', + UnaryExpression: 'UnaryExpression', + UpdateExpression: 'UpdateExpression', + VariableDeclaration: 'VariableDeclaration', + VariableDeclarator: 'VariableDeclarator', + WhileStatement: 'WhileStatement', + WithStatement: 'WithStatement', + YieldExpression: 'YieldExpression' + }; - return { - line: null, - column: null, - lastColumn: null - }; + VisitorKeys = { + AssignmentExpression: ['left', 'right'], + ArrayExpression: ['elements'], + ArrayPattern: ['elements'], + ArrowFunctionExpression: ['params', 'defaults', 'rest', 'body'], + AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7. + BlockStatement: ['body'], + BinaryExpression: ['left', 'right'], + BreakStatement: ['label'], + CallExpression: ['callee', 'arguments'], + CatchClause: ['param', 'body'], + ClassBody: ['body'], + ClassDeclaration: ['id', 'body', 'superClass'], + ClassExpression: ['id', 'body', 'superClass'], + ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7. + ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7. + ConditionalExpression: ['test', 'consequent', 'alternate'], + ContinueStatement: ['label'], + DebuggerStatement: [], + DirectiveStatement: [], + DoWhileStatement: ['body', 'test'], + EmptyStatement: [], + ExportBatchSpecifier: [], + ExportDeclaration: ['declaration', 'specifiers', 'source'], + ExportSpecifier: ['id', 'name'], + ExpressionStatement: ['expression'], + ForStatement: ['init', 'test', 'update', 'body'], + ForInStatement: ['left', 'right', 'body'], + ForOfStatement: ['left', 'right', 'body'], + FunctionDeclaration: ['id', 'params', 'defaults', 'rest', 'body'], + FunctionExpression: ['id', 'params', 'defaults', 'rest', 'body'], + GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7. + Identifier: [], + IfStatement: ['test', 'consequent', 'alternate'], + ImportDeclaration: ['specifiers', 'source'], + ImportDefaultSpecifier: ['id'], + ImportNamespaceSpecifier: ['id'], + ImportSpecifier: ['id', 'name'], + Literal: [], + LabeledStatement: ['label', 'body'], + LogicalExpression: ['left', 'right'], + MemberExpression: ['object', 'property'], + MethodDefinition: ['key', 'value'], + ModuleSpecifier: [], + NewExpression: ['callee', 'arguments'], + ObjectExpression: ['properties'], + ObjectPattern: ['properties'], + Program: ['body'], + Property: ['key', 'value'], + ReturnStatement: ['argument'], + SequenceExpression: ['expressions'], + SpreadElement: ['argument'], + SwitchStatement: ['discriminant', 'cases'], + SwitchCase: ['test', 'consequent'], + TaggedTemplateExpression: ['tag', 'quasi'], + TemplateElement: [], + TemplateLiteral: ['quasis', 'expressions'], + ThisExpression: [], + ThrowStatement: ['argument'], + TryStatement: ['block', 'handlers', 'handler', 'guardedHandlers', 'finalizer'], + UnaryExpression: ['argument'], + UpdateExpression: ['argument'], + VariableDeclaration: ['declarations'], + VariableDeclarator: ['id', 'init'], + WhileStatement: ['test', 'body'], + WithStatement: ['object', 'body'], + YieldExpression: ['argument'] }; - /** - * Returns all generated line and column information for the original source - * and line provided. The only argument is an object with the following - * properties: - * - * - source: The filename of the original source. - * - line: The line number in the original source. - * - * and an array of objects is returned, each with the following properties: - * - * - line: The line number in the generated source, or null. - * - column: The column number in the generated source, or null. - */ - SourceMapConsumer.prototype.allGeneratedPositionsFor = - function SourceMapConsumer_allGeneratedPositionsFor(aArgs) { - // When there is no exact match, SourceMapConsumer.prototype._findMapping - // returns the index of the closest mapping less than the needle. By - // setting needle.originalColumn to Infinity, we thus find the last - // mapping for the given line, provided such a mapping exists. - var needle = { - source: util.getArg(aArgs, 'source'), - originalLine: util.getArg(aArgs, 'line'), - originalColumn: Infinity - }; + // unique id + BREAK = {}; + SKIP = {}; + REMOVE = {}; - if (this.sourceRoot != null) { - needle.source = util.relative(this.sourceRoot, needle.source); - } + VisitorOption = { + Break: BREAK, + Skip: SKIP, + Remove: REMOVE + }; - var mappings = []; + function Reference(parent, key) { + this.parent = parent; + this.key = key; + } - var index = this._findMapping(needle, - this._originalMappings, - "originalLine", - "originalColumn", - util.compareByOriginalPositions); - if (index >= 0) { - var mapping = this._originalMappings[index]; + Reference.prototype.replace = function replace(node) { + this.parent[this.key] = node; + }; - while (mapping && mapping.originalLine === needle.originalLine) { - mappings.push({ - line: util.getArg(mapping, 'generatedLine', null), - column: util.getArg(mapping, 'generatedColumn', null), - lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) - }); + Reference.prototype.remove = function remove() { + if (isArray(this.parent)) { + this.parent.splice(this.key, 1); + return true; + } else { + this.replace(null); + return false; + } + }; - mapping = this._originalMappings[--index]; + function Element(node, path, wrap, ref) { + this.node = node; + this.path = path; + this.wrap = wrap; + this.ref = ref; + } + + function Controller() { } + + // API: + // return property path array from root to current node + Controller.prototype.path = function path() { + var i, iz, j, jz, result, element; + + function addToPath(result, path) { + if (isArray(path)) { + for (j = 0, jz = path.length; j < jz; ++j) { + result.push(path[j]); + } + } else { + result.push(path); + } } - } - return mappings.reverse(); + // root node + if (!this.__current.path) { + return null; + } + + // first node is sentinel, second node is root element + result = []; + for (i = 2, iz = this.__leavelist.length; i < iz; ++i) { + element = this.__leavelist[i]; + addToPath(result, element.path); + } + addToPath(result, this.__current.path); + return result; }; - SourceMapConsumer.GENERATED_ORDER = 1; - SourceMapConsumer.ORIGINAL_ORDER = 2; + // API: + // return type of current node + Controller.prototype.type = function () { + var node = this.current(); + return node.type || this.__current.wrap; + }; - /** - * Iterate over each mapping between an original source/line/column and a - * generated line/column in this source map. - * - * @param Function aCallback - * The function that is called with each mapping. - * @param Object aContext - * Optional. If specified, this object will be the value of `this` every - * time that `aCallback` is called. - * @param aOrder - * Either `SourceMapConsumer.GENERATED_ORDER` or - * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to - * iterate over the mappings sorted by the generated file's line/column - * order or the original's source/line/column order, respectively. Defaults to - * `SourceMapConsumer.GENERATED_ORDER`. - */ - SourceMapConsumer.prototype.eachMapping = - function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { - var context = aContext || null; - var order = aOrder || SourceMapConsumer.GENERATED_ORDER; - - var mappings; - switch (order) { - case SourceMapConsumer.GENERATED_ORDER: - mappings = this._generatedMappings; - break; - case SourceMapConsumer.ORIGINAL_ORDER: - mappings = this._originalMappings; - break; - default: - throw new Error("Unknown order of iteration."); - } + // API: + // return array of parent elements + Controller.prototype.parents = function parents() { + var i, iz, result; - var sourceRoot = this.sourceRoot; - mappings.map(function (mapping) { - var source = mapping.source; - if (source != null && sourceRoot != null) { - source = util.join(sourceRoot, source); + // first node is sentinel + result = []; + for (i = 1, iz = this.__leavelist.length; i < iz; ++i) { + result.push(this.__leavelist[i].node); } - return { - source: source, - generatedLine: mapping.generatedLine, - generatedColumn: mapping.generatedColumn, - originalLine: mapping.originalLine, - originalColumn: mapping.originalColumn, - name: mapping.name - }; - }).forEach(aCallback, context); + + return result; }; - exports.SourceMapConsumer = SourceMapConsumer; + // API: + // return current node + Controller.prototype.current = function current() { + return this.__current.node; + }; -}); + Controller.prototype.__execute = function __execute(callback, element) { + var previous, result; -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-consumer.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") -},{"./array-set":9,"./base64-vlq":10,"./binary-search":12,"./util":17,"1YiZ5S":25,"amdefine":18,"buffer":21}],15:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = require('amdefine')(module, require); -} -define(function (require, exports, module) { + result = undefined; - var base64VLQ = require('./base64-vlq'); - var util = require('./util'); - var ArraySet = require('./array-set').ArraySet; - var MappingList = require('./mapping-list').MappingList; + previous = this.__current; + this.__current = element; + this.__state = null; + if (callback) { + result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node); + } + this.__current = previous; - /** - * An instance of the SourceMapGenerator represents a source map which is - * being built incrementally. You may pass an object with the following - * properties: - * - * - file: The filename of the generated source. - * - sourceRoot: A root for all relative URLs in this source map. - */ - function SourceMapGenerator(aArgs) { - if (!aArgs) { - aArgs = {}; - } - this._file = util.getArg(aArgs, 'file', null); - this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); - this._skipValidation = util.getArg(aArgs, 'skipValidation', false); - this._sources = new ArraySet(); - this._names = new ArraySet(); - this._mappings = new MappingList(); - this._sourcesContents = null; - } + return result; + }; - SourceMapGenerator.prototype._version = 3; + // API: + // notify control skip / break + Controller.prototype.notify = function notify(flag) { + this.__state = flag; + }; - /** - * Creates a new SourceMapGenerator based on a SourceMapConsumer - * - * @param aSourceMapConsumer The SourceMap. - */ - SourceMapGenerator.fromSourceMap = - function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { - var sourceRoot = aSourceMapConsumer.sourceRoot; - var generator = new SourceMapGenerator({ - file: aSourceMapConsumer.file, - sourceRoot: sourceRoot - }); - aSourceMapConsumer.eachMapping(function (mapping) { - var newMapping = { - generated: { - line: mapping.generatedLine, - column: mapping.generatedColumn - } - }; + // API: + // skip child nodes of current node + Controller.prototype.skip = function () { + this.notify(SKIP); + }; - if (mapping.source != null) { - newMapping.source = mapping.source; - if (sourceRoot != null) { - newMapping.source = util.relative(sourceRoot, newMapping.source); - } + // API: + // break traversals + Controller.prototype['break'] = function () { + this.notify(BREAK); + }; - newMapping.original = { - line: mapping.originalLine, - column: mapping.originalColumn - }; + // API: + // remove node + Controller.prototype.remove = function () { + this.notify(REMOVE); + }; - if (mapping.name != null) { - newMapping.name = mapping.name; - } + Controller.prototype.__initialize = function(root, visitor) { + this.visitor = visitor; + this.root = root; + this.__worklist = []; + this.__leavelist = []; + this.__current = null; + this.__state = null; + this.__fallback = visitor.fallback === 'iteration'; + this.__keys = VisitorKeys; + if (visitor.keys) { + this.__keys = extend(objectCreate(this.__keys), visitor.keys); } + }; - generator.addMapping(newMapping); - }); - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content != null) { - generator.setSourceContent(sourceFile, content); + function isNode(node) { + if (node == null) { + return false; } - }); - return generator; - }; + return typeof node === 'object' && typeof node.type === 'string'; + } - /** - * Add a single mapping from original source line and column to the generated - * source's line and column for this source map being created. The mapping - * object should have the following properties: - * - * - generated: An object with the generated line and column positions. - * - original: An object with the original line and column positions. - * - source: The original source file (relative to the sourceRoot). - * - name: An optional original token name for this mapping. - */ - SourceMapGenerator.prototype.addMapping = - function SourceMapGenerator_addMapping(aArgs) { - var generated = util.getArg(aArgs, 'generated'); - var original = util.getArg(aArgs, 'original', null); - var source = util.getArg(aArgs, 'source', null); - var name = util.getArg(aArgs, 'name', null); + function isProperty(nodeType, key) { + return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key; + } - if (!this._skipValidation) { - this._validateMapping(generated, original, source, name); - } + Controller.prototype.traverse = function traverse(root, visitor) { + var worklist, + leavelist, + element, + node, + nodeType, + ret, + key, + current, + current2, + candidates, + candidate, + sentinel; - if (source != null && !this._sources.has(source)) { - this._sources.add(source); - } + this.__initialize(root, visitor); - if (name != null && !this._names.has(name)) { - this._names.add(name); - } + sentinel = {}; - this._mappings.add({ - generatedLine: generated.line, - generatedColumn: generated.column, - originalLine: original != null && original.line, - originalColumn: original != null && original.column, - source: source, - name: name - }); - }; + // reference + worklist = this.__worklist; + leavelist = this.__leavelist; - /** - * Set the source content for a source file. - */ - SourceMapGenerator.prototype.setSourceContent = - function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { - var source = aSourceFile; - if (this._sourceRoot != null) { - source = util.relative(this._sourceRoot, source); - } + // initialize + worklist.push(new Element(root, null, null, null)); + leavelist.push(new Element(null, null, null, null)); - if (aSourceContent != null) { - // Add the source content to the _sourcesContents map. - // Create a new _sourcesContents map if the property is null. - if (!this._sourcesContents) { - this._sourcesContents = {}; - } - this._sourcesContents[util.toSetString(source)] = aSourceContent; - } else if (this._sourcesContents) { - // Remove the source file from the _sourcesContents map. - // If the _sourcesContents map is empty, set the property to null. - delete this._sourcesContents[util.toSetString(source)]; - if (Object.keys(this._sourcesContents).length === 0) { - this._sourcesContents = null; - } - } - }; + while (worklist.length) { + element = worklist.pop(); - /** - * Applies the mappings of a sub-source-map for a specific source file to the - * source map being generated. Each mapping to the supplied source file is - * rewritten using the supplied source map. Note: The resolution for the - * resulting mappings is the minimium of this map and the supplied map. - * - * @param aSourceMapConsumer The source map to be applied. - * @param aSourceFile Optional. The filename of the source file. - * If omitted, SourceMapConsumer's file property will be used. - * @param aSourceMapPath Optional. The dirname of the path to the source map - * to be applied. If relative, it is relative to the SourceMapConsumer. - * This parameter is needed when the two source maps aren't in the same - * directory, and the source map to be applied contains relative source - * paths. If so, those relative source paths need to be rewritten - * relative to the SourceMapGenerator. - */ - SourceMapGenerator.prototype.applySourceMap = - function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { - var sourceFile = aSourceFile; - // If aSourceFile is omitted, we will use the file property of the SourceMap - if (aSourceFile == null) { - if (aSourceMapConsumer.file == null) { - throw new Error( - 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + - 'or the source map\'s "file" property. Both were omitted.' - ); - } - sourceFile = aSourceMapConsumer.file; - } - var sourceRoot = this._sourceRoot; - // Make "sourceFile" relative if an absolute Url is passed. - if (sourceRoot != null) { - sourceFile = util.relative(sourceRoot, sourceFile); - } - // Applying the SourceMap can add and remove items from the sources and - // the names array. - var newSources = new ArraySet(); - var newNames = new ArraySet(); + if (element === sentinel) { + element = leavelist.pop(); - // Find mappings for the "sourceFile" - this._mappings.unsortedForEach(function (mapping) { - if (mapping.source === sourceFile && mapping.originalLine != null) { - // Check if it can be mapped by the source map, then update the mapping. - var original = aSourceMapConsumer.originalPositionFor({ - line: mapping.originalLine, - column: mapping.originalColumn - }); - if (original.source != null) { - // Copy mapping - mapping.source = original.source; - if (aSourceMapPath != null) { - mapping.source = util.join(aSourceMapPath, mapping.source) - } - if (sourceRoot != null) { - mapping.source = util.relative(sourceRoot, mapping.source); - } - mapping.originalLine = original.line; - mapping.originalColumn = original.column; - if (original.name != null) { - mapping.name = original.name; - } - } - } + ret = this.__execute(visitor.leave, element); - var source = mapping.source; - if (source != null && !newSources.has(source)) { - newSources.add(source); - } + if (this.__state === BREAK || ret === BREAK) { + return; + } + continue; + } - var name = mapping.name; - if (name != null && !newNames.has(name)) { - newNames.add(name); - } + if (element.node) { - }, this); - this._sources = newSources; - this._names = newNames; + ret = this.__execute(visitor.enter, element); - // Copy sourcesContents of applied map. - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content != null) { - if (aSourceMapPath != null) { - sourceFile = util.join(aSourceMapPath, sourceFile); - } - if (sourceRoot != null) { - sourceFile = util.relative(sourceRoot, sourceFile); - } - this.setSourceContent(sourceFile, content); - } - }, this); - }; + if (this.__state === BREAK || ret === BREAK) { + return; + } - /** - * A mapping can have one of the three levels of data: - * - * 1. Just the generated position. - * 2. The Generated position, original position, and original source. - * 3. Generated and original position, original source, as well as a name - * token. - * - * To maintain consistency, we validate that any new mapping being added falls - * in to one of these categories. - */ - SourceMapGenerator.prototype._validateMapping = - function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, - aName) { - if (aGenerated && 'line' in aGenerated && 'column' in aGenerated - && aGenerated.line > 0 && aGenerated.column >= 0 - && !aOriginal && !aSource && !aName) { - // Case 1. - return; - } - else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated - && aOriginal && 'line' in aOriginal && 'column' in aOriginal - && aGenerated.line > 0 && aGenerated.column >= 0 - && aOriginal.line > 0 && aOriginal.column >= 0 - && aSource) { - // Cases 2 and 3. - return; - } - else { - throw new Error('Invalid mapping: ' + JSON.stringify({ - generated: aGenerated, - source: aSource, - original: aOriginal, - name: aName - })); - } - }; + worklist.push(sentinel); + leavelist.push(element); - /** - * Serialize the accumulated mappings in to the stream of base 64 VLQs - * specified by the source map format. - */ - SourceMapGenerator.prototype._serializeMappings = - function SourceMapGenerator_serializeMappings() { - var previousGeneratedColumn = 0; - var previousGeneratedLine = 1; - var previousOriginalColumn = 0; - var previousOriginalLine = 0; - var previousName = 0; - var previousSource = 0; - var result = ''; - var mapping; + if (this.__state === SKIP || ret === SKIP) { + continue; + } - var mappings = this._mappings.toArray(); + node = element.node; + nodeType = element.wrap || node.type; + candidates = this.__keys[nodeType]; + if (!candidates) { + if (this.__fallback) { + candidates = objectKeys(node); + } else { + throw new Error('Unknown node type ' + nodeType + '.'); + } + } - for (var i = 0, len = mappings.length; i < len; i++) { - mapping = mappings[i]; + current = candidates.length; + while ((current -= 1) >= 0) { + key = candidates[current]; + candidate = node[key]; + if (!candidate) { + continue; + } - if (mapping.generatedLine !== previousGeneratedLine) { - previousGeneratedColumn = 0; - while (mapping.generatedLine !== previousGeneratedLine) { - result += ';'; - previousGeneratedLine++; - } - } - else { - if (i > 0) { - if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) { - continue; + if (isArray(candidate)) { + current2 = candidate.length; + while ((current2 -= 1) >= 0) { + if (!candidate[current2]) { + continue; + } + if (isProperty(nodeType, candidates[current])) { + element = new Element(candidate[current2], [key, current2], 'Property', null); + } else if (isNode(candidate[current2])) { + element = new Element(candidate[current2], [key, current2], null, null); + } else { + continue; + } + worklist.push(element); + } + } else if (isNode(candidate)) { + worklist.push(new Element(candidate, key, null, null)); + } + } } - result += ','; - } } + }; - result += base64VLQ.encode(mapping.generatedColumn - - previousGeneratedColumn); - previousGeneratedColumn = mapping.generatedColumn; - - if (mapping.source != null) { - result += base64VLQ.encode(this._sources.indexOf(mapping.source) - - previousSource); - previousSource = this._sources.indexOf(mapping.source); - - // lines are stored 0-based in SourceMap spec version 3 - result += base64VLQ.encode(mapping.originalLine - 1 - - previousOriginalLine); - previousOriginalLine = mapping.originalLine - 1; + Controller.prototype.replace = function replace(root, visitor) { + function removeElem(element) { + var i, + key, + nextElem, + parent; - result += base64VLQ.encode(mapping.originalColumn - - previousOriginalColumn); - previousOriginalColumn = mapping.originalColumn; + if (element.ref.remove()) { + // When the reference is an element of an array. + key = element.ref.key; + parent = element.ref.parent; - if (mapping.name != null) { - result += base64VLQ.encode(this._names.indexOf(mapping.name) - - previousName); - previousName = this._names.indexOf(mapping.name); - } + // If removed from array, then decrease following items' keys. + i = worklist.length; + while (i--) { + nextElem = worklist[i]; + if (nextElem.ref && nextElem.ref.parent === parent) { + if (nextElem.ref.key < key) { + break; + } + --nextElem.ref.key; + } + } + } } - } - - return result; - }; - SourceMapGenerator.prototype._generateSourcesContent = - function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { - return aSources.map(function (source) { - if (!this._sourcesContents) { - return null; - } - if (aSourceRoot != null) { - source = util.relative(aSourceRoot, source); - } - var key = util.toSetString(source); - return Object.prototype.hasOwnProperty.call(this._sourcesContents, - key) - ? this._sourcesContents[key] - : null; - }, this); - }; + var worklist, + leavelist, + node, + nodeType, + target, + element, + current, + current2, + candidates, + candidate, + sentinel, + outer, + key; - /** - * Externalize the source map. - */ - SourceMapGenerator.prototype.toJSON = - function SourceMapGenerator_toJSON() { - var map = { - version: this._version, - sources: this._sources.toArray(), - names: this._names.toArray(), - mappings: this._serializeMappings() - }; - if (this._file != null) { - map.file = this._file; - } - if (this._sourceRoot != null) { - map.sourceRoot = this._sourceRoot; - } - if (this._sourcesContents) { - map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); - } + this.__initialize(root, visitor); - return map; - }; + sentinel = {}; - /** - * Render the source map being generated to a string. - */ - SourceMapGenerator.prototype.toString = - function SourceMapGenerator_toString() { - return JSON.stringify(this); - }; + // reference + worklist = this.__worklist; + leavelist = this.__leavelist; - exports.SourceMapGenerator = SourceMapGenerator; + // initialize + outer = { + root: root + }; + element = new Element(root, null, null, new Reference(outer, 'root')); + worklist.push(element); + leavelist.push(element); -}); + while (worklist.length) { + element = worklist.pop(); -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-generator.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") -},{"./array-set":9,"./base64-vlq":10,"./mapping-list":13,"./util":17,"1YiZ5S":25,"amdefine":18,"buffer":21}],16:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = require('amdefine')(module, require); -} -define(function (require, exports, module) { + if (element === sentinel) { + element = leavelist.pop(); - var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator; - var util = require('./util'); + target = this.__execute(visitor.leave, element); - // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other - // operating systems these days (capturing the result). - var REGEX_NEWLINE = /(\r?\n)/; + // node may be replaced with null, + // so distinguish between undefined and null in this place + if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) { + // replace + element.ref.replace(target); + } - // Newline character code for charCodeAt() comparisons - var NEWLINE_CODE = 10; + if (this.__state === REMOVE || target === REMOVE) { + removeElem(element); + } - // Private symbol for identifying `SourceNode`s when multiple versions of - // the source-map library are loaded. This MUST NOT CHANGE across - // versions! - var isSourceNode = "$$$isSourceNode$$$"; + if (this.__state === BREAK || target === BREAK) { + return outer.root; + } + continue; + } - /** - * SourceNodes provide a way to abstract over interpolating/concatenating - * snippets of generated JavaScript source code while maintaining the line and - * column information associated with the original source code. - * - * @param aLine The original line number. - * @param aColumn The original column number. - * @param aSource The original source's filename. - * @param aChunks Optional. An array of strings which are snippets of - * generated JS, or other SourceNodes. - * @param aName The original identifier. - */ - function SourceNode(aLine, aColumn, aSource, aChunks, aName) { - this.children = []; - this.sourceContents = {}; - this.line = aLine == null ? null : aLine; - this.column = aColumn == null ? null : aColumn; - this.source = aSource == null ? null : aSource; - this.name = aName == null ? null : aName; - this[isSourceNode] = true; - if (aChunks != null) this.add(aChunks); - } + target = this.__execute(visitor.enter, element); - /** - * Creates a SourceNode from generated code and a SourceMapConsumer. - * - * @param aGeneratedCode The generated code - * @param aSourceMapConsumer The SourceMap for the generated code - * @param aRelativePath Optional. The path that relative sources in the - * SourceMapConsumer should be relative to. - */ - SourceNode.fromStringWithSourceMap = - function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { - // The SourceNode we want to fill with the generated code - // and the SourceMap - var node = new SourceNode(); + // node may be replaced with null, + // so distinguish between undefined and null in this place + if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) { + // replace + element.ref.replace(target); + element.node = target; + } - // All even indices of this array are one line of the generated code, - // while all odd indices are the newlines between two adjacent lines - // (since `REGEX_NEWLINE` captures its match). - // Processed fragments are removed from this array, by calling `shiftNextLine`. - var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); - var shiftNextLine = function() { - var lineContents = remainingLines.shift(); - // The last line of a file might not have a newline. - var newLine = remainingLines.shift() || ""; - return lineContents + newLine; - }; + if (this.__state === REMOVE || target === REMOVE) { + removeElem(element); + element.node = null; + } - // We need to remember the position of "remainingLines" - var lastGeneratedLine = 1, lastGeneratedColumn = 0; + if (this.__state === BREAK || target === BREAK) { + return outer.root; + } - // The generate SourceNodes we need a code range. - // To extract it current and last mapping is used. - // Here we store the last mapping. - var lastMapping = null; + // node may be null + node = element.node; + if (!node) { + continue; + } - aSourceMapConsumer.eachMapping(function (mapping) { - if (lastMapping !== null) { - // We add the code from "lastMapping" to "mapping": - // First check if there is a new line in between. - if (lastGeneratedLine < mapping.generatedLine) { - var code = ""; - // Associate first line with "lastMapping" - addMappingWithCode(lastMapping, shiftNextLine()); - lastGeneratedLine++; - lastGeneratedColumn = 0; - // The remaining code is added without mapping - } else { - // There is no new line in between. - // Associate the code between "lastGeneratedColumn" and - // "mapping.generatedColumn" with "lastMapping" - var nextLine = remainingLines[0]; - var code = nextLine.substr(0, mapping.generatedColumn - - lastGeneratedColumn); - remainingLines[0] = nextLine.substr(mapping.generatedColumn - - lastGeneratedColumn); - lastGeneratedColumn = mapping.generatedColumn; - addMappingWithCode(lastMapping, code); - // No more remaining code, continue - lastMapping = mapping; - return; - } - } - // We add the generated code until the first mapping - // to the SourceNode without any mapping. - // Each line is added as separate string. - while (lastGeneratedLine < mapping.generatedLine) { - node.add(shiftNextLine()); - lastGeneratedLine++; - } - if (lastGeneratedColumn < mapping.generatedColumn) { - var nextLine = remainingLines[0]; - node.add(nextLine.substr(0, mapping.generatedColumn)); - remainingLines[0] = nextLine.substr(mapping.generatedColumn); - lastGeneratedColumn = mapping.generatedColumn; - } - lastMapping = mapping; - }, this); - // We have processed all mappings. - if (remainingLines.length > 0) { - if (lastMapping) { - // Associate the remaining code in the current line with "lastMapping" - addMappingWithCode(lastMapping, shiftNextLine()); - } - // and add the remaining lines without any mapping - node.add(remainingLines.join("")); - } + worklist.push(sentinel); + leavelist.push(element); - // Copy sourcesContent into SourceNode - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content != null) { - if (aRelativePath != null) { - sourceFile = util.join(aRelativePath, sourceFile); - } - node.setSourceContent(sourceFile, content); - } - }); + if (this.__state === SKIP || target === SKIP) { + continue; + } - return node; + nodeType = element.wrap || node.type; + candidates = this.__keys[nodeType]; + if (!candidates) { + if (this.__fallback) { + candidates = objectKeys(node); + } else { + throw new Error('Unknown node type ' + nodeType + '.'); + } + } - function addMappingWithCode(mapping, code) { - if (mapping === null || mapping.source === undefined) { - node.add(code); - } else { - var source = aRelativePath - ? util.join(aRelativePath, mapping.source) - : mapping.source; - node.add(new SourceNode(mapping.originalLine, - mapping.originalColumn, - source, - code, - mapping.name)); + current = candidates.length; + while ((current -= 1) >= 0) { + key = candidates[current]; + candidate = node[key]; + if (!candidate) { + continue; + } + + if (isArray(candidate)) { + current2 = candidate.length; + while ((current2 -= 1) >= 0) { + if (!candidate[current2]) { + continue; + } + if (isProperty(nodeType, candidates[current])) { + element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2)); + } else if (isNode(candidate[current2])) { + element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2)); + } else { + continue; + } + worklist.push(element); + } + } else if (isNode(candidate)) { + worklist.push(new Element(candidate, key, null, new Reference(node, key))); + } + } } - } + + return outer.root; }; - /** - * Add a chunk of generated JS to this source node. - * - * @param aChunk A string snippet of generated JS code, another instance of - * SourceNode, or an array where each member is one of those things. - */ - SourceNode.prototype.add = function SourceNode_add(aChunk) { - if (Array.isArray(aChunk)) { - aChunk.forEach(function (chunk) { - this.add(chunk); - }, this); - } - else if (aChunk[isSourceNode] || typeof aChunk === "string") { - if (aChunk) { - this.children.push(aChunk); - } - } - else { - throw new TypeError( - "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk - ); + function traverse(root, visitor) { + var controller = new Controller(); + return controller.traverse(root, visitor); } - return this; - }; - /** - * Add a chunk of generated JS to the beginning of this source node. - * - * @param aChunk A string snippet of generated JS code, another instance of - * SourceNode, or an array where each member is one of those things. - */ - SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { - if (Array.isArray(aChunk)) { - for (var i = aChunk.length-1; i >= 0; i--) { - this.prepend(aChunk[i]); - } - } - else if (aChunk[isSourceNode] || typeof aChunk === "string") { - this.children.unshift(aChunk); - } - else { - throw new TypeError( - "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk - ); + function replace(root, visitor) { + var controller = new Controller(); + return controller.replace(root, visitor); } - return this; - }; - /** - * Walk over the tree of JS snippets in this node and its children. The - * walking function is called once for each snippet of JS and is passed that - * snippet and the its original associated source's line/column location. - * - * @param aFn The traversal function. - */ - SourceNode.prototype.walk = function SourceNode_walk(aFn) { - var chunk; - for (var i = 0, len = this.children.length; i < len; i++) { - chunk = this.children[i]; - if (chunk[isSourceNode]) { - chunk.walk(aFn); - } - else { - if (chunk !== '') { - aFn(chunk, { source: this.source, - line: this.line, - column: this.column, - name: this.name }); + function extendCommentRange(comment, tokens) { + var target; + + target = upperBound(tokens, function search(token) { + return token.range[0] > comment.range[0]; + }); + + comment.extendedRange = [comment.range[0], comment.range[1]]; + + if (target !== tokens.length) { + comment.extendedRange[1] = tokens[target].range[0]; } - } - } - }; - /** - * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between - * each of `this.children`. - * - * @param aSep The separator. - */ - SourceNode.prototype.join = function SourceNode_join(aSep) { - var newChildren; - var i; - var len = this.children.length; - if (len > 0) { - newChildren = []; - for (i = 0; i < len-1; i++) { - newChildren.push(this.children[i]); - newChildren.push(aSep); - } - newChildren.push(this.children[i]); - this.children = newChildren; - } - return this; - }; + target -= 1; + if (target >= 0) { + comment.extendedRange[0] = tokens[target].range[1]; + } - /** - * Call String.prototype.replace on the very right-most source snippet. Useful - * for trimming whitespace from the end of a source node, etc. - * - * @param aPattern The pattern to replace. - * @param aReplacement The thing to replace the pattern with. - */ - SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { - var lastChild = this.children[this.children.length - 1]; - if (lastChild[isSourceNode]) { - lastChild.replaceRight(aPattern, aReplacement); - } - else if (typeof lastChild === 'string') { - this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); - } - else { - this.children.push(''.replace(aPattern, aReplacement)); + return comment; } - return this; - }; - /** - * Set the source content for a source file. This will be added to the SourceMapGenerator - * in the sourcesContent field. - * - * @param aSourceFile The filename of the source file - * @param aSourceContent The content of the source file - */ - SourceNode.prototype.setSourceContent = - function SourceNode_setSourceContent(aSourceFile, aSourceContent) { - this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; - }; + function attachComments(tree, providedComments, tokens) { + // At first, we should calculate extended comment ranges. + var comments = [], comment, len, i, cursor; - /** - * Walk over the tree of SourceNodes. The walking function is called for each - * source file content and is passed the filename and source content. - * - * @param aFn The traversal function. - */ - SourceNode.prototype.walkSourceContents = - function SourceNode_walkSourceContents(aFn) { - for (var i = 0, len = this.children.length; i < len; i++) { - if (this.children[i][isSourceNode]) { - this.children[i].walkSourceContents(aFn); + if (!tree.range) { + throw new Error('attachComments needs range information'); } - } - var sources = Object.keys(this.sourceContents); - for (var i = 0, len = sources.length; i < len; i++) { - aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); - } - }; + // tokens array is empty, we attach comments to tree as 'leadingComments' + if (!tokens.length) { + if (providedComments.length) { + for (i = 0, len = providedComments.length; i < len; i += 1) { + comment = deepCopy(providedComments[i]); + comment.extendedRange = [0, tree.range[0]]; + comments.push(comment); + } + tree.leadingComments = comments; + } + return tree; + } - /** - * Return the string representation of this source node. Walks over the tree - * and concatenates all the various snippets together to one string. - */ - SourceNode.prototype.toString = function SourceNode_toString() { - var str = ""; - this.walk(function (chunk) { - str += chunk; - }); - return str; - }; + for (i = 0, len = providedComments.length; i < len; i += 1) { + comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens)); + } - /** - * Returns the string representation of this source node along with a source - * map. - */ - SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { - var generated = { - code: "", - line: 1, - column: 0 - }; - var map = new SourceMapGenerator(aArgs); - var sourceMappingActive = false; - var lastOriginalSource = null; - var lastOriginalLine = null; - var lastOriginalColumn = null; - var lastOriginalName = null; - this.walk(function (chunk, original) { - generated.code += chunk; - if (original.source !== null - && original.line !== null - && original.column !== null) { - if(lastOriginalSource !== original.source - || lastOriginalLine !== original.line - || lastOriginalColumn !== original.column - || lastOriginalName !== original.name) { - map.addMapping({ - source: original.source, - original: { - line: original.line, - column: original.column - }, - generated: { - line: generated.line, - column: generated.column - }, - name: original.name - }); - } - lastOriginalSource = original.source; - lastOriginalLine = original.line; - lastOriginalColumn = original.column; - lastOriginalName = original.name; - sourceMappingActive = true; - } else if (sourceMappingActive) { - map.addMapping({ - generated: { - line: generated.line, - column: generated.column - } - }); - lastOriginalSource = null; - sourceMappingActive = false; - } - for (var idx = 0, length = chunk.length; idx < length; idx++) { - if (chunk.charCodeAt(idx) === NEWLINE_CODE) { - generated.line++; - generated.column = 0; - // Mappings end at eol - if (idx + 1 === length) { - lastOriginalSource = null; - sourceMappingActive = false; - } else if (sourceMappingActive) { - map.addMapping({ - source: original.source, - original: { - line: original.line, - column: original.column - }, - generated: { - line: generated.line, - column: generated.column - }, - name: original.name - }); - } - } else { - generated.column++; - } - } - }); - this.walkSourceContents(function (sourceFile, sourceContent) { - map.setSourceContent(sourceFile, sourceContent); - }); - - return { code: generated.code, map: map }; - }; + // This is based on John Freeman's implementation. + cursor = 0; + traverse(tree, { + enter: function (node) { + var comment; - exports.SourceNode = SourceNode; + while (cursor < comments.length) { + comment = comments[cursor]; + if (comment.extendedRange[1] > node.range[0]) { + break; + } -}); + if (comment.extendedRange[1] === node.range[0]) { + if (!node.leadingComments) { + node.leadingComments = []; + } + node.leadingComments.push(comment); + comments.splice(cursor, 1); + } else { + cursor += 1; + } + } -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-node.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") -},{"./source-map-generator":15,"./util":17,"1YiZ5S":25,"amdefine":18,"buffer":21}],17:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = require('amdefine')(module, require); -} -define(function (require, exports, module) { + // already out of owned node + if (cursor === comments.length) { + return VisitorOption.Break; + } - /** - * This is a helper function for getting values from parameter/options - * objects. - * - * @param args The object we are extracting values from - * @param name The name of the property we are getting. - * @param defaultValue An optional value to return if the property is missing - * from the object. If this is not specified and the property is missing, an - * error will be thrown. - */ - function getArg(aArgs, aName, aDefaultValue) { - if (aName in aArgs) { - return aArgs[aName]; - } else if (arguments.length === 3) { - return aDefaultValue; - } else { - throw new Error('"' + aName + '" is a required argument.'); - } - } - exports.getArg = getArg; + if (comments[cursor].extendedRange[0] > node.range[1]) { + return VisitorOption.Skip; + } + } + }); - var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/; - var dataUrlRegexp = /^data:.+\,.+$/; + cursor = 0; + traverse(tree, { + leave: function (node) { + var comment; - function urlParse(aUrl) { - var match = aUrl.match(urlRegexp); - if (!match) { - return null; - } - return { - scheme: match[1], - auth: match[2], - host: match[3], - port: match[4], - path: match[5] - }; - } - exports.urlParse = urlParse; + while (cursor < comments.length) { + comment = comments[cursor]; + if (node.range[1] < comment.extendedRange[0]) { + break; + } - function urlGenerate(aParsedUrl) { - var url = ''; - if (aParsedUrl.scheme) { - url += aParsedUrl.scheme + ':'; - } - url += '//'; - if (aParsedUrl.auth) { - url += aParsedUrl.auth + '@'; - } - if (aParsedUrl.host) { - url += aParsedUrl.host; - } - if (aParsedUrl.port) { - url += ":" + aParsedUrl.port - } - if (aParsedUrl.path) { - url += aParsedUrl.path; - } - return url; - } - exports.urlGenerate = urlGenerate; + if (node.range[1] === comment.extendedRange[0]) { + if (!node.trailingComments) { + node.trailingComments = []; + } + node.trailingComments.push(comment); + comments.splice(cursor, 1); + } else { + cursor += 1; + } + } - /** - * Normalizes a path, or the path portion of a URL: - * - * - Replaces consequtive slashes with one slash. - * - Removes unnecessary '.' parts. - * - Removes unnecessary '/..' parts. - * - * Based on code in the Node.js 'path' core module. - * - * @param aPath The path or url to normalize. - */ - function normalize(aPath) { - var path = aPath; - var url = urlParse(aPath); - if (url) { - if (!url.path) { - return aPath; - } - path = url.path; - } - var isAbsolute = (path.charAt(0) === '/'); + // already out of owned node + if (cursor === comments.length) { + return VisitorOption.Break; + } - var parts = path.split(/\/+/); - for (var part, up = 0, i = parts.length - 1; i >= 0; i--) { - part = parts[i]; - if (part === '.') { - parts.splice(i, 1); - } else if (part === '..') { - up++; - } else if (up > 0) { - if (part === '') { - // The first part is blank if the path is absolute. Trying to go - // above the root is a no-op. Therefore we can remove all '..' parts - // directly after the root. - parts.splice(i + 1, up); - up = 0; - } else { - parts.splice(i, 2); - up--; - } - } - } - path = parts.join('/'); + if (comments[cursor].extendedRange[0] > node.range[1]) { + return VisitorOption.Skip; + } + } + }); - if (path === '') { - path = isAbsolute ? '/' : '.'; + return tree; } - if (url) { - url.path = path; - return urlGenerate(url); - } - return path; - } - exports.normalize = normalize; + exports.version = '1.8.1-dev'; + exports.Syntax = Syntax; + exports.traverse = traverse; + exports.replace = replace; + exports.attachComments = attachComments; + exports.VisitorKeys = VisitorKeys; + exports.VisitorOption = VisitorOption; + exports.Controller = Controller; + exports.cloneEnvironment = function () { return clone({}); }; - /** - * Joins two paths/URLs. - * - * @param aRoot The root path or URL. - * @param aPath The path or URL to be joined with the root. - * - * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a - * scheme-relative URL: Then the scheme of aRoot, if any, is prepended - * first. - * - Otherwise aPath is a path. If aRoot is a URL, then its path portion - * is updated with the result and aRoot is returned. Otherwise the result - * is returned. - * - If aPath is absolute, the result is aPath. - * - Otherwise the two paths are joined with a slash. - * - Joining for example 'http://' and 'www.example.com' is also supported. - */ - function join(aRoot, aPath) { - if (aRoot === "") { - aRoot = "."; - } - if (aPath === "") { - aPath = "."; - } - var aPathUrl = urlParse(aPath); - var aRootUrl = urlParse(aRoot); - if (aRootUrl) { - aRoot = aRootUrl.path || '/'; - } + return exports; +})); +/* vim: set sw=4 ts=4 et tw=80 : */ - // `join(foo, '//www.example.org')` - if (aPathUrl && !aPathUrl.scheme) { - if (aRootUrl) { - aPathUrl.scheme = aRootUrl.scheme; - } - return urlGenerate(aPathUrl); - } +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/estraverse/estraverse.js","/../node_modules/escodegen/node_modules/estraverse") +},{"buffer":3,"pBGvAp":29}],7:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* + Copyright (C) 2013 Yusuke Suzuki - if (aPathUrl || aPath.match(dataUrlRegexp)) { - return aPath; - } + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - // `join('http://', 'www.example.com')` - if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { - aRootUrl.host = aPath; - return urlGenerate(aRootUrl); - } + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - var joined = aPath.charAt(0) === '/' - ? aPath - : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ - if (aRootUrl) { - aRootUrl.path = joined; - return urlGenerate(aRootUrl); - } - return joined; - } - exports.join = join; +(function () { + 'use strict'; - /** - * Make a path relative to a URL or another path. - * - * @param aRoot The root path or URL. - * @param aPath The path or URL to be made relative to aRoot. - */ - function relative(aRoot, aPath) { - if (aRoot === "") { - aRoot = "."; + function isExpression(node) { + if (node == null) { return false; } + switch (node.type) { + case 'ArrayExpression': + case 'AssignmentExpression': + case 'BinaryExpression': + case 'CallExpression': + case 'ConditionalExpression': + case 'FunctionExpression': + case 'Identifier': + case 'Literal': + case 'LogicalExpression': + case 'MemberExpression': + case 'NewExpression': + case 'ObjectExpression': + case 'SequenceExpression': + case 'ThisExpression': + case 'UnaryExpression': + case 'UpdateExpression': + return true; + } + return false; } - aRoot = aRoot.replace(/\/$/, ''); - - // XXX: It is possible to remove this block, and the tests still pass! - var url = urlParse(aRoot); - if (aPath.charAt(0) == "/" && url && url.path == "/") { - return aPath.slice(1); + function isIterationStatement(node) { + if (node == null) { return false; } + switch (node.type) { + case 'DoWhileStatement': + case 'ForInStatement': + case 'ForStatement': + case 'WhileStatement': + return true; + } + return false; } - return aPath.indexOf(aRoot + '/') === 0 - ? aPath.substr(aRoot.length + 1) - : aPath; - } - exports.relative = relative; - - /** - * Because behavior goes wacky when you set `__proto__` on objects, we - * have to prefix all the strings in our set with an arbitrary character. - * - * See https://github.com/mozilla/source-map/pull/31 and - * https://github.com/mozilla/source-map/issues/30 - * - * @param String aStr - */ - function toSetString(aStr) { - return '$' + aStr; - } - exports.toSetString = toSetString; - - function fromSetString(aStr) { - return aStr.substr(1); - } - exports.fromSetString = fromSetString; + function isStatement(node) { + if (node == null) { return false; } + switch (node.type) { + case 'BlockStatement': + case 'BreakStatement': + case 'ContinueStatement': + case 'DebuggerStatement': + case 'DoWhileStatement': + case 'EmptyStatement': + case 'ExpressionStatement': + case 'ForInStatement': + case 'ForStatement': + case 'IfStatement': + case 'LabeledStatement': + case 'ReturnStatement': + case 'SwitchStatement': + case 'ThrowStatement': + case 'TryStatement': + case 'VariableDeclaration': + case 'WhileStatement': + case 'WithStatement': + return true; + } + return false; + } - function strcmp(aStr1, aStr2) { - var s1 = aStr1 || ""; - var s2 = aStr2 || ""; - return (s1 > s2) - (s1 < s2); - } + function isSourceElement(node) { + return isStatement(node) || node != null && node.type === 'FunctionDeclaration'; + } - /** - * Comparator between two mappings where the original positions are compared. - * - * Optionally pass in `true` as `onlyCompareGenerated` to consider two - * mappings with the same original source/line/column, but different generated - * line and column the same. Useful when searching for a mapping with a - * stubbed out mapping. - */ - function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { - var cmp; + function trailingStatement(node) { + switch (node.type) { + case 'IfStatement': + if (node.alternate != null) { + return node.alternate; + } + return node.consequent; - cmp = strcmp(mappingA.source, mappingB.source); - if (cmp) { - return cmp; + case 'LabeledStatement': + case 'ForStatement': + case 'ForInStatement': + case 'WhileStatement': + case 'WithStatement': + return node.body; + } + return null; } - cmp = mappingA.originalLine - mappingB.originalLine; - if (cmp) { - return cmp; - } + function isProblematicIfStatement(node) { + var current; - cmp = mappingA.originalColumn - mappingB.originalColumn; - if (cmp || onlyCompareOriginal) { - return cmp; - } + if (node.type !== 'IfStatement') { + return false; + } + if (node.alternate == null) { + return false; + } + current = node.consequent; + do { + if (current.type === 'IfStatement') { + if (current.alternate == null) { + return true; + } + } + current = trailingStatement(current); + } while (current); - cmp = strcmp(mappingA.name, mappingB.name); - if (cmp) { - return cmp; + return false; } - cmp = mappingA.generatedLine - mappingB.generatedLine; - if (cmp) { - return cmp; - } - - return mappingA.generatedColumn - mappingB.generatedColumn; - }; - exports.compareByOriginalPositions = compareByOriginalPositions; + module.exports = { + isExpression: isExpression, + isStatement: isStatement, + isIterationStatement: isIterationStatement, + isSourceElement: isSourceElement, + isProblematicIfStatement: isProblematicIfStatement, - /** - * Comparator between two mappings where the generated positions are - * compared. - * - * Optionally pass in `true` as `onlyCompareGenerated` to consider two - * mappings with the same generated line and column, but different - * source/name/original line and column the same. Useful when searching for a - * mapping with a stubbed out mapping. - */ - function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) { - var cmp; + trailingStatement: trailingStatement + }; +}()); +/* vim: set sw=4 ts=4 et tw=80 : */ - cmp = mappingA.generatedLine - mappingB.generatedLine; - if (cmp) { - return cmp; - } +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/ast.js","/../node_modules/escodegen/node_modules/esutils/lib") +},{"buffer":3,"pBGvAp":29}],8:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* + Copyright (C) 2013-2014 Yusuke Suzuki + Copyright (C) 2014 Ivan Nikulin - cmp = mappingA.generatedColumn - mappingB.generatedColumn; - if (cmp || onlyCompareGenerated) { - return cmp; - } + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - cmp = strcmp(mappingA.source, mappingB.source); - if (cmp) { - return cmp; - } + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - cmp = mappingA.originalLine - mappingB.originalLine; - if (cmp) { - return cmp; - } + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ - cmp = mappingA.originalColumn - mappingB.originalColumn; - if (cmp) { - return cmp; - } +(function () { + 'use strict'; - return strcmp(mappingA.name, mappingB.name); - }; - exports.compareByGeneratedPositions = compareByGeneratedPositions; + var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; -}); + // See `tools/generate-identifier-regex.js`. + ES5Regex = { + // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart: + NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/, + // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart: + NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/ + }; -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/util.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") -},{"1YiZ5S":25,"amdefine":18,"buffer":21}],18:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/** vim: et:ts=4:sw=4:sts=4 - * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved. - * Available via the MIT or new BSD license. - * see: http://github.com/jrburke/amdefine for details - */ + ES6Regex = { + // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart: + NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/, + // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart: + NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/ + }; -/*jslint node: true */ -/*global module, process */ -'use strict'; + function isDecimalDigit(ch) { + return 0x30 <= ch && ch <= 0x39; // 0..9 + } -/** - * Creates a define for node. - * @param {Object} module the "module" object that is defined by Node for the - * current module. - * @param {Function} [requireFn]. Node's require function for the current module. - * It only needs to be passed in Node versions before 0.5, when module.require - * did not exist. - * @returns {Function} a define function that is usable for the current node - * module. - */ -function amdefine(module, requireFn) { - 'use strict'; - var defineCache = {}, - loaderCache = {}, - alreadyCalled = false, - path = require('path'), - makeRequire, stringRequire; + function isHexDigit(ch) { + return 0x30 <= ch && ch <= 0x39 || // 0..9 + 0x61 <= ch && ch <= 0x66 || // a..f + 0x41 <= ch && ch <= 0x46; // A..F + } - /** - * Trims the . and .. from an array of path segments. - * It will keep a leading path segment if a .. will become - * the first path segment, to help with module name lookups, - * which act like paths, but can be remapped. But the end result, - * all paths that use this function should look normalized. - * NOTE: this method MODIFIES the input array. - * @param {Array} ary the array of path segments. - */ - function trimDots(ary) { - var i, part; - for (i = 0; ary[i]; i+= 1) { - part = ary[i]; - if (part === '.') { - ary.splice(i, 1); - i -= 1; - } else if (part === '..') { - if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { - //End of the line. Keep at least one non-dot - //path segment at the front so it can be mapped - //correctly to disk. Otherwise, there is likely - //no path mapping for a path starting with '..'. - //This can still fail, but catches the most reasonable - //uses of .. - break; - } else if (i > 0) { - ary.splice(i - 1, 2); - i -= 2; - } - } - } + function isOctalDigit(ch) { + return ch >= 0x30 && ch <= 0x37; // 0..7 } - function normalize(name, baseName) { - var baseParts; + // 7.2 White Space - //Adjust any relative paths. - if (name && name.charAt(0) === '.') { - //If have a base name, try to normalize against it, - //otherwise, assume it is a top-level require that will - //be relative to baseUrl in the end. - if (baseName) { - baseParts = baseName.split('/'); - baseParts = baseParts.slice(0, baseParts.length - 1); - baseParts = baseParts.concat(name.split('/')); - trimDots(baseParts); - name = baseParts.join('/'); - } - } + NON_ASCII_WHITESPACES = [ + 0x1680, 0x180E, + 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, + 0x202F, 0x205F, + 0x3000, + 0xFEFF + ]; - return name; + function isWhiteSpace(ch) { + return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || + ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0; } - /** - * Create the normalize() function passed to a loader plugin's - * normalize method. - */ - function makeNormalize(relName) { - return function (name) { - return normalize(name, relName); - }; + // 7.3 Line Terminators + + function isLineTerminator(ch) { + return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029; } - function makeLoad(id) { - function load(value) { - loaderCache[id] = value; - } + // 7.6 Identifier Names and Identifiers - load.fromText = function (id, text) { - //This one is difficult because the text can/probably uses - //define, and any relative paths and requires should be relative - //to that id was it would be found on disk. But this would require - //bootstrapping a module/require fairly deeply from node core. - //Not sure how best to go about that yet. - throw new Error('amdefine does not implement load.fromText'); - }; + function fromCodePoint(cp) { + if (cp <= 0xFFFF) { return String.fromCharCode(cp); } + var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800); + var cu2 = String.fromCharCode(((cp - 0x10000) % 0x400) + 0xDC00); + return cu1 + cu2; + } - return load; + IDENTIFIER_START = new Array(0x80); + for(ch = 0; ch < 0x80; ++ch) { + IDENTIFIER_START[ch] = + ch >= 0x61 && ch <= 0x7A || // a..z + ch >= 0x41 && ch <= 0x5A || // A..Z + ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore) } - makeRequire = function (systemRequire, exports, module, relId) { - function amdRequire(deps, callback) { - if (typeof deps === 'string') { - //Synchronous, single module require('') - return stringRequire(systemRequire, exports, module, deps, relId); - } else { - //Array of dependencies with a callback. + IDENTIFIER_PART = new Array(0x80); + for(ch = 0; ch < 0x80; ++ch) { + IDENTIFIER_PART[ch] = + ch >= 0x61 && ch <= 0x7A || // a..z + ch >= 0x41 && ch <= 0x5A || // A..Z + ch >= 0x30 && ch <= 0x39 || // 0..9 + ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore) + } - //Convert the dependencies to modules. - deps = deps.map(function (depName) { - return stringRequire(systemRequire, exports, module, depName, relId); - }); + function isIdentifierStartES5(ch) { + return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)); + } - //Wait for next tick to call back the require call. - if (callback) { - process.nextTick(function () { - callback.apply(null, deps); - }); - } - } - } + function isIdentifierPartES5(ch) { + return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)); + } - amdRequire.toUrl = function (filePath) { - if (filePath.indexOf('.') === 0) { - return normalize(filePath, path.dirname(module.filename)); - } else { - return filePath; - } - }; + function isIdentifierStartES6(ch) { + return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)); + } - return amdRequire; - }; + function isIdentifierPartES6(ch) { + return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)); + } - //Favor explicit value, passed in if the module wants to support Node 0.4. - requireFn = requireFn || function req() { - return module.require.apply(module, arguments); + module.exports = { + isDecimalDigit: isDecimalDigit, + isHexDigit: isHexDigit, + isOctalDigit: isOctalDigit, + isWhiteSpace: isWhiteSpace, + isLineTerminator: isLineTerminator, + isIdentifierStartES5: isIdentifierStartES5, + isIdentifierPartES5: isIdentifierPartES5, + isIdentifierStartES6: isIdentifierStartES6, + isIdentifierPartES6: isIdentifierPartES6 }; +}()); +/* vim: set sw=4 ts=4 et tw=80 : */ - function runFactory(id, deps, factory) { - var r, e, m, result; +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/code.js","/../node_modules/escodegen/node_modules/esutils/lib") +},{"buffer":3,"pBGvAp":29}],9:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* + Copyright (C) 2013 Yusuke Suzuki - if (id) { - e = loaderCache[id] = {}; - m = { - id: id, - uri: __filename, - exports: e - }; - r = makeRequire(requireFn, e, m, id); - } else { - //Only support one define call per file - if (alreadyCalled) { - throw new Error('amdefine with no module ID cannot be called more than once per file.'); - } - alreadyCalled = true; + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - //Use the real variables from node - //Use module.exports for exports, since - //the exports in here is amdefine exports. - e = module.exports; - m = module; - r = makeRequire(requireFn, e, m, module.id); + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +(function () { + 'use strict'; + + var code = require('./code'); + + function isStrictModeReservedWordES6(id) { + switch (id) { + case 'implements': + case 'interface': + case 'package': + case 'private': + case 'protected': + case 'public': + case 'static': + case 'let': + return true; + default: + return false; } + } - //If there are dependencies, they are strings, so need - //to convert them to dependency values. - if (deps) { - deps = deps.map(function (depName) { - return r(depName); - }); + function isKeywordES5(id, strict) { + // yield should not be treated as keyword under non-strict mode. + if (!strict && id === 'yield') { + return false; } + return isKeywordES6(id, strict); + } - //Call the factory with the right dependencies. - if (typeof factory === 'function') { - result = factory.apply(m.exports, deps); - } else { - result = factory; + function isKeywordES6(id, strict) { + if (strict && isStrictModeReservedWordES6(id)) { + return true; } - if (result !== undefined) { - m.exports = result; - if (id) { - loaderCache[id] = m.exports; - } + switch (id.length) { + case 2: + return (id === 'if') || (id === 'in') || (id === 'do'); + case 3: + return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try'); + case 4: + return (id === 'this') || (id === 'else') || (id === 'case') || + (id === 'void') || (id === 'with') || (id === 'enum'); + case 5: + return (id === 'while') || (id === 'break') || (id === 'catch') || + (id === 'throw') || (id === 'const') || (id === 'yield') || + (id === 'class') || (id === 'super'); + case 6: + return (id === 'return') || (id === 'typeof') || (id === 'delete') || + (id === 'switch') || (id === 'export') || (id === 'import'); + case 7: + return (id === 'default') || (id === 'finally') || (id === 'extends'); + case 8: + return (id === 'function') || (id === 'continue') || (id === 'debugger'); + case 10: + return (id === 'instanceof'); + default: + return false; } } - stringRequire = function (systemRequire, exports, module, id, relId) { - //Split the ID by a ! so that - var index = id.indexOf('!'), - originalId = id, - prefix, plugin; + function isReservedWordES5(id, strict) { + return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict); + } - if (index === -1) { - id = normalize(id, relId); + function isReservedWordES6(id, strict) { + return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict); + } - //Straight module lookup. If it is one of the special dependencies, - //deal with it, otherwise, delegate to node. - if (id === 'require') { - return makeRequire(systemRequire, exports, module, relId); - } else if (id === 'exports') { - return exports; - } else if (id === 'module') { - return module; - } else if (loaderCache.hasOwnProperty(id)) { - return loaderCache[id]; - } else if (defineCache[id]) { - runFactory.apply(null, defineCache[id]); - return loaderCache[id]; - } else { - if(systemRequire) { - return systemRequire(originalId); - } else { - throw new Error('No module with ID: ' + id); - } - } - } else { - //There is a plugin in play. - prefix = id.substring(0, index); - id = id.substring(index + 1, id.length); + function isRestrictedWord(id) { + return id === 'eval' || id === 'arguments'; + } - plugin = stringRequire(systemRequire, exports, module, prefix, relId); + function isIdentifierNameES5(id) { + var i, iz, ch; - if (plugin.normalize) { - id = plugin.normalize(id, makeNormalize(relId)); - } else { - //Normalize the ID normally. - id = normalize(id, relId); - } + if (id.length === 0) { return false; } - if (loaderCache[id]) { - return loaderCache[id]; - } else { - plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {}); + ch = id.charCodeAt(0); + if (!code.isIdentifierStartES5(ch)) { + return false; + } - return loaderCache[id]; + for (i = 1, iz = id.length; i < iz; ++i) { + ch = id.charCodeAt(i); + if (!code.isIdentifierPartES5(ch)) { + return false; } } - }; + return true; + } - //Create a define function specific to the module asking for amdefine. - function define(id, deps, factory) { - if (Array.isArray(id)) { - factory = deps; - deps = id; - id = undefined; - } else if (typeof id !== 'string') { - factory = id; - id = deps = undefined; - } + function decodeUtf16(lead, trail) { + return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + } - if (deps && !Array.isArray(deps)) { - factory = deps; - deps = undefined; - } + function isIdentifierNameES6(id) { + var i, iz, ch, lowCh, check; - if (!deps) { - deps = ['require', 'exports', 'module']; - } + if (id.length === 0) { return false; } - //Set up properties for this module. If an ID, then use - //internal cache. If no ID, then use the external variables - //for this node module. - if (id) { - //Put the module in deep freeze until there is a - //require call for it. - defineCache[id] = [id, deps, factory]; - } else { - runFactory(id, deps, factory); + check = code.isIdentifierStartES6; + for (i = 0, iz = id.length; i < iz; ++i) { + ch = id.charCodeAt(i); + if (0xD800 <= ch && ch <= 0xDBFF) { + ++i; + if (i >= iz) { return false; } + lowCh = id.charCodeAt(i); + if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) { + return false; + } + ch = decodeUtf16(ch, lowCh); + } + if (!check(ch)) { + return false; + } + check = code.isIdentifierPartES6; } + return true; } - //define.require, which has access to all the values in the - //cache. Useful for AMD modules that all have IDs in the file, - //but need to finally export a value to node based on one of those - //IDs. - define.require = function (id) { - if (loaderCache[id]) { - return loaderCache[id]; - } + function isIdentifierES5(id, strict) { + return isIdentifierNameES5(id) && !isReservedWordES5(id, strict); + } - if (defineCache[id]) { - runFactory.apply(null, defineCache[id]); - return loaderCache[id]; - } + function isIdentifierES6(id, strict) { + return isIdentifierNameES6(id) && !isReservedWordES6(id, strict); + } + + module.exports = { + isKeywordES5: isKeywordES5, + isKeywordES6: isKeywordES6, + isReservedWordES5: isReservedWordES5, + isReservedWordES6: isReservedWordES6, + isRestrictedWord: isRestrictedWord, + isIdentifierNameES5: isIdentifierNameES5, + isIdentifierNameES6: isIdentifierNameES6, + isIdentifierES5: isIdentifierES5, + isIdentifierES6: isIdentifierES6 }; +}()); +/* vim: set sw=4 ts=4 et tw=80 : */ - define.amd = {}; +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/keyword.js","/../node_modules/escodegen/node_modules/esutils/lib") +},{"./code":8,"buffer":3,"pBGvAp":29}],10:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* + Copyright (C) 2013 Yusuke Suzuki - return define; -} + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: -module.exports = amdefine; - -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/node_modules/amdefine/amdefine.js","/../node_modules/escodegen/node_modules/source-map/node_modules/amdefine") -},{"1YiZ5S":25,"buffer":21,"path":24}],19:[function(require,module,exports){ -module.exports={ - "name": "escodegen", - "description": "ECMAScript code generator", - "homepage": "http://github.com/estools/escodegen", - "main": "escodegen.js", - "bin": { - "esgenerate": "./bin/esgenerate.js", - "escodegen": "./bin/escodegen.js" - }, - "files": [ - "LICENSE.BSD", - "LICENSE.source-map", - "README.md", - "bin", - "escodegen.js", - "package.json" - ], - "version": "1.6.1", - "engines": { - "node": ">=0.10.0" - }, - "maintainers": [ - { - "name": "constellation", - "email": "utatane.tea@gmail.com" - } - ], - "repository": { - "type": "git", - "url": "http://github.com/estools/escodegen.git" - }, - "dependencies": { - "estraverse": "^1.9.1", - "esutils": "^1.1.6", - "esprima": "^1.2.2", - "optionator": "^0.5.0", - "source-map": "~0.1.40" - }, - "optionalDependencies": { - "source-map": "~0.1.40" - }, - "devDependencies": { - "acorn-6to5": "^0.11.1-25", - "bluebird": "^2.3.11", - "bower-registry-client": "^0.2.1", - "chai": "^1.10.0", - "commonjs-everywhere": "^0.9.7", - "esprima-moz": "*", - "gulp": "^3.8.10", - "gulp-eslint": "^0.2.0", - "gulp-mocha": "^2.0.0", - "semver": "^4.1.0" - }, - "licenses": [ - { - "type": "BSD", - "url": "http://github.com/estools/escodegen/raw/master/LICENSE.BSD" - } - ], - "scripts": { - "test": "gulp travis", - "unit-test": "gulp test", - "lint": "gulp lint", - "release": "node tools/release.js", - "build-min": "cjsify -ma path: tools/entry-point.js > escodegen.browser.min.js", - "build": "cjsify -a path: tools/entry-point.js > escodegen.browser.js" - }, - "gitHead": "1ca664f68dcf220b76c9dc562b2337c5e0b4227d", - "bugs": { - "url": "https://github.com/estools/escodegen/issues" - }, - "_id": "escodegen@1.6.1", - "_shasum": "367de17d8510540d12bc6dcb8b3f918391265815", - "_from": "escodegen@^1.4.1", - "_npmVersion": "2.0.0-alpha-5", - "_npmUser": { - "name": "constellation", - "email": "utatane.tea@gmail.com" - }, - "dist": { - "shasum": "367de17d8510540d12bc6dcb8b3f918391265815", - "tarball": "http://registry.npmjs.org/escodegen/-/escodegen-1.6.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.6.1.tgz", - "readme": "ERROR: No README data found!" -} - -},{}],20:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/* - Copyright (C) 2013 Ariya Hidayat - Copyright (C) 2013 Thaddee Tyl - Copyright (C) 2013 Mathias Bynens - Copyright (C) 2012 Ariya Hidayat - Copyright (C) 2012 Mathias Bynens - Copyright (C) 2012 Joost-Wim Boekesteijn - Copyright (C) 2012 Kris Kowal - Copyright (C) 2012 Yusuke Suzuki - Copyright (C) 2012 Arpad Borsos - Copyright (C) 2011 Ariya Hidayat - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -6835,4989 +5779,7432 @@ module.exports={ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/*jslint bitwise:true plusplus:true */ -/*global esprima:true, define:true, exports:true, window: true, -throwErrorTolerant: true, -throwError: true, generateStatement: true, peek: true, -parseAssignmentExpression: true, parseBlock: true, parseExpression: true, -parseFunctionDeclaration: true, parseFunctionExpression: true, -parseFunctionSourceElements: true, parseVariableIdentifier: true, -parseLeftHandSideExpression: true, -parseUnaryExpression: true, -parseStatement: true, parseSourceElement: true */ -(function (root, factory) { +(function () { 'use strict'; - // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, - // Rhino, and plain browser loading. + exports.ast = require('./ast'); + exports.code = require('./code'); + exports.keyword = require('./keyword'); +}()); +/* vim: set sw=4 ts=4 et tw=80 : */ - /* istanbul ignore next */ - if (typeof define === 'function' && define.amd) { - define(['exports'], factory); - } else if (typeof exports !== 'undefined') { - factory(exports); - } else { - factory((root.esprima = {})); - } -}(this, function (exports) { - 'use strict'; +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/utils.js","/../node_modules/escodegen/node_modules/esutils/lib") +},{"./ast":7,"./code":8,"./keyword":9,"buffer":3,"pBGvAp":29}],11:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* + * Copyright 2009-2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE.txt or: + * http://opensource.org/licenses/BSD-3-Clause + */ +exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator; +exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer; +exports.SourceNode = require('./source-map/source-node').SourceNode; - var Token, - TokenName, - FnExprTokens, - Syntax, - PropertyKind, - Messages, - Regex, - SyntaxTreeDelegate, - source, - strict, - index, - lineNumber, - lineStart, - length, - delegate, - lookahead, - state, - extra; +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map.js","/../node_modules/escodegen/node_modules/source-map/lib") +},{"./source-map/source-map-consumer":19,"./source-map/source-map-generator":20,"./source-map/source-node":21,"buffer":3,"pBGvAp":29}],12:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { - Token = { - BooleanLiteral: 1, - EOF: 2, - Identifier: 3, - Keyword: 4, - NullLiteral: 5, - NumericLiteral: 6, - Punctuator: 7, - StringLiteral: 8, - RegularExpression: 9 - }; + var util = require('./util'); - TokenName = {}; - TokenName[Token.BooleanLiteral] = 'Boolean'; - TokenName[Token.EOF] = ''; - TokenName[Token.Identifier] = 'Identifier'; - TokenName[Token.Keyword] = 'Keyword'; - TokenName[Token.NullLiteral] = 'Null'; - TokenName[Token.NumericLiteral] = 'Numeric'; - TokenName[Token.Punctuator] = 'Punctuator'; - TokenName[Token.StringLiteral] = 'String'; - TokenName[Token.RegularExpression] = 'RegularExpression'; + /** + * A data structure which is a combination of an array and a set. Adding a new + * member is O(1), testing for membership is O(1), and finding the index of an + * element is O(1). Removing elements from the set is not supported. Only + * strings are supported for membership. + */ + function ArraySet() { + this._array = []; + this._set = {}; + } - // A function following one of those tokens is an expression. - FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new', - 'return', 'case', 'delete', 'throw', 'void', - // assignment operators - '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=', - '&=', '|=', '^=', ',', - // binary/unary operators - '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&', - '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=', - '<=', '<', '>', '!=', '!==']; + /** + * Static method for creating ArraySet instances from an existing array. + */ + ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { + var set = new ArraySet(); + for (var i = 0, len = aArray.length; i < len; i++) { + set.add(aArray[i], aAllowDuplicates); + } + return set; + }; - Syntax = { - AssignmentExpression: 'AssignmentExpression', - ArrayExpression: 'ArrayExpression', - BlockStatement: 'BlockStatement', - BinaryExpression: 'BinaryExpression', - BreakStatement: 'BreakStatement', - CallExpression: 'CallExpression', - CatchClause: 'CatchClause', - ConditionalExpression: 'ConditionalExpression', - ContinueStatement: 'ContinueStatement', - DoWhileStatement: 'DoWhileStatement', - DebuggerStatement: 'DebuggerStatement', - EmptyStatement: 'EmptyStatement', - ExpressionStatement: 'ExpressionStatement', - ForStatement: 'ForStatement', - ForInStatement: 'ForInStatement', - FunctionDeclaration: 'FunctionDeclaration', - FunctionExpression: 'FunctionExpression', - Identifier: 'Identifier', - IfStatement: 'IfStatement', - Literal: 'Literal', - LabeledStatement: 'LabeledStatement', - LogicalExpression: 'LogicalExpression', - MemberExpression: 'MemberExpression', - NewExpression: 'NewExpression', - ObjectExpression: 'ObjectExpression', - Program: 'Program', - Property: 'Property', - ReturnStatement: 'ReturnStatement', - SequenceExpression: 'SequenceExpression', - SwitchStatement: 'SwitchStatement', - SwitchCase: 'SwitchCase', - ThisExpression: 'ThisExpression', - ThrowStatement: 'ThrowStatement', - TryStatement: 'TryStatement', - UnaryExpression: 'UnaryExpression', - UpdateExpression: 'UpdateExpression', - VariableDeclaration: 'VariableDeclaration', - VariableDeclarator: 'VariableDeclarator', - WhileStatement: 'WhileStatement', - WithStatement: 'WithStatement' - }; + /** + * Add the given string to this set. + * + * @param String aStr + */ + ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { + var isDuplicate = this.has(aStr); + var idx = this._array.length; + if (!isDuplicate || aAllowDuplicates) { + this._array.push(aStr); + } + if (!isDuplicate) { + this._set[util.toSetString(aStr)] = idx; + } + }; - PropertyKind = { - Data: 1, - Get: 2, - Set: 4 - }; + /** + * Is the given string a member of this set? + * + * @param String aStr + */ + ArraySet.prototype.has = function ArraySet_has(aStr) { + return Object.prototype.hasOwnProperty.call(this._set, + util.toSetString(aStr)); + }; - // Error messages should be identical to V8. - Messages = { - UnexpectedToken: 'Unexpected token %0', - UnexpectedNumber: 'Unexpected number', - UnexpectedString: 'Unexpected string', - UnexpectedIdentifier: 'Unexpected identifier', - UnexpectedReserved: 'Unexpected reserved word', - UnexpectedEOS: 'Unexpected end of input', - NewlineAfterThrow: 'Illegal newline after throw', - InvalidRegExp: 'Invalid regular expression', - UnterminatedRegExp: 'Invalid regular expression: missing /', - InvalidLHSInAssignment: 'Invalid left-hand side in assignment', - InvalidLHSInForIn: 'Invalid left-hand side in for-in', - MultipleDefaultsInSwitch: 'More than one default clause in switch statement', - NoCatchOrFinally: 'Missing catch or finally after try', - UnknownLabel: 'Undefined label \'%0\'', - Redeclaration: '%0 \'%1\' has already been declared', - IllegalContinue: 'Illegal continue statement', - IllegalBreak: 'Illegal break statement', - IllegalReturn: 'Illegal return statement', - StrictModeWith: 'Strict mode code may not include a with statement', - StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', - StrictVarName: 'Variable name may not be eval or arguments in strict mode', - StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', - StrictParamDupe: 'Strict mode function may not have duplicate parameter names', - StrictFunctionName: 'Function name may not be eval or arguments in strict mode', - StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', - StrictDelete: 'Delete of an unqualified identifier in strict mode.', - StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode', - AccessorDataProperty: 'Object literal may not have data and accessor property with the same name', - AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name', - StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', - StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', - StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', - StrictReservedWord: 'Use of future reserved word in strict mode' + /** + * What is the index of the given string in the array? + * + * @param String aStr + */ + ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { + if (this.has(aStr)) { + return this._set[util.toSetString(aStr)]; + } + throw new Error('"' + aStr + '" is not in the set.'); + }; + + /** + * What is the element at the given index? + * + * @param Number aIdx + */ + ArraySet.prototype.at = function ArraySet_at(aIdx) { + if (aIdx >= 0 && aIdx < this._array.length) { + return this._array[aIdx]; + } + throw new Error('No element indexed by ' + aIdx); + }; + + /** + * Returns the array representation of this set (which has the proper indices + * indicated by indexOf). Note that this is a copy of the internal array used + * for storing the members so that no one can mess with internal state. + */ + ArraySet.prototype.toArray = function ArraySet_toArray() { + return this._array.slice(); + }; + + exports.ArraySet = ArraySet; + +}); + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/array-set.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"./util":22,"amdefine":5,"buffer":3,"pBGvAp":29}],13:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + * + * Based on the Base 64 VLQ implementation in Closure Compiler: + * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java + * + * Copyright 2011 The Closure Compiler Authors. All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { + + var base64 = require('./base64'); + + // A single base 64 digit can contain 6 bits of data. For the base 64 variable + // length quantities we use in the source map spec, the first bit is the sign, + // the next four bits are the actual value, and the 6th bit is the + // continuation bit. The continuation bit tells us whether there are more + // digits in this value following this digit. + // + // Continuation + // | Sign + // | | + // V V + // 101011 + + var VLQ_BASE_SHIFT = 5; + + // binary: 100000 + var VLQ_BASE = 1 << VLQ_BASE_SHIFT; + + // binary: 011111 + var VLQ_BASE_MASK = VLQ_BASE - 1; + + // binary: 100000 + var VLQ_CONTINUATION_BIT = VLQ_BASE; + + /** + * Converts from a two-complement value to a value where the sign bit is + * placed in the least significant bit. For example, as decimals: + * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) + * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) + */ + function toVLQSigned(aValue) { + return aValue < 0 + ? ((-aValue) << 1) + 1 + : (aValue << 1) + 0; + } + + /** + * Converts to a two-complement value from a value where the sign bit is + * placed in the least significant bit. For example, as decimals: + * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 + * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 + */ + function fromVLQSigned(aValue) { + var isNegative = (aValue & 1) === 1; + var shifted = aValue >> 1; + return isNegative + ? -shifted + : shifted; + } + + /** + * Returns the base 64 VLQ encoded value. + */ + exports.encode = function base64VLQ_encode(aValue) { + var encoded = ""; + var digit; + + var vlq = toVLQSigned(aValue); + + do { + digit = vlq & VLQ_BASE_MASK; + vlq >>>= VLQ_BASE_SHIFT; + if (vlq > 0) { + // There are still more digits in this value, so we must make sure the + // continuation bit is marked. + digit |= VLQ_CONTINUATION_BIT; + } + encoded += base64.encode(digit); + } while (vlq > 0); + + return encoded; + }; + + /** + * Decodes the next base 64 VLQ value from the given string and returns the + * value and the rest of the string via the out parameter. + */ + exports.decode = function base64VLQ_decode(aStr, aOutParam) { + var i = 0; + var strLen = aStr.length; + var result = 0; + var shift = 0; + var continuation, digit; + + do { + if (i >= strLen) { + throw new Error("Expected more digits in base 64 VLQ value."); + } + digit = base64.decode(aStr.charAt(i++)); + continuation = !!(digit & VLQ_CONTINUATION_BIT); + digit &= VLQ_BASE_MASK; + result = result + (digit << shift); + shift += VLQ_BASE_SHIFT; + } while (continuation); + + aOutParam.value = fromVLQSigned(result); + aOutParam.rest = aStr.slice(i); + }; + +}); + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/base64-vlq.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"./base64":14,"amdefine":5,"buffer":3,"pBGvAp":29}],14:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { + + var charToIntMap = {}; + var intToCharMap = {}; + + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' + .split('') + .forEach(function (ch, index) { + charToIntMap[ch] = index; + intToCharMap[index] = ch; + }); + + /** + * Encode an integer in the range of 0 to 63 to a single base 64 digit. + */ + exports.encode = function base64_encode(aNumber) { + if (aNumber in intToCharMap) { + return intToCharMap[aNumber]; + } + throw new TypeError("Must be between 0 and 63: " + aNumber); + }; + + /** + * Decode a single base 64 digit to an integer. + */ + exports.decode = function base64_decode(aChar) { + if (aChar in charToIntMap) { + return charToIntMap[aChar]; + } + throw new TypeError("Not a valid base 64 digit: " + aChar); + }; + +}); + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/base64.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"amdefine":5,"buffer":3,"pBGvAp":29}],15:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { + + var util = require('./util'); + var binarySearch = require('./binary-search'); + var ArraySet = require('./array-set').ArraySet; + var base64VLQ = require('./base64-vlq'); + var SourceMapConsumer = require('./source-map-consumer').SourceMapConsumer; + + /** + * A BasicSourceMapConsumer instance represents a parsed source map which we can + * query for information about the original file positions by giving it a file + * position in the generated source. + * + * The only parameter is the raw source map (either as a JSON string, or + * already parsed to an object). According to the spec, source maps have the + * following attributes: + * + * - version: Which version of the source map spec this map is following. + * - sources: An array of URLs to the original source files. + * - names: An array of identifiers which can be referrenced by individual mappings. + * - sourceRoot: Optional. The URL root from which all sources are relative. + * - sourcesContent: Optional. An array of contents of the original source files. + * - mappings: A string of base64 VLQs which contain the actual mappings. + * - file: Optional. The generated file this source map is associated with. + * + * Here is an example source map, taken from the source map spec[0]: + * + * { + * version : 3, + * file: "out.js", + * sourceRoot : "", + * sources: ["foo.js", "bar.js"], + * names: ["src", "maps", "are", "fun"], + * mappings: "AA,AB;;ABCDE;" + * } + * + * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# + */ + function BasicSourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + } + + var version = util.getArg(sourceMap, 'version'); + var sources = util.getArg(sourceMap, 'sources'); + // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which + // requires the array) to play nice here. + var names = util.getArg(sourceMap, 'names', []); + var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); + var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); + var mappings = util.getArg(sourceMap, 'mappings'); + var file = util.getArg(sourceMap, 'file', null); + + // Once again, Sass deviates from the spec and supplies the version as a + // string rather than a number, so we use loose equality checking here. + if (version != this._version) { + throw new Error('Unsupported version: ' + version); + } + + // Some source maps produce relative source paths like "./foo.js" instead of + // "foo.js". Normalize these first so that future comparisons will succeed. + // See bugzil.la/1090768. + sources = sources.map(util.normalize); + + // Pass `true` below to allow duplicate names and sources. While source maps + // are intended to be compressed and deduplicated, the TypeScript compiler + // sometimes generates source maps with duplicates in them. See Github issue + // #72 and bugzil.la/889492. + this._names = ArraySet.fromArray(names, true); + this._sources = ArraySet.fromArray(sources, true); + + this.sourceRoot = sourceRoot; + this.sourcesContent = sourcesContent; + this._mappings = mappings; + this.file = file; + } + + BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); + BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; + + /** + * Create a BasicSourceMapConsumer from a SourceMapGenerator. + * + * @param SourceMapGenerator aSourceMap + * The source map that will be consumed. + * @returns BasicSourceMapConsumer + */ + BasicSourceMapConsumer.fromSourceMap = + function SourceMapConsumer_fromSourceMap(aSourceMap) { + var smc = Object.create(BasicSourceMapConsumer.prototype); + + smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); + smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); + smc.sourceRoot = aSourceMap._sourceRoot; + smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), + smc.sourceRoot); + smc.file = aSourceMap._file; + + smc.__generatedMappings = aSourceMap._mappings.toArray().slice(); + smc.__originalMappings = aSourceMap._mappings.toArray().slice() + .sort(util.compareByOriginalPositions); + + return smc; + }; + + /** + * The version of the source mapping spec that we are consuming. + */ + BasicSourceMapConsumer.prototype._version = 3; + + /** + * The list of original sources. + */ + Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', { + get: function () { + return this._sources.toArray().map(function (s) { + return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s; + }, this); + } + }); + + /** + * Parse the mappings in a string in to a data structure which we can easily + * query (the ordered arrays in the `this.__generatedMappings` and + * `this.__originalMappings` properties). + */ + BasicSourceMapConsumer.prototype._parseMappings = + function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { + var generatedLine = 1; + var previousGeneratedColumn = 0; + var previousOriginalLine = 0; + var previousOriginalColumn = 0; + var previousSource = 0; + var previousName = 0; + var str = aStr; + var temp = {}; + var mapping; + + while (str.length > 0) { + if (str.charAt(0) === ';') { + generatedLine++; + str = str.slice(1); + previousGeneratedColumn = 0; + } + else if (str.charAt(0) === ',') { + str = str.slice(1); + } + else { + mapping = {}; + mapping.generatedLine = generatedLine; + + // Generated column. + base64VLQ.decode(str, temp); + mapping.generatedColumn = previousGeneratedColumn + temp.value; + previousGeneratedColumn = mapping.generatedColumn; + str = temp.rest; + + if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) { + // Original source. + base64VLQ.decode(str, temp); + mapping.source = this._sources.at(previousSource + temp.value); + previousSource += temp.value; + str = temp.rest; + if (str.length === 0 || this._nextCharIsMappingSeparator(str)) { + throw new Error('Found a source, but no line and column'); + } + + // Original line. + base64VLQ.decode(str, temp); + mapping.originalLine = previousOriginalLine + temp.value; + previousOriginalLine = mapping.originalLine; + // Lines are stored 0-based + mapping.originalLine += 1; + str = temp.rest; + if (str.length === 0 || this._nextCharIsMappingSeparator(str)) { + throw new Error('Found a source and line, but no column'); + } + + // Original column. + base64VLQ.decode(str, temp); + mapping.originalColumn = previousOriginalColumn + temp.value; + previousOriginalColumn = mapping.originalColumn; + str = temp.rest; + + if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) { + // Original name. + base64VLQ.decode(str, temp); + mapping.name = this._names.at(previousName + temp.value); + previousName += temp.value; + str = temp.rest; + } + } + + this.__generatedMappings.push(mapping); + if (typeof mapping.originalLine === 'number') { + this.__originalMappings.push(mapping); + } + } + } + + this.__generatedMappings.sort(util.compareByGeneratedPositions); + this.__originalMappings.sort(util.compareByOriginalPositions); + }; + + /** + * Find the mapping that best matches the hypothetical "needle" mapping that + * we are searching for in the given "haystack" of mappings. + */ + BasicSourceMapConsumer.prototype._findMapping = + function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, + aColumnName, aComparator) { + // To return the position we are searching for, we must first find the + // mapping for the given position and then return the opposite position it + // points to. Because the mappings are sorted, we can use binary search to + // find the best mapping. + + if (aNeedle[aLineName] <= 0) { + throw new TypeError('Line must be greater than or equal to 1, got ' + + aNeedle[aLineName]); + } + if (aNeedle[aColumnName] < 0) { + throw new TypeError('Column must be greater than or equal to 0, got ' + + aNeedle[aColumnName]); + } + + return binarySearch.search(aNeedle, aMappings, aComparator); + }; + + /** + * Compute the last column for each generated mapping. The last column is + * inclusive. + */ + BasicSourceMapConsumer.prototype.computeColumnSpans = + function SourceMapConsumer_computeColumnSpans() { + for (var index = 0; index < this._generatedMappings.length; ++index) { + var mapping = this._generatedMappings[index]; + + // Mappings do not contain a field for the last generated columnt. We + // can come up with an optimistic estimate, however, by assuming that + // mappings are contiguous (i.e. given two consecutive mappings, the + // first mapping ends where the second one starts). + if (index + 1 < this._generatedMappings.length) { + var nextMapping = this._generatedMappings[index + 1]; + + if (mapping.generatedLine === nextMapping.generatedLine) { + mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1; + continue; + } + } + + // The last mapping for each line spans the entire line. + mapping.lastGeneratedColumn = Infinity; + } + }; + + /** + * Returns the original source, line, and column information for the generated + * source's line and column positions provided. The only argument is an object + * with the following properties: + * + * - line: The line number in the generated source. + * - column: The column number in the generated source. + * + * and an object is returned with the following properties: + * + * - source: The original source file, or null. + * - line: The line number in the original source, or null. + * - column: The column number in the original source, or null. + * - name: The original identifier, or null. + */ + BasicSourceMapConsumer.prototype.originalPositionFor = + function SourceMapConsumer_originalPositionFor(aArgs) { + var needle = { + generatedLine: util.getArg(aArgs, 'line'), + generatedColumn: util.getArg(aArgs, 'column') + }; + + var index = this._findMapping(needle, + this._generatedMappings, + "generatedLine", + "generatedColumn", + util.compareByGeneratedPositions); + + if (index >= 0) { + var mapping = this._generatedMappings[index]; + + if (mapping.generatedLine === needle.generatedLine) { + var source = util.getArg(mapping, 'source', null); + if (source != null && this.sourceRoot != null) { + source = util.join(this.sourceRoot, source); + } + return { + source: source, + line: util.getArg(mapping, 'originalLine', null), + column: util.getArg(mapping, 'originalColumn', null), + name: util.getArg(mapping, 'name', null) + }; + } + } + + return { + source: null, + line: null, + column: null, + name: null + }; + }; + + /** + * Returns the original source content. The only argument is the url of the + * original source file. Returns null if no original source content is + * availible. + */ + BasicSourceMapConsumer.prototype.sourceContentFor = + function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { + if (!this.sourcesContent) { + return null; + } + + if (this.sourceRoot != null) { + aSource = util.relative(this.sourceRoot, aSource); + } + + if (this._sources.has(aSource)) { + return this.sourcesContent[this._sources.indexOf(aSource)]; + } + + var url; + if (this.sourceRoot != null + && (url = util.urlParse(this.sourceRoot))) { + // XXX: file:// URIs and absolute paths lead to unexpected behavior for + // many users. We can help them out when they expect file:// URIs to + // behave like it would if they were running a local HTTP server. See + // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. + var fileUriAbsPath = aSource.replace(/^file:\/\//, ""); + if (url.scheme == "file" + && this._sources.has(fileUriAbsPath)) { + return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] + } + + if ((!url.path || url.path == "/") + && this._sources.has("/" + aSource)) { + return this.sourcesContent[this._sources.indexOf("/" + aSource)]; + } + } + + // This function is used recursively from + // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we + // don't want to throw if we can't find the source - we just want to + // return null, so we provide a flag to exit gracefully. + if (nullOnMissing) { + return null; + } + else { + throw new Error('"' + aSource + '" is not in the SourceMap.'); + } + }; + + /** + * Returns the generated line and column information for the original source, + * line, and column positions provided. The only argument is an object with + * the following properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * - column: The column number in the original source. + * + * and an object is returned with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ + BasicSourceMapConsumer.prototype.generatedPositionFor = + function SourceMapConsumer_generatedPositionFor(aArgs) { + var needle = { + source: util.getArg(aArgs, 'source'), + originalLine: util.getArg(aArgs, 'line'), + originalColumn: util.getArg(aArgs, 'column') + }; + + if (this.sourceRoot != null) { + needle.source = util.relative(this.sourceRoot, needle.source); + } + + var index = this._findMapping(needle, + this._originalMappings, + "originalLine", + "originalColumn", + util.compareByOriginalPositions); + + if (index >= 0) { + var mapping = this._originalMappings[index]; + + return { + line: util.getArg(mapping, 'generatedLine', null), + column: util.getArg(mapping, 'generatedColumn', null), + lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) + }; + } + + return { + line: null, + column: null, + lastColumn: null + }; + }; + + exports.BasicSourceMapConsumer = BasicSourceMapConsumer; + +}); + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/basic-source-map-consumer.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"./array-set":12,"./base64-vlq":13,"./binary-search":16,"./source-map-consumer":19,"./util":22,"amdefine":5,"buffer":3,"pBGvAp":29}],16:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { + + /** + * Recursive implementation of binary search. + * + * @param aLow Indices here and lower do not contain the needle. + * @param aHigh Indices here and higher do not contain the needle. + * @param aNeedle The element being searched for. + * @param aHaystack The non-empty array being searched. + * @param aCompare Function which takes two elements and returns -1, 0, or 1. + */ + function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) { + // This function terminates when one of the following is true: + // + // 1. We find the exact element we are looking for. + // + // 2. We did not find the exact element, but we can return the index of + // the next closest element that is less than that element. + // + // 3. We did not find the exact element, and there is no next-closest + // element which is less than the one we are searching for, so we + // return -1. + var mid = Math.floor((aHigh - aLow) / 2) + aLow; + var cmp = aCompare(aNeedle, aHaystack[mid], true); + if (cmp === 0) { + // Found the element we are looking for. + return mid; + } + else if (cmp > 0) { + // aHaystack[mid] is greater than our needle. + if (aHigh - mid > 1) { + // The element is in the upper half. + return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare); + } + // We did not find an exact match, return the next closest one + // (termination case 2). + return mid; + } + else { + // aHaystack[mid] is less than our needle. + if (mid - aLow > 1) { + // The element is in the lower half. + return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare); + } + // The exact needle element was not found in this haystack. Determine if + // we are in termination case (2) or (3) and return the appropriate thing. + return aLow < 0 ? -1 : aLow; + } + } + + /** + * This is an implementation of binary search which will always try and return + * the index of next lowest value checked if there is no exact hit. This is + * because mappings between original and generated line/col pairs are single + * points, and there is an implicit region between each of them, so a miss + * just means that you aren't on the very start of a region. + * + * @param aNeedle The element you are looking for. + * @param aHaystack The array that is being searched. + * @param aCompare A function which takes the needle and an element in the + * array and returns -1, 0, or 1 depending on whether the needle is less + * than, equal to, or greater than the element, respectively. + */ + exports.search = function search(aNeedle, aHaystack, aCompare) { + if (aHaystack.length === 0) { + return -1; + } + return recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare) + }; + +}); + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/binary-search.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"amdefine":5,"buffer":3,"pBGvAp":29}],17:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { + + var util = require('./util'); + var binarySearch = require('./binary-search'); + var SourceMapConsumer = require('./source-map-consumer').SourceMapConsumer; + var BasicSourceMapConsumer = require('./basic-source-map-consumer').BasicSourceMapConsumer; + + /** + * An IndexedSourceMapConsumer instance represents a parsed source map which + * we can query for information. It differs from BasicSourceMapConsumer in + * that it takes "indexed" source maps (i.e. ones with a "sections" field) as + * input. + * + * The only parameter is a raw source map (either as a JSON string, or already + * parsed to an object). According to the spec for indexed source maps, they + * have the following attributes: + * + * - version: Which version of the source map spec this map is following. + * - file: Optional. The generated file this source map is associated with. + * - sections: A list of section definitions. + * + * Each value under the "sections" field has two fields: + * - offset: The offset into the original specified at which this section + * begins to apply, defined as an object with a "line" and "column" + * field. + * - map: A source map definition. This source map could also be indexed, + * but doesn't have to be. + * + * Instead of the "map" field, it's also possible to have a "url" field + * specifying a URL to retrieve a source map from, but that's currently + * unsupported. + * + * Here's an example source map, taken from the source map spec[0], but + * modified to omit a section which uses the "url" field. + * + * { + * version : 3, + * file: "app.js", + * sections: [{ + * offset: {line:100, column:10}, + * map: { + * version : 3, + * file: "section.js", + * sources: ["foo.js", "bar.js"], + * names: ["src", "maps", "are", "fun"], + * mappings: "AAAA,E;;ABCDE;" + * } + * }], + * } + * + * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt + */ + function IndexedSourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + } + + var version = util.getArg(sourceMap, 'version'); + var sections = util.getArg(sourceMap, 'sections'); + + if (version != this._version) { + throw new Error('Unsupported version: ' + version); + } + + var lastOffset = { + line: -1, + column: 0 + }; + this._sections = sections.map(function (s) { + if (s.url) { + // The url field will require support for asynchronicity. + // See https://github.com/mozilla/source-map/issues/16 + throw new Error('Support for url field in sections not implemented.'); + } + var offset = util.getArg(s, 'offset'); + var offsetLine = util.getArg(offset, 'line'); + var offsetColumn = util.getArg(offset, 'column'); + + if (offsetLine < lastOffset.line || + (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) { + throw new Error('Section offsets must be ordered and non-overlapping.'); + } + lastOffset = offset; + + return { + generatedOffset: { + // The offset fields are 0-based, but we use 1-based indices when + // encoding/decoding from VLQ. + generatedLine: offsetLine + 1, + generatedColumn: offsetColumn + 1 + }, + consumer: new SourceMapConsumer(util.getArg(s, 'map')) + } + }); + } + + IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); + IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer; + + /** + * The version of the source mapping spec that we are consuming. + */ + IndexedSourceMapConsumer.prototype._version = 3; + + /** + * The list of original sources. + */ + Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', { + get: function () { + var sources = []; + for (var i = 0; i < this._sections.length; i++) { + for (var j = 0; j < this._sections[i].consumer.sources.length; j++) { + sources.push(this._sections[i].consumer.sources[j]); + } + }; + return sources; + } + }); + + /** + * Returns the original source, line, and column information for the generated + * source's line and column positions provided. The only argument is an object + * with the following properties: + * + * - line: The line number in the generated source. + * - column: The column number in the generated source. + * + * and an object is returned with the following properties: + * + * - source: The original source file, or null. + * - line: The line number in the original source, or null. + * - column: The column number in the original source, or null. + * - name: The original identifier, or null. + */ + IndexedSourceMapConsumer.prototype.originalPositionFor = + function IndexedSourceMapConsumer_originalPositionFor(aArgs) { + var needle = { + generatedLine: util.getArg(aArgs, 'line'), + generatedColumn: util.getArg(aArgs, 'column') + }; + + // Find the section containing the generated position we're trying to map + // to an original position. + var sectionIndex = binarySearch.search(needle, this._sections, + function(needle, section) { + var cmp = needle.generatedLine - section.generatedOffset.generatedLine; + if (cmp) { + return cmp; + } + + return (needle.generatedColumn - + section.generatedOffset.generatedColumn); + }); + var section = this._sections[sectionIndex]; + + if (!section) { + return { + source: null, + line: null, + column: null, + name: null + }; + } + + return section.consumer.originalPositionFor({ + line: needle.generatedLine - + (section.generatedOffset.generatedLine - 1), + column: needle.generatedColumn - + (section.generatedOffset.generatedLine === needle.generatedLine + ? section.generatedOffset.generatedColumn - 1 + : 0) + }); + }; + + /** + * Returns the original source content. The only argument is the url of the + * original source file. Returns null if no original source content is + * available. + */ + IndexedSourceMapConsumer.prototype.sourceContentFor = + function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { + for (var i = 0; i < this._sections.length; i++) { + var section = this._sections[i]; + + var content = section.consumer.sourceContentFor(aSource, true); + if (content) { + return content; + } + } + if (nullOnMissing) { + return null; + } + else { + throw new Error('"' + aSource + '" is not in the SourceMap.'); + } + }; + + /** + * Returns the generated line and column information for the original source, + * line, and column positions provided. The only argument is an object with + * the following properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * - column: The column number in the original source. + * + * and an object is returned with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ + IndexedSourceMapConsumer.prototype.generatedPositionFor = + function IndexedSourceMapConsumer_generatedPositionFor(aArgs) { + for (var i = 0; i < this._sections.length; i++) { + var section = this._sections[i]; + + // Only consider this section if the requested source is in the list of + // sources of the consumer. + if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) { + continue; + } + var generatedPosition = section.consumer.generatedPositionFor(aArgs); + if (generatedPosition) { + var ret = { + line: generatedPosition.line + + (section.generatedOffset.generatedLine - 1), + column: generatedPosition.column + + (section.generatedOffset.generatedLine === generatedPosition.line + ? section.generatedOffset.generatedColumn - 1 + : 0) + }; + return ret; + } + } + + return { + line: null, + column: null + }; + }; + + /** + * Parse the mappings in a string in to a data structure which we can easily + * query (the ordered arrays in the `this.__generatedMappings` and + * `this.__originalMappings` properties). + */ + IndexedSourceMapConsumer.prototype._parseMappings = + function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) { + this.__generatedMappings = []; + this.__originalMappings = []; + for (var i = 0; i < this._sections.length; i++) { + var section = this._sections[i]; + var sectionMappings = section.consumer._generatedMappings; + for (var j = 0; j < sectionMappings.length; j++) { + var mapping = sectionMappings[i]; + + var source = mapping.source; + var sourceRoot = section.consumer.sourceRoot; + + if (source != null && sourceRoot != null) { + source = util.join(sourceRoot, source); + } + + // The mappings coming from the consumer for the section have + // generated positions relative to the start of the section, so we + // need to offset them to be relative to the start of the concatenated + // generated file. + var adjustedMapping = { + source: source, + generatedLine: mapping.generatedLine + + (section.generatedOffset.generatedLine - 1), + generatedColumn: mapping.column + + (section.generatedOffset.generatedLine === mapping.generatedLine) + ? section.generatedOffset.generatedColumn - 1 + : 0, + originalLine: mapping.originalLine, + originalColumn: mapping.originalColumn, + name: mapping.name + }; + + this.__generatedMappings.push(adjustedMapping); + if (typeof adjustedMapping.originalLine === 'number') { + this.__originalMappings.push(adjustedMapping); + } + }; + }; + + this.__generatedMappings.sort(util.compareByGeneratedPositions); + this.__originalMappings.sort(util.compareByOriginalPositions); + }; + + exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; +}); + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/indexed-source-map-consumer.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"./basic-source-map-consumer":15,"./binary-search":16,"./source-map-consumer":19,"./util":22,"amdefine":5,"buffer":3,"pBGvAp":29}],18:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2014 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { + + var util = require('./util'); + + /** + * Determine whether mappingB is after mappingA with respect to generated + * position. + */ + function generatedPositionAfter(mappingA, mappingB) { + // Optimized for most common case + var lineA = mappingA.generatedLine; + var lineB = mappingB.generatedLine; + var columnA = mappingA.generatedColumn; + var columnB = mappingB.generatedColumn; + return lineB > lineA || lineB == lineA && columnB >= columnA || + util.compareByGeneratedPositions(mappingA, mappingB) <= 0; + } + + /** + * A data structure to provide a sorted view of accumulated mappings in a + * performance conscious manner. It trades a neglibable overhead in general + * case for a large speedup in case of mappings being added in order. + */ + function MappingList() { + this._array = []; + this._sorted = true; + // Serves as infimum + this._last = {generatedLine: -1, generatedColumn: 0}; + } + + /** + * Iterate through internal items. This method takes the same arguments that + * `Array.prototype.forEach` takes. + * + * NOTE: The order of the mappings is NOT guaranteed. + */ + MappingList.prototype.unsortedForEach = + function MappingList_forEach(aCallback, aThisArg) { + this._array.forEach(aCallback, aThisArg); + }; + + /** + * Add the given source mapping. + * + * @param Object aMapping + */ + MappingList.prototype.add = function MappingList_add(aMapping) { + var mapping; + if (generatedPositionAfter(this._last, aMapping)) { + this._last = aMapping; + this._array.push(aMapping); + } else { + this._sorted = false; + this._array.push(aMapping); + } + }; + + /** + * Returns the flat, sorted array of mappings. The mappings are sorted by + * generated position. + * + * WARNING: This method returns internal data without copying, for + * performance. The return value must NOT be mutated, and should be treated as + * an immutable borrow. If you want to take ownership, you must make your own + * copy. + */ + MappingList.prototype.toArray = function MappingList_toArray() { + if (!this._sorted) { + this._array.sort(util.compareByGeneratedPositions); + this._sorted = true; + } + return this._array; + }; + + exports.MappingList = MappingList; + +}); + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/mapping-list.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"./util":22,"amdefine":5,"buffer":3,"pBGvAp":29}],19:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { + + var util = require('./util'); + + function SourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + } + + // We do late requires because the subclasses require() this file. + if (sourceMap.sections != null) { + var indexedSourceMapConsumer = require('./indexed-source-map-consumer'); + return new indexedSourceMapConsumer.IndexedSourceMapConsumer(sourceMap); + } else { + var basicSourceMapConsumer = require('./basic-source-map-consumer'); + return new basicSourceMapConsumer.BasicSourceMapConsumer(sourceMap); + } + } + + SourceMapConsumer.fromSourceMap = function(aSourceMap) { + var basicSourceMapConsumer = require('./basic-source-map-consumer'); + return basicSourceMapConsumer.BasicSourceMapConsumer + .fromSourceMap(aSourceMap); + } + + /** + * The version of the source mapping spec that we are consuming. + */ + SourceMapConsumer.prototype._version = 3; + + + // `__generatedMappings` and `__originalMappings` are arrays that hold the + // parsed mapping coordinates from the source map's "mappings" attribute. They + // are lazily instantiated, accessed via the `_generatedMappings` and + // `_originalMappings` getters respectively, and we only parse the mappings + // and create these arrays once queried for a source location. We jump through + // these hoops because there can be many thousands of mappings, and parsing + // them is expensive, so we only want to do it if we must. + // + // Each object in the arrays is of the form: + // + // { + // generatedLine: The line number in the generated code, + // generatedColumn: The column number in the generated code, + // source: The path to the original source file that generated this + // chunk of code, + // originalLine: The line number in the original source that + // corresponds to this chunk of generated code, + // originalColumn: The column number in the original source that + // corresponds to this chunk of generated code, + // name: The name of the original symbol which generated this chunk of + // code. + // } + // + // All properties except for `generatedLine` and `generatedColumn` can be + // `null`. + // + // `_generatedMappings` is ordered by the generated positions. + // + // `_originalMappings` is ordered by the original positions. + + SourceMapConsumer.prototype.__generatedMappings = null; + Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { + get: function () { + if (!this.__generatedMappings) { + this.__generatedMappings = []; + this.__originalMappings = []; + this._parseMappings(this._mappings, this.sourceRoot); + } + + return this.__generatedMappings; + } + }); + + SourceMapConsumer.prototype.__originalMappings = null; + Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { + get: function () { + if (!this.__originalMappings) { + this.__generatedMappings = []; + this.__originalMappings = []; + this._parseMappings(this._mappings, this.sourceRoot); + } + + return this.__originalMappings; + } + }); + + SourceMapConsumer.prototype._nextCharIsMappingSeparator = + function SourceMapConsumer_nextCharIsMappingSeparator(aStr) { + var c = aStr.charAt(0); + return c === ";" || c === ","; + }; + + /** + * Parse the mappings in a string in to a data structure which we can easily + * query (the ordered arrays in the `this.__generatedMappings` and + * `this.__originalMappings` properties). + */ + SourceMapConsumer.prototype._parseMappings = + function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { + throw new Error("Subclasses must implement _parseMappings"); + }; + + SourceMapConsumer.GENERATED_ORDER = 1; + SourceMapConsumer.ORIGINAL_ORDER = 2; + + /** + * Iterate over each mapping between an original source/line/column and a + * generated line/column in this source map. + * + * @param Function aCallback + * The function that is called with each mapping. + * @param Object aContext + * Optional. If specified, this object will be the value of `this` every + * time that `aCallback` is called. + * @param aOrder + * Either `SourceMapConsumer.GENERATED_ORDER` or + * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to + * iterate over the mappings sorted by the generated file's line/column + * order or the original's source/line/column order, respectively. Defaults to + * `SourceMapConsumer.GENERATED_ORDER`. + */ + SourceMapConsumer.prototype.eachMapping = + function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { + var context = aContext || null; + var order = aOrder || SourceMapConsumer.GENERATED_ORDER; + + var mappings; + switch (order) { + case SourceMapConsumer.GENERATED_ORDER: + mappings = this._generatedMappings; + break; + case SourceMapConsumer.ORIGINAL_ORDER: + mappings = this._originalMappings; + break; + default: + throw new Error("Unknown order of iteration."); + } + + var sourceRoot = this.sourceRoot; + mappings.map(function (mapping) { + var source = mapping.source; + if (source != null && sourceRoot != null) { + source = util.join(sourceRoot, source); + } + return { + source: source, + generatedLine: mapping.generatedLine, + generatedColumn: mapping.generatedColumn, + originalLine: mapping.originalLine, + originalColumn: mapping.originalColumn, + name: mapping.name + }; + }).forEach(aCallback, context); + }; + + /** + * Returns all generated line and column information for the original source + * and line provided. The only argument is an object with the following + * properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * + * and an array of objects is returned, each with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ + SourceMapConsumer.prototype.allGeneratedPositionsFor = + function SourceMapConsumer_allGeneratedPositionsFor(aArgs) { + // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping + // returns the index of the closest mapping less than the needle. By + // setting needle.originalColumn to Infinity, we thus find the last + // mapping for the given line, provided such a mapping exists. + var needle = { + source: util.getArg(aArgs, 'source'), + originalLine: util.getArg(aArgs, 'line'), + originalColumn: Infinity + }; + + if (this.sourceRoot != null) { + needle.source = util.relative(this.sourceRoot, needle.source); + } + + var mappings = []; + + var index = this._findMapping(needle, + this._originalMappings, + "originalLine", + "originalColumn", + util.compareByOriginalPositions); + if (index >= 0) { + var mapping = this._originalMappings[index]; + + while (mapping && mapping.originalLine === needle.originalLine) { + mappings.push({ + line: util.getArg(mapping, 'generatedLine', null), + column: util.getArg(mapping, 'generatedColumn', null), + lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) + }); + + mapping = this._originalMappings[--index]; + } + } + + return mappings.reverse(); + }; + + exports.SourceMapConsumer = SourceMapConsumer; + +}); + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-consumer.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"./basic-source-map-consumer":15,"./indexed-source-map-consumer":17,"./util":22,"amdefine":5,"buffer":3,"pBGvAp":29}],20:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { + + var base64VLQ = require('./base64-vlq'); + var util = require('./util'); + var ArraySet = require('./array-set').ArraySet; + var MappingList = require('./mapping-list').MappingList; + + /** + * An instance of the SourceMapGenerator represents a source map which is + * being built incrementally. You may pass an object with the following + * properties: + * + * - file: The filename of the generated source. + * - sourceRoot: A root for all relative URLs in this source map. + */ + function SourceMapGenerator(aArgs) { + if (!aArgs) { + aArgs = {}; + } + this._file = util.getArg(aArgs, 'file', null); + this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); + this._skipValidation = util.getArg(aArgs, 'skipValidation', false); + this._sources = new ArraySet(); + this._names = new ArraySet(); + this._mappings = new MappingList(); + this._sourcesContents = null; + } + + SourceMapGenerator.prototype._version = 3; + + /** + * Creates a new SourceMapGenerator based on a SourceMapConsumer + * + * @param aSourceMapConsumer The SourceMap. + */ + SourceMapGenerator.fromSourceMap = + function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { + var sourceRoot = aSourceMapConsumer.sourceRoot; + var generator = new SourceMapGenerator({ + file: aSourceMapConsumer.file, + sourceRoot: sourceRoot + }); + aSourceMapConsumer.eachMapping(function (mapping) { + var newMapping = { + generated: { + line: mapping.generatedLine, + column: mapping.generatedColumn + } + }; + + if (mapping.source != null) { + newMapping.source = mapping.source; + if (sourceRoot != null) { + newMapping.source = util.relative(sourceRoot, newMapping.source); + } + + newMapping.original = { + line: mapping.originalLine, + column: mapping.originalColumn + }; + + if (mapping.name != null) { + newMapping.name = mapping.name; + } + } + + generator.addMapping(newMapping); + }); + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + generator.setSourceContent(sourceFile, content); + } + }); + return generator; + }; + + /** + * Add a single mapping from original source line and column to the generated + * source's line and column for this source map being created. The mapping + * object should have the following properties: + * + * - generated: An object with the generated line and column positions. + * - original: An object with the original line and column positions. + * - source: The original source file (relative to the sourceRoot). + * - name: An optional original token name for this mapping. + */ + SourceMapGenerator.prototype.addMapping = + function SourceMapGenerator_addMapping(aArgs) { + var generated = util.getArg(aArgs, 'generated'); + var original = util.getArg(aArgs, 'original', null); + var source = util.getArg(aArgs, 'source', null); + var name = util.getArg(aArgs, 'name', null); + + if (!this._skipValidation) { + this._validateMapping(generated, original, source, name); + } + + if (source != null && !this._sources.has(source)) { + this._sources.add(source); + } + + if (name != null && !this._names.has(name)) { + this._names.add(name); + } + + this._mappings.add({ + generatedLine: generated.line, + generatedColumn: generated.column, + originalLine: original != null && original.line, + originalColumn: original != null && original.column, + source: source, + name: name + }); + }; + + /** + * Set the source content for a source file. + */ + SourceMapGenerator.prototype.setSourceContent = + function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { + var source = aSourceFile; + if (this._sourceRoot != null) { + source = util.relative(this._sourceRoot, source); + } + + if (aSourceContent != null) { + // Add the source content to the _sourcesContents map. + // Create a new _sourcesContents map if the property is null. + if (!this._sourcesContents) { + this._sourcesContents = {}; + } + this._sourcesContents[util.toSetString(source)] = aSourceContent; + } else if (this._sourcesContents) { + // Remove the source file from the _sourcesContents map. + // If the _sourcesContents map is empty, set the property to null. + delete this._sourcesContents[util.toSetString(source)]; + if (Object.keys(this._sourcesContents).length === 0) { + this._sourcesContents = null; + } + } + }; + + /** + * Applies the mappings of a sub-source-map for a specific source file to the + * source map being generated. Each mapping to the supplied source file is + * rewritten using the supplied source map. Note: The resolution for the + * resulting mappings is the minimium of this map and the supplied map. + * + * @param aSourceMapConsumer The source map to be applied. + * @param aSourceFile Optional. The filename of the source file. + * If omitted, SourceMapConsumer's file property will be used. + * @param aSourceMapPath Optional. The dirname of the path to the source map + * to be applied. If relative, it is relative to the SourceMapConsumer. + * This parameter is needed when the two source maps aren't in the same + * directory, and the source map to be applied contains relative source + * paths. If so, those relative source paths need to be rewritten + * relative to the SourceMapGenerator. + */ + SourceMapGenerator.prototype.applySourceMap = + function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { + var sourceFile = aSourceFile; + // If aSourceFile is omitted, we will use the file property of the SourceMap + if (aSourceFile == null) { + if (aSourceMapConsumer.file == null) { + throw new Error( + 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + + 'or the source map\'s "file" property. Both were omitted.' + ); + } + sourceFile = aSourceMapConsumer.file; + } + var sourceRoot = this._sourceRoot; + // Make "sourceFile" relative if an absolute Url is passed. + if (sourceRoot != null) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + // Applying the SourceMap can add and remove items from the sources and + // the names array. + var newSources = new ArraySet(); + var newNames = new ArraySet(); + + // Find mappings for the "sourceFile" + this._mappings.unsortedForEach(function (mapping) { + if (mapping.source === sourceFile && mapping.originalLine != null) { + // Check if it can be mapped by the source map, then update the mapping. + var original = aSourceMapConsumer.originalPositionFor({ + line: mapping.originalLine, + column: mapping.originalColumn + }); + if (original.source != null) { + // Copy mapping + mapping.source = original.source; + if (aSourceMapPath != null) { + mapping.source = util.join(aSourceMapPath, mapping.source) + } + if (sourceRoot != null) { + mapping.source = util.relative(sourceRoot, mapping.source); + } + mapping.originalLine = original.line; + mapping.originalColumn = original.column; + if (original.name != null) { + mapping.name = original.name; + } + } + } + + var source = mapping.source; + if (source != null && !newSources.has(source)) { + newSources.add(source); + } + + var name = mapping.name; + if (name != null && !newNames.has(name)) { + newNames.add(name); + } + + }, this); + this._sources = newSources; + this._names = newNames; + + // Copy sourcesContents of applied map. + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + if (aSourceMapPath != null) { + sourceFile = util.join(aSourceMapPath, sourceFile); + } + if (sourceRoot != null) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + this.setSourceContent(sourceFile, content); + } + }, this); + }; + + /** + * A mapping can have one of the three levels of data: + * + * 1. Just the generated position. + * 2. The Generated position, original position, and original source. + * 3. Generated and original position, original source, as well as a name + * token. + * + * To maintain consistency, we validate that any new mapping being added falls + * in to one of these categories. + */ + SourceMapGenerator.prototype._validateMapping = + function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, + aName) { + if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aGenerated.line > 0 && aGenerated.column >= 0 + && !aOriginal && !aSource && !aName) { + // Case 1. + return; + } + else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aOriginal && 'line' in aOriginal && 'column' in aOriginal + && aGenerated.line > 0 && aGenerated.column >= 0 + && aOriginal.line > 0 && aOriginal.column >= 0 + && aSource) { + // Cases 2 and 3. + return; + } + else { + throw new Error('Invalid mapping: ' + JSON.stringify({ + generated: aGenerated, + source: aSource, + original: aOriginal, + name: aName + })); + } + }; + + /** + * Serialize the accumulated mappings in to the stream of base 64 VLQs + * specified by the source map format. + */ + SourceMapGenerator.prototype._serializeMappings = + function SourceMapGenerator_serializeMappings() { + var previousGeneratedColumn = 0; + var previousGeneratedLine = 1; + var previousOriginalColumn = 0; + var previousOriginalLine = 0; + var previousName = 0; + var previousSource = 0; + var result = ''; + var mapping; + + var mappings = this._mappings.toArray(); + + for (var i = 0, len = mappings.length; i < len; i++) { + mapping = mappings[i]; + + if (mapping.generatedLine !== previousGeneratedLine) { + previousGeneratedColumn = 0; + while (mapping.generatedLine !== previousGeneratedLine) { + result += ';'; + previousGeneratedLine++; + } + } + else { + if (i > 0) { + if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) { + continue; + } + result += ','; + } + } + + result += base64VLQ.encode(mapping.generatedColumn + - previousGeneratedColumn); + previousGeneratedColumn = mapping.generatedColumn; + + if (mapping.source != null) { + result += base64VLQ.encode(this._sources.indexOf(mapping.source) + - previousSource); + previousSource = this._sources.indexOf(mapping.source); + + // lines are stored 0-based in SourceMap spec version 3 + result += base64VLQ.encode(mapping.originalLine - 1 + - previousOriginalLine); + previousOriginalLine = mapping.originalLine - 1; + + result += base64VLQ.encode(mapping.originalColumn + - previousOriginalColumn); + previousOriginalColumn = mapping.originalColumn; + + if (mapping.name != null) { + result += base64VLQ.encode(this._names.indexOf(mapping.name) + - previousName); + previousName = this._names.indexOf(mapping.name); + } + } + } + + return result; + }; + + SourceMapGenerator.prototype._generateSourcesContent = + function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { + return aSources.map(function (source) { + if (!this._sourcesContents) { + return null; + } + if (aSourceRoot != null) { + source = util.relative(aSourceRoot, source); + } + var key = util.toSetString(source); + return Object.prototype.hasOwnProperty.call(this._sourcesContents, + key) + ? this._sourcesContents[key] + : null; + }, this); + }; + + /** + * Externalize the source map. + */ + SourceMapGenerator.prototype.toJSON = + function SourceMapGenerator_toJSON() { + var map = { + version: this._version, + sources: this._sources.toArray(), + names: this._names.toArray(), + mappings: this._serializeMappings() + }; + if (this._file != null) { + map.file = this._file; + } + if (this._sourceRoot != null) { + map.sourceRoot = this._sourceRoot; + } + if (this._sourcesContents) { + map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); + } + + return map; + }; + + /** + * Render the source map being generated to a string. + */ + SourceMapGenerator.prototype.toString = + function SourceMapGenerator_toString() { + return JSON.stringify(this); + }; + + exports.SourceMapGenerator = SourceMapGenerator; + +}); + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-generator.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"./array-set":12,"./base64-vlq":13,"./mapping-list":18,"./util":22,"amdefine":5,"buffer":3,"pBGvAp":29}],21:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { + + var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator; + var util = require('./util'); + + // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other + // operating systems these days (capturing the result). + var REGEX_NEWLINE = /(\r?\n)/; + + // Newline character code for charCodeAt() comparisons + var NEWLINE_CODE = 10; + + // Private symbol for identifying `SourceNode`s when multiple versions of + // the source-map library are loaded. This MUST NOT CHANGE across + // versions! + var isSourceNode = "$$$isSourceNode$$$"; + + /** + * SourceNodes provide a way to abstract over interpolating/concatenating + * snippets of generated JavaScript source code while maintaining the line and + * column information associated with the original source code. + * + * @param aLine The original line number. + * @param aColumn The original column number. + * @param aSource The original source's filename. + * @param aChunks Optional. An array of strings which are snippets of + * generated JS, or other SourceNodes. + * @param aName The original identifier. + */ + function SourceNode(aLine, aColumn, aSource, aChunks, aName) { + this.children = []; + this.sourceContents = {}; + this.line = aLine == null ? null : aLine; + this.column = aColumn == null ? null : aColumn; + this.source = aSource == null ? null : aSource; + this.name = aName == null ? null : aName; + this[isSourceNode] = true; + if (aChunks != null) this.add(aChunks); + } + + /** + * Creates a SourceNode from generated code and a SourceMapConsumer. + * + * @param aGeneratedCode The generated code + * @param aSourceMapConsumer The SourceMap for the generated code + * @param aRelativePath Optional. The path that relative sources in the + * SourceMapConsumer should be relative to. + */ + SourceNode.fromStringWithSourceMap = + function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { + // The SourceNode we want to fill with the generated code + // and the SourceMap + var node = new SourceNode(); + + // All even indices of this array are one line of the generated code, + // while all odd indices are the newlines between two adjacent lines + // (since `REGEX_NEWLINE` captures its match). + // Processed fragments are removed from this array, by calling `shiftNextLine`. + var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); + var shiftNextLine = function() { + var lineContents = remainingLines.shift(); + // The last line of a file might not have a newline. + var newLine = remainingLines.shift() || ""; + return lineContents + newLine; + }; + + // We need to remember the position of "remainingLines" + var lastGeneratedLine = 1, lastGeneratedColumn = 0; + + // The generate SourceNodes we need a code range. + // To extract it current and last mapping is used. + // Here we store the last mapping. + var lastMapping = null; + + aSourceMapConsumer.eachMapping(function (mapping) { + if (lastMapping !== null) { + // We add the code from "lastMapping" to "mapping": + // First check if there is a new line in between. + if (lastGeneratedLine < mapping.generatedLine) { + var code = ""; + // Associate first line with "lastMapping" + addMappingWithCode(lastMapping, shiftNextLine()); + lastGeneratedLine++; + lastGeneratedColumn = 0; + // The remaining code is added without mapping + } else { + // There is no new line in between. + // Associate the code between "lastGeneratedColumn" and + // "mapping.generatedColumn" with "lastMapping" + var nextLine = remainingLines[0]; + var code = nextLine.substr(0, mapping.generatedColumn - + lastGeneratedColumn); + remainingLines[0] = nextLine.substr(mapping.generatedColumn - + lastGeneratedColumn); + lastGeneratedColumn = mapping.generatedColumn; + addMappingWithCode(lastMapping, code); + // No more remaining code, continue + lastMapping = mapping; + return; + } + } + // We add the generated code until the first mapping + // to the SourceNode without any mapping. + // Each line is added as separate string. + while (lastGeneratedLine < mapping.generatedLine) { + node.add(shiftNextLine()); + lastGeneratedLine++; + } + if (lastGeneratedColumn < mapping.generatedColumn) { + var nextLine = remainingLines[0]; + node.add(nextLine.substr(0, mapping.generatedColumn)); + remainingLines[0] = nextLine.substr(mapping.generatedColumn); + lastGeneratedColumn = mapping.generatedColumn; + } + lastMapping = mapping; + }, this); + // We have processed all mappings. + if (remainingLines.length > 0) { + if (lastMapping) { + // Associate the remaining code in the current line with "lastMapping" + addMappingWithCode(lastMapping, shiftNextLine()); + } + // and add the remaining lines without any mapping + node.add(remainingLines.join("")); + } + + // Copy sourcesContent into SourceNode + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + if (aRelativePath != null) { + sourceFile = util.join(aRelativePath, sourceFile); + } + node.setSourceContent(sourceFile, content); + } + }); + + return node; + + function addMappingWithCode(mapping, code) { + if (mapping === null || mapping.source === undefined) { + node.add(code); + } else { + var source = aRelativePath + ? util.join(aRelativePath, mapping.source) + : mapping.source; + node.add(new SourceNode(mapping.originalLine, + mapping.originalColumn, + source, + code, + mapping.name)); + } + } }; - // See also tools/generate-unicode-regex.py. - Regex = { - NonAsciiIdentifierStart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]'), - NonAsciiIdentifierPart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]') + /** + * Add a chunk of generated JS to this source node. + * + * @param aChunk A string snippet of generated JS code, another instance of + * SourceNode, or an array where each member is one of those things. + */ + SourceNode.prototype.add = function SourceNode_add(aChunk) { + if (Array.isArray(aChunk)) { + aChunk.forEach(function (chunk) { + this.add(chunk); + }, this); + } + else if (aChunk[isSourceNode] || typeof aChunk === "string") { + if (aChunk) { + this.children.push(aChunk); + } + } + else { + throw new TypeError( + "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk + ); + } + return this; + }; + + /** + * Add a chunk of generated JS to the beginning of this source node. + * + * @param aChunk A string snippet of generated JS code, another instance of + * SourceNode, or an array where each member is one of those things. + */ + SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { + if (Array.isArray(aChunk)) { + for (var i = aChunk.length-1; i >= 0; i--) { + this.prepend(aChunk[i]); + } + } + else if (aChunk[isSourceNode] || typeof aChunk === "string") { + this.children.unshift(aChunk); + } + else { + throw new TypeError( + "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk + ); + } + return this; + }; + + /** + * Walk over the tree of JS snippets in this node and its children. The + * walking function is called once for each snippet of JS and is passed that + * snippet and the its original associated source's line/column location. + * + * @param aFn The traversal function. + */ + SourceNode.prototype.walk = function SourceNode_walk(aFn) { + var chunk; + for (var i = 0, len = this.children.length; i < len; i++) { + chunk = this.children[i]; + if (chunk[isSourceNode]) { + chunk.walk(aFn); + } + else { + if (chunk !== '') { + aFn(chunk, { source: this.source, + line: this.line, + column: this.column, + name: this.name }); + } + } + } + }; + + /** + * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between + * each of `this.children`. + * + * @param aSep The separator. + */ + SourceNode.prototype.join = function SourceNode_join(aSep) { + var newChildren; + var i; + var len = this.children.length; + if (len > 0) { + newChildren = []; + for (i = 0; i < len-1; i++) { + newChildren.push(this.children[i]); + newChildren.push(aSep); + } + newChildren.push(this.children[i]); + this.children = newChildren; + } + return this; + }; + + /** + * Call String.prototype.replace on the very right-most source snippet. Useful + * for trimming whitespace from the end of a source node, etc. + * + * @param aPattern The pattern to replace. + * @param aReplacement The thing to replace the pattern with. + */ + SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { + var lastChild = this.children[this.children.length - 1]; + if (lastChild[isSourceNode]) { + lastChild.replaceRight(aPattern, aReplacement); + } + else if (typeof lastChild === 'string') { + this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); + } + else { + this.children.push(''.replace(aPattern, aReplacement)); + } + return this; + }; + + /** + * Set the source content for a source file. This will be added to the SourceMapGenerator + * in the sourcesContent field. + * + * @param aSourceFile The filename of the source file + * @param aSourceContent The content of the source file + */ + SourceNode.prototype.setSourceContent = + function SourceNode_setSourceContent(aSourceFile, aSourceContent) { + this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; }; - // Ensure the condition is true, otherwise throw an error. - // This is only to have a better contract semantic, i.e. another safety net - // to catch a logic error. The condition shall be fulfilled in normal case. - // Do NOT use this to enforce a certain condition on any user input. + /** + * Walk over the tree of SourceNodes. The walking function is called for each + * source file content and is passed the filename and source content. + * + * @param aFn The traversal function. + */ + SourceNode.prototype.walkSourceContents = + function SourceNode_walkSourceContents(aFn) { + for (var i = 0, len = this.children.length; i < len; i++) { + if (this.children[i][isSourceNode]) { + this.children[i].walkSourceContents(aFn); + } + } - function assert(condition, message) { - /* istanbul ignore if */ - if (!condition) { - throw new Error('ASSERT: ' + message); + var sources = Object.keys(this.sourceContents); + for (var i = 0, len = sources.length; i < len; i++) { + aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); + } + }; + + /** + * Return the string representation of this source node. Walks over the tree + * and concatenates all the various snippets together to one string. + */ + SourceNode.prototype.toString = function SourceNode_toString() { + var str = ""; + this.walk(function (chunk) { + str += chunk; + }); + return str; + }; + + /** + * Returns the string representation of this source node along with a source + * map. + */ + SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { + var generated = { + code: "", + line: 1, + column: 0 + }; + var map = new SourceMapGenerator(aArgs); + var sourceMappingActive = false; + var lastOriginalSource = null; + var lastOriginalLine = null; + var lastOriginalColumn = null; + var lastOriginalName = null; + this.walk(function (chunk, original) { + generated.code += chunk; + if (original.source !== null + && original.line !== null + && original.column !== null) { + if(lastOriginalSource !== original.source + || lastOriginalLine !== original.line + || lastOriginalColumn !== original.column + || lastOriginalName !== original.name) { + map.addMapping({ + source: original.source, + original: { + line: original.line, + column: original.column + }, + generated: { + line: generated.line, + column: generated.column + }, + name: original.name + }); + } + lastOriginalSource = original.source; + lastOriginalLine = original.line; + lastOriginalColumn = original.column; + lastOriginalName = original.name; + sourceMappingActive = true; + } else if (sourceMappingActive) { + map.addMapping({ + generated: { + line: generated.line, + column: generated.column + } + }); + lastOriginalSource = null; + sourceMappingActive = false; + } + for (var idx = 0, length = chunk.length; idx < length; idx++) { + if (chunk.charCodeAt(idx) === NEWLINE_CODE) { + generated.line++; + generated.column = 0; + // Mappings end at eol + if (idx + 1 === length) { + lastOriginalSource = null; + sourceMappingActive = false; + } else if (sourceMappingActive) { + map.addMapping({ + source: original.source, + original: { + line: original.line, + column: original.column + }, + generated: { + line: generated.line, + column: generated.column + }, + name: original.name + }); + } + } else { + generated.column++; } - } - - function isDecimalDigit(ch) { - return (ch >= 48 && ch <= 57); // 0..9 - } + } + }); + this.walkSourceContents(function (sourceFile, sourceContent) { + map.setSourceContent(sourceFile, sourceContent); + }); - function isHexDigit(ch) { - return '0123456789abcdefABCDEF'.indexOf(ch) >= 0; - } + return { code: generated.code, map: map }; + }; - function isOctalDigit(ch) { - return '01234567'.indexOf(ch) >= 0; - } + exports.SourceNode = SourceNode; +}); - // 7.2 White Space +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-node.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"./source-map-generator":20,"./util":22,"amdefine":5,"buffer":3,"pBGvAp":29}],22:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = require('amdefine')(module, require); +} +define(function (require, exports, module) { - function isWhiteSpace(ch) { - return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || - (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0); + /** + * This is a helper function for getting values from parameter/options + * objects. + * + * @param args The object we are extracting values from + * @param name The name of the property we are getting. + * @param defaultValue An optional value to return if the property is missing + * from the object. If this is not specified and the property is missing, an + * error will be thrown. + */ + function getArg(aArgs, aName, aDefaultValue) { + if (aName in aArgs) { + return aArgs[aName]; + } else if (arguments.length === 3) { + return aDefaultValue; + } else { + throw new Error('"' + aName + '" is a required argument.'); } + } + exports.getArg = getArg; - // 7.3 Line Terminators + var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/; + var dataUrlRegexp = /^data:.+\,.+$/; - function isLineTerminator(ch) { - return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029); + function urlParse(aUrl) { + var match = aUrl.match(urlRegexp); + if (!match) { + return null; } + return { + scheme: match[1], + auth: match[2], + host: match[3], + port: match[4], + path: match[5] + }; + } + exports.urlParse = urlParse; - // 7.6 Identifier Names and Identifiers - - function isIdentifierStart(ch) { - return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) - (ch >= 0x41 && ch <= 0x5A) || // A..Z - (ch >= 0x61 && ch <= 0x7A) || // a..z - (ch === 0x5C) || // \ (backslash) - ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))); + function urlGenerate(aParsedUrl) { + var url = ''; + if (aParsedUrl.scheme) { + url += aParsedUrl.scheme + ':'; } - - function isIdentifierPart(ch) { - return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) - (ch >= 0x41 && ch <= 0x5A) || // A..Z - (ch >= 0x61 && ch <= 0x7A) || // a..z - (ch >= 0x30 && ch <= 0x39) || // 0..9 - (ch === 0x5C) || // \ (backslash) - ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))); + url += '//'; + if (aParsedUrl.auth) { + url += aParsedUrl.auth + '@'; } + if (aParsedUrl.host) { + url += aParsedUrl.host; + } + if (aParsedUrl.port) { + url += ":" + aParsedUrl.port + } + if (aParsedUrl.path) { + url += aParsedUrl.path; + } + return url; + } + exports.urlGenerate = urlGenerate; - // 7.6.1.2 Future Reserved Words - - function isFutureReservedWord(id) { - switch (id) { - case 'class': - case 'enum': - case 'export': - case 'extends': - case 'import': - case 'super': - return true; - default: - return false; - } + /** + * Normalizes a path, or the path portion of a URL: + * + * - Replaces consequtive slashes with one slash. + * - Removes unnecessary '.' parts. + * - Removes unnecessary '/..' parts. + * + * Based on code in the Node.js 'path' core module. + * + * @param aPath The path or url to normalize. + */ + function normalize(aPath) { + var path = aPath; + var url = urlParse(aPath); + if (url) { + if (!url.path) { + return aPath; + } + path = url.path; } + var isAbsolute = (path.charAt(0) === '/'); - function isStrictModeReservedWord(id) { - switch (id) { - case 'implements': - case 'interface': - case 'package': - case 'private': - case 'protected': - case 'public': - case 'static': - case 'yield': - case 'let': - return true; - default: - return false; + var parts = path.split(/\/+/); + for (var part, up = 0, i = parts.length - 1; i >= 0; i--) { + part = parts[i]; + if (part === '.') { + parts.splice(i, 1); + } else if (part === '..') { + up++; + } else if (up > 0) { + if (part === '') { + // The first part is blank if the path is absolute. Trying to go + // above the root is a no-op. Therefore we can remove all '..' parts + // directly after the root. + parts.splice(i + 1, up); + up = 0; + } else { + parts.splice(i, 2); + up--; } + } } + path = parts.join('/'); - function isRestrictedWord(id) { - return id === 'eval' || id === 'arguments'; + if (path === '') { + path = isAbsolute ? '/' : '.'; } - // 7.6.1.1 Keywords + if (url) { + url.path = path; + return urlGenerate(url); + } + return path; + } + exports.normalize = normalize; - function isKeyword(id) { - if (strict && isStrictModeReservedWord(id)) { - return true; - } + /** + * Joins two paths/URLs. + * + * @param aRoot The root path or URL. + * @param aPath The path or URL to be joined with the root. + * + * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a + * scheme-relative URL: Then the scheme of aRoot, if any, is prepended + * first. + * - Otherwise aPath is a path. If aRoot is a URL, then its path portion + * is updated with the result and aRoot is returned. Otherwise the result + * is returned. + * - If aPath is absolute, the result is aPath. + * - Otherwise the two paths are joined with a slash. + * - Joining for example 'http://' and 'www.example.com' is also supported. + */ + function join(aRoot, aPath) { + if (aRoot === "") { + aRoot = "."; + } + if (aPath === "") { + aPath = "."; + } + var aPathUrl = urlParse(aPath); + var aRootUrl = urlParse(aRoot); + if (aRootUrl) { + aRoot = aRootUrl.path || '/'; + } - // 'const' is specialized as Keyword in V8. - // 'yield' and 'let' are for compatiblity with SpiderMonkey and ES.next. - // Some others are from future reserved words. + // `join(foo, '//www.example.org')` + if (aPathUrl && !aPathUrl.scheme) { + if (aRootUrl) { + aPathUrl.scheme = aRootUrl.scheme; + } + return urlGenerate(aPathUrl); + } - switch (id.length) { - case 2: - return (id === 'if') || (id === 'in') || (id === 'do'); - case 3: - return (id === 'var') || (id === 'for') || (id === 'new') || - (id === 'try') || (id === 'let'); - case 4: - return (id === 'this') || (id === 'else') || (id === 'case') || - (id === 'void') || (id === 'with') || (id === 'enum'); - case 5: - return (id === 'while') || (id === 'break') || (id === 'catch') || - (id === 'throw') || (id === 'const') || (id === 'yield') || - (id === 'class') || (id === 'super'); - case 6: - return (id === 'return') || (id === 'typeof') || (id === 'delete') || - (id === 'switch') || (id === 'export') || (id === 'import'); - case 7: - return (id === 'default') || (id === 'finally') || (id === 'extends'); - case 8: - return (id === 'function') || (id === 'continue') || (id === 'debugger'); - case 10: - return (id === 'instanceof'); - default: - return false; - } + if (aPathUrl || aPath.match(dataUrlRegexp)) { + return aPath; } - // 7.4 Comments - - function addComment(type, value, start, end, loc) { - var comment, attacher; + // `join('http://', 'www.example.com')` + if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { + aRootUrl.host = aPath; + return urlGenerate(aRootUrl); + } - assert(typeof start === 'number', 'Comment must have valid position'); + var joined = aPath.charAt(0) === '/' + ? aPath + : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); - // Because the way the actual token is scanned, often the comments - // (if any) are skipped twice during the lexical analysis. - // Thus, we need to skip adding a comment if the comment array already - // handled it. - if (state.lastCommentStart >= start) { - return; - } - state.lastCommentStart = start; + if (aRootUrl) { + aRootUrl.path = joined; + return urlGenerate(aRootUrl); + } + return joined; + } + exports.join = join; - comment = { - type: type, - value: value - }; - if (extra.range) { - comment.range = [start, end]; - } - if (extra.loc) { - comment.loc = loc; - } - extra.comments.push(comment); - if (extra.attachComment) { - extra.leadingComments.push(comment); - extra.trailingComments.push(comment); - } + /** + * Make a path relative to a URL or another path. + * + * @param aRoot The root path or URL. + * @param aPath The path or URL to be made relative to aRoot. + */ + function relative(aRoot, aPath) { + if (aRoot === "") { + aRoot = "."; } - function skipSingleLineComment(offset) { - var start, loc, ch, comment; + aRoot = aRoot.replace(/\/$/, ''); - start = index - offset; - loc = { - start: { - line: lineNumber, - column: index - lineStart - offset - } - }; + // XXX: It is possible to remove this block, and the tests still pass! + var url = urlParse(aRoot); + if (aPath.charAt(0) == "/" && url && url.path == "/") { + return aPath.slice(1); + } - while (index < length) { - ch = source.charCodeAt(index); - ++index; - if (isLineTerminator(ch)) { - if (extra.comments) { - comment = source.slice(start + offset, index - 1); - loc.end = { - line: lineNumber, - column: index - lineStart - 1 - }; - addComment('Line', comment, start, index - 1, loc); - } - if (ch === 13 && source.charCodeAt(index) === 10) { - ++index; - } - ++lineNumber; - lineStart = index; - return; - } - } + return aPath.indexOf(aRoot + '/') === 0 + ? aPath.substr(aRoot.length + 1) + : aPath; + } + exports.relative = relative; - if (extra.comments) { - comment = source.slice(start + offset, index); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - addComment('Line', comment, start, index, loc); - } - } + /** + * Because behavior goes wacky when you set `__proto__` on objects, we + * have to prefix all the strings in our set with an arbitrary character. + * + * See https://github.com/mozilla/source-map/pull/31 and + * https://github.com/mozilla/source-map/issues/30 + * + * @param String aStr + */ + function toSetString(aStr) { + return '$' + aStr; + } + exports.toSetString = toSetString; - function skipMultiLineComment() { - var start, loc, ch, comment; + function fromSetString(aStr) { + return aStr.substr(1); + } + exports.fromSetString = fromSetString; - if (extra.comments) { - start = index - 2; - loc = { - start: { - line: lineNumber, - column: index - lineStart - 2 - } - }; - } + function strcmp(aStr1, aStr2) { + var s1 = aStr1 || ""; + var s2 = aStr2 || ""; + return (s1 > s2) - (s1 < s2); + } - while (index < length) { - ch = source.charCodeAt(index); - if (isLineTerminator(ch)) { - if (ch === 0x0D && source.charCodeAt(index + 1) === 0x0A) { - ++index; - } - ++lineNumber; - ++index; - lineStart = index; - if (index >= length) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - } else if (ch === 0x2A) { - // Block comment ends with '*/'. - if (source.charCodeAt(index + 1) === 0x2F) { - ++index; - ++index; - if (extra.comments) { - comment = source.slice(start + 2, index - 2); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - addComment('Block', comment, start, index, loc); - } - return; - } - ++index; - } else { - ++index; - } - } + /** + * Comparator between two mappings where the original positions are compared. + * + * Optionally pass in `true` as `onlyCompareGenerated` to consider two + * mappings with the same original source/line/column, but different generated + * line and column the same. Useful when searching for a mapping with a + * stubbed out mapping. + */ + function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { + var cmp; - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + cmp = strcmp(mappingA.source, mappingB.source); + if (cmp) { + return cmp; } - function skipComment() { - var ch, start; - - start = (index === 0); - while (index < length) { - ch = source.charCodeAt(index); + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp) { + return cmp; + } - if (isWhiteSpace(ch)) { - ++index; - } else if (isLineTerminator(ch)) { - ++index; - if (ch === 0x0D && source.charCodeAt(index) === 0x0A) { - ++index; - } - ++lineNumber; - lineStart = index; - start = true; - } else if (ch === 0x2F) { // U+002F is '/' - ch = source.charCodeAt(index + 1); - if (ch === 0x2F) { - ++index; - ++index; - skipSingleLineComment(2); - start = true; - } else if (ch === 0x2A) { // U+002A is '*' - ++index; - ++index; - skipMultiLineComment(); - } else { - break; - } - } else if (start && ch === 0x2D) { // U+002D is '-' - // U+003E is '>' - if ((source.charCodeAt(index + 1) === 0x2D) && (source.charCodeAt(index + 2) === 0x3E)) { - // '-->' is a single-line comment - index += 3; - skipSingleLineComment(3); - } else { - break; - } - } else if (ch === 0x3C) { // U+003C is '<' - if (source.slice(index + 1, index + 4) === '!--') { - ++index; // `<` - ++index; // `!` - ++index; // `-` - ++index; // `-` - skipSingleLineComment(4); - } else { - break; - } - } else { - break; - } - } + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp || onlyCompareOriginal) { + return cmp; } - function scanHexEscape(prefix) { - var i, len, ch, code = 0; + cmp = strcmp(mappingA.name, mappingB.name); + if (cmp) { + return cmp; + } - len = (prefix === 'u') ? 4 : 2; - for (i = 0; i < len; ++i) { - if (index < length && isHexDigit(source[index])) { - ch = source[index++]; - code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); - } else { - return ''; - } - } - return String.fromCharCode(code); + cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp) { + return cmp; } - function getEscapedIdentifier() { - var ch, id; + return mappingA.generatedColumn - mappingB.generatedColumn; + }; + exports.compareByOriginalPositions = compareByOriginalPositions; - ch = source.charCodeAt(index++); - id = String.fromCharCode(ch); + /** + * Comparator between two mappings where the generated positions are + * compared. + * + * Optionally pass in `true` as `onlyCompareGenerated` to consider two + * mappings with the same generated line and column, but different + * source/name/original line and column the same. Useful when searching for a + * mapping with a stubbed out mapping. + */ + function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) { + var cmp; - // '\u' (U+005C, U+0075) denotes an escaped character. - if (ch === 0x5C) { - if (source.charCodeAt(index) !== 0x75) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - ++index; - ch = scanHexEscape('u'); - if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - id = ch; - } + cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp) { + return cmp; + } - while (index < length) { - ch = source.charCodeAt(index); - if (!isIdentifierPart(ch)) { - break; - } - ++index; - id += String.fromCharCode(ch); + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp || onlyCompareGenerated) { + return cmp; + } - // '\u' (U+005C, U+0075) denotes an escaped character. - if (ch === 0x5C) { - id = id.substr(0, id.length - 1); - if (source.charCodeAt(index) !== 0x75) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - ++index; - ch = scanHexEscape('u'); - if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - id += ch; - } - } + cmp = strcmp(mappingA.source, mappingB.source); + if (cmp) { + return cmp; + } - return id; + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp) { + return cmp; } - function getIdentifier() { - var start, ch; + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp) { + return cmp; + } - start = index++; - while (index < length) { - ch = source.charCodeAt(index); - if (ch === 0x5C) { - // Blackslash (U+005C) marks Unicode escape sequence. - index = start; - return getEscapedIdentifier(); - } - if (isIdentifierPart(ch)) { - ++index; - } else { - break; - } - } + return strcmp(mappingA.name, mappingB.name); + }; + exports.compareByGeneratedPositions = compareByGeneratedPositions; - return source.slice(start, index); +}); + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/util.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map") +},{"amdefine":5,"buffer":3,"pBGvAp":29}],23:[function(require,module,exports){ +module.exports={ + "_args": [ + [ + "escodegen@>=1.4.1 <2.0.0", + "" + ], + [ + "escodegen@^1.4.1", + "/Users/nanki/work/javascript-operator-overloading/operator-overloading-js" + ] + ], + "_from": "escodegen@>=1.4.1 <2.0.0", + "_id": "escodegen@1.8.0", + "_inCache": true, + "_installable": true, + "_location": "/escodegen", + "_nodeVersion": "4.1.1", + "_npmUser": { + "email": "utatane.tea@gmail.com", + "name": "constellation" + }, + "_npmVersion": "2.14.4", + "_phantomChildren": {}, + "_requested": { + "name": "escodegen", + "raw": "escodegen@>=1.4.1 <2.0.0", + "rawSpec": ">=1.4.1 <2.0.0", + "scope": null, + "spec": ">=1.4.1 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "#USER" + ], + "_shrinkwrap": null, + "_spec": "escodegen@>=1.4.1 <2.0.0", + "_where": "", + "bin": { + "escodegen": "./bin/escodegen.js", + "esgenerate": "./bin/esgenerate.js" + }, + "bugs": { + "url": "https://github.com/estools/escodegen/issues" + }, + "dependencies": { + "esprima": "^2.7.1", + "estraverse": "^1.9.1", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.2.0" + }, + "description": "ECMAScript code generator", + "devDependencies": { + "acorn-6to5": "^0.11.1-25", + "bluebird": "^2.3.11", + "bower-registry-client": "^0.2.1", + "chai": "^1.10.0", + "commonjs-everywhere": "^0.9.7", + "gulp": "^3.8.10", + "gulp-eslint": "^0.2.0", + "gulp-mocha": "^2.0.0", + "semver": "^5.1.0" + }, + "directories": {}, + "dist": { + "shasum": "b246aae829ce73d59e2c55727359edd1c130a81b", + "tarball": "http://registry.npmjs.org/escodegen/-/escodegen-1.8.0.tgz" + }, + "engines": { + "node": ">=0.12.0" + }, + "files": [ + "LICENSE.BSD", + "LICENSE.source-map", + "README.md", + "bin", + "escodegen.js", + "package.json" + ], + "gitHead": "0e8280aa061a0dbefb32d277a05015baa7f3e7f2", + "homepage": "http://github.com/estools/escodegen", + "license": "BSD-2-Clause", + "main": "escodegen.js", + "maintainers": [ + { + "name": "constellation", + "email": "utatane.tea@gmail.com" + }, + { + "name": "michaelficarra", + "email": "npm@michael.ficarra.me" } + ], + "name": "escodegen", + "optionalDependencies": { + "source-map": "~0.2.0" + }, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/estools/escodegen.git" + }, + "scripts": { + "build": "cjsify -a path: tools/entry-point.js > escodegen.browser.js", + "build-min": "cjsify -ma path: tools/entry-point.js > escodegen.browser.min.js", + "lint": "gulp lint", + "release": "node tools/release.js", + "test": "gulp travis", + "unit-test": "gulp test" + }, + "version": "1.8.0" +} - function scanIdentifier() { - var start, id, type; +},{}],24:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* + Copyright (C) 2013 Ariya Hidayat + Copyright (C) 2013 Thaddee Tyl + Copyright (C) 2013 Mathias Bynens + Copyright (C) 2012 Ariya Hidayat + Copyright (C) 2012 Mathias Bynens + Copyright (C) 2012 Joost-Wim Boekesteijn + Copyright (C) 2012 Kris Kowal + Copyright (C) 2012 Yusuke Suzuki + Copyright (C) 2012 Arpad Borsos + Copyright (C) 2011 Ariya Hidayat - start = index; + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - // Backslash (U+005C) starts an escaped character. - id = (source.charCodeAt(index) === 0x5C) ? getEscapedIdentifier() : getIdentifier(); + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - // There is no keyword or literal with only one character. - // Thus, it must be an identifier. - if (id.length === 1) { - type = Token.Identifier; - } else if (isKeyword(id)) { - type = Token.Keyword; - } else if (id === 'null') { - type = Token.NullLiteral; - } else if (id === 'true' || id === 'false') { - type = Token.BooleanLiteral; - } else { - type = Token.Identifier; - } + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ - return { - type: type, - value: id, - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; - } +/*jslint bitwise:true plusplus:true */ +/*global esprima:true, define:true, exports:true, window: true, +throwErrorTolerant: true, +throwError: true, generateStatement: true, peek: true, +parseAssignmentExpression: true, parseBlock: true, parseExpression: true, +parseFunctionDeclaration: true, parseFunctionExpression: true, +parseFunctionSourceElements: true, parseVariableIdentifier: true, +parseLeftHandSideExpression: true, +parseUnaryExpression: true, +parseStatement: true, parseSourceElement: true */ + +(function (root, factory) { + 'use strict'; + // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, + // Rhino, and plain browser loading. - // 7.7 Punctuators + /* istanbul ignore next */ + if (typeof define === 'function' && define.amd) { + define(['exports'], factory); + } else if (typeof exports !== 'undefined') { + factory(exports); + } else { + factory((root.esprima = {})); + } +}(this, function (exports) { + 'use strict'; - function scanPunctuator() { - var start = index, - code = source.charCodeAt(index), - code2, - ch1 = source[index], - ch2, - ch3, - ch4; + var Token, + TokenName, + FnExprTokens, + Syntax, + PropertyKind, + Messages, + Regex, + SyntaxTreeDelegate, + source, + strict, + index, + lineNumber, + lineStart, + length, + delegate, + lookahead, + state, + extra; - switch (code) { + Token = { + BooleanLiteral: 1, + EOF: 2, + Identifier: 3, + Keyword: 4, + NullLiteral: 5, + NumericLiteral: 6, + Punctuator: 7, + StringLiteral: 8, + RegularExpression: 9 + }; - // Check for most common single-character punctuators. - case 0x2E: // . dot - case 0x28: // ( open bracket - case 0x29: // ) close bracket - case 0x3B: // ; semicolon - case 0x2C: // , comma - case 0x7B: // { open curly brace - case 0x7D: // } close curly brace - case 0x5B: // [ - case 0x5D: // ] - case 0x3A: // : - case 0x3F: // ? - case 0x7E: // ~ - ++index; - if (extra.tokenize) { - if (code === 0x28) { - extra.openParenToken = extra.tokens.length; - } else if (code === 0x7B) { - extra.openCurlyToken = extra.tokens.length; - } - } - return { - type: Token.Punctuator, - value: String.fromCharCode(code), - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; + TokenName = {}; + TokenName[Token.BooleanLiteral] = 'Boolean'; + TokenName[Token.EOF] = ''; + TokenName[Token.Identifier] = 'Identifier'; + TokenName[Token.Keyword] = 'Keyword'; + TokenName[Token.NullLiteral] = 'Null'; + TokenName[Token.NumericLiteral] = 'Numeric'; + TokenName[Token.Punctuator] = 'Punctuator'; + TokenName[Token.StringLiteral] = 'String'; + TokenName[Token.RegularExpression] = 'RegularExpression'; - default: - code2 = source.charCodeAt(index + 1); + // A function following one of those tokens is an expression. + FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new', + 'return', 'case', 'delete', 'throw', 'void', + // assignment operators + '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=', + '&=', '|=', '^=', ',', + // binary/unary operators + '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&', + '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=', + '<=', '<', '>', '!=', '!==']; - // '=' (U+003D) marks an assignment or comparison operator. - if (code2 === 0x3D) { - switch (code) { - case 0x2B: // + - case 0x2D: // - - case 0x2F: // / - case 0x3C: // < - case 0x3E: // > - case 0x5E: // ^ - case 0x7C: // | - case 0x25: // % - case 0x26: // & - case 0x2A: // * - index += 2; - return { - type: Token.Punctuator, - value: String.fromCharCode(code) + String.fromCharCode(code2), - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; + Syntax = { + AssignmentExpression: 'AssignmentExpression', + ArrayExpression: 'ArrayExpression', + BlockStatement: 'BlockStatement', + BinaryExpression: 'BinaryExpression', + BreakStatement: 'BreakStatement', + CallExpression: 'CallExpression', + CatchClause: 'CatchClause', + ConditionalExpression: 'ConditionalExpression', + ContinueStatement: 'ContinueStatement', + DoWhileStatement: 'DoWhileStatement', + DebuggerStatement: 'DebuggerStatement', + EmptyStatement: 'EmptyStatement', + ExpressionStatement: 'ExpressionStatement', + ForStatement: 'ForStatement', + ForInStatement: 'ForInStatement', + FunctionDeclaration: 'FunctionDeclaration', + FunctionExpression: 'FunctionExpression', + Identifier: 'Identifier', + IfStatement: 'IfStatement', + Literal: 'Literal', + LabeledStatement: 'LabeledStatement', + LogicalExpression: 'LogicalExpression', + MemberExpression: 'MemberExpression', + NewExpression: 'NewExpression', + ObjectExpression: 'ObjectExpression', + Program: 'Program', + Property: 'Property', + ReturnStatement: 'ReturnStatement', + SequenceExpression: 'SequenceExpression', + SwitchStatement: 'SwitchStatement', + SwitchCase: 'SwitchCase', + ThisExpression: 'ThisExpression', + ThrowStatement: 'ThrowStatement', + TryStatement: 'TryStatement', + UnaryExpression: 'UnaryExpression', + UpdateExpression: 'UpdateExpression', + VariableDeclaration: 'VariableDeclaration', + VariableDeclarator: 'VariableDeclarator', + WhileStatement: 'WhileStatement', + WithStatement: 'WithStatement' + }; - case 0x21: // ! - case 0x3D: // = - index += 2; + PropertyKind = { + Data: 1, + Get: 2, + Set: 4 + }; - // !== and === - if (source.charCodeAt(index) === 0x3D) { - ++index; - } - return { - type: Token.Punctuator, - value: source.slice(start, index), - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; - } - } - } + // Error messages should be identical to V8. + Messages = { + UnexpectedToken: 'Unexpected token %0', + UnexpectedNumber: 'Unexpected number', + UnexpectedString: 'Unexpected string', + UnexpectedIdentifier: 'Unexpected identifier', + UnexpectedReserved: 'Unexpected reserved word', + UnexpectedEOS: 'Unexpected end of input', + NewlineAfterThrow: 'Illegal newline after throw', + InvalidRegExp: 'Invalid regular expression', + UnterminatedRegExp: 'Invalid regular expression: missing /', + InvalidLHSInAssignment: 'Invalid left-hand side in assignment', + InvalidLHSInForIn: 'Invalid left-hand side in for-in', + MultipleDefaultsInSwitch: 'More than one default clause in switch statement', + NoCatchOrFinally: 'Missing catch or finally after try', + UnknownLabel: 'Undefined label \'%0\'', + Redeclaration: '%0 \'%1\' has already been declared', + IllegalContinue: 'Illegal continue statement', + IllegalBreak: 'Illegal break statement', + IllegalReturn: 'Illegal return statement', + StrictModeWith: 'Strict mode code may not include a with statement', + StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', + StrictVarName: 'Variable name may not be eval or arguments in strict mode', + StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', + StrictParamDupe: 'Strict mode function may not have duplicate parameter names', + StrictFunctionName: 'Function name may not be eval or arguments in strict mode', + StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', + StrictDelete: 'Delete of an unqualified identifier in strict mode.', + StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode', + AccessorDataProperty: 'Object literal may not have data and accessor property with the same name', + AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name', + StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', + StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', + StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', + StrictReservedWord: 'Use of future reserved word in strict mode' + }; - // 4-character punctuator: >>>= + // See also tools/generate-unicode-regex.py. + Regex = { + NonAsciiIdentifierStart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]'), + NonAsciiIdentifierPart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]') + }; - ch4 = source.substr(index, 4); + // Ensure the condition is true, otherwise throw an error. + // This is only to have a better contract semantic, i.e. another safety net + // to catch a logic error. The condition shall be fulfilled in normal case. + // Do NOT use this to enforce a certain condition on any user input. - if (ch4 === '>>>=') { - index += 4; - return { - type: Token.Punctuator, - value: ch4, - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; + function assert(condition, message) { + /* istanbul ignore if */ + if (!condition) { + throw new Error('ASSERT: ' + message); } + } - // 3-character punctuators: === !== >>> <<= >>= + function isDecimalDigit(ch) { + return (ch >= 48 && ch <= 57); // 0..9 + } - ch3 = ch4.substr(0, 3); + function isHexDigit(ch) { + return '0123456789abcdefABCDEF'.indexOf(ch) >= 0; + } - if (ch3 === '>>>' || ch3 === '<<=' || ch3 === '>>=') { - index += 3; - return { - type: Token.Punctuator, - value: ch3, - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; - } + function isOctalDigit(ch) { + return '01234567'.indexOf(ch) >= 0; + } - // Other 2-character punctuators: ++ -- << >> && || - ch2 = ch3.substr(0, 2); - if ((ch1 === ch2[1] && ('+-<>&|'.indexOf(ch1) >= 0)) || ch2 === '=>') { - index += 2; - return { - type: Token.Punctuator, - value: ch2, - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; - } + // 7.2 White Space - // 1-character punctuators: < > = ! + - * % & | ^ / - if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) { - ++index; - return { - type: Token.Punctuator, - value: ch1, - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; - } + function isWhiteSpace(ch) { + return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || + (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0); + } - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + // 7.3 Line Terminators + + function isLineTerminator(ch) { + return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029); } - // 7.8.3 Numeric Literals + // 7.6 Identifier Names and Identifiers - function scanHexLiteral(start) { - var number = ''; + function isIdentifierStart(ch) { + return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) + (ch >= 0x41 && ch <= 0x5A) || // A..Z + (ch >= 0x61 && ch <= 0x7A) || // a..z + (ch === 0x5C) || // \ (backslash) + ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))); + } - while (index < length) { - if (!isHexDigit(source[index])) { - break; - } - number += source[index++]; - } + function isIdentifierPart(ch) { + return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) + (ch >= 0x41 && ch <= 0x5A) || // A..Z + (ch >= 0x61 && ch <= 0x7A) || // a..z + (ch >= 0x30 && ch <= 0x39) || // 0..9 + (ch === 0x5C) || // \ (backslash) + ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))); + } - if (number.length === 0) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + // 7.6.1.2 Future Reserved Words + + function isFutureReservedWord(id) { + switch (id) { + case 'class': + case 'enum': + case 'export': + case 'extends': + case 'import': + case 'super': + return true; + default: + return false; } + } - if (isIdentifierStart(source.charCodeAt(index))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + function isStrictModeReservedWord(id) { + switch (id) { + case 'implements': + case 'interface': + case 'package': + case 'private': + case 'protected': + case 'public': + case 'static': + case 'yield': + case 'let': + return true; + default: + return false; } + } - return { - type: Token.NumericLiteral, - value: parseInt('0x' + number, 16), - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; + function isRestrictedWord(id) { + return id === 'eval' || id === 'arguments'; } - function scanOctalLiteral(start) { - var number = '0' + source[index++]; - while (index < length) { - if (!isOctalDigit(source[index])) { - break; - } - number += source[index++]; - } + // 7.6.1.1 Keywords - if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + function isKeyword(id) { + if (strict && isStrictModeReservedWord(id)) { + return true; } - return { - type: Token.NumericLiteral, - value: parseInt(number, 8), - octal: true, - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; + // 'const' is specialized as Keyword in V8. + // 'yield' and 'let' are for compatiblity with SpiderMonkey and ES.next. + // Some others are from future reserved words. + + switch (id.length) { + case 2: + return (id === 'if') || (id === 'in') || (id === 'do'); + case 3: + return (id === 'var') || (id === 'for') || (id === 'new') || + (id === 'try') || (id === 'let'); + case 4: + return (id === 'this') || (id === 'else') || (id === 'case') || + (id === 'void') || (id === 'with') || (id === 'enum'); + case 5: + return (id === 'while') || (id === 'break') || (id === 'catch') || + (id === 'throw') || (id === 'const') || (id === 'yield') || + (id === 'class') || (id === 'super'); + case 6: + return (id === 'return') || (id === 'typeof') || (id === 'delete') || + (id === 'switch') || (id === 'export') || (id === 'import'); + case 7: + return (id === 'default') || (id === 'finally') || (id === 'extends'); + case 8: + return (id === 'function') || (id === 'continue') || (id === 'debugger'); + case 10: + return (id === 'instanceof'); + default: + return false; + } } - function isImplicitOctalLiteral() { - var i, ch; + // 7.4 Comments - // Implicit octal, unless there is a non-octal digit. - // (Annex B.1.1 on Numeric Literals) - for (i = index + 1; i < length; ++i) { - ch = source[i]; - if (ch === '8' || ch === '9') { - return false; - } - if (!isOctalDigit(ch)) { - return true; - } + function addComment(type, value, start, end, loc) { + var comment, attacher; + + assert(typeof start === 'number', 'Comment must have valid position'); + + // Because the way the actual token is scanned, often the comments + // (if any) are skipped twice during the lexical analysis. + // Thus, we need to skip adding a comment if the comment array already + // handled it. + if (state.lastCommentStart >= start) { + return; } + state.lastCommentStart = start; - return true; + comment = { + type: type, + value: value + }; + if (extra.range) { + comment.range = [start, end]; + } + if (extra.loc) { + comment.loc = loc; + } + extra.comments.push(comment); + if (extra.attachComment) { + extra.leadingComments.push(comment); + extra.trailingComments.push(comment); + } } - function scanNumericLiteral() { - var number, start, ch; - - ch = source[index]; - assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), - 'Numeric literal must start with a decimal digit or a decimal point'); + function skipSingleLineComment(offset) { + var start, loc, ch, comment; - start = index; - number = ''; - if (ch !== '.') { - number = source[index++]; - ch = source[index]; + start = index - offset; + loc = { + start: { + line: lineNumber, + column: index - lineStart - offset + } + }; - // Hex number starts with '0x'. - // Octal number starts with '0'. - if (number === '0') { - if (ch === 'x' || ch === 'X') { - ++index; - return scanHexLiteral(start); + while (index < length) { + ch = source.charCodeAt(index); + ++index; + if (isLineTerminator(ch)) { + if (extra.comments) { + comment = source.slice(start + offset, index - 1); + loc.end = { + line: lineNumber, + column: index - lineStart - 1 + }; + addComment('Line', comment, start, index - 1, loc); } - if (isOctalDigit(ch)) { - if (isImplicitOctalLiteral()) { - return scanOctalLiteral(start); - } + if (ch === 13 && source.charCodeAt(index) === 10) { + ++index; } + ++lineNumber; + lineStart = index; + return; } + } - while (isDecimalDigit(source.charCodeAt(index))) { - number += source[index++]; - } - ch = source[index]; + if (extra.comments) { + comment = source.slice(start + offset, index); + loc.end = { + line: lineNumber, + column: index - lineStart + }; + addComment('Line', comment, start, index, loc); } + } - if (ch === '.') { - number += source[index++]; - while (isDecimalDigit(source.charCodeAt(index))) { - number += source[index++]; - } - ch = source[index]; + function skipMultiLineComment() { + var start, loc, ch, comment; + + if (extra.comments) { + start = index - 2; + loc = { + start: { + line: lineNumber, + column: index - lineStart - 2 + } + }; } - if (ch === 'e' || ch === 'E') { - number += source[index++]; - - ch = source[index]; - if (ch === '+' || ch === '-') { - number += source[index++]; - } - if (isDecimalDigit(source.charCodeAt(index))) { - while (isDecimalDigit(source.charCodeAt(index))) { - number += source[index++]; + while (index < length) { + ch = source.charCodeAt(index); + if (isLineTerminator(ch)) { + if (ch === 0x0D && source.charCodeAt(index + 1) === 0x0A) { + ++index; + } + ++lineNumber; + ++index; + lineStart = index; + if (index >= length) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + } else if (ch === 0x2A) { + // Block comment ends with '*/'. + if (source.charCodeAt(index + 1) === 0x2F) { + ++index; + ++index; + if (extra.comments) { + comment = source.slice(start + 2, index - 2); + loc.end = { + line: lineNumber, + column: index - lineStart + }; + addComment('Block', comment, start, index, loc); + } + return; } + ++index; } else { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + ++index; } } - if (isIdentifierStart(source.charCodeAt(index))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - return { - type: Token.NumericLiteral, - value: parseFloat(number), - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); } - // 7.8.4 String Literals - - function scanStringLiteral() { - var str = '', quote, start, ch, code, unescaped, restore, octal = false, startLineNumber, startLineStart; - startLineNumber = lineNumber; - startLineStart = lineStart; - - quote = source[index]; - assert((quote === '\'' || quote === '"'), - 'String literal must starts with a quote'); - - start = index; - ++index; + function skipComment() { + var ch, start; + start = (index === 0); while (index < length) { - ch = source[index++]; - - if (ch === quote) { - quote = ''; - break; - } else if (ch === '\\') { - ch = source[index++]; - if (!ch || !isLineTerminator(ch.charCodeAt(0))) { - switch (ch) { - case 'u': - case 'x': - restore = index; - unescaped = scanHexEscape(ch); - if (unescaped) { - str += unescaped; - } else { - index = restore; - str += ch; - } - break; - case 'n': - str += '\n'; - break; - case 'r': - str += '\r'; - break; - case 't': - str += '\t'; - break; - case 'b': - str += '\b'; - break; - case 'f': - str += '\f'; - break; - case 'v': - str += '\x0B'; - break; - - default: - if (isOctalDigit(ch)) { - code = '01234567'.indexOf(ch); - - // \0 is not octal escape sequence - if (code !== 0) { - octal = true; - } - - if (index < length && isOctalDigit(source[index])) { - octal = true; - code = code * 8 + '01234567'.indexOf(source[index++]); + ch = source.charCodeAt(index); - // 3 digits are only allowed when string starts - // with 0, 1, 2, 3 - if ('0123'.indexOf(ch) >= 0 && - index < length && - isOctalDigit(source[index])) { - code = code * 8 + '01234567'.indexOf(source[index++]); - } - } - str += String.fromCharCode(code); - } else { - str += ch; - } - break; - } + if (isWhiteSpace(ch)) { + ++index; + } else if (isLineTerminator(ch)) { + ++index; + if (ch === 0x0D && source.charCodeAt(index) === 0x0A) { + ++index; + } + ++lineNumber; + lineStart = index; + start = true; + } else if (ch === 0x2F) { // U+002F is '/' + ch = source.charCodeAt(index + 1); + if (ch === 0x2F) { + ++index; + ++index; + skipSingleLineComment(2); + start = true; + } else if (ch === 0x2A) { // U+002A is '*' + ++index; + ++index; + skipMultiLineComment(); } else { - ++lineNumber; - if (ch === '\r' && source[index] === '\n') { - ++index; - } - lineStart = index; + break; + } + } else if (start && ch === 0x2D) { // U+002D is '-' + // U+003E is '>' + if ((source.charCodeAt(index + 1) === 0x2D) && (source.charCodeAt(index + 2) === 0x3E)) { + // '-->' is a single-line comment + index += 3; + skipSingleLineComment(3); + } else { + break; + } + } else if (ch === 0x3C) { // U+003C is '<' + if (source.slice(index + 1, index + 4) === '!--') { + ++index; // `<` + ++index; // `!` + ++index; // `-` + ++index; // `-` + skipSingleLineComment(4); + } else { + break; } - } else if (isLineTerminator(ch.charCodeAt(0))) { - break; } else { - str += ch; + break; } } - - if (quote !== '') { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - return { - type: Token.StringLiteral, - value: str, - octal: octal, - startLineNumber: startLineNumber, - startLineStart: startLineStart, - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; } - function testRegExp(pattern, flags) { - var value; - try { - value = new RegExp(pattern, flags); - } catch (e) { - throwError({}, Messages.InvalidRegExp); + function scanHexEscape(prefix) { + var i, len, ch, code = 0; + + len = (prefix === 'u') ? 4 : 2; + for (i = 0; i < len; ++i) { + if (index < length && isHexDigit(source[index])) { + ch = source[index++]; + code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); + } else { + return ''; + } } - return value; + return String.fromCharCode(code); } - function scanRegExpBody() { - var ch, str, classMarker, terminated, body; + function getEscapedIdentifier() { + var ch, id; - ch = source[index]; - assert(ch === '/', 'Regular expression literal must start with a slash'); - str = source[index++]; + ch = source.charCodeAt(index++); + id = String.fromCharCode(ch); - classMarker = false; - terminated = false; - while (index < length) { - ch = source[index++]; - str += ch; - if (ch === '\\') { - ch = source[index++]; - // ECMA-262 7.8.5 - if (isLineTerminator(ch.charCodeAt(0))) { - throwError({}, Messages.UnterminatedRegExp); - } - str += ch; - } else if (isLineTerminator(ch.charCodeAt(0))) { - throwError({}, Messages.UnterminatedRegExp); - } else if (classMarker) { - if (ch === ']') { - classMarker = false; - } - } else { - if (ch === '/') { - terminated = true; - break; - } else if (ch === '[') { - classMarker = true; - } + // '\u' (U+005C, U+0075) denotes an escaped character. + if (ch === 0x5C) { + if (source.charCodeAt(index) !== 0x75) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + ++index; + ch = scanHexEscape('u'); + if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); } + id = ch; } - if (!terminated) { - throwError({}, Messages.UnterminatedRegExp); + while (index < length) { + ch = source.charCodeAt(index); + if (!isIdentifierPart(ch)) { + break; + } + ++index; + id += String.fromCharCode(ch); + + // '\u' (U+005C, U+0075) denotes an escaped character. + if (ch === 0x5C) { + id = id.substr(0, id.length - 1); + if (source.charCodeAt(index) !== 0x75) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + ++index; + ch = scanHexEscape('u'); + if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + id += ch; + } } - // Exclude leading and trailing slash. - body = str.substr(1, str.length - 2); - return { - value: body, - literal: str - }; + return id; } - function scanRegExpFlags() { - var ch, str, flags, restore; + function getIdentifier() { + var start, ch; - str = ''; - flags = ''; + start = index++; while (index < length) { - ch = source[index]; - if (!isIdentifierPart(ch.charCodeAt(0))) { - break; + ch = source.charCodeAt(index); + if (ch === 0x5C) { + // Blackslash (U+005C) marks Unicode escape sequence. + index = start; + return getEscapedIdentifier(); } - - ++index; - if (ch === '\\' && index < length) { - ch = source[index]; - if (ch === 'u') { - ++index; - restore = index; - ch = scanHexEscape('u'); - if (ch) { - flags += ch; - for (str += '\\u'; restore < index; ++restore) { - str += source[restore]; - } - } else { - index = restore; - flags += 'u'; - str += '\\u'; - } - throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL'); - } else { - str += '\\'; - throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL'); - } + if (isIdentifierPart(ch)) { + ++index; } else { - flags += ch; - str += ch; + break; } } - return { - value: flags, - literal: str - }; + return source.slice(start, index); } - function scanRegExp() { - var start, body, flags, pattern, value; + function scanIdentifier() { + var start, id, type; - lookahead = null; - skipComment(); start = index; - body = scanRegExpBody(); - flags = scanRegExpFlags(); - value = testRegExp(body.value, flags.value); + // Backslash (U+005C) starts an escaped character. + id = (source.charCodeAt(index) === 0x5C) ? getEscapedIdentifier() : getIdentifier(); - if (extra.tokenize) { - return { - type: Token.RegularExpression, - value: value, - lineNumber: lineNumber, - lineStart: lineStart, - start: start, - end: index - }; + // There is no keyword or literal with only one character. + // Thus, it must be an identifier. + if (id.length === 1) { + type = Token.Identifier; + } else if (isKeyword(id)) { + type = Token.Keyword; + } else if (id === 'null') { + type = Token.NullLiteral; + } else if (id === 'true' || id === 'false') { + type = Token.BooleanLiteral; + } else { + type = Token.Identifier; } return { - literal: body.literal + flags.literal, - value: value, + type: type, + value: id, + lineNumber: lineNumber, + lineStart: lineStart, start: start, end: index }; } - function collectRegex() { - var pos, loc, regex, token; - skipComment(); + // 7.7 Punctuators - pos = index; - loc = { - start: { - line: lineNumber, - column: index - lineStart - } - }; + function scanPunctuator() { + var start = index, + code = source.charCodeAt(index), + code2, + ch1 = source[index], + ch2, + ch3, + ch4; - regex = scanRegExp(); - loc.end = { - line: lineNumber, - column: index - lineStart - }; + switch (code) { - /* istanbul ignore next */ - if (!extra.tokenize) { - // Pop the previous token, which is likely '/' or '/=' - if (extra.tokens.length > 0) { - token = extra.tokens[extra.tokens.length - 1]; - if (token.range[0] === pos && token.type === 'Punctuator') { - if (token.value === '/' || token.value === '/=') { - extra.tokens.pop(); - } + // Check for most common single-character punctuators. + case 0x2E: // . dot + case 0x28: // ( open bracket + case 0x29: // ) close bracket + case 0x3B: // ; semicolon + case 0x2C: // , comma + case 0x7B: // { open curly brace + case 0x7D: // } close curly brace + case 0x5B: // [ + case 0x5D: // ] + case 0x3A: // : + case 0x3F: // ? + case 0x7E: // ~ + ++index; + if (extra.tokenize) { + if (code === 0x28) { + extra.openParenToken = extra.tokens.length; + } else if (code === 0x7B) { + extra.openCurlyToken = extra.tokens.length; } } + return { + type: Token.Punctuator, + value: String.fromCharCode(code), + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index + }; - extra.tokens.push({ - type: 'RegularExpression', - value: regex.literal, - range: [pos, index], - loc: loc - }); - } - - return regex; - } - - function isIdentifierName(token) { - return token.type === Token.Identifier || - token.type === Token.Keyword || - token.type === Token.BooleanLiteral || - token.type === Token.NullLiteral; - } + default: + code2 = source.charCodeAt(index + 1); - function advanceSlash() { - var prevToken, - checkToken; - // Using the following algorithm: - // https://github.com/mozilla/sweet.js/wiki/design - prevToken = extra.tokens[extra.tokens.length - 1]; - if (!prevToken) { - // Nothing before that: it cannot be a division. - return collectRegex(); - } - if (prevToken.type === 'Punctuator') { - if (prevToken.value === ']') { - return scanPunctuator(); - } - if (prevToken.value === ')') { - checkToken = extra.tokens[extra.openParenToken - 1]; - if (checkToken && - checkToken.type === 'Keyword' && - (checkToken.value === 'if' || - checkToken.value === 'while' || - checkToken.value === 'for' || - checkToken.value === 'with')) { - return collectRegex(); - } - return scanPunctuator(); - } - if (prevToken.value === '}') { - // Dividing a function by anything makes little sense, - // but we have to check for that. - if (extra.tokens[extra.openCurlyToken - 3] && - extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') { - // Anonymous function. - checkToken = extra.tokens[extra.openCurlyToken - 4]; - if (!checkToken) { - return scanPunctuator(); - } - } else if (extra.tokens[extra.openCurlyToken - 4] && - extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') { - // Named function. - checkToken = extra.tokens[extra.openCurlyToken - 5]; - if (!checkToken) { - return collectRegex(); + // '=' (U+003D) marks an assignment or comparison operator. + if (code2 === 0x3D) { + switch (code) { + case 0x2B: // + + case 0x2D: // - + case 0x2F: // / + case 0x3C: // < + case 0x3E: // > + case 0x5E: // ^ + case 0x7C: // | + case 0x25: // % + case 0x26: // & + case 0x2A: // * + index += 2; + return { + type: Token.Punctuator, + value: String.fromCharCode(code) + String.fromCharCode(code2), + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index + }; + + case 0x21: // ! + case 0x3D: // = + index += 2; + + // !== and === + if (source.charCodeAt(index) === 0x3D) { + ++index; } - } else { - return scanPunctuator(); - } - // checkToken determines whether the function is - // a declaration or an expression. - if (FnExprTokens.indexOf(checkToken.value) >= 0) { - // It is an expression. - return scanPunctuator(); + return { + type: Token.Punctuator, + value: source.slice(start, index), + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index + }; } - // It is a declaration. - return collectRegex(); } - return collectRegex(); } - if (prevToken.type === 'Keyword' && prevToken.value !== 'this') { - return collectRegex(); - } - return scanPunctuator(); - } - function advance() { - var ch; + // 4-character punctuator: >>>= - skipComment(); + ch4 = source.substr(index, 4); - if (index >= length) { + if (ch4 === '>>>=') { + index += 4; return { - type: Token.EOF, + type: Token.Punctuator, + value: ch4, lineNumber: lineNumber, lineStart: lineStart, - start: index, + start: start, end: index }; } - ch = source.charCodeAt(index); - - if (isIdentifierStart(ch)) { - return scanIdentifier(); - } - - // Very common: ( and ) and ; - if (ch === 0x28 || ch === 0x29 || ch === 0x3B) { - return scanPunctuator(); - } - - // String literal starts with single quote (U+0027) or double quote (U+0022). - if (ch === 0x27 || ch === 0x22) { - return scanStringLiteral(); - } + // 3-character punctuators: === !== >>> <<= >>= + ch3 = ch4.substr(0, 3); - // Dot (.) U+002E can also start a floating-point number, hence the need - // to check the next character. - if (ch === 0x2E) { - if (isDecimalDigit(source.charCodeAt(index + 1))) { - return scanNumericLiteral(); - } - return scanPunctuator(); + if (ch3 === '>>>' || ch3 === '<<=' || ch3 === '>>=') { + index += 3; + return { + type: Token.Punctuator, + value: ch3, + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index + }; } - if (isDecimalDigit(ch)) { - return scanNumericLiteral(); - } + // Other 2-character punctuators: ++ -- << >> && || + ch2 = ch3.substr(0, 2); - // Slash (/) U+002F can also start a regex. - if (extra.tokenize && ch === 0x2F) { - return advanceSlash(); + if ((ch1 === ch2[1] && ('+-<>&|'.indexOf(ch1) >= 0)) || ch2 === '=>') { + index += 2; + return { + type: Token.Punctuator, + value: ch2, + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index + }; } - return scanPunctuator(); - } - - function collectToken() { - var loc, token, range, value; - - skipComment(); - loc = { - start: { - line: lineNumber, - column: index - lineStart - } - }; - - token = advance(); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - - if (token.type !== Token.EOF) { - value = source.slice(token.start, token.end); - extra.tokens.push({ - type: TokenName[token.type], - value: value, - range: [token.start, token.end], - loc: loc - }); + // 1-character punctuators: < > = ! + - * % & | ^ / + if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) { + ++index; + return { + type: Token.Punctuator, + value: ch1, + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index + }; } - return token; - } - - function lex() { - var token; - - token = lookahead; - index = token.end; - lineNumber = token.lineNumber; - lineStart = token.lineStart; - - lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); - - index = token.end; - lineNumber = token.lineNumber; - lineStart = token.lineStart; - - return token; - } - - function peek() { - var pos, line, start; - - pos = index; - line = lineNumber; - start = lineStart; - lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); - index = pos; - lineNumber = line; - lineStart = start; - } - - function Position(line, column) { - this.line = line; - this.column = column; - } - - function SourceLocation(startLine, startColumn, line, column) { - this.start = new Position(startLine, startColumn); - this.end = new Position(line, column); + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); } - SyntaxTreeDelegate = { - - name: 'SyntaxTree', - - processComment: function (node) { - var lastChild, trailingComments; - - if (node.type === Syntax.Program) { - if (node.body.length > 0) { - return; - } - } - - if (extra.trailingComments.length > 0) { - if (extra.trailingComments[0].range[0] >= node.range[1]) { - trailingComments = extra.trailingComments; - extra.trailingComments = []; - } else { - extra.trailingComments.length = 0; - } - } else { - if (extra.bottomRightStack.length > 0 && - extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments && - extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments[0].range[0] >= node.range[1]) { - trailingComments = extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments; - delete extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments; - } - } - - // Eating the stack. - while (extra.bottomRightStack.length > 0 && extra.bottomRightStack[extra.bottomRightStack.length - 1].range[0] >= node.range[0]) { - lastChild = extra.bottomRightStack.pop(); - } - - if (lastChild) { - if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) { - node.leadingComments = lastChild.leadingComments; - delete lastChild.leadingComments; - } - } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) { - node.leadingComments = extra.leadingComments; - extra.leadingComments = []; - } - - - if (trailingComments) { - node.trailingComments = trailingComments; - } + // 7.8.3 Numeric Literals - extra.bottomRightStack.push(node); - }, + function scanHexLiteral(start) { + var number = ''; - markEnd: function (node, startToken) { - if (extra.range) { - node.range = [startToken.start, index]; - } - if (extra.loc) { - node.loc = new SourceLocation( - startToken.startLineNumber === undefined ? startToken.lineNumber : startToken.startLineNumber, - startToken.start - (startToken.startLineStart === undefined ? startToken.lineStart : startToken.startLineStart), - lineNumber, - index - lineStart - ); - this.postProcess(node); + while (index < length) { + if (!isHexDigit(source[index])) { + break; } + number += source[index++]; + } - if (extra.attachComment) { - this.processComment(node); - } - return node; - }, + if (number.length === 0) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } - postProcess: function (node) { - if (extra.source) { - node.loc.source = extra.source; - } - return node; - }, + if (isIdentifierStart(source.charCodeAt(index))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } - createArrayExpression: function (elements) { - return { - type: Syntax.ArrayExpression, - elements: elements - }; - }, + return { + type: Token.NumericLiteral, + value: parseInt('0x' + number, 16), + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index + }; + } - createAssignmentExpression: function (operator, left, right) { - return { - type: Syntax.AssignmentExpression, - operator: operator, - left: left, - right: right - }; - }, + function scanOctalLiteral(start) { + var number = '0' + source[index++]; + while (index < length) { + if (!isOctalDigit(source[index])) { + break; + } + number += source[index++]; + } - createBinaryExpression: function (operator, left, right) { - var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : - Syntax.BinaryExpression; - return { - type: type, - operator: operator, - left: left, - right: right - }; - }, + if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } - createBlockStatement: function (body) { - return { - type: Syntax.BlockStatement, - body: body - }; - }, + return { + type: Token.NumericLiteral, + value: parseInt(number, 8), + octal: true, + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index + }; + } - createBreakStatement: function (label) { - return { - type: Syntax.BreakStatement, - label: label - }; - }, + function isImplicitOctalLiteral() { + var i, ch; - createCallExpression: function (callee, args) { - return { - type: Syntax.CallExpression, - callee: callee, - 'arguments': args - }; - }, + // Implicit octal, unless there is a non-octal digit. + // (Annex B.1.1 on Numeric Literals) + for (i = index + 1; i < length; ++i) { + ch = source[i]; + if (ch === '8' || ch === '9') { + return false; + } + if (!isOctalDigit(ch)) { + return true; + } + } - createCatchClause: function (param, body) { - return { - type: Syntax.CatchClause, - param: param, - body: body - }; - }, + return true; + } - createConditionalExpression: function (test, consequent, alternate) { - return { - type: Syntax.ConditionalExpression, - test: test, - consequent: consequent, - alternate: alternate - }; - }, + function scanNumericLiteral() { + var number, start, ch; - createContinueStatement: function (label) { - return { - type: Syntax.ContinueStatement, - label: label - }; - }, + ch = source[index]; + assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), + 'Numeric literal must start with a decimal digit or a decimal point'); - createDebuggerStatement: function () { - return { - type: Syntax.DebuggerStatement - }; - }, + start = index; + number = ''; + if (ch !== '.') { + number = source[index++]; + ch = source[index]; - createDoWhileStatement: function (body, test) { - return { - type: Syntax.DoWhileStatement, - body: body, - test: test - }; - }, + // Hex number starts with '0x'. + // Octal number starts with '0'. + if (number === '0') { + if (ch === 'x' || ch === 'X') { + ++index; + return scanHexLiteral(start); + } + if (isOctalDigit(ch)) { + if (isImplicitOctalLiteral()) { + return scanOctalLiteral(start); + } + } + } - createEmptyStatement: function () { - return { - type: Syntax.EmptyStatement - }; - }, + while (isDecimalDigit(source.charCodeAt(index))) { + number += source[index++]; + } + ch = source[index]; + } - createExpressionStatement: function (expression) { - return { - type: Syntax.ExpressionStatement, - expression: expression - }; - }, + if (ch === '.') { + number += source[index++]; + while (isDecimalDigit(source.charCodeAt(index))) { + number += source[index++]; + } + ch = source[index]; + } - createForStatement: function (init, test, update, body) { - return { - type: Syntax.ForStatement, - init: init, - test: test, - update: update, - body: body - }; - }, + if (ch === 'e' || ch === 'E') { + number += source[index++]; - createForInStatement: function (left, right, body) { - return { - type: Syntax.ForInStatement, - left: left, - right: right, - body: body, - each: false - }; - }, + ch = source[index]; + if (ch === '+' || ch === '-') { + number += source[index++]; + } + if (isDecimalDigit(source.charCodeAt(index))) { + while (isDecimalDigit(source.charCodeAt(index))) { + number += source[index++]; + } + } else { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + } - createFunctionDeclaration: function (id, params, defaults, body) { - return { - type: Syntax.FunctionDeclaration, - id: id, - params: params, - defaults: defaults, - body: body, - rest: null, - generator: false, - expression: false - }; - }, + if (isIdentifierStart(source.charCodeAt(index))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } - createFunctionExpression: function (id, params, defaults, body) { - return { - type: Syntax.FunctionExpression, - id: id, - params: params, - defaults: defaults, - body: body, - rest: null, - generator: false, - expression: false - }; - }, + return { + type: Token.NumericLiteral, + value: parseFloat(number), + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index + }; + } - createIdentifier: function (name) { - return { - type: Syntax.Identifier, - name: name - }; - }, + // 7.8.4 String Literals - createIfStatement: function (test, consequent, alternate) { - return { - type: Syntax.IfStatement, - test: test, - consequent: consequent, - alternate: alternate - }; - }, + function scanStringLiteral() { + var str = '', quote, start, ch, code, unescaped, restore, octal = false, startLineNumber, startLineStart; + startLineNumber = lineNumber; + startLineStart = lineStart; - createLabeledStatement: function (label, body) { - return { - type: Syntax.LabeledStatement, - label: label, - body: body - }; - }, + quote = source[index]; + assert((quote === '\'' || quote === '"'), + 'String literal must starts with a quote'); - createLiteral: function (token) { - return { - type: Syntax.Literal, - value: token.value, - raw: source.slice(token.start, token.end) - }; - }, + start = index; + ++index; - createMemberExpression: function (accessor, object, property) { - return { - type: Syntax.MemberExpression, - computed: accessor === '[', - object: object, - property: property - }; - }, + while (index < length) { + ch = source[index++]; - createNewExpression: function (callee, args) { - return { - type: Syntax.NewExpression, - callee: callee, - 'arguments': args - }; - }, + if (ch === quote) { + quote = ''; + break; + } else if (ch === '\\') { + ch = source[index++]; + if (!ch || !isLineTerminator(ch.charCodeAt(0))) { + switch (ch) { + case 'u': + case 'x': + restore = index; + unescaped = scanHexEscape(ch); + if (unescaped) { + str += unescaped; + } else { + index = restore; + str += ch; + } + break; + case 'n': + str += '\n'; + break; + case 'r': + str += '\r'; + break; + case 't': + str += '\t'; + break; + case 'b': + str += '\b'; + break; + case 'f': + str += '\f'; + break; + case 'v': + str += '\x0B'; + break; - createObjectExpression: function (properties) { - return { - type: Syntax.ObjectExpression, - properties: properties - }; - }, + default: + if (isOctalDigit(ch)) { + code = '01234567'.indexOf(ch); - createPostfixExpression: function (operator, argument) { - return { - type: Syntax.UpdateExpression, - operator: operator, - argument: argument, - prefix: false - }; - }, + // \0 is not octal escape sequence + if (code !== 0) { + octal = true; + } - createProgram: function (body) { - return { - type: Syntax.Program, - body: body - }; - }, + if (index < length && isOctalDigit(source[index])) { + octal = true; + code = code * 8 + '01234567'.indexOf(source[index++]); - createProperty: function (kind, key, value) { - return { - type: Syntax.Property, - key: key, - value: value, - kind: kind - }; - }, + // 3 digits are only allowed when string starts + // with 0, 1, 2, 3 + if ('0123'.indexOf(ch) >= 0 && + index < length && + isOctalDigit(source[index])) { + code = code * 8 + '01234567'.indexOf(source[index++]); + } + } + str += String.fromCharCode(code); + } else { + str += ch; + } + break; + } + } else { + ++lineNumber; + if (ch === '\r' && source[index] === '\n') { + ++index; + } + lineStart = index; + } + } else if (isLineTerminator(ch.charCodeAt(0))) { + break; + } else { + str += ch; + } + } - createReturnStatement: function (argument) { - return { - type: Syntax.ReturnStatement, - argument: argument - }; - }, + if (quote !== '') { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } - createSequenceExpression: function (expressions) { - return { - type: Syntax.SequenceExpression, - expressions: expressions - }; - }, + return { + type: Token.StringLiteral, + value: str, + octal: octal, + startLineNumber: startLineNumber, + startLineStart: startLineStart, + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index + }; + } - createSwitchCase: function (test, consequent) { - return { - type: Syntax.SwitchCase, - test: test, - consequent: consequent - }; - }, + function testRegExp(pattern, flags) { + var value; + try { + value = new RegExp(pattern, flags); + } catch (e) { + throwError({}, Messages.InvalidRegExp); + } + return value; + } - createSwitchStatement: function (discriminant, cases) { - return { - type: Syntax.SwitchStatement, - discriminant: discriminant, - cases: cases - }; - }, + function scanRegExpBody() { + var ch, str, classMarker, terminated, body; - createThisExpression: function () { - return { - type: Syntax.ThisExpression - }; - }, + ch = source[index]; + assert(ch === '/', 'Regular expression literal must start with a slash'); + str = source[index++]; + + classMarker = false; + terminated = false; + while (index < length) { + ch = source[index++]; + str += ch; + if (ch === '\\') { + ch = source[index++]; + // ECMA-262 7.8.5 + if (isLineTerminator(ch.charCodeAt(0))) { + throwError({}, Messages.UnterminatedRegExp); + } + str += ch; + } else if (isLineTerminator(ch.charCodeAt(0))) { + throwError({}, Messages.UnterminatedRegExp); + } else if (classMarker) { + if (ch === ']') { + classMarker = false; + } + } else { + if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; + } + } + } + + if (!terminated) { + throwError({}, Messages.UnterminatedRegExp); + } + + // Exclude leading and trailing slash. + body = str.substr(1, str.length - 2); + return { + value: body, + literal: str + }; + } - createThrowStatement: function (argument) { - return { - type: Syntax.ThrowStatement, - argument: argument - }; - }, + function scanRegExpFlags() { + var ch, str, flags, restore; - createTryStatement: function (block, guardedHandlers, handlers, finalizer) { - return { - type: Syntax.TryStatement, - block: block, - guardedHandlers: guardedHandlers, - handlers: handlers, - finalizer: finalizer - }; - }, + str = ''; + flags = ''; + while (index < length) { + ch = source[index]; + if (!isIdentifierPart(ch.charCodeAt(0))) { + break; + } - createUnaryExpression: function (operator, argument) { - if (operator === '++' || operator === '--') { - return { - type: Syntax.UpdateExpression, - operator: operator, - argument: argument, - prefix: true - }; + ++index; + if (ch === '\\' && index < length) { + ch = source[index]; + if (ch === 'u') { + ++index; + restore = index; + ch = scanHexEscape('u'); + if (ch) { + flags += ch; + for (str += '\\u'; restore < index; ++restore) { + str += source[restore]; + } + } else { + index = restore; + flags += 'u'; + str += '\\u'; + } + throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL'); + } else { + str += '\\'; + throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + } else { + flags += ch; + str += ch; } - return { - type: Syntax.UnaryExpression, - operator: operator, - argument: argument, - prefix: true - }; - }, + } - createVariableDeclaration: function (declarations, kind) { - return { - type: Syntax.VariableDeclaration, - declarations: declarations, - kind: kind - }; - }, + return { + value: flags, + literal: str + }; + } - createVariableDeclarator: function (id, init) { - return { - type: Syntax.VariableDeclarator, - id: id, - init: init - }; - }, + function scanRegExp() { + var start, body, flags, pattern, value; - createWhileStatement: function (test, body) { - return { - type: Syntax.WhileStatement, - test: test, - body: body - }; - }, + lookahead = null; + skipComment(); + start = index; - createWithStatement: function (object, body) { + body = scanRegExpBody(); + flags = scanRegExpFlags(); + value = testRegExp(body.value, flags.value); + + if (extra.tokenize) { return { - type: Syntax.WithStatement, - object: object, - body: body + type: Token.RegularExpression, + value: value, + lineNumber: lineNumber, + lineStart: lineStart, + start: start, + end: index }; } - }; - // Return true if there is a line terminator before the next token. + return { + literal: body.literal + flags.literal, + value: value, + start: start, + end: index + }; + } - function peekLineTerminator() { - var pos, line, start, found; + function collectRegex() { + var pos, loc, regex, token; - pos = index; - line = lineNumber; - start = lineStart; skipComment(); - found = lineNumber !== line; - index = pos; - lineNumber = line; - lineStart = start; - return found; - } + pos = index; + loc = { + start: { + line: lineNumber, + column: index - lineStart + } + }; - // Throw an exception + regex = scanRegExp(); + loc.end = { + line: lineNumber, + column: index - lineStart + }; - function throwError(token, messageFormat) { - var error, - args = Array.prototype.slice.call(arguments, 2), - msg = messageFormat.replace( - /%(\d)/g, - function (whole, index) { - assert(index < args.length, 'Message reference must be in range'); - return args[index]; + /* istanbul ignore next */ + if (!extra.tokenize) { + // Pop the previous token, which is likely '/' or '/=' + if (extra.tokens.length > 0) { + token = extra.tokens[extra.tokens.length - 1]; + if (token.range[0] === pos && token.type === 'Punctuator') { + if (token.value === '/' || token.value === '/=') { + extra.tokens.pop(); + } } - ); + } - if (typeof token.lineNumber === 'number') { - error = new Error('Line ' + token.lineNumber + ': ' + msg); - error.index = token.start; - error.lineNumber = token.lineNumber; - error.column = token.start - lineStart + 1; - } else { - error = new Error('Line ' + lineNumber + ': ' + msg); - error.index = index; - error.lineNumber = lineNumber; - error.column = index - lineStart + 1; + extra.tokens.push({ + type: 'RegularExpression', + value: regex.literal, + range: [pos, index], + loc: loc + }); } - error.description = msg; - throw error; + return regex; } - function throwErrorTolerant() { - try { - throwError.apply(null, arguments); - } catch (e) { - if (extra.errors) { - extra.errors.push(e); - } else { - throw e; + function isIdentifierName(token) { + return token.type === Token.Identifier || + token.type === Token.Keyword || + token.type === Token.BooleanLiteral || + token.type === Token.NullLiteral; + } + + function advanceSlash() { + var prevToken, + checkToken; + // Using the following algorithm: + // https://github.com/mozilla/sweet.js/wiki/design + prevToken = extra.tokens[extra.tokens.length - 1]; + if (!prevToken) { + // Nothing before that: it cannot be a division. + return collectRegex(); + } + if (prevToken.type === 'Punctuator') { + if (prevToken.value === ']') { + return scanPunctuator(); + } + if (prevToken.value === ')') { + checkToken = extra.tokens[extra.openParenToken - 1]; + if (checkToken && + checkToken.type === 'Keyword' && + (checkToken.value === 'if' || + checkToken.value === 'while' || + checkToken.value === 'for' || + checkToken.value === 'with')) { + return collectRegex(); + } + return scanPunctuator(); } + if (prevToken.value === '}') { + // Dividing a function by anything makes little sense, + // but we have to check for that. + if (extra.tokens[extra.openCurlyToken - 3] && + extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') { + // Anonymous function. + checkToken = extra.tokens[extra.openCurlyToken - 4]; + if (!checkToken) { + return scanPunctuator(); + } + } else if (extra.tokens[extra.openCurlyToken - 4] && + extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') { + // Named function. + checkToken = extra.tokens[extra.openCurlyToken - 5]; + if (!checkToken) { + return collectRegex(); + } + } else { + return scanPunctuator(); + } + // checkToken determines whether the function is + // a declaration or an expression. + if (FnExprTokens.indexOf(checkToken.value) >= 0) { + // It is an expression. + return scanPunctuator(); + } + // It is a declaration. + return collectRegex(); + } + return collectRegex(); + } + if (prevToken.type === 'Keyword' && prevToken.value !== 'this') { + return collectRegex(); } + return scanPunctuator(); } + function advance() { + var ch; - // Throw an exception because of the token. + skipComment(); - function throwUnexpected(token) { - if (token.type === Token.EOF) { - throwError(token, Messages.UnexpectedEOS); + if (index >= length) { + return { + type: Token.EOF, + lineNumber: lineNumber, + lineStart: lineStart, + start: index, + end: index + }; } - if (token.type === Token.NumericLiteral) { - throwError(token, Messages.UnexpectedNumber); + ch = source.charCodeAt(index); + + if (isIdentifierStart(ch)) { + return scanIdentifier(); } - if (token.type === Token.StringLiteral) { - throwError(token, Messages.UnexpectedString); + // Very common: ( and ) and ; + if (ch === 0x28 || ch === 0x29 || ch === 0x3B) { + return scanPunctuator(); } - if (token.type === Token.Identifier) { - throwError(token, Messages.UnexpectedIdentifier); + // String literal starts with single quote (U+0027) or double quote (U+0022). + if (ch === 0x27 || ch === 0x22) { + return scanStringLiteral(); } - if (token.type === Token.Keyword) { - if (isFutureReservedWord(token.value)) { - throwError(token, Messages.UnexpectedReserved); - } else if (strict && isStrictModeReservedWord(token.value)) { - throwErrorTolerant(token, Messages.StrictReservedWord); - return; + + // Dot (.) U+002E can also start a floating-point number, hence the need + // to check the next character. + if (ch === 0x2E) { + if (isDecimalDigit(source.charCodeAt(index + 1))) { + return scanNumericLiteral(); } - throwError(token, Messages.UnexpectedToken, token.value); + return scanPunctuator(); } - // BooleanLiteral, NullLiteral, or Punctuator. - throwError(token, Messages.UnexpectedToken, token.value); + if (isDecimalDigit(ch)) { + return scanNumericLiteral(); + } + + // Slash (/) U+002F can also start a regex. + if (extra.tokenize && ch === 0x2F) { + return advanceSlash(); + } + + return scanPunctuator(); } - // Expect the next token to match the specified punctuator. - // If not, an exception will be thrown. + function collectToken() { + var loc, token, range, value; - function expect(value) { - var token = lex(); - if (token.type !== Token.Punctuator || token.value !== value) { - throwUnexpected(token); + skipComment(); + loc = { + start: { + line: lineNumber, + column: index - lineStart + } + }; + + token = advance(); + loc.end = { + line: lineNumber, + column: index - lineStart + }; + + if (token.type !== Token.EOF) { + value = source.slice(token.start, token.end); + extra.tokens.push({ + type: TokenName[token.type], + value: value, + range: [token.start, token.end], + loc: loc + }); } + + return token; } - // Expect the next token to match the specified keyword. - // If not, an exception will be thrown. + function lex() { + var token; - function expectKeyword(keyword) { - var token = lex(); - if (token.type !== Token.Keyword || token.value !== keyword) { - throwUnexpected(token); - } + token = lookahead; + index = token.end; + lineNumber = token.lineNumber; + lineStart = token.lineStart; + + lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); + + index = token.end; + lineNumber = token.lineNumber; + lineStart = token.lineStart; + + return token; } - // Return true if the next token matches the specified punctuator. + function peek() { + var pos, line, start; - function match(value) { - return lookahead.type === Token.Punctuator && lookahead.value === value; + pos = index; + line = lineNumber; + start = lineStart; + lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); + index = pos; + lineNumber = line; + lineStart = start; } - // Return true if the next token matches the specified keyword + function Position(line, column) { + this.line = line; + this.column = column; + } - function matchKeyword(keyword) { - return lookahead.type === Token.Keyword && lookahead.value === keyword; + function SourceLocation(startLine, startColumn, line, column) { + this.start = new Position(startLine, startColumn); + this.end = new Position(line, column); } - // Return true if the next token is an assignment operator + SyntaxTreeDelegate = { - function matchAssign() { - var op; + name: 'SyntaxTree', - if (lookahead.type !== Token.Punctuator) { - return false; - } - op = lookahead.value; - return op === '=' || - op === '*=' || - op === '/=' || - op === '%=' || - op === '+=' || - op === '-=' || - op === '<<=' || - op === '>>=' || - op === '>>>=' || - op === '&=' || - op === '^=' || - op === '|='; - } + processComment: function (node) { + var lastChild, trailingComments; - function consumeSemicolon() { - var line, oldIndex = index, oldLineNumber = lineNumber, - oldLineStart = lineStart, oldLookahead = lookahead; + if (node.type === Syntax.Program) { + if (node.body.length > 0) { + return; + } + } - // Catch the very common case first: immediately a semicolon (U+003B). - if (source.charCodeAt(index) === 0x3B || match(';')) { - lex(); - return; - } + if (extra.trailingComments.length > 0) { + if (extra.trailingComments[0].range[0] >= node.range[1]) { + trailingComments = extra.trailingComments; + extra.trailingComments = []; + } else { + extra.trailingComments.length = 0; + } + } else { + if (extra.bottomRightStack.length > 0 && + extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments && + extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments[0].range[0] >= node.range[1]) { + trailingComments = extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments; + delete extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments; + } + } - line = lineNumber; - skipComment(); - if (lineNumber !== line) { - index = oldIndex; - lineNumber = oldLineNumber; - lineStart = oldLineStart; - lookahead = oldLookahead; - return; - } + // Eating the stack. + while (extra.bottomRightStack.length > 0 && extra.bottomRightStack[extra.bottomRightStack.length - 1].range[0] >= node.range[0]) { + lastChild = extra.bottomRightStack.pop(); + } - if (lookahead.type !== Token.EOF && !match('}')) { - throwUnexpected(lookahead); - } - } + if (lastChild) { + if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) { + node.leadingComments = lastChild.leadingComments; + delete lastChild.leadingComments; + } + } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) { + node.leadingComments = extra.leadingComments; + extra.leadingComments = []; + } - // Return true if provided expression is LeftHandSideExpression - function isLeftHandSide(expr) { - return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression; - } + if (trailingComments) { + node.trailingComments = trailingComments; + } + + extra.bottomRightStack.push(node); + }, + + markEnd: function (node, startToken) { + if (extra.range) { + node.range = [startToken.start, index]; + } + if (extra.loc) { + node.loc = new SourceLocation( + startToken.startLineNumber === undefined ? startToken.lineNumber : startToken.startLineNumber, + startToken.start - (startToken.startLineStart === undefined ? startToken.lineStart : startToken.startLineStart), + lineNumber, + index - lineStart + ); + this.postProcess(node); + } + + if (extra.attachComment) { + this.processComment(node); + } + return node; + }, + + postProcess: function (node) { + if (extra.source) { + node.loc.source = extra.source; + } + return node; + }, + + createArrayExpression: function (elements) { + return { + type: Syntax.ArrayExpression, + elements: elements + }; + }, + + createAssignmentExpression: function (operator, left, right) { + return { + type: Syntax.AssignmentExpression, + operator: operator, + left: left, + right: right + }; + }, + + createBinaryExpression: function (operator, left, right) { + var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : + Syntax.BinaryExpression; + return { + type: type, + operator: operator, + left: left, + right: right + }; + }, - // 11.1.4 Array Initialiser + createBlockStatement: function (body) { + return { + type: Syntax.BlockStatement, + body: body + }; + }, - function parseArrayInitialiser() { - var elements = [], startToken; + createBreakStatement: function (label) { + return { + type: Syntax.BreakStatement, + label: label + }; + }, - startToken = lookahead; - expect('['); + createCallExpression: function (callee, args) { + return { + type: Syntax.CallExpression, + callee: callee, + 'arguments': args + }; + }, - while (!match(']')) { - if (match(',')) { - lex(); - elements.push(null); - } else { - elements.push(parseAssignmentExpression()); + createCatchClause: function (param, body) { + return { + type: Syntax.CatchClause, + param: param, + body: body + }; + }, - if (!match(']')) { - expect(','); - } - } - } + createConditionalExpression: function (test, consequent, alternate) { + return { + type: Syntax.ConditionalExpression, + test: test, + consequent: consequent, + alternate: alternate + }; + }, - lex(); + createContinueStatement: function (label) { + return { + type: Syntax.ContinueStatement, + label: label + }; + }, - return delegate.markEnd(delegate.createArrayExpression(elements), startToken); - } + createDebuggerStatement: function () { + return { + type: Syntax.DebuggerStatement + }; + }, - // 11.1.5 Object Initialiser + createDoWhileStatement: function (body, test) { + return { + type: Syntax.DoWhileStatement, + body: body, + test: test + }; + }, - function parsePropertyFunction(param, first) { - var previousStrict, body, startToken; + createEmptyStatement: function () { + return { + type: Syntax.EmptyStatement + }; + }, - previousStrict = strict; - startToken = lookahead; - body = parseFunctionSourceElements(); - if (first && strict && isRestrictedWord(param[0].name)) { - throwErrorTolerant(first, Messages.StrictParamName); - } - strict = previousStrict; - return delegate.markEnd(delegate.createFunctionExpression(null, param, [], body), startToken); - } + createExpressionStatement: function (expression) { + return { + type: Syntax.ExpressionStatement, + expression: expression + }; + }, - function parseObjectPropertyKey() { - var token, startToken; + createForStatement: function (init, test, update, body) { + return { + type: Syntax.ForStatement, + init: init, + test: test, + update: update, + body: body + }; + }, - startToken = lookahead; - token = lex(); + createForInStatement: function (left, right, body) { + return { + type: Syntax.ForInStatement, + left: left, + right: right, + body: body, + each: false + }; + }, - // Note: This function is called only from parseObjectProperty(), where - // EOF and Punctuator tokens are already filtered out. + createFunctionDeclaration: function (id, params, defaults, body) { + return { + type: Syntax.FunctionDeclaration, + id: id, + params: params, + defaults: defaults, + body: body, + rest: null, + generator: false, + expression: false + }; + }, - if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) { - if (strict && token.octal) { - throwErrorTolerant(token, Messages.StrictOctalLiteral); - } - return delegate.markEnd(delegate.createLiteral(token), startToken); - } + createFunctionExpression: function (id, params, defaults, body) { + return { + type: Syntax.FunctionExpression, + id: id, + params: params, + defaults: defaults, + body: body, + rest: null, + generator: false, + expression: false + }; + }, - return delegate.markEnd(delegate.createIdentifier(token.value), startToken); - } + createIdentifier: function (name) { + return { + type: Syntax.Identifier, + name: name + }; + }, - function parseObjectProperty() { - var token, key, id, value, param, startToken; + createIfStatement: function (test, consequent, alternate) { + return { + type: Syntax.IfStatement, + test: test, + consequent: consequent, + alternate: alternate + }; + }, - token = lookahead; - startToken = lookahead; + createLabeledStatement: function (label, body) { + return { + type: Syntax.LabeledStatement, + label: label, + body: body + }; + }, - if (token.type === Token.Identifier) { + createLiteral: function (token) { + return { + type: Syntax.Literal, + value: token.value, + raw: source.slice(token.start, token.end) + }; + }, - id = parseObjectPropertyKey(); + createMemberExpression: function (accessor, object, property) { + return { + type: Syntax.MemberExpression, + computed: accessor === '[', + object: object, + property: property + }; + }, - // Property Assignment: Getter and Setter. + createNewExpression: function (callee, args) { + return { + type: Syntax.NewExpression, + callee: callee, + 'arguments': args + }; + }, - if (token.value === 'get' && !match(':')) { - key = parseObjectPropertyKey(); - expect('('); - expect(')'); - value = parsePropertyFunction([]); - return delegate.markEnd(delegate.createProperty('get', key, value), startToken); - } - if (token.value === 'set' && !match(':')) { - key = parseObjectPropertyKey(); - expect('('); - token = lookahead; - if (token.type !== Token.Identifier) { - expect(')'); - throwErrorTolerant(token, Messages.UnexpectedToken, token.value); - value = parsePropertyFunction([]); - } else { - param = [ parseVariableIdentifier() ]; - expect(')'); - value = parsePropertyFunction(param, token); - } - return delegate.markEnd(delegate.createProperty('set', key, value), startToken); - } - expect(':'); - value = parseAssignmentExpression(); - return delegate.markEnd(delegate.createProperty('init', id, value), startToken); - } - if (token.type === Token.EOF || token.type === Token.Punctuator) { - throwUnexpected(token); - } else { - key = parseObjectPropertyKey(); - expect(':'); - value = parseAssignmentExpression(); - return delegate.markEnd(delegate.createProperty('init', key, value), startToken); - } - } + createObjectExpression: function (properties) { + return { + type: Syntax.ObjectExpression, + properties: properties + }; + }, - function parseObjectInitialiser() { - var properties = [], property, name, key, kind, map = {}, toString = String, startToken; + createPostfixExpression: function (operator, argument) { + return { + type: Syntax.UpdateExpression, + operator: operator, + argument: argument, + prefix: false + }; + }, - startToken = lookahead; + createProgram: function (body) { + return { + type: Syntax.Program, + body: body + }; + }, - expect('{'); + createProperty: function (kind, key, value) { + return { + type: Syntax.Property, + key: key, + value: value, + kind: kind + }; + }, - while (!match('}')) { - property = parseObjectProperty(); + createReturnStatement: function (argument) { + return { + type: Syntax.ReturnStatement, + argument: argument + }; + }, - if (property.key.type === Syntax.Identifier) { - name = property.key.name; - } else { - name = toString(property.key.value); - } - kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set; + createSequenceExpression: function (expressions) { + return { + type: Syntax.SequenceExpression, + expressions: expressions + }; + }, - key = '$' + name; - if (Object.prototype.hasOwnProperty.call(map, key)) { - if (map[key] === PropertyKind.Data) { - if (strict && kind === PropertyKind.Data) { - throwErrorTolerant({}, Messages.StrictDuplicateProperty); - } else if (kind !== PropertyKind.Data) { - throwErrorTolerant({}, Messages.AccessorDataProperty); - } - } else { - if (kind === PropertyKind.Data) { - throwErrorTolerant({}, Messages.AccessorDataProperty); - } else if (map[key] & kind) { - throwErrorTolerant({}, Messages.AccessorGetSet); - } - } - map[key] |= kind; - } else { - map[key] = kind; - } + createSwitchCase: function (test, consequent) { + return { + type: Syntax.SwitchCase, + test: test, + consequent: consequent + }; + }, - properties.push(property); + createSwitchStatement: function (discriminant, cases) { + return { + type: Syntax.SwitchStatement, + discriminant: discriminant, + cases: cases + }; + }, - if (!match('}')) { - expect(','); - } - } + createThisExpression: function () { + return { + type: Syntax.ThisExpression + }; + }, - expect('}'); + createThrowStatement: function (argument) { + return { + type: Syntax.ThrowStatement, + argument: argument + }; + }, - return delegate.markEnd(delegate.createObjectExpression(properties), startToken); - } + createTryStatement: function (block, guardedHandlers, handlers, finalizer) { + return { + type: Syntax.TryStatement, + block: block, + guardedHandlers: guardedHandlers, + handlers: handlers, + finalizer: finalizer + }; + }, - // 11.1.6 The Grouping Operator + createUnaryExpression: function (operator, argument) { + if (operator === '++' || operator === '--') { + return { + type: Syntax.UpdateExpression, + operator: operator, + argument: argument, + prefix: true + }; + } + return { + type: Syntax.UnaryExpression, + operator: operator, + argument: argument, + prefix: true + }; + }, - function parseGroupExpression() { - var expr; + createVariableDeclaration: function (declarations, kind) { + return { + type: Syntax.VariableDeclaration, + declarations: declarations, + kind: kind + }; + }, - expect('('); + createVariableDeclarator: function (id, init) { + return { + type: Syntax.VariableDeclarator, + id: id, + init: init + }; + }, - expr = parseExpression(); + createWhileStatement: function (test, body) { + return { + type: Syntax.WhileStatement, + test: test, + body: body + }; + }, - expect(')'); + createWithStatement: function (object, body) { + return { + type: Syntax.WithStatement, + object: object, + body: body + }; + } + }; - return expr; - } + // Return true if there is a line terminator before the next token. + function peekLineTerminator() { + var pos, line, start, found; - // 11.1 Primary Expressions + pos = index; + line = lineNumber; + start = lineStart; + skipComment(); + found = lineNumber !== line; + index = pos; + lineNumber = line; + lineStart = start; - function parsePrimaryExpression() { - var type, token, expr, startToken; + return found; + } - if (match('(')) { - return parseGroupExpression(); - } + // Throw an exception - if (match('[')) { - return parseArrayInitialiser(); - } + function throwError(token, messageFormat) { + var error, + args = Array.prototype.slice.call(arguments, 2), + msg = messageFormat.replace( + /%(\d)/g, + function (whole, index) { + assert(index < args.length, 'Message reference must be in range'); + return args[index]; + } + ); - if (match('{')) { - return parseObjectInitialiser(); + if (typeof token.lineNumber === 'number') { + error = new Error('Line ' + token.lineNumber + ': ' + msg); + error.index = token.start; + error.lineNumber = token.lineNumber; + error.column = token.start - lineStart + 1; + } else { + error = new Error('Line ' + lineNumber + ': ' + msg); + error.index = index; + error.lineNumber = lineNumber; + error.column = index - lineStart + 1; } - type = lookahead.type; - startToken = lookahead; + error.description = msg; + throw error; + } - if (type === Token.Identifier) { - expr = delegate.createIdentifier(lex().value); - } else if (type === Token.StringLiteral || type === Token.NumericLiteral) { - if (strict && lookahead.octal) { - throwErrorTolerant(lookahead, Messages.StrictOctalLiteral); - } - expr = delegate.createLiteral(lex()); - } else if (type === Token.Keyword) { - if (matchKeyword('function')) { - return parseFunctionExpression(); - } - if (matchKeyword('this')) { - lex(); - expr = delegate.createThisExpression(); - } else { - throwUnexpected(lex()); - } - } else if (type === Token.BooleanLiteral) { - token = lex(); - token.value = (token.value === 'true'); - expr = delegate.createLiteral(token); - } else if (type === Token.NullLiteral) { - token = lex(); - token.value = null; - expr = delegate.createLiteral(token); - } else if (match('/') || match('/=')) { - if (typeof extra.tokens !== 'undefined') { - expr = delegate.createLiteral(collectRegex()); + function throwErrorTolerant() { + try { + throwError.apply(null, arguments); + } catch (e) { + if (extra.errors) { + extra.errors.push(e); } else { - expr = delegate.createLiteral(scanRegExp()); + throw e; } - peek(); - } else { - throwUnexpected(lex()); } - - return delegate.markEnd(expr, startToken); } - // 11.2 Left-Hand-Side Expressions - - function parseArguments() { - var args = []; - expect('('); + // Throw an exception because of the token. - if (!match(')')) { - while (index < length) { - args.push(parseAssignmentExpression()); - if (match(')')) { - break; - } - expect(','); - } + function throwUnexpected(token) { + if (token.type === Token.EOF) { + throwError(token, Messages.UnexpectedEOS); } - expect(')'); - - return args; - } + if (token.type === Token.NumericLiteral) { + throwError(token, Messages.UnexpectedNumber); + } - function parseNonComputedProperty() { - var token, startToken; + if (token.type === Token.StringLiteral) { + throwError(token, Messages.UnexpectedString); + } - startToken = lookahead; - token = lex(); + if (token.type === Token.Identifier) { + throwError(token, Messages.UnexpectedIdentifier); + } - if (!isIdentifierName(token)) { - throwUnexpected(token); + if (token.type === Token.Keyword) { + if (isFutureReservedWord(token.value)) { + throwError(token, Messages.UnexpectedReserved); + } else if (strict && isStrictModeReservedWord(token.value)) { + throwErrorTolerant(token, Messages.StrictReservedWord); + return; + } + throwError(token, Messages.UnexpectedToken, token.value); } - return delegate.markEnd(delegate.createIdentifier(token.value), startToken); + // BooleanLiteral, NullLiteral, or Punctuator. + throwError(token, Messages.UnexpectedToken, token.value); } - function parseNonComputedMember() { - expect('.'); + // Expect the next token to match the specified punctuator. + // If not, an exception will be thrown. - return parseNonComputedProperty(); + function expect(value) { + var token = lex(); + if (token.type !== Token.Punctuator || token.value !== value) { + throwUnexpected(token); + } } - function parseComputedMember() { - var expr; - - expect('['); + // Expect the next token to match the specified keyword. + // If not, an exception will be thrown. - expr = parseExpression(); + function expectKeyword(keyword) { + var token = lex(); + if (token.type !== Token.Keyword || token.value !== keyword) { + throwUnexpected(token); + } + } - expect(']'); + // Return true if the next token matches the specified punctuator. - return expr; + function match(value) { + return lookahead.type === Token.Punctuator && lookahead.value === value; } - function parseNewExpression() { - var callee, args, startToken; - - startToken = lookahead; - expectKeyword('new'); - callee = parseLeftHandSideExpression(); - args = match('(') ? parseArguments() : []; + // Return true if the next token matches the specified keyword - return delegate.markEnd(delegate.createNewExpression(callee, args), startToken); + function matchKeyword(keyword) { + return lookahead.type === Token.Keyword && lookahead.value === keyword; } - function parseLeftHandSideExpressionAllowCall() { - var expr, args, property, startToken, previousAllowIn = state.allowIn; + // Return true if the next token is an assignment operator - startToken = lookahead; - state.allowIn = true; - expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); + function matchAssign() { + var op; - for (;;) { - if (match('.')) { - property = parseNonComputedMember(); - expr = delegate.createMemberExpression('.', expr, property); - } else if (match('(')) { - args = parseArguments(); - expr = delegate.createCallExpression(expr, args); - } else if (match('[')) { - property = parseComputedMember(); - expr = delegate.createMemberExpression('[', expr, property); - } else { - break; - } - delegate.markEnd(expr, startToken); + if (lookahead.type !== Token.Punctuator) { + return false; } - state.allowIn = previousAllowIn; - - return expr; + op = lookahead.value; + return op === '=' || + op === '*=' || + op === '/=' || + op === '%=' || + op === '+=' || + op === '-=' || + op === '<<=' || + op === '>>=' || + op === '>>>=' || + op === '&=' || + op === '^=' || + op === '|='; } - function parseLeftHandSideExpression() { - var expr, property, startToken; - assert(state.allowIn, 'callee of new expression always allow in keyword.'); + function consumeSemicolon() { + var line, oldIndex = index, oldLineNumber = lineNumber, + oldLineStart = lineStart, oldLookahead = lookahead; - startToken = lookahead; + // Catch the very common case first: immediately a semicolon (U+003B). + if (source.charCodeAt(index) === 0x3B || match(';')) { + lex(); + return; + } - expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); + line = lineNumber; + skipComment(); + if (lineNumber !== line) { + index = oldIndex; + lineNumber = oldLineNumber; + lineStart = oldLineStart; + lookahead = oldLookahead; + return; + } - while (match('.') || match('[')) { - if (match('[')) { - property = parseComputedMember(); - expr = delegate.createMemberExpression('[', expr, property); - } else { - property = parseNonComputedMember(); - expr = delegate.createMemberExpression('.', expr, property); - } - delegate.markEnd(expr, startToken); + if (lookahead.type !== Token.EOF && !match('}')) { + throwUnexpected(lookahead); } - return expr; } - // 11.3 Postfix Expressions - - function parsePostfixExpression() { - var expr, token, startToken = lookahead; - - expr = parseLeftHandSideExpressionAllowCall(); - - if (lookahead.type === Token.Punctuator) { - if ((match('++') || match('--')) && !peekLineTerminator()) { - // 11.3.1, 11.3.2 - if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { - throwErrorTolerant({}, Messages.StrictLHSPostfix); - } - - if (!isLeftHandSide(expr)) { - throwErrorTolerant({}, Messages.InvalidLHSInAssignment); - } - - token = lex(); - expr = delegate.markEnd(delegate.createPostfixExpression(token.value, expr), startToken); - } - } + // Return true if provided expression is LeftHandSideExpression - return expr; + function isLeftHandSide(expr) { + return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression; } - // 11.4 Unary Operators + // 11.1.4 Array Initialiser - function parseUnaryExpression() { - var token, expr, startToken; + function parseArrayInitialiser() { + var elements = [], startToken; - if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) { - expr = parsePostfixExpression(); - } else if (match('++') || match('--')) { - startToken = lookahead; - token = lex(); - expr = parseUnaryExpression(); - // 11.4.4, 11.4.5 - if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { - throwErrorTolerant({}, Messages.StrictLHSPrefix); - } + startToken = lookahead; + expect('['); - if (!isLeftHandSide(expr)) { - throwErrorTolerant({}, Messages.InvalidLHSInAssignment); - } + while (!match(']')) { + if (match(',')) { + lex(); + elements.push(null); + } else { + elements.push(parseAssignmentExpression()); - expr = delegate.createUnaryExpression(token.value, expr); - expr = delegate.markEnd(expr, startToken); - } else if (match('+') || match('-') || match('~') || match('!')) { - startToken = lookahead; - token = lex(); - expr = parseUnaryExpression(); - expr = delegate.createUnaryExpression(token.value, expr); - expr = delegate.markEnd(expr, startToken); - } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { - startToken = lookahead; - token = lex(); - expr = parseUnaryExpression(); - expr = delegate.createUnaryExpression(token.value, expr); - expr = delegate.markEnd(expr, startToken); - if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { - throwErrorTolerant({}, Messages.StrictDelete); + if (!match(']')) { + expect(','); + } } - } else { - expr = parsePostfixExpression(); } - return expr; + lex(); + + return delegate.markEnd(delegate.createArrayExpression(elements), startToken); } - function binaryPrecedence(token, allowIn) { - var prec = 0; + // 11.1.5 Object Initialiser - if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { - return 0; - } + function parsePropertyFunction(param, first) { + var previousStrict, body, startToken; - switch (token.value) { - case '||': - prec = 1; - break; + previousStrict = strict; + startToken = lookahead; + body = parseFunctionSourceElements(); + if (first && strict && isRestrictedWord(param[0].name)) { + throwErrorTolerant(first, Messages.StrictParamName); + } + strict = previousStrict; + return delegate.markEnd(delegate.createFunctionExpression(null, param, [], body), startToken); + } - case '&&': - prec = 2; - break; + function parseObjectPropertyKey() { + var token, startToken; - case '|': - prec = 3; - break; + startToken = lookahead; + token = lex(); - case '^': - prec = 4; - break; + // Note: This function is called only from parseObjectProperty(), where + // EOF and Punctuator tokens are already filtered out. - case '&': - prec = 5; - break; + if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) { + if (strict && token.octal) { + throwErrorTolerant(token, Messages.StrictOctalLiteral); + } + return delegate.markEnd(delegate.createLiteral(token), startToken); + } - case '==': - case '!=': - case '===': - case '!==': - prec = 6; - break; + return delegate.markEnd(delegate.createIdentifier(token.value), startToken); + } - case '<': - case '>': - case '<=': - case '>=': - case 'instanceof': - prec = 7; - break; + function parseObjectProperty() { + var token, key, id, value, param, startToken; - case 'in': - prec = allowIn ? 7 : 0; - break; + token = lookahead; + startToken = lookahead; - case '<<': - case '>>': - case '>>>': - prec = 8; - break; + if (token.type === Token.Identifier) { - case '+': - case '-': - prec = 9; - break; + id = parseObjectPropertyKey(); - case '*': - case '/': - case '%': - prec = 11; - break; + // Property Assignment: Getter and Setter. - default: - break; + if (token.value === 'get' && !match(':')) { + key = parseObjectPropertyKey(); + expect('('); + expect(')'); + value = parsePropertyFunction([]); + return delegate.markEnd(delegate.createProperty('get', key, value), startToken); + } + if (token.value === 'set' && !match(':')) { + key = parseObjectPropertyKey(); + expect('('); + token = lookahead; + if (token.type !== Token.Identifier) { + expect(')'); + throwErrorTolerant(token, Messages.UnexpectedToken, token.value); + value = parsePropertyFunction([]); + } else { + param = [ parseVariableIdentifier() ]; + expect(')'); + value = parsePropertyFunction(param, token); + } + return delegate.markEnd(delegate.createProperty('set', key, value), startToken); + } + expect(':'); + value = parseAssignmentExpression(); + return delegate.markEnd(delegate.createProperty('init', id, value), startToken); + } + if (token.type === Token.EOF || token.type === Token.Punctuator) { + throwUnexpected(token); + } else { + key = parseObjectPropertyKey(); + expect(':'); + value = parseAssignmentExpression(); + return delegate.markEnd(delegate.createProperty('init', key, value), startToken); } - - return prec; } - // 11.5 Multiplicative Operators - // 11.6 Additive Operators - // 11.7 Bitwise Shift Operators - // 11.8 Relational Operators - // 11.9 Equality Operators - // 11.10 Binary Bitwise Operators - // 11.11 Binary Logical Operators + function parseObjectInitialiser() { + var properties = [], property, name, key, kind, map = {}, toString = String, startToken; - function parseBinaryExpression() { - var marker, markers, expr, token, prec, stack, right, operator, left, i; + startToken = lookahead; - marker = lookahead; - left = parseUnaryExpression(); + expect('{'); - token = lookahead; - prec = binaryPrecedence(token, state.allowIn); - if (prec === 0) { - return left; - } - token.prec = prec; - lex(); + while (!match('}')) { + property = parseObjectProperty(); - markers = [marker, lookahead]; - right = parseUnaryExpression(); + if (property.key.type === Syntax.Identifier) { + name = property.key.name; + } else { + name = toString(property.key.value); + } + kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set; - stack = [left, token, right]; + key = '$' + name; + if (Object.prototype.hasOwnProperty.call(map, key)) { + if (map[key] === PropertyKind.Data) { + if (strict && kind === PropertyKind.Data) { + throwErrorTolerant({}, Messages.StrictDuplicateProperty); + } else if (kind !== PropertyKind.Data) { + throwErrorTolerant({}, Messages.AccessorDataProperty); + } + } else { + if (kind === PropertyKind.Data) { + throwErrorTolerant({}, Messages.AccessorDataProperty); + } else if (map[key] & kind) { + throwErrorTolerant({}, Messages.AccessorGetSet); + } + } + map[key] |= kind; + } else { + map[key] = kind; + } - while ((prec = binaryPrecedence(lookahead, state.allowIn)) > 0) { + properties.push(property); - // Reduce: make a binary expression from the three topmost entries. - while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { - right = stack.pop(); - operator = stack.pop().value; - left = stack.pop(); - expr = delegate.createBinaryExpression(operator, left, right); - markers.pop(); - marker = markers[markers.length - 1]; - delegate.markEnd(expr, marker); - stack.push(expr); + if (!match('}')) { + expect(','); } - - // Shift. - token = lex(); - token.prec = prec; - stack.push(token); - markers.push(lookahead); - expr = parseUnaryExpression(); - stack.push(expr); } - // Final reduce to clean-up the stack. - i = stack.length - 1; - expr = stack[i]; - markers.pop(); - while (i > 1) { - expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr); - i -= 2; - marker = markers.pop(); - delegate.markEnd(expr, marker); - } + expect('}'); - return expr; + return delegate.markEnd(delegate.createObjectExpression(properties), startToken); } + // 11.1.6 The Grouping Operator - // 11.12 Conditional Operator - - function parseConditionalExpression() { - var expr, previousAllowIn, consequent, alternate, startToken; - - startToken = lookahead; + function parseGroupExpression() { + var expr; - expr = parseBinaryExpression(); + expect('('); - if (match('?')) { - lex(); - previousAllowIn = state.allowIn; - state.allowIn = true; - consequent = parseAssignmentExpression(); - state.allowIn = previousAllowIn; - expect(':'); - alternate = parseAssignmentExpression(); + expr = parseExpression(); - expr = delegate.createConditionalExpression(expr, consequent, alternate); - delegate.markEnd(expr, startToken); - } + expect(')'); return expr; } - // 11.13 Assignment Operators - function parseAssignmentExpression() { - var token, left, right, node, startToken; + // 11.1 Primary Expressions - token = lookahead; - startToken = lookahead; + function parsePrimaryExpression() { + var type, token, expr, startToken; - node = left = parseConditionalExpression(); + if (match('(')) { + return parseGroupExpression(); + } - if (matchAssign()) { - // LeftHandSideExpression - if (!isLeftHandSide(left)) { - throwErrorTolerant({}, Messages.InvalidLHSInAssignment); - } + if (match('[')) { + return parseArrayInitialiser(); + } - // 11.13.1 - if (strict && left.type === Syntax.Identifier && isRestrictedWord(left.name)) { - throwErrorTolerant(token, Messages.StrictLHSAssignment); + if (match('{')) { + return parseObjectInitialiser(); + } + + type = lookahead.type; + startToken = lookahead; + + if (type === Token.Identifier) { + expr = delegate.createIdentifier(lex().value); + } else if (type === Token.StringLiteral || type === Token.NumericLiteral) { + if (strict && lookahead.octal) { + throwErrorTolerant(lookahead, Messages.StrictOctalLiteral); + } + expr = delegate.createLiteral(lex()); + } else if (type === Token.Keyword) { + if (matchKeyword('function')) { + return parseFunctionExpression(); + } + if (matchKeyword('this')) { + lex(); + expr = delegate.createThisExpression(); + } else { + throwUnexpected(lex()); } - + } else if (type === Token.BooleanLiteral) { token = lex(); - right = parseAssignmentExpression(); - node = delegate.markEnd(delegate.createAssignmentExpression(token.value, left, right), startToken); + token.value = (token.value === 'true'); + expr = delegate.createLiteral(token); + } else if (type === Token.NullLiteral) { + token = lex(); + token.value = null; + expr = delegate.createLiteral(token); + } else if (match('/') || match('/=')) { + if (typeof extra.tokens !== 'undefined') { + expr = delegate.createLiteral(collectRegex()); + } else { + expr = delegate.createLiteral(scanRegExp()); + } + peek(); + } else { + throwUnexpected(lex()); } - return node; + return delegate.markEnd(expr, startToken); } - // 11.14 Comma Operator - - function parseExpression() { - var expr, startToken = lookahead; + // 11.2 Left-Hand-Side Expressions - expr = parseAssignmentExpression(); + function parseArguments() { + var args = []; - if (match(',')) { - expr = delegate.createSequenceExpression([ expr ]); + expect('('); + if (!match(')')) { while (index < length) { - if (!match(',')) { + args.push(parseAssignmentExpression()); + if (match(')')) { break; } - lex(); - expr.expressions.push(parseAssignmentExpression()); - } - - delegate.markEnd(expr, startToken); - } - - return expr; - } - - // 12.1 Block - - function parseStatementList() { - var list = [], - statement; - - while (index < length) { - if (match('}')) { - break; - } - statement = parseSourceElement(); - if (typeof statement === 'undefined') { - break; + expect(','); } - list.push(statement); } - return list; - } - - function parseBlock() { - var block, startToken; - - startToken = lookahead; - expect('{'); - - block = parseStatementList(); - - expect('}'); + expect(')'); - return delegate.markEnd(delegate.createBlockStatement(block), startToken); + return args; } - // 12.2 Variable Statement - - function parseVariableIdentifier() { + function parseNonComputedProperty() { var token, startToken; startToken = lookahead; token = lex(); - if (token.type !== Token.Identifier) { + if (!isIdentifierName(token)) { throwUnexpected(token); } return delegate.markEnd(delegate.createIdentifier(token.value), startToken); } - function parseVariableDeclaration(kind) { - var init = null, id, startToken; + function parseNonComputedMember() { + expect('.'); - startToken = lookahead; - id = parseVariableIdentifier(); + return parseNonComputedProperty(); + } - // 12.2.1 - if (strict && isRestrictedWord(id.name)) { - throwErrorTolerant({}, Messages.StrictVarName); - } + function parseComputedMember() { + var expr; - if (kind === 'const') { - expect('='); - init = parseAssignmentExpression(); - } else if (match('=')) { - lex(); - init = parseAssignmentExpression(); - } + expect('['); - return delegate.markEnd(delegate.createVariableDeclarator(id, init), startToken); + expr = parseExpression(); + + expect(']'); + + return expr; } - function parseVariableDeclarationList(kind) { - var list = []; + function parseNewExpression() { + var callee, args, startToken; - do { - list.push(parseVariableDeclaration(kind)); - if (!match(',')) { - break; - } - lex(); - } while (index < length); + startToken = lookahead; + expectKeyword('new'); + callee = parseLeftHandSideExpression(); + args = match('(') ? parseArguments() : []; - return list; + return delegate.markEnd(delegate.createNewExpression(callee, args), startToken); } - function parseVariableStatement() { - var declarations; - - expectKeyword('var'); + function parseLeftHandSideExpressionAllowCall() { + var expr, args, property, startToken, previousAllowIn = state.allowIn; - declarations = parseVariableDeclarationList(); + startToken = lookahead; + state.allowIn = true; + expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); - consumeSemicolon(); + for (;;) { + if (match('.')) { + property = parseNonComputedMember(); + expr = delegate.createMemberExpression('.', expr, property); + } else if (match('(')) { + args = parseArguments(); + expr = delegate.createCallExpression(expr, args); + } else if (match('[')) { + property = parseComputedMember(); + expr = delegate.createMemberExpression('[', expr, property); + } else { + break; + } + delegate.markEnd(expr, startToken); + } + state.allowIn = previousAllowIn; - return delegate.createVariableDeclaration(declarations, 'var'); + return expr; } - // kind may be `const` or `let` - // Both are experimental and not in the specification yet. - // see http://wiki.ecmascript.org/doku.php?id=harmony:const - // and http://wiki.ecmascript.org/doku.php?id=harmony:let - function parseConstLetDeclaration(kind) { - var declarations, startToken; + function parseLeftHandSideExpression() { + var expr, property, startToken; + assert(state.allowIn, 'callee of new expression always allow in keyword.'); startToken = lookahead; - expectKeyword(kind); - - declarations = parseVariableDeclarationList(kind); - - consumeSemicolon(); + expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); - return delegate.markEnd(delegate.createVariableDeclaration(declarations, kind), startToken); + while (match('.') || match('[')) { + if (match('[')) { + property = parseComputedMember(); + expr = delegate.createMemberExpression('[', expr, property); + } else { + property = parseNonComputedMember(); + expr = delegate.createMemberExpression('.', expr, property); + } + delegate.markEnd(expr, startToken); + } + return expr; } - // 12.3 Empty Statement + // 11.3 Postfix Expressions - function parseEmptyStatement() { - expect(';'); - return delegate.createEmptyStatement(); - } + function parsePostfixExpression() { + var expr, token, startToken = lookahead; - // 12.4 Expression Statement + expr = parseLeftHandSideExpressionAllowCall(); - function parseExpressionStatement() { - var expr = parseExpression(); - consumeSemicolon(); - return delegate.createExpressionStatement(expr); - } + if (lookahead.type === Token.Punctuator) { + if ((match('++') || match('--')) && !peekLineTerminator()) { + // 11.3.1, 11.3.2 + if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { + throwErrorTolerant({}, Messages.StrictLHSPostfix); + } - // 12.5 If statement + if (!isLeftHandSide(expr)) { + throwErrorTolerant({}, Messages.InvalidLHSInAssignment); + } - function parseIfStatement() { - var test, consequent, alternate; + token = lex(); + expr = delegate.markEnd(delegate.createPostfixExpression(token.value, expr), startToken); + } + } - expectKeyword('if'); + return expr; + } - expect('('); + // 11.4 Unary Operators - test = parseExpression(); + function parseUnaryExpression() { + var token, expr, startToken; - expect(')'); + if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) { + expr = parsePostfixExpression(); + } else if (match('++') || match('--')) { + startToken = lookahead; + token = lex(); + expr = parseUnaryExpression(); + // 11.4.4, 11.4.5 + if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { + throwErrorTolerant({}, Messages.StrictLHSPrefix); + } - consequent = parseStatement(); + if (!isLeftHandSide(expr)) { + throwErrorTolerant({}, Messages.InvalidLHSInAssignment); + } - if (matchKeyword('else')) { - lex(); - alternate = parseStatement(); + expr = delegate.createUnaryExpression(token.value, expr); + expr = delegate.markEnd(expr, startToken); + } else if (match('+') || match('-') || match('~') || match('!')) { + startToken = lookahead; + token = lex(); + expr = parseUnaryExpression(); + expr = delegate.createUnaryExpression(token.value, expr); + expr = delegate.markEnd(expr, startToken); + } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { + startToken = lookahead; + token = lex(); + expr = parseUnaryExpression(); + expr = delegate.createUnaryExpression(token.value, expr); + expr = delegate.markEnd(expr, startToken); + if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { + throwErrorTolerant({}, Messages.StrictDelete); + } } else { - alternate = null; + expr = parsePostfixExpression(); } - return delegate.createIfStatement(test, consequent, alternate); + return expr; } - // 12.6 Iteration Statements - - function parseDoWhileStatement() { - var body, test, oldInIteration; - - expectKeyword('do'); - - oldInIteration = state.inIteration; - state.inIteration = true; - - body = parseStatement(); - - state.inIteration = oldInIteration; - - expectKeyword('while'); - - expect('('); - - test = parseExpression(); - - expect(')'); + function binaryPrecedence(token, allowIn) { + var prec = 0; - if (match(';')) { - lex(); + if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { + return 0; } - return delegate.createDoWhileStatement(body, test); - } + switch (token.value) { + case '||': + prec = 1; + break; - function parseWhileStatement() { - var test, body, oldInIteration; + case '&&': + prec = 2; + break; - expectKeyword('while'); + case '|': + prec = 3; + break; - expect('('); + case '^': + prec = 4; + break; - test = parseExpression(); + case '&': + prec = 5; + break; - expect(')'); + case '==': + case '!=': + case '===': + case '!==': + prec = 6; + break; - oldInIteration = state.inIteration; - state.inIteration = true; + case '<': + case '>': + case '<=': + case '>=': + case 'instanceof': + prec = 7; + break; - body = parseStatement(); + case 'in': + prec = allowIn ? 7 : 0; + break; - state.inIteration = oldInIteration; + case '<<': + case '>>': + case '>>>': + prec = 8; + break; - return delegate.createWhileStatement(test, body); - } + case '+': + case '-': + prec = 9; + break; - function parseForVariableDeclaration() { - var token, declarations, startToken; + case '*': + case '/': + case '%': + prec = 11; + break; - startToken = lookahead; - token = lex(); - declarations = parseVariableDeclarationList(); + default: + break; + } - return delegate.markEnd(delegate.createVariableDeclaration(declarations, token.value), startToken); + return prec; } - function parseForStatement() { - var init, test, update, left, right, body, oldInIteration, previousAllowIn = state.allowIn; + // 11.5 Multiplicative Operators + // 11.6 Additive Operators + // 11.7 Bitwise Shift Operators + // 11.8 Relational Operators + // 11.9 Equality Operators + // 11.10 Binary Bitwise Operators + // 11.11 Binary Logical Operators - init = test = update = null; + function parseBinaryExpression() { + var marker, markers, expr, token, prec, stack, right, operator, left, i; - expectKeyword('for'); + marker = lookahead; + left = parseUnaryExpression(); - expect('('); + token = lookahead; + prec = binaryPrecedence(token, state.allowIn); + if (prec === 0) { + return left; + } + token.prec = prec; + lex(); - if (match(';')) { - lex(); - } else { - if (matchKeyword('var') || matchKeyword('let')) { - state.allowIn = false; - init = parseForVariableDeclaration(); - state.allowIn = previousAllowIn; + markers = [marker, lookahead]; + right = parseUnaryExpression(); - if (init.declarations.length === 1 && matchKeyword('in')) { - lex(); - left = init; - right = parseExpression(); - init = null; - } - } else { - state.allowIn = false; - init = parseExpression(); - state.allowIn = previousAllowIn; + stack = [left, token, right]; - if (matchKeyword('in')) { - // LeftHandSideExpression - if (!isLeftHandSide(init)) { - throwErrorTolerant({}, Messages.InvalidLHSInForIn); - } + while ((prec = binaryPrecedence(lookahead, state.allowIn)) > 0) { - lex(); - left = init; - right = parseExpression(); - init = null; - } + // Reduce: make a binary expression from the three topmost entries. + while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { + right = stack.pop(); + operator = stack.pop().value; + left = stack.pop(); + expr = delegate.createBinaryExpression(operator, left, right); + markers.pop(); + marker = markers[markers.length - 1]; + delegate.markEnd(expr, marker); + stack.push(expr); } - if (typeof left === 'undefined') { - expect(';'); - } + // Shift. + token = lex(); + token.prec = prec; + stack.push(token); + markers.push(lookahead); + expr = parseUnaryExpression(); + stack.push(expr); } - if (typeof left === 'undefined') { - - if (!match(';')) { - test = parseExpression(); - } - expect(';'); - - if (!match(')')) { - update = parseExpression(); - } + // Final reduce to clean-up the stack. + i = stack.length - 1; + expr = stack[i]; + markers.pop(); + while (i > 1) { + expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr); + i -= 2; + marker = markers.pop(); + delegate.markEnd(expr, marker); } - expect(')'); - - oldInIteration = state.inIteration; - state.inIteration = true; - - body = parseStatement(); + return expr; + } - state.inIteration = oldInIteration; - return (typeof left === 'undefined') ? - delegate.createForStatement(init, test, update, body) : - delegate.createForInStatement(left, right, body); - } + // 11.12 Conditional Operator - // 12.7 The continue statement + function parseConditionalExpression() { + var expr, previousAllowIn, consequent, alternate, startToken; - function parseContinueStatement() { - var label = null, key; + startToken = lookahead; - expectKeyword('continue'); + expr = parseBinaryExpression(); - // Optimize the most common form: 'continue;'. - if (source.charCodeAt(index) === 0x3B) { + if (match('?')) { lex(); + previousAllowIn = state.allowIn; + state.allowIn = true; + consequent = parseAssignmentExpression(); + state.allowIn = previousAllowIn; + expect(':'); + alternate = parseAssignmentExpression(); - if (!state.inIteration) { - throwError({}, Messages.IllegalContinue); - } - - return delegate.createContinueStatement(null); + expr = delegate.createConditionalExpression(expr, consequent, alternate); + delegate.markEnd(expr, startToken); } - if (peekLineTerminator()) { - if (!state.inIteration) { - throwError({}, Messages.IllegalContinue); - } + return expr; + } - return delegate.createContinueStatement(null); - } + // 11.13 Assignment Operators - if (lookahead.type === Token.Identifier) { - label = parseVariableIdentifier(); + function parseAssignmentExpression() { + var token, left, right, node, startToken; - key = '$' + label.name; - if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { - throwError({}, Messages.UnknownLabel, label.name); + token = lookahead; + startToken = lookahead; + + node = left = parseConditionalExpression(); + + if (matchAssign()) { + // LeftHandSideExpression + if (!isLeftHandSide(left)) { + throwErrorTolerant({}, Messages.InvalidLHSInAssignment); } - } - consumeSemicolon(); + // 11.13.1 + if (strict && left.type === Syntax.Identifier && isRestrictedWord(left.name)) { + throwErrorTolerant(token, Messages.StrictLHSAssignment); + } - if (label === null && !state.inIteration) { - throwError({}, Messages.IllegalContinue); + token = lex(); + right = parseAssignmentExpression(); + node = delegate.markEnd(delegate.createAssignmentExpression(token.value, left, right), startToken); } - return delegate.createContinueStatement(label); + return node; } - // 12.8 The break statement + // 11.14 Comma Operator - function parseBreakStatement() { - var label = null, key; + function parseExpression() { + var expr, startToken = lookahead; - expectKeyword('break'); + expr = parseAssignmentExpression(); - // Catch the very common case first: immediately a semicolon (U+003B). - if (source.charCodeAt(index) === 0x3B) { - lex(); + if (match(',')) { + expr = delegate.createSequenceExpression([ expr ]); - if (!(state.inIteration || state.inSwitch)) { - throwError({}, Messages.IllegalBreak); + while (index < length) { + if (!match(',')) { + break; + } + lex(); + expr.expressions.push(parseAssignmentExpression()); } - return delegate.createBreakStatement(null); + delegate.markEnd(expr, startToken); } - if (peekLineTerminator()) { - if (!(state.inIteration || state.inSwitch)) { - throwError({}, Messages.IllegalBreak); - } + return expr; + } - return delegate.createBreakStatement(null); - } + // 12.1 Block - if (lookahead.type === Token.Identifier) { - label = parseVariableIdentifier(); + function parseStatementList() { + var list = [], + statement; - key = '$' + label.name; - if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { - throwError({}, Messages.UnknownLabel, label.name); + while (index < length) { + if (match('}')) { + break; + } + statement = parseSourceElement(); + if (typeof statement === 'undefined') { + break; } + list.push(statement); } - consumeSemicolon(); + return list; + } - if (label === null && !(state.inIteration || state.inSwitch)) { - throwError({}, Messages.IllegalBreak); - } + function parseBlock() { + var block, startToken; - return delegate.createBreakStatement(label); + startToken = lookahead; + expect('{'); + + block = parseStatementList(); + + expect('}'); + + return delegate.markEnd(delegate.createBlockStatement(block), startToken); } - // 12.9 The return statement + // 12.2 Variable Statement - function parseReturnStatement() { - var argument = null; + function parseVariableIdentifier() { + var token, startToken; - expectKeyword('return'); + startToken = lookahead; + token = lex(); - if (!state.inFunctionBody) { - throwErrorTolerant({}, Messages.IllegalReturn); + if (token.type !== Token.Identifier) { + throwUnexpected(token); } - // 'return' followed by a space and an identifier is very common. - if (source.charCodeAt(index) === 0x20) { - if (isIdentifierStart(source.charCodeAt(index + 1))) { - argument = parseExpression(); - consumeSemicolon(); - return delegate.createReturnStatement(argument); - } - } + return delegate.markEnd(delegate.createIdentifier(token.value), startToken); + } - if (peekLineTerminator()) { - return delegate.createReturnStatement(null); + function parseVariableDeclaration(kind) { + var init = null, id, startToken; + + startToken = lookahead; + id = parseVariableIdentifier(); + + // 12.2.1 + if (strict && isRestrictedWord(id.name)) { + throwErrorTolerant({}, Messages.StrictVarName); } - if (!match(';')) { - if (!match('}') && lookahead.type !== Token.EOF) { - argument = parseExpression(); - } + if (kind === 'const') { + expect('='); + init = parseAssignmentExpression(); + } else if (match('=')) { + lex(); + init = parseAssignmentExpression(); } - consumeSemicolon(); + return delegate.markEnd(delegate.createVariableDeclarator(id, init), startToken); + } - return delegate.createReturnStatement(argument); + function parseVariableDeclarationList(kind) { + var list = []; + + do { + list.push(parseVariableDeclaration(kind)); + if (!match(',')) { + break; + } + lex(); + } while (index < length); + + return list; } - // 12.10 The with statement + function parseVariableStatement() { + var declarations; - function parseWithStatement() { - var object, body; + expectKeyword('var'); - if (strict) { - // TODO(ikarienator): Should we update the test cases instead? - skipComment(); - throwErrorTolerant({}, Messages.StrictModeWith); - } + declarations = parseVariableDeclarationList(); - expectKeyword('with'); + consumeSemicolon(); - expect('('); + return delegate.createVariableDeclaration(declarations, 'var'); + } - object = parseExpression(); + // kind may be `const` or `let` + // Both are experimental and not in the specification yet. + // see http://wiki.ecmascript.org/doku.php?id=harmony:const + // and http://wiki.ecmascript.org/doku.php?id=harmony:let + function parseConstLetDeclaration(kind) { + var declarations, startToken; - expect(')'); + startToken = lookahead; - body = parseStatement(); + expectKeyword(kind); - return delegate.createWithStatement(object, body); - } + declarations = parseVariableDeclarationList(kind); - // 12.10 The swith statement + consumeSemicolon(); - function parseSwitchCase() { - var test, consequent = [], statement, startToken; + return delegate.markEnd(delegate.createVariableDeclaration(declarations, kind), startToken); + } - startToken = lookahead; - if (matchKeyword('default')) { - lex(); - test = null; - } else { - expectKeyword('case'); - test = parseExpression(); - } - expect(':'); + // 12.3 Empty Statement - while (index < length) { - if (match('}') || matchKeyword('default') || matchKeyword('case')) { - break; - } - statement = parseStatement(); - consequent.push(statement); - } + function parseEmptyStatement() { + expect(';'); + return delegate.createEmptyStatement(); + } - return delegate.markEnd(delegate.createSwitchCase(test, consequent), startToken); + // 12.4 Expression Statement + + function parseExpressionStatement() { + var expr = parseExpression(); + consumeSemicolon(); + return delegate.createExpressionStatement(expr); } - function parseSwitchStatement() { - var discriminant, cases, clause, oldInSwitch, defaultFound; + // 12.5 If statement - expectKeyword('switch'); + function parseIfStatement() { + var test, consequent, alternate; + + expectKeyword('if'); expect('('); - discriminant = parseExpression(); + test = parseExpression(); expect(')'); - expect('{'); - - cases = []; + consequent = parseStatement(); - if (match('}')) { + if (matchKeyword('else')) { lex(); - return delegate.createSwitchStatement(discriminant, cases); + alternate = parseStatement(); + } else { + alternate = null; } - oldInSwitch = state.inSwitch; - state.inSwitch = true; - defaultFound = false; + return delegate.createIfStatement(test, consequent, alternate); + } - while (index < length) { - if (match('}')) { - break; - } - clause = parseSwitchCase(); - if (clause.test === null) { - if (defaultFound) { - throwError({}, Messages.MultipleDefaultsInSwitch); - } - defaultFound = true; - } - cases.push(clause); - } + // 12.6 Iteration Statements + + function parseDoWhileStatement() { + var body, test, oldInIteration; + + expectKeyword('do'); + + oldInIteration = state.inIteration; + state.inIteration = true; - state.inSwitch = oldInSwitch; + body = parseStatement(); - expect('}'); + state.inIteration = oldInIteration; - return delegate.createSwitchStatement(discriminant, cases); - } + expectKeyword('while'); - // 12.13 The throw statement + expect('('); - function parseThrowStatement() { - var argument; + test = parseExpression(); - expectKeyword('throw'); + expect(')'); - if (peekLineTerminator()) { - throwError({}, Messages.NewlineAfterThrow); + if (match(';')) { + lex(); } - argument = parseExpression(); - - consumeSemicolon(); - - return delegate.createThrowStatement(argument); + return delegate.createDoWhileStatement(body, test); } - // 12.14 The try statement - - function parseCatchClause() { - var param, body, startToken; + function parseWhileStatement() { + var test, body, oldInIteration; - startToken = lookahead; - expectKeyword('catch'); + expectKeyword('while'); expect('('); - if (match(')')) { - throwUnexpected(lookahead); - } - param = parseVariableIdentifier(); - // 12.14.1 - if (strict && isRestrictedWord(param.name)) { - throwErrorTolerant({}, Messages.StrictCatchVariable); - } + test = parseExpression(); expect(')'); - body = parseBlock(); - return delegate.markEnd(delegate.createCatchClause(param, body), startToken); - } - function parseTryStatement() { - var block, handlers = [], finalizer = null; + oldInIteration = state.inIteration; + state.inIteration = true; - expectKeyword('try'); + body = parseStatement(); - block = parseBlock(); + state.inIteration = oldInIteration; - if (matchKeyword('catch')) { - handlers.push(parseCatchClause()); - } + return delegate.createWhileStatement(test, body); + } - if (matchKeyword('finally')) { - lex(); - finalizer = parseBlock(); - } + function parseForVariableDeclaration() { + var token, declarations, startToken; - if (handlers.length === 0 && !finalizer) { - throwError({}, Messages.NoCatchOrFinally); - } + startToken = lookahead; + token = lex(); + declarations = parseVariableDeclarationList(); - return delegate.createTryStatement(block, [], handlers, finalizer); + return delegate.markEnd(delegate.createVariableDeclaration(declarations, token.value), startToken); } - // 12.15 The debugger statement - - function parseDebuggerStatement() { - expectKeyword('debugger'); - - consumeSemicolon(); + function parseForStatement() { + var init, test, update, left, right, body, oldInIteration, previousAllowIn = state.allowIn; - return delegate.createDebuggerStatement(); - } + init = test = update = null; - // 12 Statements + expectKeyword('for'); - function parseStatement() { - var type = lookahead.type, - expr, - labeledBody, - key, - startToken; + expect('('); - if (type === Token.EOF) { - throwUnexpected(lookahead); - } + if (match(';')) { + lex(); + } else { + if (matchKeyword('var') || matchKeyword('let')) { + state.allowIn = false; + init = parseForVariableDeclaration(); + state.allowIn = previousAllowIn; - if (type === Token.Punctuator && lookahead.value === '{') { - return parseBlock(); - } + if (init.declarations.length === 1 && matchKeyword('in')) { + lex(); + left = init; + right = parseExpression(); + init = null; + } + } else { + state.allowIn = false; + init = parseExpression(); + state.allowIn = previousAllowIn; - startToken = lookahead; + if (matchKeyword('in')) { + // LeftHandSideExpression + if (!isLeftHandSide(init)) { + throwErrorTolerant({}, Messages.InvalidLHSInForIn); + } - if (type === Token.Punctuator) { - switch (lookahead.value) { - case ';': - return delegate.markEnd(parseEmptyStatement(), startToken); - case '(': - return delegate.markEnd(parseExpressionStatement(), startToken); - default: - break; + lex(); + left = init; + right = parseExpression(); + init = null; + } } - } - if (type === Token.Keyword) { - switch (lookahead.value) { - case 'break': - return delegate.markEnd(parseBreakStatement(), startToken); - case 'continue': - return delegate.markEnd(parseContinueStatement(), startToken); - case 'debugger': - return delegate.markEnd(parseDebuggerStatement(), startToken); - case 'do': - return delegate.markEnd(parseDoWhileStatement(), startToken); - case 'for': - return delegate.markEnd(parseForStatement(), startToken); - case 'function': - return delegate.markEnd(parseFunctionDeclaration(), startToken); - case 'if': - return delegate.markEnd(parseIfStatement(), startToken); - case 'return': - return delegate.markEnd(parseReturnStatement(), startToken); - case 'switch': - return delegate.markEnd(parseSwitchStatement(), startToken); - case 'throw': - return delegate.markEnd(parseThrowStatement(), startToken); - case 'try': - return delegate.markEnd(parseTryStatement(), startToken); - case 'var': - return delegate.markEnd(parseVariableStatement(), startToken); - case 'while': - return delegate.markEnd(parseWhileStatement(), startToken); - case 'with': - return delegate.markEnd(parseWithStatement(), startToken); - default: - break; + if (typeof left === 'undefined') { + expect(';'); } } - expr = parseExpression(); - - // 12.12 Labelled Statements - if ((expr.type === Syntax.Identifier) && match(':')) { - lex(); + if (typeof left === 'undefined') { - key = '$' + expr.name; - if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) { - throwError({}, Messages.Redeclaration, 'Label', expr.name); + if (!match(';')) { + test = parseExpression(); } + expect(';'); - state.labelSet[key] = true; - labeledBody = parseStatement(); - delete state.labelSet[key]; - return delegate.markEnd(delegate.createLabeledStatement(expr, labeledBody), startToken); + if (!match(')')) { + update = parseExpression(); + } } - consumeSemicolon(); + expect(')'); - return delegate.markEnd(delegate.createExpressionStatement(expr), startToken); - } + oldInIteration = state.inIteration; + state.inIteration = true; - // 13 Function Definition + body = parseStatement(); - function parseFunctionSourceElements() { - var sourceElement, sourceElements = [], token, directive, firstRestricted, - oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, startToken; + state.inIteration = oldInIteration; - startToken = lookahead; - expect('{'); + return (typeof left === 'undefined') ? + delegate.createForStatement(init, test, update, body) : + delegate.createForInStatement(left, right, body); + } - while (index < length) { - if (lookahead.type !== Token.StringLiteral) { - break; - } - token = lookahead; + // 12.7 The continue statement - sourceElement = parseSourceElement(); - sourceElements.push(sourceElement); - if (sourceElement.expression.type !== Syntax.Literal) { - // this is not directive - break; - } - directive = source.slice(token.start + 1, token.end - 1); - if (directive === 'use strict') { - strict = true; - if (firstRestricted) { - throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); - } - } else { - if (!firstRestricted && token.octal) { - firstRestricted = token; - } - } - } + function parseContinueStatement() { + var label = null, key; - oldLabelSet = state.labelSet; - oldInIteration = state.inIteration; - oldInSwitch = state.inSwitch; - oldInFunctionBody = state.inFunctionBody; + expectKeyword('continue'); - state.labelSet = {}; - state.inIteration = false; - state.inSwitch = false; - state.inFunctionBody = true; + // Optimize the most common form: 'continue;'. + if (source.charCodeAt(index) === 0x3B) { + lex(); - while (index < length) { - if (match('}')) { - break; - } - sourceElement = parseSourceElement(); - if (typeof sourceElement === 'undefined') { - break; - } - sourceElements.push(sourceElement); - } + if (!state.inIteration) { + throwError({}, Messages.IllegalContinue); + } - expect('}'); + return delegate.createContinueStatement(null); + } - state.labelSet = oldLabelSet; - state.inIteration = oldInIteration; - state.inSwitch = oldInSwitch; - state.inFunctionBody = oldInFunctionBody; + if (peekLineTerminator()) { + if (!state.inIteration) { + throwError({}, Messages.IllegalContinue); + } - return delegate.markEnd(delegate.createBlockStatement(sourceElements), startToken); - } + return delegate.createContinueStatement(null); + } - function parseParams(firstRestricted) { - var param, params = [], token, stricted, paramSet, key, message; - expect('('); + if (lookahead.type === Token.Identifier) { + label = parseVariableIdentifier(); - if (!match(')')) { - paramSet = {}; - while (index < length) { - token = lookahead; - param = parseVariableIdentifier(); - key = '$' + token.value; - if (strict) { - if (isRestrictedWord(token.value)) { - stricted = token; - message = Messages.StrictParamName; - } - if (Object.prototype.hasOwnProperty.call(paramSet, key)) { - stricted = token; - message = Messages.StrictParamDupe; - } - } else if (!firstRestricted) { - if (isRestrictedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictParamName; - } else if (isStrictModeReservedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictReservedWord; - } else if (Object.prototype.hasOwnProperty.call(paramSet, key)) { - firstRestricted = token; - message = Messages.StrictParamDupe; - } - } - params.push(param); - paramSet[key] = true; - if (match(')')) { - break; - } - expect(','); + key = '$' + label.name; + if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { + throwError({}, Messages.UnknownLabel, label.name); } } - expect(')'); + consumeSemicolon(); - return { - params: params, - stricted: stricted, - firstRestricted: firstRestricted, - message: message - }; + if (label === null && !state.inIteration) { + throwError({}, Messages.IllegalContinue); + } + + return delegate.createContinueStatement(label); } - function parseFunctionDeclaration() { - var id, params = [], body, token, stricted, tmp, firstRestricted, message, previousStrict, startToken; + // 12.8 The break statement - startToken = lookahead; + function parseBreakStatement() { + var label = null, key; - expectKeyword('function'); - token = lookahead; - id = parseVariableIdentifier(); - if (strict) { - if (isRestrictedWord(token.value)) { - throwErrorTolerant(token, Messages.StrictFunctionName); - } - } else { - if (isRestrictedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictFunctionName; - } else if (isStrictModeReservedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictReservedWord; + expectKeyword('break'); + + // Catch the very common case first: immediately a semicolon (U+003B). + if (source.charCodeAt(index) === 0x3B) { + lex(); + + if (!(state.inIteration || state.inSwitch)) { + throwError({}, Messages.IllegalBreak); } + + return delegate.createBreakStatement(null); } - tmp = parseParams(firstRestricted); - params = tmp.params; - stricted = tmp.stricted; - firstRestricted = tmp.firstRestricted; - if (tmp.message) { - message = tmp.message; + if (peekLineTerminator()) { + if (!(state.inIteration || state.inSwitch)) { + throwError({}, Messages.IllegalBreak); + } + + return delegate.createBreakStatement(null); } - previousStrict = strict; - body = parseFunctionSourceElements(); - if (strict && firstRestricted) { - throwError(firstRestricted, message); + if (lookahead.type === Token.Identifier) { + label = parseVariableIdentifier(); + + key = '$' + label.name; + if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { + throwError({}, Messages.UnknownLabel, label.name); + } } - if (strict && stricted) { - throwErrorTolerant(stricted, message); + + consumeSemicolon(); + + if (label === null && !(state.inIteration || state.inSwitch)) { + throwError({}, Messages.IllegalBreak); } - strict = previousStrict; - return delegate.markEnd(delegate.createFunctionDeclaration(id, params, [], body), startToken); + return delegate.createBreakStatement(label); } - function parseFunctionExpression() { - var token, id = null, stricted, firstRestricted, message, tmp, params = [], body, previousStrict, startToken; + // 12.9 The return statement - startToken = lookahead; - expectKeyword('function'); + function parseReturnStatement() { + var argument = null; - if (!match('(')) { - token = lookahead; - id = parseVariableIdentifier(); - if (strict) { - if (isRestrictedWord(token.value)) { - throwErrorTolerant(token, Messages.StrictFunctionName); - } - } else { - if (isRestrictedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictFunctionName; - } else if (isStrictModeReservedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictReservedWord; - } - } + expectKeyword('return'); + + if (!state.inFunctionBody) { + throwErrorTolerant({}, Messages.IllegalReturn); } - tmp = parseParams(firstRestricted); - params = tmp.params; - stricted = tmp.stricted; - firstRestricted = tmp.firstRestricted; - if (tmp.message) { - message = tmp.message; + // 'return' followed by a space and an identifier is very common. + if (source.charCodeAt(index) === 0x20) { + if (isIdentifierStart(source.charCodeAt(index + 1))) { + argument = parseExpression(); + consumeSemicolon(); + return delegate.createReturnStatement(argument); + } } - previousStrict = strict; - body = parseFunctionSourceElements(); - if (strict && firstRestricted) { - throwError(firstRestricted, message); + if (peekLineTerminator()) { + return delegate.createReturnStatement(null); } - if (strict && stricted) { - throwErrorTolerant(stricted, message); + + if (!match(';')) { + if (!match('}') && lookahead.type !== Token.EOF) { + argument = parseExpression(); + } } - strict = previousStrict; - return delegate.markEnd(delegate.createFunctionExpression(id, params, [], body), startToken); + consumeSemicolon(); + + return delegate.createReturnStatement(argument); } - // 14 Program + // 12.10 The with statement - function parseSourceElement() { - if (lookahead.type === Token.Keyword) { - switch (lookahead.value) { - case 'const': - case 'let': - return parseConstLetDeclaration(lookahead.value); - case 'function': - return parseFunctionDeclaration(); - default: - return parseStatement(); - } - } + function parseWithStatement() { + var object, body; - if (lookahead.type !== Token.EOF) { - return parseStatement(); + if (strict) { + // TODO(ikarienator): Should we update the test cases instead? + skipComment(); + throwErrorTolerant({}, Messages.StrictModeWith); } + + expectKeyword('with'); + + expect('('); + + object = parseExpression(); + + expect(')'); + + body = parseStatement(); + + return delegate.createWithStatement(object, body); } - function parseSourceElements() { - var sourceElement, sourceElements = [], token, directive, firstRestricted; + // 12.10 The swith statement - while (index < length) { - token = lookahead; - if (token.type !== Token.StringLiteral) { - break; - } + function parseSwitchCase() { + var test, consequent = [], statement, startToken; - sourceElement = parseSourceElement(); - sourceElements.push(sourceElement); - if (sourceElement.expression.type !== Syntax.Literal) { - // this is not directive - break; - } - directive = source.slice(token.start + 1, token.end - 1); - if (directive === 'use strict') { - strict = true; - if (firstRestricted) { - throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); - } - } else { - if (!firstRestricted && token.octal) { - firstRestricted = token; - } - } + startToken = lookahead; + if (matchKeyword('default')) { + lex(); + test = null; + } else { + expectKeyword('case'); + test = parseExpression(); } + expect(':'); while (index < length) { - sourceElement = parseSourceElement(); - /* istanbul ignore if */ - if (typeof sourceElement === 'undefined') { + if (match('}') || matchKeyword('default') || matchKeyword('case')) { break; } - sourceElements.push(sourceElement); + statement = parseStatement(); + consequent.push(statement); } - return sourceElements; + + return delegate.markEnd(delegate.createSwitchCase(test, consequent), startToken); } - function parseProgram() { - var body, startToken; + function parseSwitchStatement() { + var discriminant, cases, clause, oldInSwitch, defaultFound; - skipComment(); - peek(); - startToken = lookahead; - strict = false; + expectKeyword('switch'); - body = parseSourceElements(); - return delegate.markEnd(delegate.createProgram(body), startToken); - } + expect('('); - function filterTokenLocation() { - var i, entry, token, tokens = []; + discriminant = parseExpression(); - for (i = 0; i < extra.tokens.length; ++i) { - entry = extra.tokens[i]; - token = { - type: entry.type, - value: entry.value - }; - if (extra.range) { - token.range = entry.range; + expect(')'); + + expect('{'); + + cases = []; + + if (match('}')) { + lex(); + return delegate.createSwitchStatement(discriminant, cases); + } + + oldInSwitch = state.inSwitch; + state.inSwitch = true; + defaultFound = false; + + while (index < length) { + if (match('}')) { + break; } - if (extra.loc) { - token.loc = entry.loc; + clause = parseSwitchCase(); + if (clause.test === null) { + if (defaultFound) { + throwError({}, Messages.MultipleDefaultsInSwitch); + } + defaultFound = true; } - tokens.push(token); + cases.push(clause); } - extra.tokens = tokens; + state.inSwitch = oldInSwitch; + + expect('}'); + + return delegate.createSwitchStatement(discriminant, cases); } - function tokenize(code, options) { - var toString, - token, - tokens; + // 12.13 The throw statement - toString = String; - if (typeof code !== 'string' && !(code instanceof String)) { - code = toString(code); + function parseThrowStatement() { + var argument; + + expectKeyword('throw'); + + if (peekLineTerminator()) { + throwError({}, Messages.NewlineAfterThrow); } - delegate = SyntaxTreeDelegate; - source = code; - index = 0; - lineNumber = (source.length > 0) ? 1 : 0; - lineStart = 0; - length = source.length; - lookahead = null; - state = { - allowIn: true, - labelSet: {}, - inFunctionBody: false, - inIteration: false, - inSwitch: false, - lastCommentStart: -1 - }; + argument = parseExpression(); - extra = {}; + consumeSemicolon(); - // Options matching. - options = options || {}; + return delegate.createThrowStatement(argument); + } - // Of course we collect tokens here. - options.tokens = true; - extra.tokens = []; - extra.tokenize = true; - // The following two fields are necessary to compute the Regex tokens. - extra.openParenToken = -1; - extra.openCurlyToken = -1; + // 12.14 The try statement - extra.range = (typeof options.range === 'boolean') && options.range; - extra.loc = (typeof options.loc === 'boolean') && options.loc; + function parseCatchClause() { + var param, body, startToken; - if (typeof options.comment === 'boolean' && options.comment) { - extra.comments = []; + startToken = lookahead; + expectKeyword('catch'); + + expect('('); + if (match(')')) { + throwUnexpected(lookahead); } - if (typeof options.tolerant === 'boolean' && options.tolerant) { - extra.errors = []; + + param = parseVariableIdentifier(); + // 12.14.1 + if (strict && isRestrictedWord(param.name)) { + throwErrorTolerant({}, Messages.StrictCatchVariable); } - try { - peek(); - if (lookahead.type === Token.EOF) { - return extra.tokens; - } + expect(')'); + body = parseBlock(); + return delegate.markEnd(delegate.createCatchClause(param, body), startToken); + } - token = lex(); - while (lookahead.type !== Token.EOF) { - try { - token = lex(); - } catch (lexError) { - token = lookahead; - if (extra.errors) { - extra.errors.push(lexError); - // We have to break on the first error - // to avoid infinite loops. - break; - } else { - throw lexError; - } - } - } + function parseTryStatement() { + var block, handlers = [], finalizer = null; - filterTokenLocation(); - tokens = extra.tokens; - if (typeof extra.comments !== 'undefined') { - tokens.comments = extra.comments; - } - if (typeof extra.errors !== 'undefined') { - tokens.errors = extra.errors; - } - } catch (e) { - throw e; - } finally { - extra = {}; - } - return tokens; - } + expectKeyword('try'); - function parse(code, options) { - var program, toString; + block = parseBlock(); - toString = String; - if (typeof code !== 'string' && !(code instanceof String)) { - code = toString(code); + if (matchKeyword('catch')) { + handlers.push(parseCatchClause()); } - delegate = SyntaxTreeDelegate; - source = code; - index = 0; - lineNumber = (source.length > 0) ? 1 : 0; - lineStart = 0; - length = source.length; - lookahead = null; - state = { - allowIn: true, - labelSet: {}, - inFunctionBody: false, - inIteration: false, - inSwitch: false, - lastCommentStart: -1 - }; + if (matchKeyword('finally')) { + lex(); + finalizer = parseBlock(); + } - extra = {}; - if (typeof options !== 'undefined') { - extra.range = (typeof options.range === 'boolean') && options.range; - extra.loc = (typeof options.loc === 'boolean') && options.loc; - extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment; + if (handlers.length === 0 && !finalizer) { + throwError({}, Messages.NoCatchOrFinally); + } - if (extra.loc && options.source !== null && options.source !== undefined) { - extra.source = toString(options.source); - } + return delegate.createTryStatement(block, [], handlers, finalizer); + } - if (typeof options.tokens === 'boolean' && options.tokens) { - extra.tokens = []; - } - if (typeof options.comment === 'boolean' && options.comment) { - extra.comments = []; - } - if (typeof options.tolerant === 'boolean' && options.tolerant) { - extra.errors = []; - } - if (extra.attachComment) { - extra.range = true; - extra.comments = []; - extra.bottomRightStack = []; - extra.trailingComments = []; - extra.leadingComments = []; - } - } + // 12.15 The debugger statement - try { - program = parseProgram(); - if (typeof extra.comments !== 'undefined') { - program.comments = extra.comments; - } - if (typeof extra.tokens !== 'undefined') { - filterTokenLocation(); - program.tokens = extra.tokens; - } - if (typeof extra.errors !== 'undefined') { - program.errors = extra.errors; - } - } catch (e) { - throw e; - } finally { - extra = {}; - } + function parseDebuggerStatement() { + expectKeyword('debugger'); - return program; - } + consumeSemicolon(); - // Sync with *.json manifests. - exports.version = '1.2.5'; + return delegate.createDebuggerStatement(); + } - exports.tokenize = tokenize; + // 12 Statements - exports.parse = parse; + function parseStatement() { + var type = lookahead.type, + expr, + labeledBody, + key, + startToken; - // Deep copy. - /* istanbul ignore next */ - exports.Syntax = (function () { - var name, types = {}; + if (type === Token.EOF) { + throwUnexpected(lookahead); + } - if (typeof Object.create === 'function') { - types = Object.create(null); + if (type === Token.Punctuator && lookahead.value === '{') { + return parseBlock(); } - for (name in Syntax) { - if (Syntax.hasOwnProperty(name)) { - types[name] = Syntax[name]; + startToken = lookahead; + + if (type === Token.Punctuator) { + switch (lookahead.value) { + case ';': + return delegate.markEnd(parseEmptyStatement(), startToken); + case '(': + return delegate.markEnd(parseExpressionStatement(), startToken); + default: + break; } } - if (typeof Object.freeze === 'function') { - Object.freeze(types); + if (type === Token.Keyword) { + switch (lookahead.value) { + case 'break': + return delegate.markEnd(parseBreakStatement(), startToken); + case 'continue': + return delegate.markEnd(parseContinueStatement(), startToken); + case 'debugger': + return delegate.markEnd(parseDebuggerStatement(), startToken); + case 'do': + return delegate.markEnd(parseDoWhileStatement(), startToken); + case 'for': + return delegate.markEnd(parseForStatement(), startToken); + case 'function': + return delegate.markEnd(parseFunctionDeclaration(), startToken); + case 'if': + return delegate.markEnd(parseIfStatement(), startToken); + case 'return': + return delegate.markEnd(parseReturnStatement(), startToken); + case 'switch': + return delegate.markEnd(parseSwitchStatement(), startToken); + case 'throw': + return delegate.markEnd(parseThrowStatement(), startToken); + case 'try': + return delegate.markEnd(parseTryStatement(), startToken); + case 'var': + return delegate.markEnd(parseVariableStatement(), startToken); + case 'while': + return delegate.markEnd(parseWhileStatement(), startToken); + case 'with': + return delegate.markEnd(parseWithStatement(), startToken); + default: + break; + } } - return types; - }()); - -})); -/* vim: set sw=4 ts=4 et tw=80 : */ + expr = parseExpression(); -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/esprima/esprima.js","/../node_modules/esprima") -},{"1YiZ5S":25,"buffer":21}],21:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ + // 12.12 Labelled Statements + if ((expr.type === Syntax.Identifier) && match(':')) { + lex(); -var base64 = require('base64-js') -var ieee754 = require('ieee754') + key = '$' + expr.name; + if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) { + throwError({}, Messages.Redeclaration, 'Label', expr.name); + } -exports.Buffer = Buffer -exports.SlowBuffer = Buffer -exports.INSPECT_MAX_BYTES = 50 -Buffer.poolSize = 8192 + state.labelSet[key] = true; + labeledBody = parseStatement(); + delete state.labelSet[key]; + return delegate.markEnd(delegate.createLabeledStatement(expr, labeledBody), startToken); + } -/** - * If `Buffer._useTypedArrays`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (compatible down to IE6) - */ -Buffer._useTypedArrays = (function () { - // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+, - // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding - // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support - // because we need to be able to add all the node Buffer API methods. This is an issue - // in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438 - try { - var buf = new ArrayBuffer(0) - var arr = new Uint8Array(buf) - arr.foo = function () { return 42 } - return 42 === arr.foo() && - typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray` - } catch (e) { - return false - } -})() + consumeSemicolon(); -/** - * Class: Buffer - * ============= - * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. - * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. - */ -function Buffer (subject, encoding, noZero) { - if (!(this instanceof Buffer)) - return new Buffer(subject, encoding, noZero) + return delegate.markEnd(delegate.createExpressionStatement(expr), startToken); + } - var type = typeof subject + // 13 Function Definition - // Workaround: node's base64 implementation allows for non-padded strings - // while base64-js does not. - if (encoding === 'base64' && type === 'string') { - subject = stringtrim(subject) - while (subject.length % 4 !== 0) { - subject = subject + '=' - } - } + function parseFunctionSourceElements() { + var sourceElement, sourceElements = [], token, directive, firstRestricted, + oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, startToken; - // Find the length - var length - if (type === 'number') - length = coerce(subject) - else if (type === 'string') - length = Buffer.byteLength(subject, encoding) - else if (type === 'object') - length = coerce(subject.length) // assume that object is array-like - else - throw new Error('First argument needs to be a number, array or string.') + startToken = lookahead; + expect('{'); - var buf - if (Buffer._useTypedArrays) { - // Preferred: Return an augmented `Uint8Array` instance for best performance - buf = Buffer._augment(new Uint8Array(length)) - } else { - // Fallback: Return THIS instance of Buffer (created by `new`) - buf = this - buf.length = length - buf._isBuffer = true - } + while (index < length) { + if (lookahead.type !== Token.StringLiteral) { + break; + } + token = lookahead; - var i - if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') { - // Speed optimization -- use set if we're copying from a typed array - buf._set(subject) - } else if (isArrayish(subject)) { - // Treat array-ish objects as a byte array - for (i = 0; i < length; i++) { - if (Buffer.isBuffer(subject)) - buf[i] = subject.readUInt8(i) - else - buf[i] = subject[i] - } - } else if (type === 'string') { - buf.write(subject, 0, encoding) - } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) { - for (i = 0; i < length; i++) { - buf[i] = 0 - } - } + sourceElement = parseSourceElement(); + sourceElements.push(sourceElement); + if (sourceElement.expression.type !== Syntax.Literal) { + // this is not directive + break; + } + directive = source.slice(token.start + 1, token.end - 1); + if (directive === 'use strict') { + strict = true; + if (firstRestricted) { + throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); + } + } else { + if (!firstRestricted && token.octal) { + firstRestricted = token; + } + } + } - return buf -} + oldLabelSet = state.labelSet; + oldInIteration = state.inIteration; + oldInSwitch = state.inSwitch; + oldInFunctionBody = state.inFunctionBody; -// STATIC METHODS -// ============== + state.labelSet = {}; + state.inIteration = false; + state.inSwitch = false; + state.inFunctionBody = true; -Buffer.isEncoding = function (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'binary': - case 'base64': - case 'raw': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} + while (index < length) { + if (match('}')) { + break; + } + sourceElement = parseSourceElement(); + if (typeof sourceElement === 'undefined') { + break; + } + sourceElements.push(sourceElement); + } -Buffer.isBuffer = function (b) { - return !!(b !== null && b !== undefined && b._isBuffer) -} + expect('}'); -Buffer.byteLength = function (str, encoding) { - var ret - str = str + '' - switch (encoding || 'utf8') { - case 'hex': - ret = str.length / 2 - break - case 'utf8': - case 'utf-8': - ret = utf8ToBytes(str).length - break - case 'ascii': - case 'binary': - case 'raw': - ret = str.length - break - case 'base64': - ret = base64ToBytes(str).length - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = str.length * 2 - break - default: - throw new Error('Unknown encoding') - } - return ret -} + state.labelSet = oldLabelSet; + state.inIteration = oldInIteration; + state.inSwitch = oldInSwitch; + state.inFunctionBody = oldInFunctionBody; -Buffer.concat = function (list, totalLength) { - assert(isArray(list), 'Usage: Buffer.concat(list, [totalLength])\n' + - 'list should be an Array.') + return delegate.markEnd(delegate.createBlockStatement(sourceElements), startToken); + } - if (list.length === 0) { - return new Buffer(0) - } else if (list.length === 1) { - return list[0] - } + function parseParams(firstRestricted) { + var param, params = [], token, stricted, paramSet, key, message; + expect('('); - var i - if (typeof totalLength !== 'number') { - totalLength = 0 - for (i = 0; i < list.length; i++) { - totalLength += list[i].length + if (!match(')')) { + paramSet = {}; + while (index < length) { + token = lookahead; + param = parseVariableIdentifier(); + key = '$' + token.value; + if (strict) { + if (isRestrictedWord(token.value)) { + stricted = token; + message = Messages.StrictParamName; + } + if (Object.prototype.hasOwnProperty.call(paramSet, key)) { + stricted = token; + message = Messages.StrictParamDupe; + } + } else if (!firstRestricted) { + if (isRestrictedWord(token.value)) { + firstRestricted = token; + message = Messages.StrictParamName; + } else if (isStrictModeReservedWord(token.value)) { + firstRestricted = token; + message = Messages.StrictReservedWord; + } else if (Object.prototype.hasOwnProperty.call(paramSet, key)) { + firstRestricted = token; + message = Messages.StrictParamDupe; + } + } + params.push(param); + paramSet[key] = true; + if (match(')')) { + break; + } + expect(','); + } + } + + expect(')'); + + return { + params: params, + stricted: stricted, + firstRestricted: firstRestricted, + message: message + }; } - } - var buf = new Buffer(totalLength) - var pos = 0 - for (i = 0; i < list.length; i++) { - var item = list[i] - item.copy(buf, pos) - pos += item.length - } - return buf -} + function parseFunctionDeclaration() { + var id, params = [], body, token, stricted, tmp, firstRestricted, message, previousStrict, startToken; -// BUFFER INSTANCE METHODS -// ======================= + startToken = lookahead; -function _hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } + expectKeyword('function'); + token = lookahead; + id = parseVariableIdentifier(); + if (strict) { + if (isRestrictedWord(token.value)) { + throwErrorTolerant(token, Messages.StrictFunctionName); + } + } else { + if (isRestrictedWord(token.value)) { + firstRestricted = token; + message = Messages.StrictFunctionName; + } else if (isStrictModeReservedWord(token.value)) { + firstRestricted = token; + message = Messages.StrictReservedWord; + } + } - // must be an even number of digits - var strLen = string.length - assert(strLen % 2 === 0, 'Invalid hex string') + tmp = parseParams(firstRestricted); + params = tmp.params; + stricted = tmp.stricted; + firstRestricted = tmp.firstRestricted; + if (tmp.message) { + message = tmp.message; + } - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; i++) { - var byte = parseInt(string.substr(i * 2, 2), 16) - assert(!isNaN(byte), 'Invalid hex string') - buf[offset + i] = byte - } - Buffer._charsWritten = i * 2 - return i -} + previousStrict = strict; + body = parseFunctionSourceElements(); + if (strict && firstRestricted) { + throwError(firstRestricted, message); + } + if (strict && stricted) { + throwErrorTolerant(stricted, message); + } + strict = previousStrict; -function _utf8Write (buf, string, offset, length) { - var charsWritten = Buffer._charsWritten = - blitBuffer(utf8ToBytes(string), buf, offset, length) - return charsWritten -} + return delegate.markEnd(delegate.createFunctionDeclaration(id, params, [], body), startToken); + } -function _asciiWrite (buf, string, offset, length) { - var charsWritten = Buffer._charsWritten = - blitBuffer(asciiToBytes(string), buf, offset, length) - return charsWritten -} + function parseFunctionExpression() { + var token, id = null, stricted, firstRestricted, message, tmp, params = [], body, previousStrict, startToken; -function _binaryWrite (buf, string, offset, length) { - return _asciiWrite(buf, string, offset, length) -} + startToken = lookahead; + expectKeyword('function'); -function _base64Write (buf, string, offset, length) { - var charsWritten = Buffer._charsWritten = - blitBuffer(base64ToBytes(string), buf, offset, length) - return charsWritten -} + if (!match('(')) { + token = lookahead; + id = parseVariableIdentifier(); + if (strict) { + if (isRestrictedWord(token.value)) { + throwErrorTolerant(token, Messages.StrictFunctionName); + } + } else { + if (isRestrictedWord(token.value)) { + firstRestricted = token; + message = Messages.StrictFunctionName; + } else if (isStrictModeReservedWord(token.value)) { + firstRestricted = token; + message = Messages.StrictReservedWord; + } + } + } -function _utf16leWrite (buf, string, offset, length) { - var charsWritten = Buffer._charsWritten = - blitBuffer(utf16leToBytes(string), buf, offset, length) - return charsWritten -} + tmp = parseParams(firstRestricted); + params = tmp.params; + stricted = tmp.stricted; + firstRestricted = tmp.firstRestricted; + if (tmp.message) { + message = tmp.message; + } -Buffer.prototype.write = function (string, offset, length, encoding) { - // Support both (string, offset, length, encoding) - // and the legacy (string, encoding, offset, length) - if (isFinite(offset)) { - if (!isFinite(length)) { - encoding = length - length = undefined + previousStrict = strict; + body = parseFunctionSourceElements(); + if (strict && firstRestricted) { + throwError(firstRestricted, message); + } + if (strict && stricted) { + throwErrorTolerant(stricted, message); + } + strict = previousStrict; + + return delegate.markEnd(delegate.createFunctionExpression(id, params, [], body), startToken); } - } else { // legacy - var swap = encoding - encoding = offset - offset = length - length = swap - } - offset = Number(offset) || 0 - var remaining = this.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining + // 14 Program + + function parseSourceElement() { + if (lookahead.type === Token.Keyword) { + switch (lookahead.value) { + case 'const': + case 'let': + return parseConstLetDeclaration(lookahead.value); + case 'function': + return parseFunctionDeclaration(); + default: + return parseStatement(); + } + } + + if (lookahead.type !== Token.EOF) { + return parseStatement(); + } } - } - encoding = String(encoding || 'utf8').toLowerCase() - var ret - switch (encoding) { - case 'hex': - ret = _hexWrite(this, string, offset, length) - break - case 'utf8': - case 'utf-8': - ret = _utf8Write(this, string, offset, length) - break - case 'ascii': - ret = _asciiWrite(this, string, offset, length) - break - case 'binary': - ret = _binaryWrite(this, string, offset, length) - break - case 'base64': - ret = _base64Write(this, string, offset, length) - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = _utf16leWrite(this, string, offset, length) - break - default: - throw new Error('Unknown encoding') - } - return ret -} + function parseSourceElements() { + var sourceElement, sourceElements = [], token, directive, firstRestricted; -Buffer.prototype.toString = function (encoding, start, end) { - var self = this + while (index < length) { + token = lookahead; + if (token.type !== Token.StringLiteral) { + break; + } - encoding = String(encoding || 'utf8').toLowerCase() - start = Number(start) || 0 - end = (end !== undefined) - ? Number(end) - : end = self.length + sourceElement = parseSourceElement(); + sourceElements.push(sourceElement); + if (sourceElement.expression.type !== Syntax.Literal) { + // this is not directive + break; + } + directive = source.slice(token.start + 1, token.end - 1); + if (directive === 'use strict') { + strict = true; + if (firstRestricted) { + throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); + } + } else { + if (!firstRestricted && token.octal) { + firstRestricted = token; + } + } + } - // Fastpath empty strings - if (end === start) - return '' + while (index < length) { + sourceElement = parseSourceElement(); + /* istanbul ignore if */ + if (typeof sourceElement === 'undefined') { + break; + } + sourceElements.push(sourceElement); + } + return sourceElements; + } - var ret - switch (encoding) { - case 'hex': - ret = _hexSlice(self, start, end) - break - case 'utf8': - case 'utf-8': - ret = _utf8Slice(self, start, end) - break - case 'ascii': - ret = _asciiSlice(self, start, end) - break - case 'binary': - ret = _binarySlice(self, start, end) - break - case 'base64': - ret = _base64Slice(self, start, end) - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = _utf16leSlice(self, start, end) - break - default: - throw new Error('Unknown encoding') - } - return ret -} + function parseProgram() { + var body, startToken; -Buffer.prototype.toJSON = function () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} + skipComment(); + peek(); + startToken = lookahead; + strict = false; -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function (target, target_start, start, end) { - var source = this + body = parseSourceElements(); + return delegate.markEnd(delegate.createProgram(body), startToken); + } - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (!target_start) target_start = 0 + function filterTokenLocation() { + var i, entry, token, tokens = []; - // Copy 0 bytes; we're done - if (end === start) return - if (target.length === 0 || source.length === 0) return + for (i = 0; i < extra.tokens.length; ++i) { + entry = extra.tokens[i]; + token = { + type: entry.type, + value: entry.value + }; + if (extra.range) { + token.range = entry.range; + } + if (extra.loc) { + token.loc = entry.loc; + } + tokens.push(token); + } - // Fatal error conditions - assert(end >= start, 'sourceEnd < sourceStart') - assert(target_start >= 0 && target_start < target.length, - 'targetStart out of bounds') - assert(start >= 0 && start < source.length, 'sourceStart out of bounds') - assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds') + extra.tokens = tokens; + } - // Are we oob? - if (end > this.length) - end = this.length - if (target.length - target_start < end - start) - end = target.length - target_start + start + function tokenize(code, options) { + var toString, + token, + tokens; - var len = end - start + toString = String; + if (typeof code !== 'string' && !(code instanceof String)) { + code = toString(code); + } - if (len < 100 || !Buffer._useTypedArrays) { - for (var i = 0; i < len; i++) - target[i + target_start] = this[i + start] - } else { - target._set(this.subarray(start, start + len), target_start) - } -} + delegate = SyntaxTreeDelegate; + source = code; + index = 0; + lineNumber = (source.length > 0) ? 1 : 0; + lineStart = 0; + length = source.length; + lookahead = null; + state = { + allowIn: true, + labelSet: {}, + inFunctionBody: false, + inIteration: false, + inSwitch: false, + lastCommentStart: -1 + }; -function _base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} + extra = {}; -function _utf8Slice (buf, start, end) { - var res = '' - var tmp = '' - end = Math.min(buf.length, end) + // Options matching. + options = options || {}; - for (var i = start; i < end; i++) { - if (buf[i] <= 0x7F) { - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) - tmp = '' - } else { - tmp += '%' + buf[i].toString(16) - } - } + // Of course we collect tokens here. + options.tokens = true; + extra.tokens = []; + extra.tokenize = true; + // The following two fields are necessary to compute the Regex tokens. + extra.openParenToken = -1; + extra.openCurlyToken = -1; - return res + decodeUtf8Char(tmp) -} + extra.range = (typeof options.range === 'boolean') && options.range; + extra.loc = (typeof options.loc === 'boolean') && options.loc; -function _asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) + if (typeof options.comment === 'boolean' && options.comment) { + extra.comments = []; + } + if (typeof options.tolerant === 'boolean' && options.tolerant) { + extra.errors = []; + } - for (var i = start; i < end; i++) - ret += String.fromCharCode(buf[i]) - return ret -} + try { + peek(); + if (lookahead.type === Token.EOF) { + return extra.tokens; + } -function _binarySlice (buf, start, end) { - return _asciiSlice(buf, start, end) -} + token = lex(); + while (lookahead.type !== Token.EOF) { + try { + token = lex(); + } catch (lexError) { + token = lookahead; + if (extra.errors) { + extra.errors.push(lexError); + // We have to break on the first error + // to avoid infinite loops. + break; + } else { + throw lexError; + } + } + } -function _hexSlice (buf, start, end) { - var len = buf.length + filterTokenLocation(); + tokens = extra.tokens; + if (typeof extra.comments !== 'undefined') { + tokens.comments = extra.comments; + } + if (typeof extra.errors !== 'undefined') { + tokens.errors = extra.errors; + } + } catch (e) { + throw e; + } finally { + extra = {}; + } + return tokens; + } - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len + function parse(code, options) { + var program, toString; - var out = '' - for (var i = start; i < end; i++) { - out += toHex(buf[i]) - } - return out -} + toString = String; + if (typeof code !== 'string' && !(code instanceof String)) { + code = toString(code); + } -function _utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i+1] * 256) - } - return res -} + delegate = SyntaxTreeDelegate; + source = code; + index = 0; + lineNumber = (source.length > 0) ? 1 : 0; + lineStart = 0; + length = source.length; + lookahead = null; + state = { + allowIn: true, + labelSet: {}, + inFunctionBody: false, + inIteration: false, + inSwitch: false, + lastCommentStart: -1 + }; -Buffer.prototype.slice = function (start, end) { - var len = this.length - start = clamp(start, len, 0) - end = clamp(end, len, len) + extra = {}; + if (typeof options !== 'undefined') { + extra.range = (typeof options.range === 'boolean') && options.range; + extra.loc = (typeof options.loc === 'boolean') && options.loc; + extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment; - if (Buffer._useTypedArrays) { - return Buffer._augment(this.subarray(start, end)) - } else { - var sliceLen = end - start - var newBuf = new Buffer(sliceLen, undefined, true) - for (var i = 0; i < sliceLen; i++) { - newBuf[i] = this[i + start] - } - return newBuf - } -} + if (extra.loc && options.source !== null && options.source !== undefined) { + extra.source = toString(options.source); + } -// `get` will be removed in Node 0.13+ -Buffer.prototype.get = function (offset) { - console.log('.get() is deprecated. Access using array indexes instead.') - return this.readUInt8(offset) -} + if (typeof options.tokens === 'boolean' && options.tokens) { + extra.tokens = []; + } + if (typeof options.comment === 'boolean' && options.comment) { + extra.comments = []; + } + if (typeof options.tolerant === 'boolean' && options.tolerant) { + extra.errors = []; + } + if (extra.attachComment) { + extra.range = true; + extra.comments = []; + extra.bottomRightStack = []; + extra.trailingComments = []; + extra.leadingComments = []; + } + } -// `set` will be removed in Node 0.13+ -Buffer.prototype.set = function (v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.') - return this.writeUInt8(v, offset) -} + try { + program = parseProgram(); + if (typeof extra.comments !== 'undefined') { + program.comments = extra.comments; + } + if (typeof extra.tokens !== 'undefined') { + filterTokenLocation(); + program.tokens = extra.tokens; + } + if (typeof extra.errors !== 'undefined') { + program.errors = extra.errors; + } + } catch (e) { + throw e; + } finally { + extra = {}; + } -Buffer.prototype.readUInt8 = function (offset, noAssert) { - if (!noAssert) { - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset < this.length, 'Trying to read beyond buffer length') - } + return program; + } - if (offset >= this.length) - return + // Sync with *.json manifests. + exports.version = '1.2.5'; - return this[offset] -} + exports.tokenize = tokenize; -function _readUInt16 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') - } + exports.parse = parse; - var len = buf.length - if (offset >= len) - return + // Deep copy. + /* istanbul ignore next */ + exports.Syntax = (function () { + var name, types = {}; - var val - if (littleEndian) { - val = buf[offset] - if (offset + 1 < len) - val |= buf[offset + 1] << 8 - } else { - val = buf[offset] << 8 - if (offset + 1 < len) - val |= buf[offset + 1] - } - return val -} + if (typeof Object.create === 'function') { + types = Object.create(null); + } -Buffer.prototype.readUInt16LE = function (offset, noAssert) { - return _readUInt16(this, offset, true, noAssert) -} + for (name in Syntax) { + if (Syntax.hasOwnProperty(name)) { + types[name] = Syntax[name]; + } + } -Buffer.prototype.readUInt16BE = function (offset, noAssert) { - return _readUInt16(this, offset, false, noAssert) -} + if (typeof Object.freeze === 'function') { + Object.freeze(types); + } -function _readUInt32 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') - } + return types; + }()); - var len = buf.length - if (offset >= len) - return +})); +/* vim: set sw=4 ts=4 et tw=80 : */ - var val - if (littleEndian) { - if (offset + 2 < len) - val = buf[offset + 2] << 16 - if (offset + 1 < len) - val |= buf[offset + 1] << 8 - val |= buf[offset] - if (offset + 3 < len) - val = val + (buf[offset + 3] << 24 >>> 0) - } else { - if (offset + 1 < len) - val = buf[offset + 1] << 16 - if (offset + 2 < len) - val |= buf[offset + 2] << 8 - if (offset + 3 < len) - val |= buf[offset + 3] - val = val + (buf[offset] << 24 >>> 0) - } - return val -} +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/esprima/esprima.js","/../node_modules/esprima") +},{"buffer":3,"pBGvAp":29}],25:[function(require,module,exports){ +(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/* + Copyright (C) 2012-2013 Yusuke Suzuki + Copyright (C) 2012 Ariya Hidayat -Buffer.prototype.readUInt32LE = function (offset, noAssert) { - return _readUInt32(this, offset, true, noAssert) -} + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: -Buffer.prototype.readUInt32BE = function (offset, noAssert) { - return _readUInt32(this, offset, false, noAssert) -} + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. -Buffer.prototype.readInt8 = function (offset, noAssert) { - if (!noAssert) { - assert(offset !== undefined && offset !== null, - 'missing offset') - assert(offset < this.length, 'Trying to read beyond buffer length') - } + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/*jslint vars:false, bitwise:true*/ +/*jshint indent:4*/ +/*global exports:true*/ +(function clone(exports) { + 'use strict'; - if (offset >= this.length) - return + var Syntax, + isArray, + VisitorOption, + VisitorKeys, + objectCreate, + objectKeys, + BREAK, + SKIP, + REMOVE; - var neg = this[offset] & 0x80 - if (neg) - return (0xff - this[offset] + 1) * -1 - else - return this[offset] -} + function ignoreJSHintError() { } -function _readInt16 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') - } + isArray = Array.isArray; + if (!isArray) { + isArray = function isArray(array) { + return Object.prototype.toString.call(array) === '[object Array]'; + }; + } - var len = buf.length - if (offset >= len) - return + function deepCopy(obj) { + var ret = {}, key, val; + for (key in obj) { + if (obj.hasOwnProperty(key)) { + val = obj[key]; + if (typeof val === 'object' && val !== null) { + ret[key] = deepCopy(val); + } else { + ret[key] = val; + } + } + } + return ret; + } - var val = _readUInt16(buf, offset, littleEndian, true) - var neg = val & 0x8000 - if (neg) - return (0xffff - val + 1) * -1 - else - return val -} + function shallowCopy(obj) { + var ret = {}, key; + for (key in obj) { + if (obj.hasOwnProperty(key)) { + ret[key] = obj[key]; + } + } + return ret; + } + ignoreJSHintError(shallowCopy); -Buffer.prototype.readInt16LE = function (offset, noAssert) { - return _readInt16(this, offset, true, noAssert) -} + // based on LLVM libc++ upper_bound / lower_bound + // MIT License -Buffer.prototype.readInt16BE = function (offset, noAssert) { - return _readInt16(this, offset, false, noAssert) -} + function upperBound(array, func) { + var diff, len, i, current; -function _readInt32 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') - } + len = array.length; + i = 0; - var len = buf.length - if (offset >= len) - return + while (len) { + diff = len >>> 1; + current = i + diff; + if (func(array[current])) { + len = diff; + } else { + i = current + 1; + len -= diff + 1; + } + } + return i; + } - var val = _readUInt32(buf, offset, littleEndian, true) - var neg = val & 0x80000000 - if (neg) - return (0xffffffff - val + 1) * -1 - else - return val -} + function lowerBound(array, func) { + var diff, len, i, current; -Buffer.prototype.readInt32LE = function (offset, noAssert) { - return _readInt32(this, offset, true, noAssert) -} + len = array.length; + i = 0; -Buffer.prototype.readInt32BE = function (offset, noAssert) { - return _readInt32(this, offset, false, noAssert) -} + while (len) { + diff = len >>> 1; + current = i + diff; + if (func(array[current])) { + i = current + 1; + len -= diff + 1; + } else { + len = diff; + } + } + return i; + } + ignoreJSHintError(lowerBound); -function _readFloat (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') - } + objectCreate = Object.create || (function () { + function F() { } - return ieee754.read(buf, offset, littleEndian, 23, 4) -} + return function (o) { + F.prototype = o; + return new F(); + }; + })(); -Buffer.prototype.readFloatLE = function (offset, noAssert) { - return _readFloat(this, offset, true, noAssert) -} + objectKeys = Object.keys || function (o) { + var keys = [], key; + for (key in o) { + keys.push(key); + } + return keys; + }; -Buffer.prototype.readFloatBE = function (offset, noAssert) { - return _readFloat(this, offset, false, noAssert) -} + function extend(to, from) { + var keys = objectKeys(from), key, i, len; + for (i = 0, len = keys.length; i < len; i += 1) { + key = keys[i]; + to[key] = from[key]; + } + return to; + } -function _readDouble (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset + 7 < buf.length, 'Trying to read beyond buffer length') - } + Syntax = { + AssignmentExpression: 'AssignmentExpression', + AssignmentPattern: 'AssignmentPattern', + ArrayExpression: 'ArrayExpression', + ArrayPattern: 'ArrayPattern', + ArrowFunctionExpression: 'ArrowFunctionExpression', + AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7. + BlockStatement: 'BlockStatement', + BinaryExpression: 'BinaryExpression', + BreakStatement: 'BreakStatement', + CallExpression: 'CallExpression', + CatchClause: 'CatchClause', + ClassBody: 'ClassBody', + ClassDeclaration: 'ClassDeclaration', + ClassExpression: 'ClassExpression', + ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7. + ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7. + ConditionalExpression: 'ConditionalExpression', + ContinueStatement: 'ContinueStatement', + DebuggerStatement: 'DebuggerStatement', + DirectiveStatement: 'DirectiveStatement', + DoWhileStatement: 'DoWhileStatement', + EmptyStatement: 'EmptyStatement', + ExportAllDeclaration: 'ExportAllDeclaration', + ExportDefaultDeclaration: 'ExportDefaultDeclaration', + ExportNamedDeclaration: 'ExportNamedDeclaration', + ExportSpecifier: 'ExportSpecifier', + ExpressionStatement: 'ExpressionStatement', + ForStatement: 'ForStatement', + ForInStatement: 'ForInStatement', + ForOfStatement: 'ForOfStatement', + FunctionDeclaration: 'FunctionDeclaration', + FunctionExpression: 'FunctionExpression', + GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7. + Identifier: 'Identifier', + IfStatement: 'IfStatement', + ImportDeclaration: 'ImportDeclaration', + ImportDefaultSpecifier: 'ImportDefaultSpecifier', + ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', + ImportSpecifier: 'ImportSpecifier', + Literal: 'Literal', + LabeledStatement: 'LabeledStatement', + LogicalExpression: 'LogicalExpression', + MemberExpression: 'MemberExpression', + MetaProperty: 'MetaProperty', + MethodDefinition: 'MethodDefinition', + ModuleSpecifier: 'ModuleSpecifier', + NewExpression: 'NewExpression', + ObjectExpression: 'ObjectExpression', + ObjectPattern: 'ObjectPattern', + Program: 'Program', + Property: 'Property', + RestElement: 'RestElement', + ReturnStatement: 'ReturnStatement', + SequenceExpression: 'SequenceExpression', + SpreadElement: 'SpreadElement', + Super: 'Super', + SwitchStatement: 'SwitchStatement', + SwitchCase: 'SwitchCase', + TaggedTemplateExpression: 'TaggedTemplateExpression', + TemplateElement: 'TemplateElement', + TemplateLiteral: 'TemplateLiteral', + ThisExpression: 'ThisExpression', + ThrowStatement: 'ThrowStatement', + TryStatement: 'TryStatement', + UnaryExpression: 'UnaryExpression', + UpdateExpression: 'UpdateExpression', + VariableDeclaration: 'VariableDeclaration', + VariableDeclarator: 'VariableDeclarator', + WhileStatement: 'WhileStatement', + WithStatement: 'WithStatement', + YieldExpression: 'YieldExpression' + }; + + VisitorKeys = { + AssignmentExpression: ['left', 'right'], + AssignmentPattern: ['left', 'right'], + ArrayExpression: ['elements'], + ArrayPattern: ['elements'], + ArrowFunctionExpression: ['params', 'body'], + AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7. + BlockStatement: ['body'], + BinaryExpression: ['left', 'right'], + BreakStatement: ['label'], + CallExpression: ['callee', 'arguments'], + CatchClause: ['param', 'body'], + ClassBody: ['body'], + ClassDeclaration: ['id', 'superClass', 'body'], + ClassExpression: ['id', 'superClass', 'body'], + ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7. + ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7. + ConditionalExpression: ['test', 'consequent', 'alternate'], + ContinueStatement: ['label'], + DebuggerStatement: [], + DirectiveStatement: [], + DoWhileStatement: ['body', 'test'], + EmptyStatement: [], + ExportAllDeclaration: ['source'], + ExportDefaultDeclaration: ['declaration'], + ExportNamedDeclaration: ['declaration', 'specifiers', 'source'], + ExportSpecifier: ['exported', 'local'], + ExpressionStatement: ['expression'], + ForStatement: ['init', 'test', 'update', 'body'], + ForInStatement: ['left', 'right', 'body'], + ForOfStatement: ['left', 'right', 'body'], + FunctionDeclaration: ['id', 'params', 'body'], + FunctionExpression: ['id', 'params', 'body'], + GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7. + Identifier: [], + IfStatement: ['test', 'consequent', 'alternate'], + ImportDeclaration: ['specifiers', 'source'], + ImportDefaultSpecifier: ['local'], + ImportNamespaceSpecifier: ['local'], + ImportSpecifier: ['imported', 'local'], + Literal: [], + LabeledStatement: ['label', 'body'], + LogicalExpression: ['left', 'right'], + MemberExpression: ['object', 'property'], + MetaProperty: ['meta', 'property'], + MethodDefinition: ['key', 'value'], + ModuleSpecifier: [], + NewExpression: ['callee', 'arguments'], + ObjectExpression: ['properties'], + ObjectPattern: ['properties'], + Program: ['body'], + Property: ['key', 'value'], + RestElement: [ 'argument' ], + ReturnStatement: ['argument'], + SequenceExpression: ['expressions'], + SpreadElement: ['argument'], + Super: [], + SwitchStatement: ['discriminant', 'cases'], + SwitchCase: ['test', 'consequent'], + TaggedTemplateExpression: ['tag', 'quasi'], + TemplateElement: [], + TemplateLiteral: ['quasis', 'expressions'], + ThisExpression: [], + ThrowStatement: ['argument'], + TryStatement: ['block', 'handler', 'finalizer'], + UnaryExpression: ['argument'], + UpdateExpression: ['argument'], + VariableDeclaration: ['declarations'], + VariableDeclarator: ['id', 'init'], + WhileStatement: ['test', 'body'], + WithStatement: ['object', 'body'], + YieldExpression: ['argument'] + }; - return ieee754.read(buf, offset, littleEndian, 52, 8) -} + // unique id + BREAK = {}; + SKIP = {}; + REMOVE = {}; -Buffer.prototype.readDoubleLE = function (offset, noAssert) { - return _readDouble(this, offset, true, noAssert) -} + VisitorOption = { + Break: BREAK, + Skip: SKIP, + Remove: REMOVE + }; -Buffer.prototype.readDoubleBE = function (offset, noAssert) { - return _readDouble(this, offset, false, noAssert) -} + function Reference(parent, key) { + this.parent = parent; + this.key = key; + } -Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset < this.length, 'trying to write beyond buffer length') - verifuint(value, 0xff) - } + Reference.prototype.replace = function replace(node) { + this.parent[this.key] = node; + }; - if (offset >= this.length) return + Reference.prototype.remove = function remove() { + if (isArray(this.parent)) { + this.parent.splice(this.key, 1); + return true; + } else { + this.replace(null); + return false; + } + }; - this[offset] = value -} + function Element(node, path, wrap, ref) { + this.node = node; + this.path = path; + this.wrap = wrap; + this.ref = ref; + } -function _writeUInt16 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'trying to write beyond buffer length') - verifuint(value, 0xffff) - } + function Controller() { } - var len = buf.length - if (offset >= len) - return + // API: + // return property path array from root to current node + Controller.prototype.path = function path() { + var i, iz, j, jz, result, element; - for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) { - buf[offset + i] = - (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } -} + function addToPath(result, path) { + if (isArray(path)) { + for (j = 0, jz = path.length; j < jz; ++j) { + result.push(path[j]); + } + } else { + result.push(path); + } + } -Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) { - _writeUInt16(this, value, offset, true, noAssert) -} + // root node + if (!this.__current.path) { + return null; + } -Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) { - _writeUInt16(this, value, offset, false, noAssert) -} + // first node is sentinel, second node is root element + result = []; + for (i = 2, iz = this.__leavelist.length; i < iz; ++i) { + element = this.__leavelist[i]; + addToPath(result, element.path); + } + addToPath(result, this.__current.path); + return result; + }; -function _writeUInt32 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'trying to write beyond buffer length') - verifuint(value, 0xffffffff) - } + // API: + // return type of current node + Controller.prototype.type = function () { + var node = this.current(); + return node.type || this.__current.wrap; + }; - var len = buf.length - if (offset >= len) - return + // API: + // return array of parent elements + Controller.prototype.parents = function parents() { + var i, iz, result; - for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) { - buf[offset + i] = - (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } -} + // first node is sentinel + result = []; + for (i = 1, iz = this.__leavelist.length; i < iz; ++i) { + result.push(this.__leavelist[i].node); + } -Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) { - _writeUInt32(this, value, offset, true, noAssert) -} + return result; + }; -Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) { - _writeUInt32(this, value, offset, false, noAssert) -} + // API: + // return current node + Controller.prototype.current = function current() { + return this.__current.node; + }; -Buffer.prototype.writeInt8 = function (value, offset, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset < this.length, 'Trying to write beyond buffer length') - verifsint(value, 0x7f, -0x80) - } + Controller.prototype.__execute = function __execute(callback, element) { + var previous, result; - if (offset >= this.length) - return + result = undefined; - if (value >= 0) - this.writeUInt8(value, offset, noAssert) - else - this.writeUInt8(0xff + value + 1, offset, noAssert) -} + previous = this.__current; + this.__current = element; + this.__state = null; + if (callback) { + result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node); + } + this.__current = previous; -function _writeInt16 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'Trying to write beyond buffer length') - verifsint(value, 0x7fff, -0x8000) - } + return result; + }; - var len = buf.length - if (offset >= len) - return + // API: + // notify control skip / break + Controller.prototype.notify = function notify(flag) { + this.__state = flag; + }; - if (value >= 0) - _writeUInt16(buf, value, offset, littleEndian, noAssert) - else - _writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert) -} + // API: + // skip child nodes of current node + Controller.prototype.skip = function () { + this.notify(SKIP); + }; -Buffer.prototype.writeInt16LE = function (value, offset, noAssert) { - _writeInt16(this, value, offset, true, noAssert) -} + // API: + // break traversals + Controller.prototype['break'] = function () { + this.notify(BREAK); + }; -Buffer.prototype.writeInt16BE = function (value, offset, noAssert) { - _writeInt16(this, value, offset, false, noAssert) -} + // API: + // remove node + Controller.prototype.remove = function () { + this.notify(REMOVE); + }; -function _writeInt32 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') - verifsint(value, 0x7fffffff, -0x80000000) - } + Controller.prototype.__initialize = function(root, visitor) { + this.visitor = visitor; + this.root = root; + this.__worklist = []; + this.__leavelist = []; + this.__current = null; + this.__state = null; + this.__fallback = visitor.fallback === 'iteration'; + this.__keys = VisitorKeys; + if (visitor.keys) { + this.__keys = extend(objectCreate(this.__keys), visitor.keys); + } + }; - var len = buf.length - if (offset >= len) - return + function isNode(node) { + if (node == null) { + return false; + } + return typeof node === 'object' && typeof node.type === 'string'; + } - if (value >= 0) - _writeUInt32(buf, value, offset, littleEndian, noAssert) - else - _writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert) -} + function isProperty(nodeType, key) { + return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key; + } -Buffer.prototype.writeInt32LE = function (value, offset, noAssert) { - _writeInt32(this, value, offset, true, noAssert) -} + Controller.prototype.traverse = function traverse(root, visitor) { + var worklist, + leavelist, + element, + node, + nodeType, + ret, + key, + current, + current2, + candidates, + candidate, + sentinel; -Buffer.prototype.writeInt32BE = function (value, offset, noAssert) { - _writeInt32(this, value, offset, false, noAssert) -} + this.__initialize(root, visitor); -function _writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') - verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38) - } + sentinel = {}; - var len = buf.length - if (offset >= len) - return + // reference + worklist = this.__worklist; + leavelist = this.__leavelist; - ieee754.write(buf, value, offset, littleEndian, 23, 4) -} + // initialize + worklist.push(new Element(root, null, null, null)); + leavelist.push(new Element(null, null, null, null)); -Buffer.prototype.writeFloatLE = function (value, offset, noAssert) { - _writeFloat(this, value, offset, true, noAssert) -} + while (worklist.length) { + element = worklist.pop(); -Buffer.prototype.writeFloatBE = function (value, offset, noAssert) { - _writeFloat(this, value, offset, false, noAssert) -} + if (element === sentinel) { + element = leavelist.pop(); -function _writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 7 < buf.length, - 'Trying to write beyond buffer length') - verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308) - } + ret = this.__execute(visitor.leave, element); - var len = buf.length - if (offset >= len) - return + if (this.__state === BREAK || ret === BREAK) { + return; + } + continue; + } - ieee754.write(buf, value, offset, littleEndian, 52, 8) -} + if (element.node) { -Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) { - _writeDouble(this, value, offset, true, noAssert) -} + ret = this.__execute(visitor.enter, element); -Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) { - _writeDouble(this, value, offset, false, noAssert) -} + if (this.__state === BREAK || ret === BREAK) { + return; + } -// fill(value, start=0, end=buffer.length) -Buffer.prototype.fill = function (value, start, end) { - if (!value) value = 0 - if (!start) start = 0 - if (!end) end = this.length + worklist.push(sentinel); + leavelist.push(element); - if (typeof value === 'string') { - value = value.charCodeAt(0) - } + if (this.__state === SKIP || ret === SKIP) { + continue; + } - assert(typeof value === 'number' && !isNaN(value), 'value is not a number') - assert(end >= start, 'end < start') + node = element.node; + nodeType = node.type || element.wrap; + candidates = this.__keys[nodeType]; + if (!candidates) { + if (this.__fallback) { + candidates = objectKeys(node); + } else { + throw new Error('Unknown node type ' + nodeType + '.'); + } + } - // Fill 0 bytes; we're done - if (end === start) return - if (this.length === 0) return + current = candidates.length; + while ((current -= 1) >= 0) { + key = candidates[current]; + candidate = node[key]; + if (!candidate) { + continue; + } - assert(start >= 0 && start < this.length, 'start out of bounds') - assert(end >= 0 && end <= this.length, 'end out of bounds') + if (isArray(candidate)) { + current2 = candidate.length; + while ((current2 -= 1) >= 0) { + if (!candidate[current2]) { + continue; + } + if (isProperty(nodeType, candidates[current])) { + element = new Element(candidate[current2], [key, current2], 'Property', null); + } else if (isNode(candidate[current2])) { + element = new Element(candidate[current2], [key, current2], null, null); + } else { + continue; + } + worklist.push(element); + } + } else if (isNode(candidate)) { + worklist.push(new Element(candidate, key, null, null)); + } + } + } + } + }; - for (var i = start; i < end; i++) { - this[i] = value - } -} + Controller.prototype.replace = function replace(root, visitor) { + function removeElem(element) { + var i, + key, + nextElem, + parent; -Buffer.prototype.inspect = function () { - var out = [] - var len = this.length - for (var i = 0; i < len; i++) { - out[i] = toHex(this[i]) - if (i === exports.INSPECT_MAX_BYTES) { - out[i + 1] = '...' - break - } - } - return '' -} + if (element.ref.remove()) { + // When the reference is an element of an array. + key = element.ref.key; + parent = element.ref.parent; -/** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ -Buffer.prototype.toArrayBuffer = function () { - if (typeof Uint8Array !== 'undefined') { - if (Buffer._useTypedArrays) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) - buf[i] = this[i] - return buf.buffer - } - } else { - throw new Error('Buffer.toArrayBuffer not supported in this browser') - } -} + // If removed from array, then decrease following items' keys. + i = worklist.length; + while (i--) { + nextElem = worklist[i]; + if (nextElem.ref && nextElem.ref.parent === parent) { + if (nextElem.ref.key < key) { + break; + } + --nextElem.ref.key; + } + } + } + } + + var worklist, + leavelist, + node, + nodeType, + target, + element, + current, + current2, + candidates, + candidate, + sentinel, + outer, + key; -// HELPER FUNCTIONS -// ================ + this.__initialize(root, visitor); -function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') -} + sentinel = {}; -var BP = Buffer.prototype + // reference + worklist = this.__worklist; + leavelist = this.__leavelist; -/** - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods - */ -Buffer._augment = function (arr) { - arr._isBuffer = true + // initialize + outer = { + root: root + }; + element = new Element(root, null, null, new Reference(outer, 'root')); + worklist.push(element); + leavelist.push(element); - // save reference to original Uint8Array get/set methods before overwriting - arr._get = arr.get - arr._set = arr.set + while (worklist.length) { + element = worklist.pop(); - // deprecated, will be removed in node 0.13+ - arr.get = BP.get - arr.set = BP.set + if (element === sentinel) { + element = leavelist.pop(); - arr.write = BP.write - arr.toString = BP.toString - arr.toLocaleString = BP.toString - arr.toJSON = BP.toJSON - arr.copy = BP.copy - arr.slice = BP.slice - arr.readUInt8 = BP.readUInt8 - arr.readUInt16LE = BP.readUInt16LE - arr.readUInt16BE = BP.readUInt16BE - arr.readUInt32LE = BP.readUInt32LE - arr.readUInt32BE = BP.readUInt32BE - arr.readInt8 = BP.readInt8 - arr.readInt16LE = BP.readInt16LE - arr.readInt16BE = BP.readInt16BE - arr.readInt32LE = BP.readInt32LE - arr.readInt32BE = BP.readInt32BE - arr.readFloatLE = BP.readFloatLE - arr.readFloatBE = BP.readFloatBE - arr.readDoubleLE = BP.readDoubleLE - arr.readDoubleBE = BP.readDoubleBE - arr.writeUInt8 = BP.writeUInt8 - arr.writeUInt16LE = BP.writeUInt16LE - arr.writeUInt16BE = BP.writeUInt16BE - arr.writeUInt32LE = BP.writeUInt32LE - arr.writeUInt32BE = BP.writeUInt32BE - arr.writeInt8 = BP.writeInt8 - arr.writeInt16LE = BP.writeInt16LE - arr.writeInt16BE = BP.writeInt16BE - arr.writeInt32LE = BP.writeInt32LE - arr.writeInt32BE = BP.writeInt32BE - arr.writeFloatLE = BP.writeFloatLE - arr.writeFloatBE = BP.writeFloatBE - arr.writeDoubleLE = BP.writeDoubleLE - arr.writeDoubleBE = BP.writeDoubleBE - arr.fill = BP.fill - arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer + target = this.__execute(visitor.leave, element); - return arr -} + // node may be replaced with null, + // so distinguish between undefined and null in this place + if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) { + // replace + element.ref.replace(target); + } -// slice(start, end) -function clamp (index, len, defaultValue) { - if (typeof index !== 'number') return defaultValue - index = ~~index; // Coerce to integer. - if (index >= len) return len - if (index >= 0) return index - index += len - if (index >= 0) return index - return 0 -} + if (this.__state === REMOVE || target === REMOVE) { + removeElem(element); + } -function coerce (length) { - // Coerce length to a number (possibly NaN), round up - // in case it's fractional (e.g. 123.456) then do a - // double negate to coerce a NaN to 0. Easy, right? - length = ~~Math.ceil(+length) - return length < 0 ? 0 : length -} + if (this.__state === BREAK || target === BREAK) { + return outer.root; + } + continue; + } -function isArray (subject) { - return (Array.isArray || function (subject) { - return Object.prototype.toString.call(subject) === '[object Array]' - })(subject) -} + target = this.__execute(visitor.enter, element); -function isArrayish (subject) { - return isArray(subject) || Buffer.isBuffer(subject) || - subject && typeof subject === 'object' && - typeof subject.length === 'number' -} + // node may be replaced with null, + // so distinguish between undefined and null in this place + if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) { + // replace + element.ref.replace(target); + element.node = target; + } -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} + if (this.__state === REMOVE || target === REMOVE) { + removeElem(element); + element.node = null; + } -function utf8ToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - var b = str.charCodeAt(i) - if (b <= 0x7F) - byteArray.push(str.charCodeAt(i)) - else { - var start = i - if (b >= 0xD800 && b <= 0xDFFF) i++ - var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%') - for (var j = 0; j < h.length; j++) - byteArray.push(parseInt(h[j], 16)) - } - } - return byteArray -} + if (this.__state === BREAK || target === BREAK) { + return outer.root; + } -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} + // node may be null + node = element.node; + if (!node) { + continue; + } -function utf16leToBytes (str) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; i++) { - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } + worklist.push(sentinel); + leavelist.push(element); - return byteArray -} + if (this.__state === SKIP || target === SKIP) { + continue; + } -function base64ToBytes (str) { - return base64.toByteArray(str) -} + nodeType = node.type || element.wrap; + candidates = this.__keys[nodeType]; + if (!candidates) { + if (this.__fallback) { + candidates = objectKeys(node); + } else { + throw new Error('Unknown node type ' + nodeType + '.'); + } + } -function blitBuffer (src, dst, offset, length) { - var pos - for (var i = 0; i < length; i++) { - if ((i + offset >= dst.length) || (i >= src.length)) - break - dst[i + offset] = src[i] - } - return i -} + current = candidates.length; + while ((current -= 1) >= 0) { + key = candidates[current]; + candidate = node[key]; + if (!candidate) { + continue; + } -function decodeUtf8Char (str) { - try { - return decodeURIComponent(str) - } catch (err) { - return String.fromCharCode(0xFFFD) // UTF 8 invalid char - } -} + if (isArray(candidate)) { + current2 = candidate.length; + while ((current2 -= 1) >= 0) { + if (!candidate[current2]) { + continue; + } + if (isProperty(nodeType, candidates[current])) { + element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2)); + } else if (isNode(candidate[current2])) { + element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2)); + } else { + continue; + } + worklist.push(element); + } + } else if (isNode(candidate)) { + worklist.push(new Element(candidate, key, null, new Reference(node, key))); + } + } + } -/* - * We have to make sure that the value is a valid integer. This means that it - * is non-negative. It has no fractional component and that it does not - * exceed the maximum allowed value. - */ -function verifuint (value, max) { - assert(typeof value === 'number', 'cannot write a non-number as a number') - assert(value >= 0, 'specified a negative value for writing an unsigned value') - assert(value <= max, 'value is larger than maximum value for type') - assert(Math.floor(value) === value, 'value has a fractional component') -} + return outer.root; + }; -function verifsint (value, max, min) { - assert(typeof value === 'number', 'cannot write a non-number as a number') - assert(value <= max, 'value larger than maximum allowed value') - assert(value >= min, 'value smaller than minimum allowed value') - assert(Math.floor(value) === value, 'value has a fractional component') -} + function traverse(root, visitor) { + var controller = new Controller(); + return controller.traverse(root, visitor); + } -function verifIEEE754 (value, max, min) { - assert(typeof value === 'number', 'cannot write a non-number as a number') - assert(value <= max, 'value larger than maximum allowed value') - assert(value >= min, 'value smaller than minimum allowed value') -} + function replace(root, visitor) { + var controller = new Controller(); + return controller.replace(root, visitor); + } -function assert (test, message) { - if (!test) throw new Error(message || 'Failed assertion') -} + function extendCommentRange(comment, tokens) { + var target; -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/index.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer") -},{"1YiZ5S":25,"base64-js":22,"buffer":21,"ieee754":23}],22:[function(require,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + target = upperBound(tokens, function search(token) { + return token.range[0] > comment.range[0]; + }); -;(function (exports) { - 'use strict'; + comment.extendedRange = [comment.range[0], comment.range[1]]; - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array + if (target !== tokens.length) { + comment.extendedRange[1] = tokens[target].range[0]; + } - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - var PLUS_URL_SAFE = '-'.charCodeAt(0) - var SLASH_URL_SAFE = '_'.charCodeAt(0) + target -= 1; + if (target >= 0) { + comment.extendedRange[0] = tokens[target].range[1]; + } - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS || - code === PLUS_URL_SAFE) - return 62 // '+' - if (code === SLASH || - code === SLASH_URL_SAFE) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } + return comment; + } - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr + function attachComments(tree, providedComments, tokens) { + // At first, we should calculate extended comment ranges. + var comments = [], comment, len, i, cursor; - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } + if (!tree.range) { + throw new Error('attachComments needs range information'); + } - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 + // tokens array is empty, we attach comments to tree as 'leadingComments' + if (!tokens.length) { + if (providedComments.length) { + for (i = 0, len = providedComments.length; i < len; i += 1) { + comment = deepCopy(providedComments[i]); + comment.extendedRange = [0, tree.range[0]]; + comments.push(comment); + } + tree.leadingComments = comments; + } + return tree; + } - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) + for (i = 0, len = providedComments.length; i < len; i += 1) { + comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens)); + } - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length + // This is based on John Freeman's implementation. + cursor = 0; + traverse(tree, { + enter: function (node) { + var comment; - var L = 0 + while (cursor < comments.length) { + comment = comments[cursor]; + if (comment.extendedRange[1] > node.range[0]) { + break; + } - function push (v) { - arr[L++] = v - } + if (comment.extendedRange[1] === node.range[0]) { + if (!node.leadingComments) { + node.leadingComments = []; + } + node.leadingComments.push(comment); + comments.splice(cursor, 1); + } else { + cursor += 1; + } + } - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } + // already out of owned node + if (cursor === comments.length) { + return VisitorOption.Break; + } - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } + if (comments[cursor].extendedRange[0] > node.range[1]) { + return VisitorOption.Skip; + } + } + }); - return arr - } + cursor = 0; + traverse(tree, { + leave: function (node) { + var comment; - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length + while (cursor < comments.length) { + comment = comments[cursor]; + if (node.range[1] < comment.extendedRange[0]) { + break; + } - function encode (num) { - return lookup.charAt(num) - } + if (node.range[1] === comment.extendedRange[0]) { + if (!node.trailingComments) { + node.trailingComments = []; + } + node.trailingComments.push(comment); + comments.splice(cursor, 1); + } else { + cursor += 1; + } + } - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } + // already out of owned node + if (cursor === comments.length) { + return VisitorOption.Break; + } - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } + if (comments[cursor].extendedRange[0] > node.range[1]) { + return VisitorOption.Skip; + } + } + }); - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } + return tree; + } - return output - } + exports.version = require('./package.json').version; + exports.Syntax = Syntax; + exports.traverse = traverse; + exports.replace = replace; + exports.attachComments = attachComments; + exports.VisitorKeys = VisitorKeys; + exports.VisitorOption = VisitorOption; + exports.Controller = Controller; + exports.cloneEnvironment = function () { return clone({}); }; - exports.toByteArray = b64ToByteArray - exports.fromByteArray = uint8ToBase64 -}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) + return exports; +}(exports)); +/* vim: set sw=4 ts=4 et tw=80 : */ + +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/estraverse/estraverse.js","/../node_modules/estraverse") +},{"./package.json":26,"buffer":3,"pBGvAp":29}],26:[function(require,module,exports){ +module.exports={ + "_args": [ + [ + "estraverse", + "/Users/nanki/work/javascript-operator-overloading/operator-overloading-js" + ], + [ + "estraverse@latest", + "" + ] + ], + "_from": "estraverse@latest", + "_id": "estraverse@4.1.1", + "_inCache": true, + "_installable": true, + "_location": "/estraverse", + "_nodeVersion": "4.1.1", + "_npmUser": { + "email": "utatane.tea@gmail.com", + "name": "constellation" + }, + "_npmVersion": "2.14.4", + "_phantomChildren": {}, + "_requested": { + "name": "estraverse", + "raw": "estraverse@latest", + "rawSpec": "latest", + "scope": null, + "spec": "latest", + "type": "tag" + }, + "_requiredBy": [ + "#USER" + ], + "_shrinkwrap": null, + "_spec": "estraverse@latest", + "_where": "", + "bugs": { + "url": "https://github.com/estools/estraverse/issues" + }, + "dependencies": {}, + "description": "ECMAScript JS AST traversal functions", + "devDependencies": { + "chai": "^2.1.1", + "coffee-script": "^1.8.0", + "espree": "^1.11.0", + "gulp": "^3.8.10", + "gulp-bump": "^0.2.2", + "gulp-filter": "^2.0.0", + "gulp-git": "^1.0.1", + "gulp-tag-version": "^1.2.1", + "jshint": "^2.5.6", + "mocha": "^2.1.0" + }, + "directories": {}, + "dist": { + "shasum": "f6caca728933a850ef90661d0e17982ba47111a2", + "tarball": "http://registry.npmjs.org/estraverse/-/estraverse-4.1.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "gitHead": "bbcccbfe98296585e4311c8755e1d00dcd581e3c", + "homepage": "https://github.com/estools/estraverse", + "license": "BSD-2-Clause", + "main": "estraverse.js", + "maintainers": [ + { + "name": "constellation", + "email": "utatane.tea@gmail.com" + }, + { + "name": "michaelficarra", + "email": "npm@michael.ficarra.me" + }, + { + "name": "nzakas", + "email": "nicholas@nczconsulting.com" + } + ], + "name": "estraverse", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/estools/estraverse.git" + }, + "scripts": { + "lint": "jshint estraverse.js", + "test": "npm run-script lint && npm run-script unit-test", + "unit-test": "mocha --compilers coffee:coffee-script/register" + }, + "version": "4.1.1" +} -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib/b64.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib") -},{"1YiZ5S":25,"buffer":21}],23:[function(require,module,exports){ +},{}],27:[function(require,module,exports){ (function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m @@ -11904,8 +13291,8 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754/index.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754") -},{"1YiZ5S":25,"buffer":21}],24:[function(require,module,exports){ +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/ieee754/index.js","/../node_modules/ieee754") +},{"buffer":3,"pBGvAp":29}],28:[function(require,module,exports){ (function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ // Copyright Joyent, Inc. and other Node contributors. // @@ -12132,8 +13519,8 @@ var substr = 'ab'.substr(-1) === 'b' } ; -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/path-browserify/index.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/path-browserify") -},{"1YiZ5S":25,"buffer":21}],25:[function(require,module,exports){ +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/path-browserify/index.js","/../node_modules/path-browserify") +},{"buffer":3,"pBGvAp":29}],29:[function(require,module,exports){ (function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ // shim for using process in browser @@ -12199,5 +13586,5 @@ process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; -}).call(this,require("1YiZ5S"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/process/browser.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/process") -},{"1YiZ5S":25,"buffer":21}]},{},[1]) \ No newline at end of file +}).call(this,require("pBGvAp"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/process/browser.js","/../node_modules/process") +},{"buffer":3,"pBGvAp":29}]},{},[1]) \ No newline at end of file diff --git a/dist/browser/overload.min.js b/dist/browser/overload.min.js index f5aa978..46c6b5a 100644 --- a/dist/browser/overload.min.js +++ b/dist/browser/overload.min.js @@ -1,24 +1,27 @@ -!function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(i)return i(a,!0);throw new Error("Cannot find module '"+a+"'")}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a":"__greaterThan","<=":"__lessThanEqual",">=":"__greaterThanEqual","in":"__in","instanceof":"__instanceOf","<<":"__bitwiseLSHIFT",">>":"__bitwiseRSHIFT",">>>":"__zeroFillRSHIFT","-":"__minus","*":"__multiply","%":"__modulus","/":"__divide","u-":"__unaryNegation","u+":"__unaryAddition","~":"__bitwiseNOT","++":"__increment","--":"__decrement","!":"__unaryNOT","+=":"__addAssign","-=":"__minusAssign","*=":"__multiplyAssign","/=":"__divideAssign","%=":"__modulusAssign","<<=":"__leftShiftAssign",">>=":"__rightShiftAssign",">>>=":"__zeroFillRightShiftAssign","&=":"__andAssign","|=":"__orAssign","^=":"__xorAssign"}; +case"Literal":case"Identifier":}}/* jshint ignore:start */ +function d(e,t,n){Object.defineProperty(e.prototype,t,{enumerable:!1,writable:!0,configurable:!1,value:n})}var m=e("esprima"),h=e("escodegen"),g={"+":"__plus","==":"__doubleEqual","===":"__tripleEqual","||":"__logicalOR","&&":"__logicalAND","|":"__bitwiseOR","^":"__bitwiseXOR","&":"__bitwiseAND","!=":"__notEqual","!==":"__notDoubleEqual","<":"__lessThan",">":"__greaterThan","<=":"__lessThanEqual",">=":"__greaterThanEqual","in":"__in","instanceof":"__instanceOf","<<":"__bitwiseLSHIFT",">>":"__bitwiseRSHIFT",">>>":"__zeroFillRSHIFT","-":"__minus","*":"__multiply","%":"__modulus","/":"__divide","u-":"__unaryNegation","u+":"__unaryAddition","~":"__bitwiseNOT","++":"__increment","--":"__decrement","!":"__unaryNOT","+=":"__addAssign","-=":"__minusAssign","*=":"__multiplyAssign","/=":"__divideAssign","%=":"__modulusAssign","<<=":"__leftShiftAssign",">>=":"__rightShiftAssign",">>>=":"__zeroFillRightShiftAssign","&=":"__andAssign","|=":"__orAssign","^=":"__xorAssign"}; //Do the magic -Function.prototype.enableOverloading=function(){ +t.exports=n=function(e){ //Generate AST -var e=p.parse("var fn = "+this); +var t=m.parse("var fn = "+e); //Check for AST -if(!e)throw new Error("Invalid code block! Cannot overload. AST Generation Error."); +if(!t)throw new Error("Invalid code block! Cannot overload. AST Generation Error."); //Fetch arguments -var t=e.body[0].declarations[0].init.params.reduce(function(e,t){return e.push(t.name),e},[]),n=e.body[0].declarations[0].init.body,r={type:"Program",body:n.body}; +var n=t.body[0].declarations[0].init.params.reduce(function(e,t){return e.push(t.name),e},[]),i=t.body[0].declarations[0].init.body,o={type:"Program",body:i.body}; //Transform -r.body.forEach(function(e,t){c(e,t,r)}), +o.body.forEach(function(e,t){p(e,t,o)}), //Build new function args -t.push(d.generate(r,{comment:!0,format:{indent:{style:" "}}}));var o=Function.apply(this,t);return console.log(JSON.stringify(r,null,4)),console.log(o.toString()),o}; +n.push(h.generate(o,{comment:!0,format:{indent:{style:" "}}}));var a=Function.apply(e,n);return r.env.OVERLOAD_DEBUG&&console.log(JSON.stringify(o,null,4)),r.env.OVERLOAD_DEBUG&&console.log(a.toString()),a}; //Load defaults -var h=[Object,Number,String,Function,RegExp];h.forEach(function(e){f(e,m["+"],function(e){return e+this}),f(e,m["=="],function(e){return e==this}),f(e,m["==="],function(e){return e===this}),f(e,m["||"],function(e){return e||this}),f(e,m["&&"],function(e){return e&&this}),f(e,m["&"],function(e){return e&this}),f(e,m["|"],function(e){return e|this}),f(e,m["^"],function(e){return e^this}),f(e,m["!="],function(e){return e!=this}),f(e,m["!=="],function(e){return e!==this}),f(e,m["<"],function(e){return this>e}),f(e,m[">"],function(e){return e>this}),f(e,m[">>"],function(e){return e>>this}),f(e,m["<<"],function(e){return e<>>"],function(e){return e>>>this}),f(e,m["<="],function(e){return this>=e}),f(e,m[">="],function(e){return e>=this}),f(e,m["in"],function(e){return e in this}),f(e,m["instanceof"],function(e){return e instanceof this}),f(e,m["-"],function(e){return e-this}),f(e,m["*"],function(e){return e*this}),f(e,m["%"],function(e){return e%this}),f(e,m["/"],function(e){return e/this}),f(e,m["u-"],function(){return-this}),f(e,m["u+"],function(){return+this}),f(e,m["~"],function(){return~this}),f(e,m["++"],function(){var e=this;return++e,e}),f(e,m["--"],function(){var e=this;return--e,e}),f(e,m["!"],function(){return!this}),f(e,m["+="],function(e){return e+=this}),f(e,m["-="],function(e){return e-=this}),f(e,m["*="],function(e){return e*=this}),f(e,m["/="],function(e){return e/=this}),f(e,m["%="],function(e){return e%=this}),f(e,m["<<="],function(e){return e<<=this}),f(e,m[">>="],function(e){return e>>=this}),f(e,m[">>>="],function(e){return e>>>=this}),f(e,m["&="],function(e){return e&=this}),f(e,m["|="],function(e){return e|=this}),f(e,m["^="],function(e){return e^=this})})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_f4a727e3.js","/")},{"1YiZ5S":24,buffer:20,escodegen:2,esprima:19}],2:[function(e,t,n){(function(t,r,o,i,a,s,l,u,c){/* +var y=[Object,Number,String,Function,RegExp];y.forEach(function(e){d(e,g["+"],function(e){return e+this}),d(e,g["=="],function(e){return e==this}),d(e,g["==="],function(e){return e===this}),d(e,g["||"],function(e){return e||this}),d(e,g["&&"],function(e){return e&&this}),d(e,g["&"],function(e){return e&this}),d(e,g["|"],function(e){return e|this}),d(e,g["^"],function(e){return e^this}),d(e,g["!="],function(e){return e!=this}),d(e,g["!=="],function(e){return e!==this}),d(e,g["<"],function(e){return this>e}),d(e,g[">"],function(e){return e>this}),d(e,g[">>"],function(e){return e>>this}),d(e,g["<<"],function(e){return e<>>"],function(e){return e>>>this}),d(e,g["<="],function(e){return this>=e}),d(e,g[">="],function(e){return e>=this}),d(e,g["in"],function(e){return e in this}),d(e,g["instanceof"],function(e){return e instanceof this}),d(e,g["-"],function(e){return e-this}),d(e,g["*"],function(e){return e*this}),d(e,g["%"],function(e){return e%this}),d(e,g["/"],function(e){return e/this}),d(e,g["u-"],function(){return-this}),d(e,g["u+"],function(){return+this}),d(e,g["~"],function(){return~this}),d(e,g["++"],function(){var e=this;return++e,e}),d(e,g["--"],function(){var e=this;return--e,e}),d(e,g["!"],function(){return!this}),d(e,g["+="],function(e){return e+=this}),d(e,g["-="],function(e){return e-=this}),d(e,g["*="],function(e){return e*=this}),d(e,g["/="],function(e){return e/=this}),d(e,g["%="],function(e){return e%=this}),d(e,g["<<="],function(e){return e<<=this}),d(e,g[">>="],function(e){return e>>=this}),d(e,g[">>>="],function(e){return e>>>=this}),d(e,g["&="],function(e){return e&=this}),d(e,g["|="],function(e){return e|=this}),d(e,g["^="],function(e){return e^=this})}),/* jshint ignore:end */ +n.functionNames=g}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_61dd2044.js","/")},{"1YiZ5S":25,buffer:21,escodegen:2,esprima:20}],2:[function(e,t,n){(function(t,r,i,o,a,s,u,l,c){/* Copyright (C) 2012-2014 Yusuke Suzuki + Copyright (C) 2015 Ingvar Stepanyan + Copyright (C) 2014 Ivan Nikulin Copyright (C) 2012-2013 Michael Ficarra Copyright (C) 2012-2013 Mathias Bynens Copyright (C) 2013 Irakli Gozalishvili @@ -52,142 +55,52 @@ var h=[Object,Number,String,Function,RegExp];h.forEach(function(e){f(e,m["+"],fu /*global exports:true, require:true, global:true*/ !function(){"use strict"; // Generation is done by generateExpression. -function t(e){switch(e.type){case V.AssignmentExpression:case V.ArrayExpression:case V.ArrayPattern:case V.BinaryExpression:case V.CallExpression:case V.ConditionalExpression:case V.ClassExpression:case V.ExportBatchSpecifier:case V.ExportSpecifier:case V.FunctionExpression:case V.Identifier:case V.ImportSpecifier:case V.Literal:case V.LogicalExpression:case V.MemberExpression:case V.MethodDefinition:case V.NewExpression:case V.ObjectExpression:case V.ObjectPattern:case V.Property:case V.SequenceExpression:case V.ThisExpression:case V.UnaryExpression:case V.UpdateExpression:case V.YieldExpression:return!0}return!1} +function t(e){return M.Expression.hasOwnProperty(e.type)} // Generation is done by generateStatement. -function o(e){switch(e.type){case V.BlockStatement:case V.BreakStatement:case V.CatchClause:case V.ContinueStatement:case V.ClassDeclaration:case V.ClassBody:case V.DirectiveStatement:case V.DoWhileStatement:case V.DebuggerStatement:case V.EmptyStatement:case V.ExpressionStatement:case V.ForStatement:case V.ForInStatement:case V.ForOfStatement:case V.FunctionDeclaration:case V.IfStatement:case V.LabeledStatement:case V.ModuleDeclaration:case V.Program:case V.ReturnStatement:case V.SwitchStatement:case V.SwitchCase:case V.ThrowStatement:case V.TryStatement:case V.VariableDeclaration:case V.VariableDeclarator:case V.WhileStatement:case V.WithStatement:return!0}return!1}function i(){ +function i(e){return M.Statement.hasOwnProperty(e.type)}function o(){ // default options -return{indent:null,base:null,parse:null,comment:!1,format:{indent:{style:" ",base:0,adjustMultilineComment:!1},newline:"\n",space:" ",json:!1,renumber:!1,hexadecimal:!1,quotes:"single",escapeless:!1,compact:!1,parentheses:!0,semicolons:!0,safeConcatenation:!1},moz:{comprehensionExpressionStartsWithAssignment:!1,starlessGenerator:!1},sourceMap:null,sourceMapRoot:null,sourceMapWithCode:!1,directive:!1,raw:!0,verbatim:null}}function a(e,t){var n="";for(t|=0;t>0;t>>>=1,e+=e)1&t&&(n+=e);return n}function s(e){return/[\r\n]/g.test(e)}function l(e){var t=e.length;return t&&X.code.isLineTerminator(e.charCodeAt(t-1))}function u(e,t){function n(e){return"object"==typeof e&&e instanceof Object&&!(e instanceof RegExp)}var r,o;for(r in t)t.hasOwnProperty(r)&&(o=t[r],n(o)?n(e[r])?u(e[r],o):e[r]=u({},o):e[r]=o);return e}function c(e){var t,n,r,o,i;if(e!==e)throw new Error("Numeric literal whose value is NaN");if(0>e||0===e&&0>1/e)throw new Error("Numeric literal whose value is negative");if(e===1/0)return ne?"null":re?"1e400":"1e+400";if(t=""+e,!re||t.length<3)return t;for(n=t.indexOf("."),ne||48!==t.charCodeAt(0)||1!==n||(n=0,t=t.slice(1)),r=t,t=t.replace("e+","e"),o=0,(i=r.indexOf("e"))>0&&(o=+r.slice(i+1),r=r.slice(0,i)),n>=0&&(o-=r.length-n-1,r=+(r.slice(0,n)+r.slice(n+1))+""),i=0;48===r.charCodeAt(r.length+i-1);)--i;return 0!==i&&(o-=i,r=r.slice(0,i)),0!==o&&(r+="e"+o),(r.length1e12&&Math.floor(e)===e&&(r="0x"+e.toString(16)).length0;t>>>=1,e+=e)1&t&&(n+=e);return n}function s(e){return/[\r\n]/g.test(e)}function u(e){var t=e.length;return t&&G.code.isLineTerminator(e.charCodeAt(t-1))}function l(e,t){var n;for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function c(e,t){function n(e){return"object"==typeof e&&e instanceof Object&&!(e instanceof RegExp)}var r,i;for(r in t)t.hasOwnProperty(r)&&(i=t[r],n(i)?n(e[r])?c(e[r],i):e[r]=c({},i):e[r]=i);return e}function f(e){var t,n,r,i,o;if(e!==e)throw new Error("Numeric literal whose value is NaN");if(0>e||0===e&&0>1/e)throw new Error("Numeric literal whose value is negative");if(e===1/0)return K?"null":H?"1e400":"1e+400";if(t=""+e,!H||t.length<3)return t;for(n=t.indexOf("."),K||48!==t.charCodeAt(0)||1!==n||(n=0,t=t.slice(1)),r=t,t=t.replace("e+","e"),i=0,(o=r.indexOf("e"))>0&&(i=+r.slice(o+1),r=r.slice(0,o)),n>=0&&(i-=r.length-n-1,r=+(r.slice(0,n)+r.slice(n+1))+""),o=0;48===r.charCodeAt(r.length+o-1);)--o;return 0!==o&&(i-=o,r=r.slice(0,o)),0!==i&&(r+="e"+i),(r.length1e12&&Math.floor(e)===e&&(r="0x"+e.toString(16)).lengtho;++o)a=e.source.charCodeAt(o),l?( -// if new RegExp("\\\n') is provided, create /\n/ -n+=f(a,l), -// prevent like /\\[/]/ -l=!1):(s?93===a&&(// ] -s=!1):47===a?// / -n+="\\":91===a&&(// [ -s=!0),n+=f(a,l),l=92===a);return"/"+n+"/"+r}return n}function d(e,t){var n,r="\\";switch(e){case 8:r+="b";break;case 12:r+="f";break;case 9:r+="t";break;default:n=e.toString(16).toUpperCase(),r+=ne||e>255?"u"+"0000".slice(n.length)+n:0!==e||X.code.isDecimalDigit(t)?11===e?"x0B":"x"+"00".slice(n.length)+n:"0"}return r}function m(e){var t="\\";switch(e){case 92:t+="\\";break;case 10:t+="n";break;case 13:t+="r";break;case 8232:t+="u2028";break;case 8233:t+="u2029";break;default:throw new Error("Incorrectly classified character")}return t}function h(e){var t,n,r,o;for(o="double"===ie?'"':"'",t=0,n=e.length;n>t;++t){if(r=e.charCodeAt(t),39===r){o='"';break}if(34===r){o="'";break}92===r&&++t}return o+e+o}function g(e){var t,n,r,o,i,a="",s=0,l=0;for(t=0,n=e.length;n>t;++t){if(r=e.charCodeAt(t),39===r)++s;else if(34===r)++l;else if(47===r&&ne)a+="\\";else{if(X.code.isLineTerminator(r)||92===r){a+=m(r);continue}if(ne&&32>r||!(ne||ae||r>=32&&126>=r)){a+=d(r,e.charCodeAt(t+1));continue}}a+=String.fromCharCode(r)}if(o=!("double"===ie||"auto"===ie&&s>l),i=o?"'":'"',!(o?s:l))return i+a+i;for(e=a,a=i,t=0,n=e.length;n>t;++t)r=e.charCodeAt(t),(39===r&&o||34===r&&!o)&&(a+="\\"),a+=String.fromCharCode(r);return a+i}/** +return 8232===(-2&e)?(t?"u":"\\u")+(8232===e?"2028":"2029"):10===e||13===e?(t?"":"\\")+(10===e?"n":"r"):String.fromCharCode(e)}function d(e){var t,n,r,i,o,a,s,u;if(n=e.toString(),e.source){if(t=n.match(/\/([^\/]*)$/),!t)return n;for(r=t[1],n="",s=!1,u=!1,i=0,o=e.source.length;o>i;++i)a=e.source.charCodeAt(i),u?(n+=p(a,u),u=!1):(s?93===a&&(s=!1):47===a?n+="\\":91===a&&(s=!0),n+=p(a,u),u=92===a);return"/"+n+"/"+r}return n}function m(e,t){var n;return 8===e?"\\b":12===e?"\\f":9===e?"\\t":(n=e.toString(16).toUpperCase(),K||e>255?"\\u"+"0000".slice(n.length)+n:0!==e||G.code.isDecimalDigit(t)?11===e?"\\x0B":"\\x"+"00".slice(n.length)+n:"\\0")}function h(e){if(92===e)return"\\\\";if(10===e)return"\\n";if(13===e)return"\\r";if(8232===e)return"\\u2028";if(8233===e)return"\\u2029";throw new Error("Incorrectly classified character")}function g(e){var t,n,r,i;for(i="double"===J?'"':"'",t=0,n=e.length;n>t;++t){if(r=e.charCodeAt(t),39===r){i='"';break}if(34===r){i="'";break}92===r&&++t}return i+e+i}function y(e){var t,n,r,i,o,a="",s=0,u=0;for(t=0,n=e.length;n>t;++t){if(r=e.charCodeAt(t),39===r)++s;else if(34===r)++u;else if(47===r&&K)a+="\\";else{if(G.code.isLineTerminator(r)||92===r){a+=h(r);continue}if(K&&32>r||!(K||X||r>=32&&126>=r)){a+=m(r,e.charCodeAt(t+1));continue}}a+=String.fromCharCode(r)}if(i=!("double"===J||"auto"===J&&s>u),o=i?"'":'"',!(i?s:u))return o+a+o;for(e=a,a=o,t=0,n=e.length;n>t;++t)r=e.charCodeAt(t),(39===r&&i||34===r&&!i)&&(a+="\\"),a+=String.fromCharCode(r);return a+o}/** * flatten an array to a string, where the array can contain * either strings or nested arrays */ -function y(e){var t,n,r,o="";for(t=0,n=e.length;n>t;++t)r=e[t],o+=Q(r)?y(r):r;return o}/** +function b(e){var t,n,r,i="";for(t=0,n=e.length;n>t;++t)r=e[t],i+=Z(r)?b(r):r;return i}/** * convert generated to a SourceNode when source maps are enabled. */ -function w(e,t){if(!he) +function v(e,t){if(!se) // with no source maps, generated is either an // array or a string. if an array, flatten it. // if a string, just return it // with no source maps, generated is either an // array or a string. if an array, flatten it. // if a string, just return it -return Q(e)?y(e):e;if(null==t){if(e instanceof $)return e;t={}}return null==t.loc?new $(null,null,he,e,t.name||null):new $(t.loc.start.line,t.loc.start.column,he===!0?t.loc.source||null:he,e,t.name||null)}function b(){return le?le:" "}function S(e,t){var n,r,o,i;return n=w(e).toString(),0===n.length?[t]:(r=w(t).toString(),0===r.length?[e]:(o=n.charCodeAt(n.length-1),i=r.charCodeAt(0),(43===o||45===o)&&o===i||X.code.isIdentifierPart(o)&&X.code.isIdentifierPart(i)||47===o&&105===i?[e,b(),t]:X.code.isWhiteSpace(o)||X.code.isLineTerminator(o)||X.code.isWhiteSpace(i)||X.code.isLineTerminator(i)?[e,t]:[e,le,t]))}function v(e){return[ee,e]}function E(e){var t,n;return t=ee,ee+=te,n=e.call(this,ee),ee=t,n}function C(e){var t;for(t=e.length-1;t>=0&&!X.code.isLineTerminator(e.charCodeAt(t));--t);return e.length-1-t}function x(e,t){var n,r,o,i,a,s,l,u; +return Z(e)?b(e):e;if(null==t){if(e instanceof W)return e;t={}}return null==t.loc?new W(null,null,se,e,t.name||null):new W(t.loc.start.line,t.loc.start.column,se===!0?t.loc.source||null:se,e,t.name||null)}function S(){return ee?ee:" "}function w(e,t){var n,r,i,o;return n=v(e).toString(),0===n.length?[t]:(r=v(t).toString(),0===r.length?[e]:(i=n.charCodeAt(n.length-1),o=r.charCodeAt(0),(43===i||45===i)&&i===o||G.code.isIdentifierPart(i)&&G.code.isIdentifierPart(o)||47===i&&105===o?[e,S(),t]:G.code.isWhiteSpace(i)||G.code.isLineTerminator(i)||G.code.isWhiteSpace(o)||G.code.isLineTerminator(o)?[e,t]:[e,ee,t]))}function E(e){return[V,e]}function x(e){var t;t=V,V+=z,e(V),V=t}function _(e){var t;for(t=e.length-1;t>=0&&!G.code.isLineTerminator(e.charCodeAt(t));--t);return e.length-1-t}function C(e,t){var n,r,i,o,a,s,u,l; // first line doesn't have indentation -for(n=e.split(/\r\n|[\r\n]/),s=Number.MAX_VALUE,r=1,o=n.length;o>r;++r){for(i=n[r],a=0;aa&&(s=a)}for("undefined"!=typeof t?( -// pattern like -// { -// var t = 20; /* -// * this is comment -// */ -// } -l=ee,"*"===n[1][s]&&(t+=" "),ee=t):(1&s&& +for(n=e.split(/\r\n|[\r\n]/),s=Number.MAX_VALUE,r=1,i=n.length;i>r;++r){for(o=n[r],a=0;aa&&(s=a)}for("undefined"!=typeof t?(u=V,"*"===n[1][s]&&(t+=" "),V=t):(1&s&& // /* // * // */ // If spaces are odd number, above pattern is considered. // We waste 1 space. ---s,l=ee),r=1,o=n.length;o>r;++r)u=w(v(n[r].slice(s))),n[r]=he?u.join(""):u;return ee=l,n.join("\n")}function _(e,t){return"Line"===e.type?l(e.value)?"//"+e.value:"//"+e.value+"\n":de.format.indent.adjustMultilineComment&&/[\n\r]/.test(e.value)?x("/*"+e.value+"*/",t):"/*"+e.value+"*/"}function k(e,t){var n,r,o,i,s,u,c;if(e.leadingComments&&e.leadingComments.length>0){for(i=t,o=e.leadingComments[0],t=[],fe&&e.type===V.Program&&0===e.body.length&&t.push("\n"),t.push(_(o)),l(w(t).toString())||t.push("\n"),n=1,r=e.leadingComments.length;r>n;++n)o=e.leadingComments[n],c=[_(o)],l(w(c).toString())||c.push("\n"),t.push(v(c));t.push(v(i))}if(e.trailingComments)for(s=!l(w(t).toString()),u=a(" ",C(w([ee,t,te]).toString())),n=0,r=e.trailingComments.length;r>n;++n)o=e.trailingComments[n],s?( -// We assume target like following script -// -// var t = 20; /** -// * This is comment of t -// */ -// first case -t=0===n?[t,te]:[t,u],t.push(_(o,u))):t=[t,v(_(o))],n===r-1||l(w(t).toString())||(t=[t,"\n"]);return t}function I(e,t,n){return n>t?["(",e,")"]:e}function A(e,t,n){var r,o;return o=!de.comment||!e.leadingComments,e.type===V.BlockStatement&&o?[le,G(e,{functionBody:n})]:e.type===V.EmptyStatement&&o?";":(E(function(){r=[se,v(G(e,{semicolonOptional:t,functionBody:n}))]}),r)}function L(e,t){var n=l(w(t).toString());return e.type!==V.BlockStatement||de.comment&&e.leadingComments||n?n?[t,ee]:[t,se,ee]:[t,le]}function B(e){var t,n,r;for(r=e.split(/\r\n|\n/),t=1,n=r.length;n>t;t++)r[t]=se+ee+r[t];return r}function D(e,t){var n,r,o; +--s,u=V),r=1,i=n.length;i>r;++r)l=v(E(n[r].slice(s))),n[r]=se?l.join(""):l;return V=u,n.join("\n")}function k(e,t){if("Line"===e.type){if(u(e.value))return"//"+e.value; +// Always use LineTerminator +var n="//"+e.value;return le||(n+="\n"),n}return oe.format.indent.adjustMultilineComment&&/[\n\r]/.test(e.value)?C("/*"+e.value+"*/",t):"/*"+e.value+"*/"}function A(e,t){var n,r,i,o,s,l,c,f,p,d,m,h,g,y;if(e.leadingComments&&e.leadingComments.length>0){if(o=t,le){for(i=e.leadingComments[0],t=[],f=i.extendedRange,p=i.range,m=ue.substring(f[0],p[0]),y=(m.match(/\n/g)||[]).length,y>0?(t.push(a("\n",y)),t.push(E(k(i)))):(t.push(m),t.push(k(i))),d=p,n=1,r=e.leadingComments.length;r>n;n++)i=e.leadingComments[n],p=i.range,h=ue.substring(d[1],p[0]),y=(h.match(/\n/g)||[]).length,t.push(a("\n",y)),t.push(E(k(i))),d=p;g=ue.substring(p[1],f[1]),y=(g.match(/\n/g)||[]).length,t.push(a("\n",y))}else for(i=e.leadingComments[0],t=[],re&&e.type===j.Program&&0===e.body.length&&t.push("\n"),t.push(k(i)),u(v(t).toString())||t.push("\n"),n=1,r=e.leadingComments.length;r>n;++n)i=e.leadingComments[n],c=[k(i)],u(v(c).toString())||c.push("\n"),t.push(E(c));t.push(E(o))}if(e.trailingComments)if(le)i=e.trailingComments[0],f=i.extendedRange,p=i.range,m=ue.substring(f[0],p[0]),y=(m.match(/\n/g)||[]).length,y>0?(t.push(a("\n",y)),t.push(E(k(i)))):(t.push(m),t.push(k(i)));else for(s=!u(v(t).toString()),l=a(" ",_(v([V,t,z]).toString())),n=0,r=e.trailingComments.length;r>n;++n)i=e.trailingComments[n],s?(t=0===n?[t,z]:[t,l],t.push(k(i,l))):t=[t,E(k(i))],n===r-1||u(v(t).toString())||(t=[t,"\n"]);return t}function I(e,t,n){var r,i=0;for(r=e;t>r;r++)"\n"===ue[r]&&i++;for(r=1;i>r;r++)n.push(Q)}function L(e,t,n){return n>t?["(",e,")"]:e}function B(e){var t,n,r;for(r=e.split(/\r\n|\n/),t=1,n=r.length;n>t;t++)r[t]=Q+V+r[t];return r}function R(e,t){var n,r,i; // verbatim is object -return n=e[de.verbatim],"string"==typeof n?r=I(B(n),H.Sequence,t.precedence):(r=B(n.content),o=null!=n.precedence?n.precedence:H.Sequence,r=I(r,o,t.precedence)),w(r,e)}function O(e){return w(e.name,e)}function T(e,t){var n;return n=e.type===V.Identifier?O(e):W(e,{precedence:t.precedence,allowIn:t.allowIn,allowCall:!0})}function P(e){var t,n,r,o;if(o=!1,e.type!==V.ArrowFunctionExpression||e.rest||e.defaults&&0!==e.defaults.length||1!==e.params.length||e.params[0].type!==V.Identifier){for(r=["("],e.defaults&&(o=!0),t=0,n=e.params.length;n>t;++t) -// Handle default values. -r.push(o&&e.defaults[t]?q(e.params[t],e.defaults[t],"=",{precedence:H.Assignment,allowIn:!0,allowCall:!0}):T(e.params[t],{precedence:H.Assignment,allowIn:!0,allowCall:!0})),n>t+1&&r.push(","+le);e.rest&&(e.params.length&&r.push(","+le),r.push("..."),r.push(O(e.rest,{precedence:H.Assignment,allowIn:!0,allowCall:!0}))),r.push(")")}else -// arg => { } case -r=[O(e.params[0])];return r}function M(e){var t,n;return t=P(e),e.type===V.ArrowFunctionExpression&&(t.push(le),t.push("=>")),e.expression?(t.push(le),n=W(e.body,{precedence:H.Assignment,allowIn:!0,allowCall:!0}),"{"===n.toString().charAt(0)&&(n=["(",n,")"]),t.push(n)):t.push(A(e.body,!1,!0)),t}function R(e,t,n){var r=["for"+le+"("];return E(function(){t.left.type===V.VariableDeclaration?E(function(){r.push(t.left.kind+b()),r.push(G(t.left.declarations[0],{allowIn:!1}))}):r.push(W(t.left,{precedence:H.Call,allowIn:!0,allowCall:!0})),r=S(r,e),r=[S(r,W(t.right,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),")"]}),r.push(A(t.body,n)),r}function N(e,t,n){function r(){for(s=e.declarations[0],de.comment&&s.leadingComments?(o.push("\n"),o.push(v(G(s,{allowIn:n})))):(o.push(b()),o.push(G(s,{allowIn:n}))),i=1,a=e.declarations.length;a>i;++i)s=e.declarations[i],de.comment&&s.leadingComments?(o.push(","+se),o.push(v(G(s,{allowIn:n})))):(o.push(","+le),o.push(G(s,{allowIn:n})))}var o,i,a,s;return o=[e.kind],e.declarations.length>1?E(r):r(),o.push(t),o}function F(e){var t=["{",se];return E(function(n){var r,o;for(r=0,o=e.body.length;o>r;++r)t.push(n),t.push(W(e.body[r],{precedence:H.Sequence,allowIn:!0,allowCall:!0,type:V.Property})),o>r+1&&t.push(se)}),l(w(t).toString())||t.push(se),t.push(ee),t.push("}"),t}function U(e){var t;if(e.hasOwnProperty("raw")&&me&&de.raw)try{if(t=me(e.raw).body[0].expression,t.type===V.Literal&&t.value===e.value)return e.raw}catch(n){}return null===e.value?"null":"string"==typeof e.value?g(e.value):"number"==typeof e.value?c(e.value):"boolean"==typeof e.value?e.value?"true":"false":p(e.value)}function j(e,t,n){var r=[];return t&&r.push("["),r.push(W(e,n)),t&&r.push("]"),r}function q(e,t,n,r){var o,i;return i=r.precedence,o=r.allowIn||H.Assignmenta;++a)n.push(W(e.expressions[a],{precedence:H.Assignment,allowIn:h,allowCall:!0})),u>a+1&&n.push(","+le);n=I(n,H.Sequence,r);break;case V.AssignmentExpression:n=q(e.left,e.right,e.operator,t);break;case V.ArrowFunctionExpression:h|=H.ArrowFunctioni,c=W(e.left,{precedence:i,allowIn:h,allowCall:!0}),d=c.toString(),n=47===d.charCodeAt(d.length-1)&&X.code.isIdentifierPart(e.operator.charCodeAt(0))?[c,b(),e.operator]:S(c,e.operator),c=W(e.right,{precedence:i+1,allowIn:h,allowCall:!0}),"/"===e.operator&&"/"===c.toString().charAt(0)||"<"===e.operator.slice(-1)&&"!--"===c.toString().slice(0,3)?( -// If '/' concats with '/' or `<` concats with `!--`, it is interpreted as comment start -n.push(b()),n.push(c)):n=S(n,c),n="in"!==e.operator||h?I(n,i,r):["(",n,")"];break;case V.CallExpression:for(n=[W(e.callee,{precedence:H.Call,allowIn:!0,allowCall:!0,allowUnparenthesizedNew:!1})],n.push("("),a=0,u=e.arguments.length;u>a;++a)n.push(W(e.arguments[a],{precedence:H.Assignment,allowIn:!0,allowCall:!0})),u>a+1&&n.push(","+le);n.push(")"),n=g?I(n,H.Call,r):["(",n,")"];break;case V.NewExpression:if(u=e.arguments.length,y=void 0===t.allowUnparenthesizedNew||t.allowUnparenthesizedNew,n=S("new",W(e.callee,{precedence:H.New,allowIn:!0,allowCall:!1,allowUnparenthesizedNew:y&&!ue&&0===u})),!y||ue||u>0){for(n.push("("),a=0;u>a;++a)n.push(W(e.arguments[a],{precedence:H.Assignment,allowIn:!0,allowCall:!0})),u>a+1&&n.push(","+le);n.push(")")}n=I(n,H.New,r);break;case V.MemberExpression:n=[W(e.object,{precedence:H.Call,allowIn:!0,allowCall:g,allowUnparenthesizedNew:!1})],e.computed?(n.push("["),n.push(W(e.property,{precedence:H.Sequence,allowIn:!0,allowCall:g})),n.push("]")):(e.object.type===V.Literal&&"number"==typeof e.object.value&&(c=w(n).toString(), -// When the following conditions are all true, -// 1. No floating point -// 2. Don't have exponents -// 3. The last character is a decimal digit -// 4. Not hexadecimal OR octal number literal -// we should add a floating point. -c.indexOf(".")<0&&!/[eExX]/.test(c)&&X.code.isDecimalDigit(c.charCodeAt(c.length-1))&&!(c.length>=2&&48===c.charCodeAt(0))&&n.push(".")),n.push("."),n.push(O(e.property))),n=I(n,H.Member,r);break;case V.UnaryExpression:c=W(e.argument,{precedence:H.Unary,allowIn:!0,allowCall:!0}),""===le?n=S(e.operator,c):(n=[e.operator],e.operator.length>2? -// delete, void, typeof -// get `typeof []`, not `typeof[]` -n=S(n,c):( -// Prevent inserting spaces between operator and argument if it is unnecessary -// like, `!cond` -d=w(n).toString(),p=d.charCodeAt(d.length-1),m=c.toString().charCodeAt(0),(43===p||45===p)&&p===m||X.code.isIdentifierPart(p)&&X.code.isIdentifierPart(m)?(n.push(b()),n.push(c)):n.push(c))),n=I(n,H.Unary,r);break;case V.YieldExpression:n=e.delegate?"yield*":"yield",e.argument&&(n=S(n,W(e.argument,{precedence:H.Yield,allowIn:!0,allowCall:!0}))),n=I(n,H.Yield,r);break;case V.UpdateExpression:n=e.prefix?I([e.operator,W(e.argument,{precedence:H.Unary,allowIn:!0,allowCall:!0})],H.Unary,r):I([W(e.argument,{precedence:H.Postfix,allowIn:!0,allowCall:!0}),e.operator],H.Postfix,r);break;case V.FunctionExpression:C=e.generator&&!de.moz.starlessGenerator,n=C?"function*":"function",n=e.id?[n,C?le:b(),O(e.id),M(e)]:[n+le,M(e)];break;case V.ExportBatchSpecifier:n="*";break;case V.ArrayPattern:case V.ArrayExpression:if(!e.elements.length){n="[]";break}f=e.elements.length>1,n=["[",f?se:""],E(function(t){for(a=0,u=e.elements.length;u>a;++a)e.elements[a]?(n.push(f?t:""),n.push(W(e.elements[a],{precedence:H.Assignment,allowIn:!0,allowCall:!0}))):(f&&n.push(t),a+1===u&&n.push(",")),u>a+1&&n.push(","+(f?se:le))}),f&&!l(w(n).toString())&&n.push(se),n.push(f?ee:""),n.push("]");break;case V.ClassExpression:n=["class"],e.id&&(n=S(n,W(e.id,{allowIn:!0,allowCall:!0}))),e.superClass&&(c=S("extends",W(e.superClass,{precedence:H.Assignment,allowIn:!0,allowCall:!0})),n=S(n,c)),n.push(le),n.push(G(e.body,{semicolonOptional:!0,directiveContext:!1}));break;case V.MethodDefinition:n=e["static"]?["static"+le]:[],"get"===e.kind||"set"===e.kind?n=S(n,[S(e.kind,j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),M(e.value)]):(c=[j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),M(e.value)],e.value.generator?(n.push("*"),n.push(c)):n=S(n,c));break;case V.Property:"get"===e.kind||"set"===e.kind?n=[e.kind,b(),j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),M(e.value)]:e.shorthand?n=j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0}):e.method?(n=[],e.value.generator&&n.push("*"),n.push(j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),n.push(M(e.value))):n=[j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),":"+le,W(e.value,{precedence:H.Assignment,allowIn:!0,allowCall:!0})];break;case V.ObjectExpression:if(!e.properties.length){n="{}";break}if(f=e.properties.length>1,E(function(){c=W(e.properties[0],{precedence:H.Sequence,allowIn:!0,allowCall:!0,type:V.Property})}),!f&&!s(w(c).toString())){n=["{",le,c,le,"}"];break}E(function(t){if(n=["{",se,t,c],f)for(n.push(","+se),a=1,u=e.properties.length;u>a;++a)n.push(t),n.push(W(e.properties[a],{precedence:H.Sequence,allowIn:!0,allowCall:!0,type:V.Property})),u>a+1&&n.push(","+se)}),l(w(n).toString())||n.push(se),n.push(ee),n.push("}");break;case V.ObjectPattern:if(!e.properties.length){n="{}";break}if(f=!1,1===e.properties.length)v=e.properties[0],v.value.type!==V.Identifier&&(f=!0);else for(a=0,u=e.properties.length;u>a;++a)if(v=e.properties[a],!v.shorthand){f=!0;break}n=["{",f?se:""],E(function(t){for(a=0,u=e.properties.length;u>a;++a)n.push(f?t:""),n.push(W(e.properties[a],{precedence:H.Sequence,allowIn:!0,allowCall:!0})),u>a+1&&n.push(","+(f?se:le))}),f&&!l(w(n).toString())&&n.push(se),n.push(f?ee:""),n.push("}");break;case V.ThisExpression:n="this";break;case V.Identifier:n=O(e);break;case V.ImportSpecifier:case V.ExportSpecifier:n=[e.id.name],e.name&&n.push(b()+"as"+b()+e.name.name);break;case V.Literal:n=U(e);break;case V.GeneratorExpression:case V.ComprehensionExpression: -// GeneratorExpression should be parenthesized with (...), ComprehensionExpression with [...] -// Due to https://bugzilla.mozilla.org/show_bug.cgi?id=883468 position of expr.body can differ in Spidermonkey and ES6 -n=o===V.GeneratorExpression?["("]:["["],de.moz.comprehensionExpressionStartsWithAssignment&&(c=W(e.body,{precedence:H.Assignment,allowIn:!0,allowCall:!0}),n.push(c)),e.blocks&&E(function(){for(a=0,u=e.blocks.length;u>a;++a)c=W(e.blocks[a],{precedence:H.Sequence,allowIn:!0,allowCall:!0}),a>0||de.moz.comprehensionExpressionStartsWithAssignment?n=S(n,c):n.push(c)}),e.filter&&(n=S(n,"if"+le),c=W(e.filter,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),n=S(n,["(",c,")"])),de.moz.comprehensionExpressionStartsWithAssignment||(c=W(e.body,{precedence:H.Assignment,allowIn:!0,allowCall:!0}),n=S(n,c)),n.push(o===V.GeneratorExpression?")":"]");break;case V.ComprehensionBlock:c=e.left.type===V.VariableDeclaration?[e.left.kind,b(),G(e.left.declarations[0],{allowIn:!1})]:W(e.left,{precedence:H.Call,allowIn:!0,allowCall:!0}),c=S(c,e.of?"of":"in"),c=S(c,W(e.right,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),n=["for"+le+"(",c,")"];break;case V.SpreadElement:n=["...",W(e.argument,{precedence:H.Assignment,allowIn:!0,allowCall:!0})];break;case V.TaggedTemplateExpression:n=[W(e.tag,{precedence:H.Call,allowIn:!0,allowCall:g,allowUnparenthesizedNew:!1}),W(e.quasi,{precedence:H.Primary})],n=I(n,H.TaggedTemplate,r);break;case V.TemplateElement: -// Don't use "cooked". Since tagged template can use raw template -// representation. So if we do so, it breaks the script semantics. -n=e.value.raw;break;case V.TemplateLiteral:for(n=["`"],a=0,u=e.quasis.length;u>a;++a)n.push(W(e.quasis[a],{precedence:H.Primary,allowIn:!0,allowCall:!0})),u>a+1&&(n.push("${"+le),n.push(W(e.expressions[a],{precedence:H.Sequence,allowIn:!0,allowCall:!0})),n.push(le+"}"));n.push("`");break;default:throw new Error("Unknown expression type: "+e.type)}return de.comment&&(n=k(e,n)),w(n,e)} -// ES6: 15.2.1 valid import declarations: -// - import ImportClause FromClause ; -// - import ModuleSpecifier ; -function Y(e,t){var n,r; -// If no ImportClause is present, -// this should be `import ModuleSpecifier` so skip `from` -// ModuleSpecifier is StringLiteral. -// If no ImportClause is present, -// this should be `import ModuleSpecifier` so skip `from` -// ModuleSpecifier is StringLiteral. -// import ImportClause FromClause ; -// ImportedBinding -// NamedImports -// import { ... } from "..."; -// import { -// ..., -// ..., -// } from "..."; -return 0===e.specifiers.length?["import",le,U(e.source),t]:(n=["import"],r=0,e.specifiers[0]["default"]&&(n=S(n,[e.specifiers[0].id.name]),++r),e.specifiers[r]&&(0!==r&&n.push(","),n.push(le+"{"),e.specifiers.length-r===1?(n.push(le),n.push(W(e.specifiers[r],{precedence:H.Sequence,allowIn:!0,allowCall:!0})),n.push(le+"}"+le)):(E(function(t){var o,i;for(n.push(se),o=r,i=e.specifiers.length;i>o;++o)n.push(t),n.push(W(e.specifiers[o],{precedence:H.Sequence,allowIn:!0,allowCall:!0})),i>o+1&&n.push(","+se)}),l(w(n).toString())||n.push(se),n.push(ee+"}"+le))),n=S(n,["from"+le,U(e.source),t]))}function G(e,t){var n,r,o,i,a,s,u,c,f,p;switch(i=!0,c=";",a=!1,s=!1,t&&(i=void 0===t.allowIn||t.allowIn,ce||t.semicolonOptional!==!0||(c=""),a=t.functionBody,s=t.directiveContext),e.type){case V.BlockStatement:o=["{",se],E(function(){for(n=0,r=e.body.length;r>n;++n)u=v(G(e.body[n],{semicolonOptional:n===r-1,directiveContext:a})),o.push(u),l(w(u).toString())||o.push(se)}),o.push(v("}"));break;case V.BreakStatement:o=e.label?"break "+e.label.name+c:"break"+c;break;case V.ContinueStatement:o=e.label?"continue "+e.label.name+c:"continue"+c;break;case V.ClassBody:o=F(e);break;case V.ClassDeclaration:o=["class "+e.id.name],e.superClass&&(u=S("extends",W(e.superClass,{precedence:H.Assignment,allowIn:!0,allowCall:!0})),o=S(o,u)),o.push(le),o.push(G(e.body,{semicolonOptional:!0,directiveContext:!1}));break;case V.DirectiveStatement:o=de.raw&&e.raw?e.raw+c:h(e.directive)+c;break;case V.DoWhileStatement: -// Because `do 42 while (cond)` is Syntax Error. We need semicolon. -o=S("do",A(e.body)),o=L(e.body,o),o=S(o,["while"+le+"(",W(e.test,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"+c]);break;case V.CatchClause:E(function(){var t;o=["catch"+le+"(",W(e.param,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"],e.guard&&(t=W(e.guard,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),o.splice(2,0," if ",t))}),o.push(A(e.body));break;case V.DebuggerStatement:o="debugger"+c;break;case V.EmptyStatement:o=";";break;case V.ExportDeclaration: -// export default AssignmentExpression[In] ; -if(o=["export"],e["default"]){o=S(o,"default"),o=S(o,W(e.declaration,{precedence:H.Assignment,allowIn:!0,allowCall:!0})+c);break} -// export * FromClause ; -// export ExportClause[NoReference] FromClause ; -// export ExportClause ; -if(e.specifiers){0===e.specifiers.length?o=S(o,"{"+le+"}"):e.specifiers[0].type===V.ExportBatchSpecifier?o=S(o,W(e.specifiers[0],{precedence:H.Sequence,allowIn:!0,allowCall:!0})):(o=S(o,"{"),E(function(t){var n,r;for(o.push(se),n=0,r=e.specifiers.length;r>n;++n)o.push(t),o.push(W(e.specifiers[n],{precedence:H.Sequence,allowIn:!0,allowCall:!0})),r>n+1&&o.push(","+se)}),l(w(o).toString())||o.push(se),o.push(ee+"}")),e.source?o=S(o,["from"+le,U(e.source),c]):o.push(c);break} -// export VariableStatement -// export Declaration[Default] -e.declaration&&(o=S(o,G(e.declaration,{semicolonOptional:""===c})));break;case V.ExpressionStatement:o=[W(e.expression,{precedence:H.Sequence,allowIn:!0,allowCall:!0})], -// 12.4 '{', 'function', 'class' is not allowed in this position. -// wrap expression with parentheses -u=w(o).toString(),"{"===u.charAt(0)||// ObjectExpression -"class"===u.slice(0,5)&&" {".indexOf(u.charAt(5))>=0||// class -"function"===u.slice(0,8)&&"* (".indexOf(u.charAt(8))>=0||// function or generator -pe&&s&&e.expression.type===V.Literal&&"string"==typeof e.expression.value?o=["(",o,")"+c]:o.push(c);break;case V.ImportDeclaration:o=Y(e,c);break;case V.VariableDeclarator:o=e.init?[W(e.id,{precedence:H.Assignment,allowIn:i,allowCall:!0}),le,"=",le,W(e.init,{precedence:H.Assignment,allowIn:i,allowCall:!0})]:T(e.id,{precedence:H.Assignment,allowIn:i});break;case V.VariableDeclaration: -// VariableDeclarator is typed as Statement, -// but joined with comma (not LineTerminator). -// So if comment is attached to target node, we should specialize. -o=N(e,c,i);break;case V.ThrowStatement:o=[S("throw",W(e.argument,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),c];break;case V.TryStatement:if(o=["try",A(e.block)],o=L(e.block,o),e.handlers) -// old interface -for(n=0,r=e.handlers.length;r>n;++n)o=S(o,G(e.handlers[n])),(e.finalizer||n+1!==r)&&(o=L(e.handlers[n].body,o));else{for(p=e.guardedHandlers||[],n=0,r=p.length;r>n;++n)o=S(o,G(p[n])),(e.finalizer||n+1!==r)&&(o=L(p[n].body,o)); -// new interface -if(e.handler)if(Q(e.handler))for(n=0,r=e.handler.length;r>n;++n)o=S(o,G(e.handler[n])),(e.finalizer||n+1!==r)&&(o=L(e.handler[n].body,o));else o=S(o,G(e.handler)),e.finalizer&&(o=L(e.handler.body,o))}e.finalizer&&(o=S(o,["finally",A(e.finalizer)]));break;case V.SwitchStatement:if(E(function(){o=["switch"+le+"(",W(e.discriminant,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"+le+"{"+se]}),e.cases)for(n=0,r=e.cases.length;r>n;++n)u=v(G(e.cases[n],{semicolonOptional:n===r-1})),o.push(u),l(w(u).toString())||o.push(se);o.push(v("}"));break;case V.SwitchCase:E(function(){for(o=e.test?[S("case",W(e.test,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),":"]:["default:"],n=0,r=e.consequent.length,r&&e.consequent[0].type===V.BlockStatement&&(u=A(e.consequent[0]),o.push(u),n=1),n===r||l(w(o).toString())||o.push(se);r>n;++n)u=v(G(e.consequent[n],{semicolonOptional:n===r-1&&""===c})),o.push(u),n+1===r||l(w(u).toString())||o.push(se)});break;case V.IfStatement:E(function(){o=["if"+le+"(",W(e.test,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"]}),e.alternate?(o.push(A(e.consequent)),o=L(e.consequent,o),o=e.alternate.type===V.IfStatement?S(o,["else ",G(e.alternate,{semicolonOptional:""===c})]):S(o,S("else",A(e.alternate,""===c)))):o.push(A(e.consequent,""===c));break;case V.ForStatement:E(function(){o=["for"+le+"("],e.init?e.init.type===V.VariableDeclaration?o.push(G(e.init,{allowIn:!1})):(o.push(W(e.init,{precedence:H.Sequence,allowIn:!1,allowCall:!0})),o.push(";")):o.push(";"),e.test?(o.push(le),o.push(W(e.test,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),o.push(";")):o.push(";"),e.update?(o.push(le),o.push(W(e.update,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),o.push(")")):o.push(")")}),o.push(A(e.body,""===c));break;case V.ForInStatement:o=R("in",e,""===c);break;case V.ForOfStatement:o=R("of",e,""===c);break;case V.LabeledStatement:o=[e.label.name+":",A(e.body,""===c)];break;case V.ModuleDeclaration:o=["module",b(),e.id.name,b(),"from",le,U(e.source),c];break;case V.Program:for(r=e.body.length,o=[fe&&r>0?"\n":""],n=0;r>n;++n)u=v(G(e.body[n],{semicolonOptional:!fe&&n===r-1,directiveContext:!0})),o.push(u),r>n+1&&!l(w(u).toString())&&o.push(se);break;case V.FunctionDeclaration:f=e.generator&&!de.moz.starlessGenerator,o=[f?"function*":"function",f?le:b(),O(e.id),M(e)];break;case V.ReturnStatement:o=e.argument?[S("return",W(e.argument,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),c]:["return"+c];break;case V.WhileStatement:E(function(){o=["while"+le+"(",W(e.test,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"]}),o.push(A(e.body,""===c));break;case V.WithStatement:E(function(){o=["with"+le+"(",W(e.object,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"]}),o.push(A(e.body,""===c));break;default:throw new Error("Unknown statement type: "+e.type)} -// Attach comments -return de.comment&&(o=k(e,o)),u=w(o).toString(),e.type!==V.Program||fe||""!==se||"\n"!==u.charAt(u.length-1)||(o=he?w(o).replaceRight(/\s+$/,""):u.replace(/\s+$/,"")),w(o,e)}function Z(e){if(o(e))return G(e);if(t(e))return W(e,{precedence:H.Sequence,allowIn:!0,allowCall:!0});throw new Error("Unknown node type: "+e.type)}function z(t,o){var s,l,c=i(); +return n=e[oe.verbatim],"string"==typeof n?r=L(B(n),U.Sequence,t):(r=B(n.content),i=null!=n.precedence?n.precedence:U.Sequence,r=L(r,i,t)),v(r,e)}function M(){}function P(e){return v(e.name,e)}function O(e,t){return e.async?"async"+(t?S():ee):""}function D(e){var t=e.generator&&!oe.moz.starlessGenerator;return t?"*"+ee:""}function N(e){var t=e.value;return t.async?O(t,!e.computed):D(t)?"*":""}function T(e){var n;if(n=new M,i(e))return n.generateStatement(e,_e);if(t(e))return n.generateExpression(e,U.Sequence,Se);throw new Error("Unknown node type: "+e.type)}function F(t,i){var s,u,l=o(); // Obsolete options // // `options.indent` // `options.base` // // Instead of them, we can use `option.format.indent`. -return null!=o?("string"==typeof o.indent&&(c.format.indent.style=o.indent),"number"==typeof o.base&&(c.format.indent.base=o.base),o=u(c,o),te=o.format.indent.style,ee="string"==typeof o.base?o.base:a(te,o.format.indent.base)):(o=c,te=o.format.indent.style,ee=a(te,o.format.indent.base)),ne=o.format.json,re=o.format.renumber,oe=ne?!1:o.format.hexadecimal,ie=ne?"double":o.format.quotes,ae=o.format.escapeless,se=o.format.newline,le=o.format.space,o.format.compact&&(se=le=te=ee=""),ue=o.format.parentheses,ce=o.format.semicolons,fe=o.format.safeConcatenation,pe=o.directive,me=ne?null:o.parse,he=o.sourceMap,de=o,he&&($=n.browser?r.sourceMap.SourceNode:e("source-map").SourceNode),s=Z(t),he?(l=s.toStringWithSourceMap({file:o.file,sourceRoot:o.sourceMapRoot}),o.sourceContent&&l.map.setSourceContent(o.sourceMap,o.sourceContent),o.sourceMapWithCode?l:l.map.toString()):(l={code:s.toString(),map:null},o.sourceMapWithCode?l:l.code)}var V,H,K,$,J,X,Q,ee,te,ne,re,oe,ie,ae,se,le,ue,ce,fe,pe,de,me,he,ge,ye;J=e("estraverse"),X=e("esutils"),V={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExportBatchSpecifier:"ExportBatchSpecifier",ExportDeclaration:"ExportDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportSpecifier:"ImportSpecifier",ImportDeclaration:"ImportDeclaration",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MethodDefinition:"MethodDefinition",ModuleDeclaration:"ModuleDeclaration",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},H={Sequence:0,Yield:1,Assignment:1,Conditional:2,ArrowFunction:2,LogicalOR:3,LogicalAND:4,BitwiseOR:5,BitwiseXOR:6,BitwiseAND:7,Equality:8,Relational:9,BitwiseSHIFT:10,Additive:11,Multiplicative:12,Unary:13,Postfix:14,Call:15,New:16,TaggedTemplate:17,Member:18,Primary:19},K={"||":H.LogicalOR,"&&":H.LogicalAND,"|":H.BitwiseOR,"^":H.BitwiseXOR,"&":H.BitwiseAND,"==":H.Equality,"!=":H.Equality,"===":H.Equality,"!==":H.Equality,is:H.Equality,isnt:H.Equality,"<":H.Relational,">":H.Relational,"<=":H.Relational,">=":H.Relational,"in":H.Relational,"instanceof":H.Relational,"<<":H.BitwiseSHIFT,">>":H.BitwiseSHIFT,">>>":H.BitwiseSHIFT,"+":H.Additive,"-":H.Additive,"*":H.Multiplicative,"%":H.Multiplicative,"/":H.Multiplicative},Q=Array.isArray,Q||(Q=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),ge={indent:{style:"",base:0},renumber:!0,hexadecimal:!0,quotes:"auto",escapeless:!0,compact:!0,parentheses:!1,semicolons:!1},ye=i().format,n.version=e("./package.json").version,n.generate=z,n.attachComments=J.attachComments,n.Precedence=u({},H),n.browser=!1,n.FORMAT_MINIFY=ge,n.FORMAT_DEFAULTS=ye}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/escodegen.js","/../node_modules/escodegen")},{"./package.json":18,"1YiZ5S":24,buffer:20,estraverse:3,esutils:7,"source-map":8}],3:[function(e,t,n){(function(e,t,r,o,i,a,s,l,u){/* +return null!=i?("string"==typeof i.indent&&(l.format.indent.style=i.indent),"number"==typeof i.base&&(l.format.indent.base=i.base),i=c(l,i),z=i.format.indent.style,V="string"==typeof i.base?i.base:a(z,i.format.indent.base)):(i=l,z=i.format.indent.style,V=a(z,i.format.indent.base)),K=i.format.json,H=i.format.renumber,$=K?!1:i.format.hexadecimal,J=K?"double":i.format.quotes,X=i.format.escapeless,Q=i.format.newline,ee=i.format.space,i.format.compact&&(Q=ee=z=V=""),te=i.format.parentheses,ne=i.format.semicolons,re=i.format.safeConcatenation,ie=i.directive,ae=K?null:i.parse,se=i.sourceMap,ue=i.sourceCode,le=i.format.preserveBlankLines&&null!==ue,oe=i,se&&(W=n.browser?r.sourceMap.SourceNode:e("source-map").SourceNode),s=T(t),se?(u=s.toStringWithSourceMap({file:i.file,sourceRoot:i.sourceMapRoot}),i.sourceContent&&u.map.setSourceContent(i.sourceMap,i.sourceContent),i.sourceMapWithCode?u:u.map.toString()):(u={code:s.toString(),map:null},i.sourceMapWithCode?u:u.code)}var j,U,q,W,Y,G,Z,V,z,K,H,$,J,X,Q,ee,te,ne,re,ie,oe,ae,se,ue,le,ce,fe;Y=e("estraverse"),G=e("esutils"),j=Y.Syntax,U={Sequence:0,Yield:1,Await:1,Assignment:1,Conditional:2,ArrowFunction:2,LogicalOR:3,LogicalAND:4,BitwiseOR:5,BitwiseXOR:6,BitwiseAND:7,Equality:8,Relational:9,BitwiseSHIFT:10,Additive:11,Multiplicative:12,Unary:13,Postfix:14,Call:15,New:16,TaggedTemplate:17,Member:18,Primary:19},q={"||":U.LogicalOR,"&&":U.LogicalAND,"|":U.BitwiseOR,"^":U.BitwiseXOR,"&":U.BitwiseAND,"==":U.Equality,"!=":U.Equality,"===":U.Equality,"!==":U.Equality,is:U.Equality,isnt:U.Equality,"<":U.Relational,">":U.Relational,"<=":U.Relational,">=":U.Relational,"in":U.Relational,"instanceof":U.Relational,"<<":U.BitwiseSHIFT,">>":U.BitwiseSHIFT,">>>":U.BitwiseSHIFT,"+":U.Additive,"-":U.Additive,"*":U.Multiplicative,"%":U.Multiplicative,"/":U.Multiplicative}; +//Flags +var pe=1,de=2,me=4,he=8,ge=16,ye=32,be=de|me,ve=pe|de,Se=pe|de|me,we=pe,Ee=me,xe=pe|me,_e=pe,Ce=pe|ye,ke=0,Ae=pe|ge,Ie=pe|he;Z=Array.isArray,Z||(Z=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),M.prototype.maybeBlock=function(e,t){var n,r,i=this;return r=!oe.comment||!e.leadingComments,e.type===j.BlockStatement&&r?[ee,this.generateStatement(e,t)]:e.type===j.EmptyStatement&&r?";":(x(function(){n=[Q,E(i.generateStatement(e,t))]}),n)},M.prototype.maybeBlockSuffix=function(e,t){var n=u(v(t).toString());return e.type!==j.BlockStatement||oe.comment&&e.leadingComments||n?n?[t,V]:[t,Q,V]:[t,ee]},M.prototype.generatePattern=function(e,t,n){return e.type===j.Identifier?P(e):this.generateExpression(e,t,n)},M.prototype.generateFunctionParams=function(e){var t,n,r,i;if(i=!1,e.type!==j.ArrowFunctionExpression||e.rest||e.defaults&&0!==e.defaults.length||1!==e.params.length||e.params[0].type!==j.Identifier){for(r=e.type===j.ArrowFunctionExpression?[O(e,!1)]:[],r.push("("),e.defaults&&(i=!0),t=0,n=e.params.length;n>t;++t)i&&e.defaults[t]?r.push(this.generateAssignment(e.params[t],e.defaults[t],"=",U.Assignment,Se)):r.push(this.generatePattern(e.params[t],U.Assignment,Se)),n>t+1&&r.push(","+ee);e.rest&&(e.params.length&&r.push(","+ee),r.push("..."),r.push(P(e.rest))),r.push(")")}else r=[O(e,!0),P(e.params[0])];return r},M.prototype.generateFunctionBody=function(e){var t,n;return t=this.generateFunctionParams(e),e.type===j.ArrowFunctionExpression&&(t.push(ee),t.push("=>")),e.expression?(t.push(ee),n=this.generateExpression(e.body,U.Assignment,Se),"{"===n.toString().charAt(0)&&(n=["(",n,")"]),t.push(n)):t.push(this.maybeBlock(e.body,Ie)),t},M.prototype.generateIterationForStatement=function(e,t,n){var r=["for"+ee+"("],i=this;return x(function(){t.left.type===j.VariableDeclaration?x(function(){r.push(t.left.kind+S()),r.push(i.generateStatement(t.left.declarations[0],ke))}):r.push(i.generateExpression(t.left,U.Call,Se)),r=w(r,e),r=[w(r,i.generateExpression(t.right,U.Sequence,Se)),")"]}),r.push(this.maybeBlock(t.body,n)),r},M.prototype.generatePropertyKey=function(e,t){var n=[];return t&&n.push("["),n.push(this.generateExpression(e,U.Sequence,Se)),t&&n.push("]"),n},M.prototype.generateAssignment=function(e,t,n,r,i){return U.Assignment2&&(r=ue.substring(n[0]+1,n[1]-1),"\n"===r[0]&&(i=["{"]),i.push(r)));var a,s,l,c;for(c=_e,t&he&&(c|=ge),a=0,s=e.body.length;s>a;++a)le&&(0===a&&(e.body[0].leadingComments&&(n=e.body[0].leadingComments[0].extendedRange,r=ue.substring(n[0],n[1]),"\n"===r[0]&&(i=["{"])),e.body[0].leadingComments||I(e.range[0],e.body[0].range[0],i)),a>0&&(e.body[a-1].trailingComments||e.body[a].leadingComments||I(e.body[a-1].range[1],e.body[a].range[0],i))),a===s-1&&(c|=ye),l=e.body[a].leadingComments&&le?o.generateStatement(e.body[a],c):E(o.generateStatement(e.body[a],c)),i.push(l),u(v(l).toString())||(le&&s-1>a?e.body[a+1].leadingComments||i.push(Q):i.push(Q)),le&&a===s-1&&(e.body[a].trailingComments||I(e.body[a].range[1],e.range[1],i))}),i.push(E("}")),i},BreakStatement:function(e,t){return e.label?"break "+e.label.name+this.semicolon(t):"break"+this.semicolon(t)},ContinueStatement:function(e,t){return e.label?"continue "+e.label.name+this.semicolon(t):"continue"+this.semicolon(t)},ClassBody:function(e,t){var n=["{",Q],r=this;return x(function(t){var i,o;for(i=0,o=e.body.length;o>i;++i)n.push(t),n.push(r.generateExpression(e.body[i],U.Sequence,Se)),o>i+1&&n.push(Q)}),u(v(n).toString())||n.push(Q),n.push(V),n.push("}"),n},ClassDeclaration:function(e,t){var n,r;return n=["class "+e.id.name],e.superClass&&(r=w("extends",this.generateExpression(e.superClass,U.Assignment,Se)),n=w(n,r)),n.push(ee),n.push(this.generateStatement(e.body,Ce)),n},DirectiveStatement:function(e,t){return oe.raw&&e.raw?e.raw+this.semicolon(t):g(e.directive)+this.semicolon(t)},DoWhileStatement:function(e,t){var n=w("do",this.maybeBlock(e.body,_e));return n=this.maybeBlockSuffix(e.body,n),w(n,["while"+ee+"(",this.generateExpression(e.test,U.Sequence,Se),")"+this.semicolon(t)])},CatchClause:function(e,t){var n,r=this;return x(function(){var t;n=["catch"+ee+"(",r.generateExpression(e.param,U.Sequence,Se),")"],e.guard&&(t=r.generateExpression(e.guard,U.Sequence,Se),n.splice(2,0," if ",t))}),n.push(this.maybeBlock(e.body,_e)),n},DebuggerStatement:function(e,t){return"debugger"+this.semicolon(t)},EmptyStatement:function(e,t){return";"},ExportDeclaration:function(e,t){var n,r=["export"],o=this;return n=t&ye?Ce:_e,e["default"]?(r=w(r,"default"),r=i(e.declaration)?w(r,this.generateStatement(e.declaration,n)):w(r,this.generateExpression(e.declaration,U.Assignment,Se)+this.semicolon(t))):e.declaration?w(r,this.generateStatement(e.declaration,n)):(e.specifiers&&(0===e.specifiers.length?r=w(r,"{"+ee+"}"):e.specifiers[0].type===j.ExportBatchSpecifier?r=w(r,this.generateExpression(e.specifiers[0],U.Sequence,Se)):(r=w(r,"{"),x(function(t){var n,i;for(r.push(Q),n=0,i=e.specifiers.length;i>n;++n)r.push(t),r.push(o.generateExpression(e.specifiers[n],U.Sequence,Se)),i>n+1&&r.push(","+Q)}),u(v(r).toString())||r.push(Q),r.push(V+"}")),e.source?r=w(r,["from"+ee,this.generateExpression(e.source,U.Sequence,Se),this.semicolon(t)]):r.push(this.semicolon(t))),r)},ExpressionStatement:function(e,t){function n(e){var t;return"class"!==e.slice(0,5)?!1:(t=e.charCodeAt(5),123===t||G.code.isWhiteSpace(t)||G.code.isLineTerminator(t))}function r(e){var t;return"function"!==e.slice(0,8)?!1:(t=e.charCodeAt(8),40===t||G.code.isWhiteSpace(t)||42===t||G.code.isLineTerminator(t))}function i(e){var t,n,r;if("async"!==e.slice(0,5))return!1;if(!G.code.isWhiteSpace(e.charCodeAt(5)))return!1;for(n=6,r=e.length;r>n&&G.code.isWhiteSpace(e.charCodeAt(n));++n);return n===r?!1:"function"!==e.slice(n,n+8)?!1:(t=e.charCodeAt(n+8),40===t||G.code.isWhiteSpace(t)||42===t||G.code.isLineTerminator(t))}var o,a;return o=[this.generateExpression(e.expression,U.Sequence,Se)],a=v(o).toString(),123===a.charCodeAt(0)||n(a)||r(a)||i(a)||ie&&t&ge&&e.expression.type===j.Literal&&"string"==typeof e.expression.value?o=["(",o,")"+this.semicolon(t)]:o.push(this.semicolon(t)),o},ImportDeclaration:function(e,t){var n,r,i=this;return 0===e.specifiers.length?["import",ee,this.generateExpression(e.source,U.Sequence,Se),this.semicolon(t)]:(n=["import"],r=0,e.specifiers[r].type===j.ImportDefaultSpecifier&&(n=w(n,[this.generateExpression(e.specifiers[r],U.Sequence,Se)]),++r),e.specifiers[r]&&(0!==r&&n.push(","),e.specifiers[r].type===j.ImportNamespaceSpecifier?n=w(n,[ee,this.generateExpression(e.specifiers[r],U.Sequence,Se)]):(n.push(ee+"{"),e.specifiers.length-r===1?(n.push(ee),n.push(this.generateExpression(e.specifiers[r],U.Sequence,Se)),n.push(ee+"}"+ee)):(x(function(t){var o,a;for(n.push(Q),o=r,a=e.specifiers.length;a>o;++o)n.push(t),n.push(i.generateExpression(e.specifiers[o],U.Sequence,Se)),a>o+1&&n.push(","+Q)}),u(v(n).toString())||n.push(Q),n.push(V+"}"+ee)))),n=w(n,["from"+ee,this.generateExpression(e.source,U.Sequence,Se),this.semicolon(t)]))},VariableDeclarator:function(e,t){var n=t&pe?Se:be;return e.init?[this.generateExpression(e.id,U.Assignment,n),ee,"=",ee,this.generateExpression(e.init,U.Assignment,n)]:this.generatePattern(e.id,U.Assignment,n)},VariableDeclaration:function(e,t){function n(){for(a=e.declarations[0],oe.comment&&a.leadingComments?(r.push("\n"),r.push(E(u.generateStatement(a,s)))):(r.push(S()),r.push(u.generateStatement(a,s))),i=1,o=e.declarations.length;o>i;++i)a=e.declarations[i],oe.comment&&a.leadingComments?(r.push(","+Q),r.push(E(u.generateStatement(a,s)))):(r.push(","+ee),r.push(u.generateStatement(a,s)))}var r,i,o,a,s,u=this;return r=[e.kind],s=t&pe?_e:ke,e.declarations.length>1?x(n):n(),r.push(this.semicolon(t)),r},ThrowStatement:function(e,t){return[w("throw",this.generateExpression(e.argument,U.Sequence,Se)),this.semicolon(t)]},TryStatement:function(e,t){var n,r,i,o;if(n=["try",this.maybeBlock(e.block,_e)],n=this.maybeBlockSuffix(e.block,n),e.handlers)for(r=0,i=e.handlers.length;i>r;++r)n=w(n,this.generateStatement(e.handlers[r],_e)),(e.finalizer||r+1!==i)&&(n=this.maybeBlockSuffix(e.handlers[r].body,n));else{for(o=e.guardedHandlers||[],r=0,i=o.length;i>r;++r)n=w(n,this.generateStatement(o[r],_e)),(e.finalizer||r+1!==i)&&(n=this.maybeBlockSuffix(o[r].body,n));if(e.handler)if(Z(e.handler))for(r=0,i=e.handler.length;i>r;++r)n=w(n,this.generateStatement(e.handler[r],_e)),(e.finalizer||r+1!==i)&&(n=this.maybeBlockSuffix(e.handler[r].body,n));else n=w(n,this.generateStatement(e.handler,_e)),e.finalizer&&(n=this.maybeBlockSuffix(e.handler.body,n))}return e.finalizer&&(n=w(n,["finally",this.maybeBlock(e.finalizer,_e)])),n},SwitchStatement:function(e,t){var n,r,i,o,a,s=this;if(x(function(){n=["switch"+ee+"(",s.generateExpression(e.discriminant,U.Sequence,Se),")"+ee+"{"+Q]}),e.cases)for(a=_e,i=0,o=e.cases.length;o>i;++i)i===o-1&&(a|=ye),r=E(this.generateStatement(e.cases[i],a)),n.push(r),u(v(r).toString())||n.push(Q);return n.push(E("}")),n},SwitchCase:function(e,t){var n,r,i,o,a,s=this;return x(function(){for(n=e.test?[w("case",s.generateExpression(e.test,U.Sequence,Se)),":"]:["default:"],i=0,o=e.consequent.length,o&&e.consequent[0].type===j.BlockStatement&&(r=s.maybeBlock(e.consequent[0],_e),n.push(r),i=1),i===o||u(v(n).toString())||n.push(Q),a=_e;o>i;++i)i===o-1&&t&ye&&(a|=ye),r=E(s.generateStatement(e.consequent[i],a)),n.push(r),i+1===o||u(v(r).toString())||n.push(Q)}),n},IfStatement:function(e,t){var n,r,i,o=this;return x(function(){n=["if"+ee+"(",o.generateExpression(e.test,U.Sequence,Se),")"]}),i=t&ye,r=_e,i&&(r|=ye),e.alternate?(n.push(this.maybeBlock(e.consequent,_e)),n=this.maybeBlockSuffix(e.consequent,n),n=e.alternate.type===j.IfStatement?w(n,["else ",this.generateStatement(e.alternate,r)]):w(n,w("else",this.maybeBlock(e.alternate,r)))):n.push(this.maybeBlock(e.consequent,r)),n},ForStatement:function(e,t){var n,r=this;return x(function(){n=["for"+ee+"("],e.init?e.init.type===j.VariableDeclaration?n.push(r.generateStatement(e.init,ke)):(n.push(r.generateExpression(e.init,U.Sequence,be)),n.push(";")):n.push(";"),e.test?(n.push(ee),n.push(r.generateExpression(e.test,U.Sequence,Se)),n.push(";")):n.push(";"),e.update?(n.push(ee),n.push(r.generateExpression(e.update,U.Sequence,Se)),n.push(")")):n.push(")")}),n.push(this.maybeBlock(e.body,t&ye?Ce:_e)),n},ForInStatement:function(e,t){return this.generateIterationForStatement("in",e,t&ye?Ce:_e)},ForOfStatement:function(e,t){return this.generateIterationForStatement("of",e,t&ye?Ce:_e)},LabeledStatement:function(e,t){return[e.label.name+":",this.maybeBlock(e.body,t&ye?Ce:_e)]},Program:function(e,t){var n,r,i,o,a;for(o=e.body.length,n=[re&&o>0?"\n":""],a=Ae,i=0;o>i;++i)re||i!==o-1||(a|=ye),le&&(0===i&&(e.body[0].leadingComments||I(e.range[0],e.body[i].range[0],n)),i>0&&(e.body[i-1].trailingComments||e.body[i].leadingComments||I(e.body[i-1].range[1],e.body[i].range[0],n))),r=E(this.generateStatement(e.body[i],a)),n.push(r),o>i+1&&!u(v(r).toString())&&(le?e.body[i+1].leadingComments||n.push(Q):n.push(Q)),le&&i===o-1&&(e.body[i].trailingComments||I(e.body[i].range[1],e.range[1],n));return n},FunctionDeclaration:function(e,t){return[O(e,!0),"function",D(e)||S(),P(e.id),this.generateFunctionBody(e)]},ReturnStatement:function(e,t){return e.argument?[w("return",this.generateExpression(e.argument,U.Sequence,Se)),this.semicolon(t)]:["return"+this.semicolon(t)]},WhileStatement:function(e,t){var n,r=this;return x(function(){n=["while"+ee+"(",r.generateExpression(e.test,U.Sequence,Se),")"]}),n.push(this.maybeBlock(e.body,t&ye?Ce:_e)),n},WithStatement:function(e,t){var n,r=this;return x(function(){n=["with"+ee+"(",r.generateExpression(e.object,U.Sequence,Se),")"]}),n.push(this.maybeBlock(e.body,t&ye?Ce:_e)),n}},l(M.prototype,M.Statement),M.Expression={SequenceExpression:function(e,t,n){var r,i,o;for(U.Sequencei;++i)r.push(this.generateExpression(e.expressions[i],U.Assignment,n)),o>i+1&&r.push(","+ee);return L(r,U.Sequence,t)},AssignmentExpression:function(e,t,n){return this.generateAssignment(e.left,e.right,e.operator,t,n)},ArrowFunctionExpression:function(e,t,n){return L(this.generateFunctionBody(e),U.ArrowFunction,t)},ConditionalExpression:function(e,t,n){return U.Conditionali&&(n|=pe),o=this.generateExpression(e.left,i,n),a=o.toString(),r=47===a.charCodeAt(a.length-1)&&G.code.isIdentifierPart(e.operator.charCodeAt(0))?[o,S(),e.operator]:w(o,e.operator),o=this.generateExpression(e.right,i+1,n),"/"===e.operator&&"/"===o.toString().charAt(0)||"<"===e.operator.slice(-1)&&"!--"===o.toString().slice(0,3)?(r.push(S()),r.push(o)):r=w(r,o),"in"!==e.operator||n&pe?L(r,i,t):["(",r,")"]},CallExpression:function(e,t,n){var r,i,o;for(r=[this.generateExpression(e.callee,U.Call,ve)],r.push("("),i=0,o=e.arguments.length;o>i;++i)r.push(this.generateExpression(e.arguments[i],U.Assignment,Se)),o>i+1&&r.push(","+ee);return r.push(")"),n&de?L(r,U.Call,t):["(",r,")"]},NewExpression:function(e,t,n){var r,i,o,a,s;if(i=e.arguments.length,s=n&me&&!te&&0===i?xe:we,r=w("new",this.generateExpression(e.callee,U.New,s)),!(n&me)||te||i>0){for(r.push("("),o=0,a=i;a>o;++o)r.push(this.generateExpression(e.arguments[o],U.Assignment,Se)),a>o+1&&r.push(","+ee);r.push(")")}return L(r,U.New,t)},MemberExpression:function(e,t,n){var r,i;return r=[this.generateExpression(e.object,U.Call,n&de?ve:we)],e.computed?(r.push("["),r.push(this.generateExpression(e.property,U.Sequence,n&de?Se:xe)),r.push("]")):(e.object.type===j.Literal&&"number"==typeof e.object.value&&(i=v(r).toString(),i.indexOf(".")<0&&!/[eExX]/.test(i)&&G.code.isDecimalDigit(i.charCodeAt(i.length-1))&&!(i.length>=2&&48===i.charCodeAt(0))&&r.push(".")),r.push("."),r.push(P(e.property))),L(r,U.Member,t)},UnaryExpression:function(e,t,n){var r,i,o,a,s;return i=this.generateExpression(e.argument,U.Unary,Se),""===ee?r=w(e.operator,i):(r=[e.operator],e.operator.length>2?r=w(r,i):(a=v(r).toString(),s=a.charCodeAt(a.length-1),o=i.toString().charCodeAt(0),(43===s||45===s)&&s===o||G.code.isIdentifierPart(s)&&G.code.isIdentifierPart(o)?(r.push(S()),r.push(i)):r.push(i))),L(r,U.Unary,t)},YieldExpression:function(e,t,n){var r;return r=e.delegate?"yield*":"yield",e.argument&&(r=w(r,this.generateExpression(e.argument,U.Yield,Se))),L(r,U.Yield,t)},AwaitExpression:function(e,t,n){var r=w(e.delegate?"await*":"await",this.generateExpression(e.argument,U.Await,Se));return L(r,U.Await,t)},UpdateExpression:function(e,t,n){return e.prefix?L([e.operator,this.generateExpression(e.argument,U.Unary,Se)],U.Unary,t):L([this.generateExpression(e.argument,U.Postfix,Se),e.operator],U.Postfix,t)},FunctionExpression:function(e,t,n){var r=[O(e,!0),"function"];return e.id?(r.push(D(e)||S()),r.push(P(e.id))):r.push(D(e)||ee),r.push(this.generateFunctionBody(e)),r},ExportBatchSpecifier:function(e,t,n){return"*"},ArrayPattern:function(e,t,n){return this.ArrayExpression(e,t,n)},ArrayExpression:function(e,t,n){var r,i,o=this;return e.elements.length?(i=e.elements.length>1,r=["[",i?Q:""],x(function(t){var n,a;for(n=0,a=e.elements.length;a>n;++n)e.elements[n]?(r.push(i?t:""),r.push(o.generateExpression(e.elements[n],U.Assignment,Se))):(i&&r.push(t),n+1===a&&r.push(",")),a>n+1&&r.push(","+(i?Q:ee))}),i&&!u(v(r).toString())&&r.push(Q),r.push(i?V:""),r.push("]"),r):"[]"},ClassExpression:function(e,t,n){var r,i;return r=["class"],e.id&&(r=w(r,this.generateExpression(e.id,U.Sequence,Se))),e.superClass&&(i=w("extends",this.generateExpression(e.superClass,U.Assignment,Se)),r=w(r,i)),r.push(ee),r.push(this.generateStatement(e.body,Ce)),r},MethodDefinition:function(e,t,n){var r,i;return r=e["static"]?["static"+ee]:[],i="get"===e.kind||"set"===e.kind?[w(e.kind,this.generatePropertyKey(e.key,e.computed)),this.generateFunctionBody(e.value)]:[N(e),this.generatePropertyKey(e.key,e.computed),this.generateFunctionBody(e.value)],w(r,i)},Property:function(e,t,n){return"get"===e.kind||"set"===e.kind?[e.kind,S(),this.generatePropertyKey(e.key,e.computed),this.generateFunctionBody(e.value)]:e.shorthand?this.generatePropertyKey(e.key,e.computed):e.method?[N(e),this.generatePropertyKey(e.key,e.computed),this.generateFunctionBody(e.value)]:[this.generatePropertyKey(e.key,e.computed),":"+ee,this.generateExpression(e.value,U.Assignment,Se)]},ObjectExpression:function(e,t,n){var r,i,o,a=this;return e.properties.length?(r=e.properties.length>1,x(function(){o=a.generateExpression(e.properties[0],U.Sequence,Se)}),r||s(v(o).toString())?(x(function(t){var n,s;if(i=["{",Q,t,o],r)for(i.push(","+Q),n=1,s=e.properties.length;s>n;++n)i.push(t),i.push(a.generateExpression(e.properties[n],U.Sequence,Se)),s>n+1&&i.push(","+Q)}),u(v(i).toString())||i.push(Q),i.push(V),i.push("}"),i):["{",ee,o,ee,"}"]):"{}"},ObjectPattern:function(e,t,n){var r,i,o,a,s,l=this;if(!e.properties.length)return"{}";if(a=!1,1===e.properties.length)s=e.properties[0],s.value.type!==j.Identifier&&(a=!0);else for(i=0,o=e.properties.length;o>i;++i)if(s=e.properties[i],!s.shorthand){a=!0;break}return r=["{",a?Q:""],x(function(t){var n,i;for(n=0,i=e.properties.length;i>n;++n)r.push(a?t:""),r.push(l.generateExpression(e.properties[n],U.Sequence,Se)),i>n+1&&r.push(","+(a?Q:ee))}),a&&!u(v(r).toString())&&r.push(Q),r.push(a?V:""),r.push("}"),r},ThisExpression:function(e,t,n){return"this"},Identifier:function(e,t,n){return P(e)},ImportDefaultSpecifier:function(e,t,n){return P(e.id)},ImportNamespaceSpecifier:function(e,t,n){var r=["*"];return e.id&&r.push(ee+"as"+S()+P(e.id)),r},ImportSpecifier:function(e,t,n){return this.ExportSpecifier(e,t,n)},ExportSpecifier:function(e,t,n){var r=[e.id.name];return e.name&&r.push(S()+"as"+S()+P(e.name)),r},Literal:function(e,t,n){var r;if(e.hasOwnProperty("raw")&&ae&&oe.raw)try{if(r=ae(e.raw).body[0].expression,r.type===j.Literal&&r.value===e.value)return e.raw}catch(i){}return null===e.value?"null":"string"==typeof e.value?y(e.value):"number"==typeof e.value?f(e.value):"boolean"==typeof e.value?e.value?"true":"false":d(e.value)},GeneratorExpression:function(e,t,n){return this.ComprehensionExpression(e,t,n)},ComprehensionExpression:function(e,t,n){var r,i,o,a,s=this;return r=e.type===j.GeneratorExpression?["("]:["["],oe.moz.comprehensionExpressionStartsWithAssignment&&(a=this.generateExpression(e.body,U.Assignment,Se),r.push(a)),e.blocks&&x(function(){for(i=0,o=e.blocks.length;o>i;++i)a=s.generateExpression(e.blocks[i],U.Sequence,Se),i>0||oe.moz.comprehensionExpressionStartsWithAssignment?r=w(r,a):r.push(a)}),e.filter&&(r=w(r,"if"+ee),a=this.generateExpression(e.filter,U.Sequence,Se),r=w(r,["(",a,")"])),oe.moz.comprehensionExpressionStartsWithAssignment||(a=this.generateExpression(e.body,U.Assignment,Se),r=w(r,a)),r.push(e.type===j.GeneratorExpression?")":"]"),r},ComprehensionBlock:function(e,t,n){var r;return r=e.left.type===j.VariableDeclaration?[e.left.kind,S(),this.generateStatement(e.left.declarations[0],ke)]:this.generateExpression(e.left,U.Call,Se),r=w(r,e.of?"of":"in"),r=w(r,this.generateExpression(e.right,U.Sequence,Se)),["for"+ee+"(",r,")"]},SpreadElement:function(e,t,n){return["...",this.generateExpression(e.argument,U.Assignment,Se)]},TaggedTemplateExpression:function(e,t,n){var r=ve;n&de||(r=we);var i=[this.generateExpression(e.tag,U.Call,r),this.generateExpression(e.quasi,U.Primary,Ee)];return L(i,U.TaggedTemplate,t)},TemplateElement:function(e,t,n){return e.value.raw},TemplateLiteral:function(e,t,n){var r,i,o;for(r=["`"],i=0,o=e.quasis.length;o>i;++i)r.push(this.generateExpression(e.quasis[i],U.Primary,Se)),o>i+1&&(r.push("${"+ee),r.push(this.generateExpression(e.expressions[i],U.Sequence,Se)),r.push(ee+"}"));return r.push("`"),r},ModuleSpecifier:function(e,t,n){return this.Literal(e,t,n)}},l(M.prototype,M.Expression),M.prototype.generateExpression=function(e,t,n){var r,i;return i=e.type||j.Property,oe.verbatim&&e.hasOwnProperty(oe.verbatim)?R(e,t):(r=this[i](e,t,n),oe.comment&&(r=A(e,r)),v(r,e))},M.prototype.generateStatement=function(e,t){var n,r;return n=this[e.type](e,t),oe.comment&&(n=A(e,n)),r=v(n).toString(),e.type!==j.Program||re||""!==Q||"\n"!==r.charAt(r.length-1)||(n=se?v(n).replaceRight(/\s+$/,""):r.replace(/\s+$/,"")),v(n,e)},ce={indent:{style:"",base:0},renumber:!0,hexadecimal:!0,quotes:"auto",escapeless:!0,compact:!0,parentheses:!1,semicolons:!1},fe=o().format,n.version=e("./package.json").version,n.generate=F,n.attachComments=Y.attachComments,n.Precedence=c({},U),n.browser=!1,n.FORMAT_MINIFY=ce,n.FORMAT_DEFAULTS=fe}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/escodegen.js","/../node_modules/escodegen")},{"./package.json":19,"1YiZ5S":25,buffer:21,estraverse:3,esutils:7,"source-map":8}],3:[function(e,t,n){(function(e,t,r,i,o,a,s,u,l){/* Copyright (C) 2012-2013 Yusuke Suzuki Copyright (C) 2012 Ariya Hidayat @@ -217,81 +130,34 @@ return null!=o?("string"==typeof o.indent&&(c.format.indent.style=o.indent),"num !function(e,t){"use strict"; // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, // and plain browser loading, -"function"==typeof define&&define.amd?define(["exports"],t):t("undefined"!=typeof n?n:e.estraverse={})}(this,function(e){"use strict";function t(){}function n(e){var t,r,o={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],o[t]="object"==typeof r&&null!==r?n(r):r);return o}function r(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n} +"function"==typeof define&&define.amd?define(["exports"],t):t("undefined"!=typeof n?n:e.estraverse={})}(this,function c(e){"use strict";function t(){}function n(e){var t,r,i={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],"object"==typeof r&&null!==r?i[t]=n(r):i[t]=r);return i}function r(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n} // based on LLVM libc++ upper_bound / lower_bound // MIT License -function o(e,t){var n,r,o,i;for(r=e.length,o=0;r;)n=r>>>1,i=o+n,t(e[i])?r=n:(o=i+1,r-=n+1);return o}function i(e,t){var n,r,o,i;for(r=e.length,o=0;r;)n=r>>>1,i=o+n,t(e[i])?(o=i+1,r-=n+1):r=n;return o}function a(e,t){return v(t).forEach(function(n){e[n]=t[n]}),e}function s(e,t){this.parent=e,this.key=t}function l(e,t,n,r){this.node=e,this.path=t,this.wrap=n,this.ref=r}function u(){}function c(e){return null==e?!1:"object"==typeof e&&"string"==typeof e.type}function f(e,t){return(e===g.ObjectExpression||e===g.ObjectPattern)&&"properties"===t}function p(e,t){var n=new u;return n.traverse(e,t)}function d(e,t){var n=new u;return n.replace(e,t)}function m(e,t){var n;return n=o(t,function(t){return t.range[0]>e.range[0]}),e.extendedRange=[e.range[0],e.range[1]],n!==t.length&&(e.extendedRange[1]=t[n].range[0]),n-=1,n>=0&&(e.extendedRange[0]=t[n].range[1]),e}function h(e,t,r){ +function i(e,t){var n,r,i,o;for(r=e.length,i=0;r;)n=r>>>1,o=i+n,t(e[o])?r=n:(i=o+1,r-=n+1);return i}function o(e,t){var n,r,i,o;for(r=e.length,i=0;r;)n=r>>>1,o=i+n,t(e[o])?(i=o+1,r-=n+1):r=n;return i}function a(e,t){var n,r,i,o=E(t);for(r=0,i=o.length;i>r;r+=1)n=o[r],e[n]=t[n];return e}function s(e,t){this.parent=e,this.key=t}function u(e,t,n,r){this.node=e,this.path=t,this.wrap=n,this.ref=r}function l(){}function f(e){return null==e?!1:"object"==typeof e&&"string"==typeof e.type}function p(e,t){return(e===y.ObjectExpression||e===y.ObjectPattern)&&"properties"===t}function d(e,t){var n=new l;return n.traverse(e,t)}function m(e,t){var n=new l;return n.replace(e,t)}function h(e,t){var n;return n=i(t,function(t){return t.range[0]>e.range[0]}),e.extendedRange=[e.range[0],e.range[1]],n!==t.length&&(e.extendedRange[1]=t[n].range[0]),n-=1,n>=0&&(e.extendedRange[0]=t[n].range[1]),e}function g(e,t,r){ // At first, we should calculate extended comment ranges. -var o,i,a,s,l=[];if(!e.range)throw new Error("attachComments needs range information"); +var i,o,a,s,u=[];if(!e.range)throw new Error("attachComments needs range information"); // tokens array is empty, we attach comments to tree as 'leadingComments' -if(!r.length){if(t.length){for(a=0,i=t.length;i>a;a+=1)o=n(t[a]),o.extendedRange=[0,e.range[0]],l.push(o);e.leadingComments=l}return e}for(a=0,i=t.length;i>a;a+=1)l.push(m(n(t[a]),r)); +if(!r.length){if(t.length){for(a=0,o=t.length;o>a;a+=1)i=n(t[a]),i.extendedRange=[0,e.range[0]],u.push(i);e.leadingComments=u}return e}for(a=0,o=t.length;o>a;a+=1)u.push(h(n(t[a]),r)); // This is based on John Freeman's implementation. -return s=0,p(e,{enter:function(e){for(var t;se.range[0]));)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),l.splice(s,1)):s+=1; -// already out of owned node -// already out of owned node -return s===l.length?w.Break:l[s].extendedRange[0]>e.range[1]?w.Skip:void 0}}),s=0,p(e,{leave:function(e){for(var t;se.range[1]?w.Skip:void 0}}),e}var g,y,w,b,S,v,E,C,x;y=Array.isArray,y||(y=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),t(r),t(i),S=Object.create||function(){function e(){}return function(t){return e.prototype=t,new e}}(),v=Object.keys||function(e){var t,n=[];for(t in e)n.push(t);return n},g={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",// CAUTION: It's deferred to ES7. -ComprehensionExpression:"ComprehensionExpression",// CAUTION: It's deferred to ES7. -ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportBatchSpecifier:"ExportBatchSpecifier",ExportDeclaration:"ExportDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",// CAUTION: It's deferred to ES7. -Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},b={AssignmentExpression:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","defaults","rest","body"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ClassBody:["body"],ClassDeclaration:["id","body","superClass"],ClassExpression:["id","body","superClass"],ComprehensionBlock:["left","right"],// CAUTION: It's deferred to ES7. -ComprehensionExpression:["blocks","filter","body"],// CAUTION: It's deferred to ES7. -ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportBatchSpecifier:[],ExportDeclaration:["declaration","specifiers","source"],ExportSpecifier:["id","name"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","defaults","rest","body"],FunctionExpression:["id","params","defaults","rest","body"],GeneratorExpression:["blocks","filter","body"],// CAUTION: It's deferred to ES7. -Identifier:[],IfStatement:["test","consequent","alternate"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["id"],ImportNamespaceSpecifier:["id"],ImportSpecifier:["id","name"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handlers","handler","guardedHandlers","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]}, +return s=0,d(e,{enter:function(e){for(var t;se.range[0]));)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),u.splice(s,1)):s+=1;return s===u.length?v.Break:u[s].extendedRange[0]>e.range[1]?v.Skip:void 0}}),s=0,d(e,{leave:function(e){for(var t;se.range[1]?v.Skip:void 0}}),e}var y,b,v,S,w,E,x,_,C; // unique id -E={},C={},x={},w={Break:E,Skip:C,Remove:x},s.prototype.replace=function(e){this.parent[this.key]=e},s.prototype.remove=function(){return y(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)}, // API: // return property path array from root to current node -u.prototype.path=function(){function e(e,t){if(y(t))for(r=0,o=t.length;o>r;++r)e.push(t[r]);else e.push(t)}var t,n,r,o,i,a; -// root node -if(!this.__current.path)return null;for( -// first node is sentinel, second node is root element -i=[],t=2,n=this.__leavelist.length;n>t;++t)a=this.__leavelist[t],e(i,a.path);return e(i,this.__current.path),i}, +// API: +// return type of current node // API: // return array of parent elements -u.prototype.parents=function(){var e,t,n;for( -// first node is sentinel -n=[],e=1,t=this.__leavelist.length;t>e;++e)n.push(this.__leavelist[e].node);return n}, // API: // return current node -u.prototype.current=function(){return this.__current.node},u.prototype.__execute=function(e,t){var n,r;return r=void 0,n=this.__current,this.__current=t,this.__state=null,e&&(r=e.call(this,t.node,this.__leavelist[this.__leavelist.length-1].node)),this.__current=n,r}, // API: // notify control skip / break -u.prototype.notify=function(e){this.__state=e}, // API: // skip child nodes of current node -u.prototype.skip=function(){this.notify(C)}, // API: // break traversals -u.prototype["break"]=function(){this.notify(E)}, // API: // remove node -u.prototype.remove=function(){this.notify(x)},u.prototype.__initialize=function(e,t){this.visitor=t,this.root=e,this.__worklist=[],this.__leavelist=[],this.__current=null,this.__state=null,this.__fallback="iteration"===t.fallback,this.__keys=b,t.keys&&(this.__keys=a(S(this.__keys),t.keys))},u.prototype.traverse=function(e,t){var n,r,o,i,a,s,u,p,d,m,h,g;for(this.__initialize(e,t),g={}, -// reference -n=this.__worklist,r=this.__leavelist, -// initialize -n.push(new l(e,null,null,null)),r.push(new l(null,null,null,null));n.length;)if(o=n.pop(),o!==g){if(o.node){if(s=this.__execute(t.enter,o),this.__state===E||s===E)return;if(n.push(g),r.push(o),this.__state===C||s===C)continue;if(i=o.node,a=o.wrap||i.type,m=this.__keys[a],!m){if(!this.__fallback)throw new Error("Unknown node type "+a+".");m=v(i)}for(p=m.length;(p-=1)>=0;)if(u=m[p],h=i[u])if(y(h)){for(d=h.length;(d-=1)>=0;)if(h[d]){if(f(a,m[p]))o=new l(h[d],[u,d],"Property",null);else{if(!c(h[d]))continue;o=new l(h[d],[u,d],null,null)}n.push(o)}}else c(h)&&n.push(new l(h,u,null,null))}}else if(o=r.pop(),s=this.__execute(t.leave,o),this.__state===E||s===E)return},u.prototype.replace=function(e,t){function n(e){var t,n,o,i;if(e.ref.remove())for( -// When the reference is an element of an array. -n=e.ref.key,i=e.ref.parent, -// If removed from array, then decrease following items' keys. -t=r.length;t--;)if(o=r[t],o.ref&&o.ref.parent===i){if(o.ref.key=0;)if(S=h[d],g=i[S])if(y(g)){for(m=g.length;(m-=1)>=0;)if(g[m]){if(f(a,h[d]))p=new l(g[m],[S,m],"Property",new s(g,m));else{if(!c(g[m]))continue;p=new l(g[m],[S,m],null,new s(g,m))}r.push(p)}}else c(g)&&r.push(new l(g,S,null,new s(i,S)))}}else if(p=o.pop(),u=this.__execute(t.leave,p), -// node may be replaced with null, -// so distinguish between undefined and null in this place -void 0!==u&&u!==E&&u!==C&&u!==x&& -// replace -p.ref.replace(u),(this.__state===x||u===x)&&n(p),this.__state===E||u===E)return b.root;return b.root},e.version="1.7.1",e.Syntax=g,e.traverse=p,e.replace=d,e.attachComments=h,e.VisitorKeys=b,e.VisitorOption=w,e.Controller=u})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/estraverse/estraverse.js","/../node_modules/escodegen/node_modules/estraverse")},{"1YiZ5S":24,buffer:20}],4:[function(e,t,n){(function(e,n,r,o,i,a,s,l,u){/* +return b=Array.isArray,b||(b=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),t(r),t(o),w=Object.create||function(){function e(){}return function(t){return e.prototype=t,new e}}(),E=Object.keys||function(e){var t,n=[];for(t in e)n.push(t);return n},y={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportBatchSpecifier:"ExportBatchSpecifier",ExportDeclaration:"ExportDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},S={AssignmentExpression:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","defaults","rest","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ClassBody:["body"],ClassDeclaration:["id","body","superClass"],ClassExpression:["id","body","superClass"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportBatchSpecifier:[],ExportDeclaration:["declaration","specifiers","source"],ExportSpecifier:["id","name"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","defaults","rest","body"],FunctionExpression:["id","params","defaults","rest","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["id"],ImportNamespaceSpecifier:["id"],ImportSpecifier:["id","name"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handlers","handler","guardedHandlers","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},x={},_={},C={},v={Break:x,Skip:_,Remove:C},s.prototype.replace=function(e){this.parent[this.key]=e},s.prototype.remove=function(){return b(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)},l.prototype.path=function(){function e(e,t){if(b(t))for(r=0,i=t.length;i>r;++r)e.push(t[r]);else e.push(t)}var t,n,r,i,o,a;if(!this.__current.path)return null;for(o=[],t=2,n=this.__leavelist.length;n>t;++t)a=this.__leavelist[t],e(o,a.path);return e(o,this.__current.path),o},l.prototype.type=function(){var e=this.current();return e.type||this.__current.wrap},l.prototype.parents=function(){var e,t,n;for(n=[],e=1,t=this.__leavelist.length;t>e;++e)n.push(this.__leavelist[e].node);return n},l.prototype.current=function(){return this.__current.node},l.prototype.__execute=function(e,t){var n,r;return r=void 0,n=this.__current,this.__current=t,this.__state=null,e&&(r=e.call(this,t.node,this.__leavelist[this.__leavelist.length-1].node)),this.__current=n,r},l.prototype.notify=function(e){this.__state=e},l.prototype.skip=function(){this.notify(_)},l.prototype["break"]=function(){this.notify(x)},l.prototype.remove=function(){this.notify(C)},l.prototype.__initialize=function(e,t){this.visitor=t,this.root=e,this.__worklist=[],this.__leavelist=[],this.__current=null,this.__state=null,this.__fallback="iteration"===t.fallback,this.__keys=S,t.keys&&(this.__keys=a(w(this.__keys),t.keys))},l.prototype.traverse=function(e,t){var n,r,i,o,a,s,l,c,d,m,h,g;for(this.__initialize(e,t),g={},n=this.__worklist,r=this.__leavelist,n.push(new u(e,null,null,null)),r.push(new u(null,null,null,null));n.length;)if(i=n.pop(),i!==g){if(i.node){if(s=this.__execute(t.enter,i),this.__state===x||s===x)return;if(n.push(g),r.push(i),this.__state===_||s===_)continue;if(o=i.node,a=i.wrap||o.type,m=this.__keys[a],!m){if(!this.__fallback)throw new Error("Unknown node type "+a+".");m=E(o)}for(c=m.length;(c-=1)>=0;)if(l=m[c],h=o[l])if(b(h)){for(d=h.length;(d-=1)>=0;)if(h[d]){if(p(a,m[c]))i=new u(h[d],[l,d],"Property",null);else{if(!f(h[d]))continue;i=new u(h[d],[l,d],null,null)}n.push(i)}}else f(h)&&n.push(new u(h,l,null,null))}}else if(i=r.pop(),s=this.__execute(t.leave,i),this.__state===x||s===x)return},l.prototype.replace=function(e,t){function n(e){var t,n,i,o;if(e.ref.remove())for(n=e.ref.key,o=e.ref.parent,t=r.length;t--;)if(i=r[t],i.ref&&i.ref.parent===o){if(i.ref.key=0;)if(S=h[d],g=o[S])if(b(g)){for(m=g.length;(m-=1)>=0;)if(g[m]){if(p(a,h[d]))c=new u(g[m],[S,m],"Property",new s(g,m));else{if(!f(g[m]))continue;c=new u(g[m],[S,m],null,new s(g,m))}r.push(c)}}else f(g)&&r.push(new u(g,S,null,new s(o,S)))}}else if(c=i.pop(),l=this.__execute(t.leave,c),void 0!==l&&l!==x&&l!==_&&l!==C&&c.ref.replace(l),(this.__state===C||l===C)&&n(c),this.__state===x||l===x)return v.root;return v.root},e.version="1.8.1-dev",e.Syntax=y,e.traverse=d,e.replace=m,e.attachComments=g,e.VisitorKeys=S,e.VisitorOption=v,e.Controller=l,e.cloneEnvironment=function(){return c({})},e})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/estraverse/estraverse.js","/../node_modules/escodegen/node_modules/estraverse")},{"1YiZ5S":25,buffer:21}],4:[function(e,t,n){(function(e,n,r,i,o,a,s,u,l){/* Copyright (C) 2013 Yusuke Suzuki Redistribution and use in source and binary forms, with or without @@ -314,8 +180,9 @@ p.ref.replace(u),(this.__state===x||u===x)&&n(p),this.__state===E||u===E)return (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -!function(){"use strict";function e(e){if(null==e)return!1;switch(e.type){case"ArrayExpression":case"AssignmentExpression":case"BinaryExpression":case"CallExpression":case"ConditionalExpression":case"FunctionExpression":case"Identifier":case"Literal":case"LogicalExpression":case"MemberExpression":case"NewExpression":case"ObjectExpression":case"SequenceExpression":case"ThisExpression":case"UnaryExpression":case"UpdateExpression":return!0}return!1}function n(e){if(null==e)return!1;switch(e.type){case"DoWhileStatement":case"ForInStatement":case"ForStatement":case"WhileStatement":return!0}return!1}function r(e){if(null==e)return!1;switch(e.type){case"BlockStatement":case"BreakStatement":case"ContinueStatement":case"DebuggerStatement":case"DoWhileStatement":case"EmptyStatement":case"ExpressionStatement":case"ForInStatement":case"ForStatement":case"IfStatement":case"LabeledStatement":case"ReturnStatement":case"SwitchStatement":case"ThrowStatement":case"TryStatement":case"VariableDeclaration":case"WhileStatement":case"WithStatement":return!0}return!1}function o(e){return r(e)||null!=e&&"FunctionDeclaration"===e.type}function i(e){switch(e.type){case"IfStatement":return null!=e.alternate?e.alternate:e.consequent;case"LabeledStatement":case"ForStatement":case"ForInStatement":case"WhileStatement":case"WithStatement":return e.body}return null}function a(e){var t;if("IfStatement"!==e.type)return!1;if(null==e.alternate)return!1;t=e.consequent;do{if("IfStatement"===t.type&&null==t.alternate)return!0;t=i(t)}while(t);return!1}t.exports={isExpression:e,isStatement:r,isIterationStatement:n,isSourceElement:o,isProblematicIfStatement:a,trailingStatement:i}}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/ast.js","/../node_modules/escodegen/node_modules/esutils/lib")},{"1YiZ5S":24,buffer:20}],5:[function(e,t,n){(function(e,n,r,o,i,a,s,l,u){/* - Copyright (C) 2013 Yusuke Suzuki +!function(){"use strict";function e(e){if(null==e)return!1;switch(e.type){case"ArrayExpression":case"AssignmentExpression":case"BinaryExpression":case"CallExpression":case"ConditionalExpression":case"FunctionExpression":case"Identifier":case"Literal":case"LogicalExpression":case"MemberExpression":case"NewExpression":case"ObjectExpression":case"SequenceExpression":case"ThisExpression":case"UnaryExpression":case"UpdateExpression":return!0}return!1}function n(e){if(null==e)return!1;switch(e.type){case"DoWhileStatement":case"ForInStatement":case"ForStatement":case"WhileStatement":return!0}return!1}function r(e){if(null==e)return!1;switch(e.type){case"BlockStatement":case"BreakStatement":case"ContinueStatement":case"DebuggerStatement":case"DoWhileStatement":case"EmptyStatement":case"ExpressionStatement":case"ForInStatement":case"ForStatement":case"IfStatement":case"LabeledStatement":case"ReturnStatement":case"SwitchStatement":case"ThrowStatement":case"TryStatement":case"VariableDeclaration":case"WhileStatement":case"WithStatement":return!0}return!1}function i(e){return r(e)||null!=e&&"FunctionDeclaration"===e.type}function o(e){switch(e.type){case"IfStatement":return null!=e.alternate?e.alternate:e.consequent;case"LabeledStatement":case"ForStatement":case"ForInStatement":case"WhileStatement":case"WithStatement":return e.body}return null}function a(e){var t;if("IfStatement"!==e.type)return!1;if(null==e.alternate)return!1;t=e.consequent;do{if("IfStatement"===t.type&&null==t.alternate)return!0;t=o(t)}while(t);return!1}t.exports={isExpression:e,isStatement:r,isIterationStatement:n,isSourceElement:i,isProblematicIfStatement:a,trailingStatement:o}}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/ast.js","/../node_modules/escodegen/node_modules/esutils/lib")},{"1YiZ5S":25,buffer:21}],5:[function(e,t,n){(function(e,n,r,i,o,a,s,u,l){/* + Copyright (C) 2013-2014 Yusuke Suzuki + Copyright (C) 2014 Ivan Nikulin Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -337,24 +204,22 @@ p.ref.replace(u),(this.__state===x||u===x)&&n(p),this.__state===E||u===E)return (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -!function(){"use strict";function e(e){return e>=48&&57>=e}function n(t){return e(t)||t>=97&&102>=t||t>=65&&70>=t}function r(e){return e>=48&&55>=e} -// 7.2 White Space -function o(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0} +!function(){"use strict";function e(e){return e>=48&&57>=e}function n(t){// 0..9 +// a..f +return e(t)||t>=97&&102>=t||t>=65&&70>=t}function r(e){return e>=48&&55>=e}function i(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&l.indexOf(e)>=0} // 7.3 Line Terminators -function i(e){return 10===e||13===e||8232===e||8233===e} +function o(e){return 10===e||13===e||8232===e||8233===e} // 7.6 Identifier Names and Identifiers -function a(e){// $ (dollar) and _ (underscore) +function a(e){// a..z // A..Z -// a..z +// $ (dollar) and _ (underscore) // \ (backslash) -return 36===e||95===e||e>=65&&90>=e||e>=97&&122>=e||92===e||e>=128&&l.NonAsciiIdentifierStart.test(String.fromCharCode(e))}function s(e){// $ (dollar) and _ (underscore) +return e>=97&&122>=e||e>=65&&90>=e||36===e||95===e||92===e||e>=128&&u.NonAsciiIdentifierStart.test(String.fromCharCode(e))}function s(e){// a..z // A..Z -// a..z // 0..9 +// $ (dollar) and _ (underscore) // \ (backslash) -return 36===e||95===e||e>=65&&90>=e||e>=97&&122>=e||e>=48&&57>=e||92===e||e>=128&&l.NonAsciiIdentifierPart.test(String.fromCharCode(e))}var l; -// See `tools/generate-identifier-regex.js`. -l={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‌‍‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")},t.exports={isDecimalDigit:e,isHexDigit:n,isOctalDigit:r,isWhiteSpace:o,isLineTerminator:i,isIdentifierStart:a,isIdentifierPart:s}}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/code.js","/../node_modules/escodegen/node_modules/esutils/lib")},{"1YiZ5S":24,buffer:20}],6:[function(e,t,n){(function(n,r,o,i,a,s,l,u,c){/* +return e>=97&&122>=e||e>=65&&90>=e||e>=48&&57>=e||36===e||95===e||92===e||e>=128&&u.NonAsciiIdentifierPart.test(String.fromCharCode(e))}var u,l;u={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‌‍‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")},l=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279],t.exports={isDecimalDigit:e,isHexDigit:n,isOctalDigit:r,isWhiteSpace:i,isLineTerminator:o,isIdentifierStart:a,isIdentifierPart:s}}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/code.js","/../node_modules/escodegen/node_modules/esutils/lib")},{"1YiZ5S":25,buffer:21}],6:[function(e,t,n){(function(n,r,i,o,a,s,u,l,c){/* Copyright (C) 2013 Yusuke Suzuki Redistribution and use in source and binary forms, with or without @@ -380,9 +245,9 @@ l={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹ !function(){"use strict";function n(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"let":return!0;default:return!1}}function r(e,t){ // yield should not be treated as keyword under non-strict mode. // yield should not be treated as keyword under non-strict mode. -return t||"yield"!==e?o(e,t):!1}function o(e,t){if(t&&n(e))return!0;switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}}function i(e,t){return"null"===e||"true"===e||"false"===e||r(e,t)}function a(e,t){return"null"===e||"true"===e||"false"===e||o(e,t)}function s(e){return"eval"===e||"arguments"===e}function l(e){var t,n,r;if(0===e.length)return!1;if(r=e.charCodeAt(0),!f.isIdentifierStart(r)||92===r)// \ (backslash) +return t||"yield"!==e?i(e,t):!1}function i(e,t){if(t&&n(e))return!0;switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}}function o(e,t){return"null"===e||"true"===e||"false"===e||r(e,t)}function a(e,t){return"null"===e||"true"===e||"false"===e||i(e,t)}function s(e){return"eval"===e||"arguments"===e}function u(e){var t,n,r;if(0===e.length)return!1;if(r=e.charCodeAt(0),!f.isIdentifierStart(r)||92===r)// \ (backslash) return!1;for(t=1,n=e.length;n>t;++t)if(r=e.charCodeAt(t),!f.isIdentifierPart(r)||92===r)// \ (backslash) -return!1;return!0}function u(e,t){return l(e)&&!i(e,t)}function c(e,t){return l(e)&&!a(e,t)}var f=e("./code");t.exports={isKeywordES5:r,isKeywordES6:o,isReservedWordES5:i,isReservedWordES6:a,isRestrictedWord:s,isIdentifierName:l,isIdentifierES5:u,isIdentifierES6:c}}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/keyword.js","/../node_modules/escodegen/node_modules/esutils/lib")},{"./code":5,"1YiZ5S":24,buffer:20}],7:[function(e,t,n){(function(t,r,o,i,a,s,l,u,c){/* +return!1;return!0}function l(e,t){return u(e)&&!o(e,t)}function c(e,t){return u(e)&&!a(e,t)}var f=e("./code");t.exports={isKeywordES5:r,isKeywordES6:i,isReservedWordES5:o,isReservedWordES6:a,isRestrictedWord:s,isIdentifierName:u,isIdentifierES5:l,isIdentifierES6:c}}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/keyword.js","/../node_modules/escodegen/node_modules/esutils/lib")},{"./code":5,"1YiZ5S":25,buffer:21}],7:[function(e,t,n){(function(t,r,i,o,a,s,u,l,c){/* Copyright (C) 2013 Yusuke Suzuki Redistribution and use in source and binary forms, with or without @@ -405,12 +270,12 @@ return!1;return!0}function u(e,t){return l(e)&&!i(e,t)}function c(e,t){return l( (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -!function(){"use strict";n.ast=e("./ast"),n.code=e("./code"),n.keyword=e("./keyword")}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/utils.js","/../node_modules/escodegen/node_modules/esutils/lib")},{"./ast":4,"./code":5,"./keyword":6,"1YiZ5S":24,buffer:20}],8:[function(e,t,n){(function(t,r,o,i,a,s,l,u,c){/* +!function(){"use strict";n.ast=e("./ast"),n.code=e("./code"),n.keyword=e("./keyword")}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/esutils/lib/utils.js","/../node_modules/escodegen/node_modules/esutils/lib")},{"./ast":4,"./code":5,"./keyword":6,"1YiZ5S":25,buffer:21}],8:[function(e,t,n){(function(t,r,i,o,a,s,u,l,c){/* * Copyright 2009-2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE.txt or: * http://opensource.org/licenses/BSD-3-Clause */ -n.SourceMapGenerator=e("./source-map/source-map-generator").SourceMapGenerator,n.SourceMapConsumer=e("./source-map/source-map-consumer").SourceMapConsumer,n.SourceNode=e("./source-map/source-node").SourceNode}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map.js","/../node_modules/escodegen/node_modules/source-map/lib")},{"./source-map/source-map-consumer":13,"./source-map/source-map-generator":14,"./source-map/source-node":15,"1YiZ5S":24,buffer:20}],9:[function(e,t,n){(function(n,r,o,i,a,s,l,u,c){/* -*- Mode: js; js-indent-level: 2; -*- */ +n.SourceMapGenerator=e("./source-map/source-map-generator").SourceMapGenerator,n.SourceMapConsumer=e("./source-map/source-map-consumer").SourceMapConsumer,n.SourceNode=e("./source-map/source-node").SourceNode}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map.js","/../node_modules/escodegen/node_modules/source-map/lib")},{"./source-map/source-map-consumer":14,"./source-map/source-map-generator":15,"./source-map/source-node":16,"1YiZ5S":25,buffer:21}],9:[function(e,t,n){(function(n,r,i,o,a,s,u,l,c){/* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: @@ -422,25 +287,25 @@ if("function"!=typeof f)var f=e("amdefine")(t,e);f(function(e,t,n){/** * element is O(1). Removing elements from the set is not supported. Only * strings are supported for membership. */ -function r(){this._array=[],this._set={}}var o=e("./util");/** +function r(){this._array=[],this._set={}}var i=e("./util");/** * Static method for creating ArraySet instances from an existing array. */ -r.fromArray=function(e,t){for(var n=new r,o=0,i=e.length;i>o;o++)n.add(e[o],t);return n},/** +r.fromArray=function(e,t){for(var n=new r,i=0,o=e.length;o>i;i++)n.add(e[i],t);return n},/** * Add the given string to this set. * * @param String aStr */ -r.prototype.add=function(e,t){var n=this.has(e),r=this._array.length;(!n||t)&&this._array.push(e),n||(this._set[o.toSetString(e)]=r)},/** +r.prototype.add=function(e,t){var n=this.has(e),r=this._array.length;(!n||t)&&this._array.push(e),n||(this._set[i.toSetString(e)]=r)},/** * Is the given string a member of this set? * * @param String aStr */ -r.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this._set,o.toSetString(e))},/** +r.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this._set,i.toSetString(e))},/** * What is the index of the given string in the array? * * @param String aStr */ -r.prototype.indexOf=function(e){if(this.has(e))return this._set[o.toSetString(e)];throw new Error('"'+e+'" is not in the set.')},/** +r.prototype.indexOf=function(e){if(this.has(e))return this._set[i.toSetString(e)];throw new Error('"'+e+'" is not in the set.')},/** * What is the element at the given index? * * @param Number aIdx @@ -450,7 +315,7 @@ r.prototype.at=function(e){if(e>=0&&ee?(-e<<1)+1:(e<<1)+0}/** * Converts to a two-complement value from a value where the sign bit is - * is placed in the least significant bit. For example, as decimals: + * placed in the least significant bit. For example, as decimals: * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 */ -function o(e){var t=1===(1&e),n=e>>1;return t?-n:n}var i=e("./base64"),a=5,s=1<>1;return t?-n:n}var o=e("./base64"),a=5,s=1<>>=a,o>0&&( -// There are still more digits in this value, so we must make sure the -// continuation bit is marked. -t|=u),n+=i.encode(t);while(o>0);return n},/** +t.encode=function(e){var t,n="",i=r(e);do t=i&u,i>>>=a,i>0&&(t|=l),n+=o.encode(t);while(i>0);return n},/** * Decodes the next base 64 VLQ value from the given string and returns the * value and the rest of the string via the out parameter. */ -t.decode=function(e,t){var n,r,s=0,c=e.length,f=0,p=0;do{if(s>=c)throw new Error("Expected more digits in base 64 VLQ value.");r=i.decode(e.charAt(s++)),n=!!(r&u),r&=l,f+=r<=c)throw new Error("Expected more digits in base 64 VLQ value.");r=o.decode(e.charAt(s++)),n=!!(r&l),r&=u,f+=r<0?t-a>1?r(a,t,n,o,i):o[a]:a-e>1?r(e,a,n,o,i):0>e?null:o[e]}/** +return 0===s?a:s>0?t-a>1?r(a,t,n,i,o):a:a-e>1?r(e,a,n,i,o):0>e?-1:e}/** * This is an implementation of binary search which will always try and return - * the next lowest value checked if there is no exact hit. This is because - * mappings between original and generated line/col pairs are single points, - * and there is an implicit region between each of them, so a miss just means - * that you aren't on the very start of a region. + * the index of next lowest value checked if there is no exact hit. This is + * because mappings between original and generated line/col pairs are single + * points, and there is an implicit region between each of them, so a miss + * just means that you aren't on the very start of a region. * * @param aNeedle The element you are looking for. * @param aHaystack The array that is being searched. @@ -562,7 +424,46 @@ return 0===s?o[a]:s>0?t-a>1?r(a,t,n,o,i):o[a]:a-e>1?r(e,a,n,o,i):0>e?null:o[e]}/ * array and returns -1, 0, or 1 depending on whether the needle is less * than, equal to, or greater than the element, respectively. */ -t.search=function(e,t,n){return t.length>0?r(-1,t.length,e,t,n):null}})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/binary-search.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"1YiZ5S":24,amdefine:17,buffer:20}],13:[function(e,t,n){(function(n,r,o,i,a,s,l,u,c){/* -*- Mode: js; js-indent-level: 2; -*- */ +t.search=function(e,t,n){return 0===t.length?-1:r(-1,t.length,e,t,n)}})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/binary-search.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"1YiZ5S":25,amdefine:18,buffer:21}],13:[function(e,t,n){(function(n,r,i,o,a,s,u,l,c){/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2014 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if("function"!=typeof f)var f=e("amdefine")(t,e);f(function(e,t,n){/** + * Determine whether mappingB is after mappingA with respect to generated + * position. + */ +function r(e,t){ +// Optimized for most common case +var n=e.generatedLine,r=t.generatedLine,i=e.generatedColumn,a=t.generatedColumn;return r>n||r==n&&a>=i||o.compareByGeneratedPositions(e,t)<=0}/** + * A data structure to provide a sorted view of accumulated mappings in a + * performance conscious manner. It trades a neglibable overhead in general + * case for a large speedup in case of mappings being added in order. + */ +function i(){this._array=[],this._sorted=!0, +// Serves as infimum +this._last={generatedLine:-1,generatedColumn:0}}var o=e("./util");/** + * Iterate through internal items. This method takes the same arguments that + * `Array.prototype.forEach` takes. + * + * NOTE: The order of the mappings is NOT guaranteed. + */ +i.prototype.unsortedForEach=function(e,t){this._array.forEach(e,t)},/** + * Add the given source mapping. + * + * @param Object aMapping + */ +i.prototype.add=function(e){r(this._last,e)?(this._last=e,this._array.push(e)):(this._sorted=!1,this._array.push(e))},/** + * Returns the flat, sorted array of mappings. The mappings are sorted by + * generated position. + * + * WARNING: This method returns internal data without copying, for + * performance. The return value must NOT be mutated, and should be treated as + * an immutable borrow. If you want to take ownership, you must make your own + * copy. + */ +i.prototype.toArray=function(){return this._sorted||(this._array.sort(o.compareByGeneratedPositions),this._sorted=!0),this._array},t.MappingList=i})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/mapping-list.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"./util":17,"1YiZ5S":25,amdefine:18,buffer:21}],14:[function(e,t,n){(function(n,r,i,o,a,s,u,l,c){/* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: @@ -598,28 +499,23 @@ if("function"!=typeof f)var f=e("amdefine")(t,e);f(function(e,t,n){/** * * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# */ -function r(e){var t=e;"string"==typeof e&&(t=JSON.parse(e.replace(/^\)\]\}'/,"")));var n=o.getArg(t,"version"),r=o.getArg(t,"sources"),i=o.getArg(t,"names",[]),s=o.getArg(t,"sourceRoot",null),l=o.getArg(t,"sourcesContent",null),u=o.getArg(t,"mappings"),c=o.getArg(t,"file",null); +function r(e){var t=e;"string"==typeof e&&(t=JSON.parse(e.replace(/^\)\]\}'/,"")));var n=i.getArg(t,"version"),r=i.getArg(t,"sources"),o=i.getArg(t,"names",[]),s=i.getArg(t,"sourceRoot",null),u=i.getArg(t,"sourcesContent",null),l=i.getArg(t,"mappings"),c=i.getArg(t,"file",null); // Once again, Sass deviates from the spec and supplies the version as a // string rather than a number, so we use loose equality checking here. -if(n!=this._version)throw new Error("Unsupported version: "+n); -// Pass `true` below to allow duplicate names and sources. While source maps -// are intended to be compressed and deduplicated, the TypeScript compiler -// sometimes generates source maps with duplicates in them. See Github issue -// #72 and bugzil.la/889492. -this._names=a.fromArray(i,!0),this._sources=a.fromArray(r,!0),this.sourceRoot=s,this.sourcesContent=l,this._mappings=u,this.file=c}var o=e("./util"),i=e("./binary-search"),a=e("./array-set").ArraySet,s=e("./base64-vlq");/** +if(n!=this._version)throw new Error("Unsupported version: "+n);r=r.map(i.normalize),this._names=a.fromArray(o,!0),this._sources=a.fromArray(r,!0),this.sourceRoot=s,this.sourcesContent=u,this._mappings=l,this.file=c}var i=e("./util"),o=e("./binary-search"),a=e("./array-set").ArraySet,s=e("./base64-vlq");/** * Create a SourceMapConsumer from a SourceMapGenerator. * * @param SourceMapGenerator aSourceMap * The source map that will be consumed. * @returns SourceMapConsumer */ -r.fromSourceMap=function(e){var t=Object.create(r.prototype);return t._names=a.fromArray(e._names.toArray(),!0),t._sources=a.fromArray(e._sources.toArray(),!0),t.sourceRoot=e._sourceRoot,t.sourcesContent=e._generateSourcesContent(t._sources.toArray(),t.sourceRoot),t.file=e._file,t.__generatedMappings=e._mappings.slice().sort(o.compareByGeneratedPositions),t.__originalMappings=e._mappings.slice().sort(o.compareByOriginalPositions),t},/** +r.fromSourceMap=function(e){var t=Object.create(r.prototype);return t._names=a.fromArray(e._names.toArray(),!0),t._sources=a.fromArray(e._sources.toArray(),!0),t.sourceRoot=e._sourceRoot,t.sourcesContent=e._generateSourcesContent(t._sources.toArray(),t.sourceRoot),t.file=e._file,t.__generatedMappings=e._mappings.toArray().slice(),t.__originalMappings=e._mappings.toArray().slice().sort(i.compareByOriginalPositions),t},/** * The version of the source mapping spec that we are consuming. */ r.prototype._version=3,/** * The list of original sources. */ -Object.defineProperty(r.prototype,"sources",{get:function(){return this._sources.toArray().map(function(e){return null!=this.sourceRoot?o.join(this.sourceRoot,e):e},this)}}), +Object.defineProperty(r.prototype,"sources",{get:function(){return this._sources.toArray().map(function(e){return null!=this.sourceRoot?i.join(this.sourceRoot,e):e},this)}}), // `__generatedMappings` and `__originalMappings` are arrays that hold the // parsed mapping coordinates from the source map's "mappings" attribute. They // are lazily instantiated, accessed via the `_generatedMappings` and @@ -654,28 +550,35 @@ r.prototype.__generatedMappings=null,Object.defineProperty(r.prototype,"_generat * query (the ordered arrays in the `this.__generatedMappings` and * `this.__originalMappings` properties). */ -r.prototype._parseMappings=function(e,t){for(var n,r=1,i=0,a=0,l=0,u=0,c=0,f=e,p={};f.length>0;)if(";"===f.charAt(0))r++,f=f.slice(1),i=0;else if(","===f.charAt(0))f=f.slice(1);else{if(n={},n.generatedLine=r, -// Generated column. -s.decode(f,p),n.generatedColumn=i+p.value,i=n.generatedColumn,f=p.rest,f.length>0&&!this._nextCharIsMappingSeparator(f)){if( +r.prototype._parseMappings=function(e,t){for(var n,r=1,o=0,a=0,u=0,l=0,c=0,f=e,p={};f.length>0;)if(";"===f.charAt(0))r++,f=f.slice(1),o=0;else if(","===f.charAt(0))f=f.slice(1);else{if(n={},n.generatedLine=r,s.decode(f,p),n.generatedColumn=o+p.value,o=n.generatedColumn,f=p.rest,f.length>0&&!this._nextCharIsMappingSeparator(f)){if( // Original source. -s.decode(f,p),n.source=this._sources.at(u+p.value),u+=p.value,f=p.rest,0===f.length||this._nextCharIsMappingSeparator(f))throw new Error("Found a source, but no line and column");if( +s.decode(f,p),n.source=this._sources.at(l+p.value),l+=p.value,f=p.rest,0===f.length||this._nextCharIsMappingSeparator(f))throw new Error("Found a source, but no line and column");if( // Original line. -s.decode(f,p),n.originalLine=a+p.value,a=n.originalLine, -// Lines are stored 0-based -n.originalLine+=1,f=p.rest,0===f.length||this._nextCharIsMappingSeparator(f))throw new Error("Found a source and line, but no column"); +s.decode(f,p),n.originalLine=a+p.value,a=n.originalLine,n.originalLine+=1,f=p.rest,0===f.length||this._nextCharIsMappingSeparator(f))throw new Error("Found a source and line, but no column"); // Original column. -s.decode(f,p),n.originalColumn=l+p.value,l=n.originalColumn,f=p.rest,f.length>0&&!this._nextCharIsMappingSeparator(f)&&( +s.decode(f,p),n.originalColumn=u+p.value,u=n.originalColumn,f=p.rest,f.length>0&&!this._nextCharIsMappingSeparator(f)&&( // Original name. -s.decode(f,p),n.name=this._names.at(c+p.value),c+=p.value,f=p.rest)}this.__generatedMappings.push(n),"number"==typeof n.originalLine&&this.__originalMappings.push(n)}this.__generatedMappings.sort(o.compareByGeneratedPositions),this.__originalMappings.sort(o.compareByOriginalPositions)},/** +s.decode(f,p),n.name=this._names.at(c+p.value),c+=p.value,f=p.rest)}this.__generatedMappings.push(n),"number"==typeof n.originalLine&&this.__originalMappings.push(n)}this.__generatedMappings.sort(i.compareByGeneratedPositions),this.__originalMappings.sort(i.compareByOriginalPositions)},/** * Find the mapping that best matches the hypothetical "needle" mapping that * we are searching for in the given "haystack" of mappings. */ -r.prototype._findMapping=function(e,t,n,r,o){ +r.prototype._findMapping=function(e,t,n,r,i){ // To return the position we are searching for, we must first find the // mapping for the given position and then return the opposite position it // points to. Because the mappings are sorted, we can use binary search to // find the best mapping. -if(e[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[n]);if(e[r]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[r]);return i.search(e,t,o)},/** +if(e[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[n]);if(e[r]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[r]);return o.search(e,t,i)},/** + * Compute the last column for each generated mapping. The last column is + * inclusive. + */ +r.prototype.computeColumnSpans=function(){for(var e=0;e=0){var r=this._generatedMappings[n];if(r.generatedLine===t.generatedLine){var o=i.getArg(r,"source",null);return null!=o&&null!=this.sourceRoot&&(o=i.join(this.sourceRoot,o)),{source:o,line:i.getArg(r,"originalLine",null),column:i.getArg(r,"originalColumn",null),name:i.getArg(r,"name",null)}}}return{source:null,line:null,column:null,name:null}},/** * Returns the original source content. The only argument is the url of the * original source file. Returns null if no original source content is * availible. */ -r.prototype.sourceContentFor=function(e){if(!this.sourcesContent)return null;if(null!=this.sourceRoot&&(e=o.relative(this.sourceRoot,e)),this._sources.has(e))return this.sourcesContent[this._sources.indexOf(e)];var t;if(null!=this.sourceRoot&&(t=o.urlParse(this.sourceRoot))){ +r.prototype.sourceContentFor=function(e){if(!this.sourcesContent)return null;if(null!=this.sourceRoot&&(e=i.relative(this.sourceRoot,e)),this._sources.has(e))return this.sourcesContent[this._sources.indexOf(e)];var t;if(null!=this.sourceRoot&&(t=i.urlParse(this.sourceRoot))){ // XXX: file:// URIs and absolute paths lead to unexpected behavior for // many users. We can help them out when they expect file:// URIs to // behave like it would if they were running a local HTTP server. See @@ -714,7 +617,25 @@ var n=e.replace(/^file:\/\//,"");if("file"==t.scheme&&this._sources.has(n))retur * - line: The line number in the generated source, or null. * - column: The column number in the generated source, or null. */ -r.prototype.generatedPositionFor=function(e){var t={source:o.getArg(e,"source"),originalLine:o.getArg(e,"line"),originalColumn:o.getArg(e,"column")};null!=this.sourceRoot&&(t.source=o.relative(this.sourceRoot,t.source));var n=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions);return n?{line:o.getArg(n,"generatedLine",null),column:o.getArg(n,"generatedColumn",null)}:{line:null,column:null}},r.GENERATED_ORDER=1,r.ORIGINAL_ORDER=2,/** +r.prototype.generatedPositionFor=function(e){var t={source:i.getArg(e,"source"),originalLine:i.getArg(e,"line"),originalColumn:i.getArg(e,"column")};null!=this.sourceRoot&&(t.source=i.relative(this.sourceRoot,t.source));var n=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions);if(n>=0){var r=this._originalMappings[n];return{line:i.getArg(r,"generatedLine",null),column:i.getArg(r,"generatedColumn",null),lastColumn:i.getArg(r,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},/** + * Returns all generated line and column information for the original source + * and line provided. The only argument is an object with the following + * properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * + * and an array of objects is returned, each with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ +r.prototype.allGeneratedPositionsFor=function(e){ +// When there is no exact match, SourceMapConsumer.prototype._findMapping +// returns the index of the closest mapping less than the needle. By +// setting needle.originalColumn to Infinity, we thus find the last +// mapping for the given line, provided such a mapping exists. +var t={source:i.getArg(e,"source"),originalLine:i.getArg(e,"line"),originalColumn:1/0};null!=this.sourceRoot&&(t.source=i.relative(this.sourceRoot,t.source));var n=[],r=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions);if(r>=0)for(var o=this._originalMappings[r];o&&o.originalLine===t.originalLine;)n.push({line:i.getArg(o,"generatedLine",null),column:i.getArg(o,"generatedColumn",null),lastColumn:i.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[--r];return n.reverse()},r.GENERATED_ORDER=1,r.ORIGINAL_ORDER=2,/** * Iterate over each mapping between an original source/line/column and a * generated line/column in this source map. * @@ -730,7 +651,7 @@ r.prototype.generatedPositionFor=function(e){var t={source:o.getArg(e,"source"), * order or the original's source/line/column order, respectively. Defaults to * `SourceMapConsumer.GENERATED_ORDER`. */ -r.prototype.eachMapping=function(e,t,n){var i,a=t||null,s=n||r.GENERATED_ORDER;switch(s){case r.GENERATED_ORDER:i=this._generatedMappings;break;case r.ORIGINAL_ORDER:i=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var l=this.sourceRoot;i.map(function(e){var t=e.source;return null!=t&&null!=l&&(t=o.join(l,t)),{source:t,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name}}).forEach(e,a)},t.SourceMapConsumer=r})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-consumer.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"./array-set":9,"./base64-vlq":10,"./binary-search":12,"./util":16,"1YiZ5S":24,amdefine:17,buffer:20}],14:[function(e,t,n){(function(n,r,o,i,a,s,l,u,c){/* -*- Mode: js; js-indent-level: 2; -*- */ +r.prototype.eachMapping=function(e,t,n){var o,a=t||null,s=n||r.GENERATED_ORDER;switch(s){case r.GENERATED_ORDER:o=this._generatedMappings;break;case r.ORIGINAL_ORDER:o=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var u=this.sourceRoot;o.map(function(e){var t=e.source;return null!=t&&null!=u&&(t=i.join(u,t)),{source:t,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name}}).forEach(e,a)},t.SourceMapConsumer=r})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-consumer.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"./array-set":9,"./base64-vlq":10,"./binary-search":12,"./util":17,"1YiZ5S":25,amdefine:18,buffer:21}],15:[function(e,t,n){(function(n,r,i,o,a,s,u,l,c){/* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: @@ -744,12 +665,12 @@ if("function"!=typeof f)var f=e("amdefine")(t,e);f(function(e,t,n){/** * - file: The filename of the generated source. * - sourceRoot: A root for all relative URLs in this source map. */ -function r(e){e||(e={}),this._file=i.getArg(e,"file",null),this._sourceRoot=i.getArg(e,"sourceRoot",null),this._sources=new a,this._names=new a,this._mappings=[],this._sourcesContents=null}var o=e("./base64-vlq"),i=e("./util"),a=e("./array-set").ArraySet;r.prototype._version=3,/** +function r(e){e||(e={}),this._file=o.getArg(e,"file",null),this._sourceRoot=o.getArg(e,"sourceRoot",null),this._skipValidation=o.getArg(e,"skipValidation",!1),this._sources=new a,this._names=new a,this._mappings=new s,this._sourcesContents=null}var i=e("./base64-vlq"),o=e("./util"),a=e("./array-set").ArraySet,s=e("./mapping-list").MappingList;r.prototype._version=3,/** * Creates a new SourceMapGenerator based on a SourceMapConsumer * * @param aSourceMapConsumer The SourceMap. */ -r.fromSourceMap=function(e){var t=e.sourceRoot,n=new r({file:e.file,sourceRoot:t});return e.eachMapping(function(e){var r={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(r.source=e.source,null!=t&&(r.source=i.relative(t,r.source)),r.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(r.name=e.name)),n.addMapping(r)}),e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&n.setSourceContent(t,r)}),n},/** +r.fromSourceMap=function(e){var t=e.sourceRoot,n=new r({file:e.file,sourceRoot:t});return e.eachMapping(function(e){var r={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(r.source=e.source,null!=t&&(r.source=o.relative(t,r.source)),r.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(r.name=e.name)),n.addMapping(r)}),e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&n.setSourceContent(t,r)}),n},/** * Add a single mapping from original source line and column to the generated * source's line and column for this source map being created. The mapping * object should have the following properties: @@ -759,16 +680,16 @@ r.fromSourceMap=function(e){var t=e.sourceRoot,n=new r({file:e.file,sourceRoot:t * - source: The original source file (relative to the sourceRoot). * - name: An optional original token name for this mapping. */ -r.prototype.addMapping=function(e){var t=i.getArg(e,"generated"),n=i.getArg(e,"original",null),r=i.getArg(e,"source",null),o=i.getArg(e,"name",null);this._validateMapping(t,n,r,o),null==r||this._sources.has(r)||this._sources.add(r),null==o||this._names.has(o)||this._names.add(o),this._mappings.push({generatedLine:t.line,generatedColumn:t.column,originalLine:null!=n&&n.line,originalColumn:null!=n&&n.column,source:r,name:o})},/** +r.prototype.addMapping=function(e){var t=o.getArg(e,"generated"),n=o.getArg(e,"original",null),r=o.getArg(e,"source",null),i=o.getArg(e,"name",null);this._skipValidation||this._validateMapping(t,n,r,i),null==r||this._sources.has(r)||this._sources.add(r),null==i||this._names.has(i)||this._names.add(i),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:null!=n&&n.line,originalColumn:null!=n&&n.column,source:r,name:i})},/** * Set the source content for a source file. */ -r.prototype.setSourceContent=function(e,t){var n=e;null!=this._sourceRoot&&(n=i.relative(this._sourceRoot,n)),null!=t?( +r.prototype.setSourceContent=function(e,t){var n=e;null!=this._sourceRoot&&(n=o.relative(this._sourceRoot,n)),null!=t?( // Add the source content to the _sourcesContents map. // Create a new _sourcesContents map if the property is null. -this._sourcesContents||(this._sourcesContents={}),this._sourcesContents[i.toSetString(n)]=t):this._sourcesContents&&( +this._sourcesContents||(this._sourcesContents={}),this._sourcesContents[o.toSetString(n)]=t):this._sourcesContents&&( // Remove the source file from the _sourcesContents map. // If the _sourcesContents map is empty, set the property to null. -delete this._sourcesContents[i.toSetString(n)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},/** +delete this._sourcesContents[o.toSetString(n)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},/** * Applies the mappings of a sub-source-map for a specific source file to the * source map being generated. Each mapping to the supplied source file is * rewritten using the supplied source map. Note: The resolution for the @@ -786,20 +707,20 @@ delete this._sourcesContents[i.toSetString(n)],0===Object.keys(this._sourcesCont */ r.prototype.applySourceMap=function(e,t,n){var r=t; // If aSourceFile is omitted, we will use the file property of the SourceMap -if(null==t){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');r=e.file}var o=this._sourceRoot; +if(null==t){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');r=e.file}var i=this._sourceRoot; // Make "sourceFile" relative if an absolute Url is passed. -null!=o&&(r=i.relative(o,r)); +null!=i&&(r=o.relative(i,r)); // Applying the SourceMap can add and remove items from the sources and // the names array. -var s=new a,l=new a; +var s=new a,u=new a; // Find mappings for the "sourceFile" -this._mappings.forEach(function(t){if(t.source===r&&null!=t.originalLine){ +this._mappings.unsortedForEach(function(t){if(t.source===r&&null!=t.originalLine){ // Check if it can be mapped by the source map, then update the mapping. var a=e.originalPositionFor({line:t.originalLine,column:t.originalColumn});null!=a.source&&( // Copy mapping -t.source=a.source,null!=n&&(t.source=i.join(n,t.source)),null!=o&&(t.source=i.relative(o,t.source)),t.originalLine=a.line,t.originalColumn=a.column,null!=a.name&&(t.name=a.name))}var u=t.source;null==u||s.has(u)||s.add(u);var c=t.name;null==c||l.has(c)||l.add(c)},this),this._sources=s,this._names=l, +t.source=a.source,null!=n&&(t.source=o.join(n,t.source)),null!=i&&(t.source=o.relative(i,t.source)),t.originalLine=a.line,t.originalColumn=a.column,null!=a.name&&(t.name=a.name))}var l=t.source;null==l||s.has(l)||s.add(l);var c=t.name;null==c||u.has(c)||u.add(c)},this),this._sources=s,this._names=u, // Copy sourcesContents of applied map. -e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&(null!=n&&(t=i.join(n,t)),null!=o&&(t=i.relative(o,t)),this.setSourceContent(t,r))},this)},/** +e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&(null!=n&&(t=o.join(n,t)),null!=i&&(t=o.relative(i,t)),this.setSourceContent(t,r))},this)},/** * A mapping can have one of the three levels of data: * * 1. Just the generated position. @@ -810,25 +731,17 @@ e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&(null!=n&&(t= * To maintain consistency, we validate that any new mapping being added falls * in to one of these categories. */ -r.prototype._validateMapping=function(e,t,n,r){if(!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!t&&!n&&!r||e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:t,name:r}))},/** +r.prototype._validateMapping=function(e,t,n,r){if((!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||n||r)&&!(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:t,name:r}))},/** * Serialize the accumulated mappings in to the stream of base 64 VLQs * specified by the source map format. */ -r.prototype._serializeMappings=function(){var e,t=0,n=1,r=0,a=0,s=0,l=0,u=""; -// The mappings must be guaranteed to be in sorted order before we start -// serializing them or else the generated line numbers (which are defined -// via the ';' separators) will be all messed up. Note: it might be more -// performant to maintain the sorting as we insert them, rather than as we -// serialize them, but the big O is the same either way. -this._mappings.sort(i.compareByGeneratedPositions);for(var c=0,f=this._mappings.length;f>c;c++){if(e=this._mappings[c],e.generatedLine!==n)for(t=0;e.generatedLine!==n;)u+=";",n++;else if(c>0){if(!i.compareByGeneratedPositions(e,this._mappings[c-1]))continue;u+=","}u+=o.encode(e.generatedColumn-t),t=e.generatedColumn,null!=e.source&&(u+=o.encode(this._sources.indexOf(e.source)-l),l=this._sources.indexOf(e.source), -// lines are stored 0-based in SourceMap spec version 3 -u+=o.encode(e.originalLine-1-a),a=e.originalLine-1,u+=o.encode(e.originalColumn-r),r=e.originalColumn,null!=e.name&&(u+=o.encode(this._names.indexOf(e.name)-s),s=this._names.indexOf(e.name)))}return u},r.prototype._generateSourcesContent=function(e,t){return e.map(function(e){if(!this._sourcesContents)return null;null!=t&&(e=i.relative(t,e));var n=i.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null},this)},/** +r.prototype._serializeMappings=function(){for(var e,t=0,n=1,r=0,a=0,s=0,u=0,l="",c=this._mappings.toArray(),f=0,p=c.length;p>f;f++){if(e=c[f],e.generatedLine!==n)for(t=0;e.generatedLine!==n;)l+=";",n++;else if(f>0){if(!o.compareByGeneratedPositions(e,c[f-1]))continue;l+=","}l+=i.encode(e.generatedColumn-t),t=e.generatedColumn,null!=e.source&&(l+=i.encode(this._sources.indexOf(e.source)-u),u=this._sources.indexOf(e.source),l+=i.encode(e.originalLine-1-a),a=e.originalLine-1,l+=i.encode(e.originalColumn-r),r=e.originalColumn,null!=e.name&&(l+=i.encode(this._names.indexOf(e.name)-s),s=this._names.indexOf(e.name)))}return l},r.prototype._generateSourcesContent=function(e,t){return e.map(function(e){if(!this._sourcesContents)return null;null!=t&&(e=o.relative(t,e));var n=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null},this)},/** * Externalize the source map. */ r.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},/** * Render the source map being generated to a string. */ -r.prototype.toString=function(){return JSON.stringify(this)},t.SourceMapGenerator=r})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-generator.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"./array-set":9,"./base64-vlq":10,"./util":16,"1YiZ5S":24,amdefine:17,buffer:20}],15:[function(e,t,n){(function(n,r,o,i,a,s,l,u,c){/* -*- Mode: js; js-indent-level: 2; -*- */ +r.prototype.toString=function(){return JSON.stringify(this)},t.SourceMapGenerator=r})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-generator.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"./array-set":9,"./base64-vlq":10,"./mapping-list":13,"./util":17,"1YiZ5S":25,amdefine:18,buffer:21}],16:[function(e,t,n){(function(n,r,i,o,a,s,u,l,c){/* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: @@ -846,7 +759,7 @@ if("function"!=typeof f)var f=e("amdefine")(t,e);f(function(e,t,n){/** * generated JS, or other SourceNodes. * @param aName The original identifier. */ -function r(e,t,n,r,o){this.children=[],this.sourceContents={},this.line=null==e?null:e,this.column=null==t?null:t,this.source=null==n?null:n,this.name=null==o?null:o,null!=r&&this.add(r)}var o=e("./source-map-generator").SourceMapGenerator,i=e("./util"),a=/(\r?\n)/,s=/\r\n|[\s\S]/g;/** +function r(e,t,n,r,i){this.children=[],this.sourceContents={},this.line=null==e?null:e,this.column=null==t?null:t,this.source=null==n?null:n,this.name=null==i?null:i,this[u]=!0,null!=r&&this.add(r)}var i=e("./source-map-generator").SourceMapGenerator,o=e("./util"),a=/(\r?\n)/,s=10,u="$$$isSourceNode$$$";/** * Creates a SourceNode from generated code and a SourceMapConsumer. * * @param aGeneratedCode The generated code @@ -854,10 +767,10 @@ function r(e,t,n,r,o){this.children=[],this.sourceContents={},this.line=null==e? * @param aRelativePath Optional. The path that relative sources in the * SourceMapConsumer should be relative to. */ -r.fromStringWithSourceMap=function(e,t,n){function o(e,t){if(null===e||void 0===e.source)s.add(t);else{var o=n?i.join(n,e.source):e.source;s.add(new r(e.originalLine,e.originalColumn,o,t,e.name))}} +r.fromStringWithSourceMap=function(e,t,n){function i(e,t){if(null===e||void 0===e.source)s.add(t);else{var i=n?o.join(n,e.source):e.source;s.add(new r(e.originalLine,e.originalColumn,i,t,e.name))}} // The SourceNode we want to fill with the generated code // and the SourceMap -var s=new r,l=e.split(a),u=function(){var e=l.shift(),t=l.shift()||"";return e+t},c=1,f=0,p=null; +var s=new r,u=e.split(a),l=function(){var e=u.shift(),t=u.shift()||"";return e+t},c=1,f=0,p=null; // We have processed all mappings. // Associate the remaining code in the current line with "lastMapping" // and add the remaining lines without any mapping @@ -869,34 +782,32 @@ if(!(c0&&(p&&o(p,u()),s.add(l.join(""))),t.sources.forEach(function(e){var r=t.sourceContentFor(e);null!=r&&(null!=n&&(e=i.join(n,e)),s.setSourceContent(e,r))}),s},/** +for(;c0&&(p&&i(p,l()),s.add(u.join(""))),t.sources.forEach(function(e){var r=t.sourceContentFor(e);null!=r&&(null!=n&&(e=o.join(n,e)),s.setSourceContent(e,r))}),s},/** * Add a chunk of generated JS to this source node. * * @param aChunk A string snippet of generated JS code, another instance of * SourceNode, or an array where each member is one of those things. */ -r.prototype.add=function(e){if(Array.isArray(e))e.forEach(function(e){this.add(e)},this);else{if(!(e instanceof r||"string"==typeof e))throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);e&&this.children.push(e)}return this},/** +r.prototype.add=function(e){if(Array.isArray(e))e.forEach(function(e){this.add(e)},this);else{if(!e[u]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);e&&this.children.push(e)}return this},/** * Add a chunk of generated JS to the beginning of this source node. * * @param aChunk A string snippet of generated JS code, another instance of * SourceNode, or an array where each member is one of those things. */ -r.prototype.prepend=function(e){if(Array.isArray(e))for(var t=e.length-1;t>=0;t--)this.prepend(e[t]);else{if(!(e instanceof r||"string"==typeof e))throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this},/** +r.prototype.prepend=function(e){if(Array.isArray(e))for(var t=e.length-1;t>=0;t--)this.prepend(e[t]);else{if(!e[u]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this},/** * Walk over the tree of JS snippets in this node and its children. The * walking function is called once for each snippet of JS and is passed that * snippet and the its original associated source's line/column location. * * @param aFn The traversal function. */ -r.prototype.walk=function(e){for(var t,n=0,o=this.children.length;o>n;n++)t=this.children[n],t instanceof r?t.walk(e):""!==t&&e(t,{source:this.source,line:this.line,column:this.column,name:this.name})},/** +r.prototype.walk=function(e){for(var t,n=0,r=this.children.length;r>n;n++)t=this.children[n],t[u]?t.walk(e):""!==t&&e(t,{source:this.source,line:this.line,column:this.column,name:this.name})},/** * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between * each of `this.children`. * @@ -909,20 +820,20 @@ r.prototype.join=function(e){var t,n,r=this.children.length;if(r>0){for(t=[],n=0 * @param aPattern The pattern to replace. * @param aReplacement The thing to replace the pattern with. */ -r.prototype.replaceRight=function(e,t){var n=this.children[this.children.length-1];return n instanceof r?n.replaceRight(e,t):"string"==typeof n?this.children[this.children.length-1]=n.replace(e,t):this.children.push("".replace(e,t)),this},/** +r.prototype.replaceRight=function(e,t){var n=this.children[this.children.length-1];return n[u]?n.replaceRight(e,t):"string"==typeof n?this.children[this.children.length-1]=n.replace(e,t):this.children.push("".replace(e,t)),this},/** * Set the source content for a source file. This will be added to the SourceMapGenerator * in the sourcesContent field. * * @param aSourceFile The filename of the source file * @param aSourceContent The content of the source file */ -r.prototype.setSourceContent=function(e,t){this.sourceContents[i.toSetString(e)]=t},/** +r.prototype.setSourceContent=function(e,t){this.sourceContents[o.toSetString(e)]=t},/** * Walk over the tree of SourceNodes. The walking function is called for each * source file content and is passed the filename and source content. * * @param aFn The traversal function. */ -r.prototype.walkSourceContents=function(e){for(var t=0,n=this.children.length;n>t;t++)this.children[t]instanceof r&&this.children[t].walkSourceContents(e);for(var o=Object.keys(this.sourceContents),t=0,n=o.length;n>t;t++)e(i.fromSetString(o[t]),this.sourceContents[o[t]])},/** +r.prototype.walkSourceContents=function(e){for(var t=0,n=this.children.length;n>t;t++)this.children[t][u]&&this.children[t].walkSourceContents(e);for(var r=Object.keys(this.sourceContents),t=0,n=r.length;n>t;t++)e(o.fromSetString(r[t]),this.sourceContents[r[t]])},/** * Return the string representation of this source node. Walks over the tree * and concatenates all the various snippets together to one string. */ @@ -930,9 +841,9 @@ r.prototype.toString=function(){var e="";return this.walk(function(t){e+=t}),e}, * Returns the string representation of this source node along with a source * map. */ -r.prototype.toStringWithSourceMap=function(e){var t={code:"",line:1,column:0},n=new o(e),r=!1,i=null,l=null,u=null,c=null;return this.walk(function(e,o){t.code+=e,null!==o.source&&null!==o.line&&null!==o.column?((i!==o.source||l!==o.line||u!==o.column||c!==o.name)&&n.addMapping({source:o.source,original:{line:o.line,column:o.column},generated:{line:t.line,column:t.column},name:o.name}),i=o.source,l=o.line,u=o.column,c=o.name,r=!0):r&&(n.addMapping({generated:{line:t.line,column:t.column}}),i=null,r=!1),e.match(s).forEach(function(e,s,l){a.test(e)?(t.line++,t.column=0, +r.prototype.toStringWithSourceMap=function(e){var t={code:"",line:1,column:0},n=new i(e),r=!1,o=null,a=null,u=null,l=null;return this.walk(function(e,i){t.code+=e,null!==i.source&&null!==i.line&&null!==i.column?((o!==i.source||a!==i.line||u!==i.column||l!==i.name)&&n.addMapping({source:i.source,original:{line:i.line,column:i.column},generated:{line:t.line,column:t.column},name:i.name}),o=i.source,a=i.line,u=i.column,l=i.name,r=!0):r&&(n.addMapping({generated:{line:t.line,column:t.column}}),o=null,r=!1);for(var c=0,f=e.length;f>c;c++)e.charCodeAt(c)===s?(t.line++,t.column=0, // Mappings end at eol -s+1===l.length?(i=null,r=!1):r&&n.addMapping({source:o.source,original:{line:o.line,column:o.column},generated:{line:t.line,column:t.column},name:o.name})):t.column+=e.length})}),this.walkSourceContents(function(e,t){n.setSourceContent(e,t)}),{code:t.code,map:n}},t.SourceNode=r})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-node.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"./source-map-generator":14,"./util":16,"1YiZ5S":24,amdefine:17,buffer:20}],16:[function(e,t,n){(function(n,r,o,i,a,s,l,u,c){/* -*- Mode: js; js-indent-level: 2; -*- */ +c+1===f?(o=null,r=!1):r&&n.addMapping({source:i.source,original:{line:i.line,column:i.column},generated:{line:t.line,column:t.column},name:i.name})):t.column++}),this.walkSourceContents(function(e,t){n.setSourceContent(e,t)}),{code:t.code,map:n}},t.SourceNode=r})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/source-node.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"./source-map-generator":15,"./util":17,"1YiZ5S":25,amdefine:18,buffer:21}],17:[function(e,t,n){(function(n,r,i,o,a,s,u,l,c){/* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: @@ -948,7 +859,7 @@ if("function"!=typeof f)var f=e("amdefine")(t,e);f(function(e,t,n){/** * from the object. If this is not specified and the property is missing, an * error will be thrown. */ -function r(e,t,n){if(t in e)return e[t];if(3===arguments.length)return n;throw new Error('"'+t+'" is a required argument.')}function o(e){var t=e.match(m);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}function i(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}/** +function r(e,t,n){if(t in e)return e[t];if(3===arguments.length)return n;throw new Error('"'+t+'" is a required argument.')}function i(e){var t=e.match(m);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}function o(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}/** * Normalizes a path, or the path portion of a URL: * * - Replaces consequtive slashes with one slash. @@ -959,11 +870,7 @@ function r(e,t,n){if(t in e)return e[t];if(3===arguments.length)return n;throw n * * @param aPath The path or url to normalize. */ -function a(e){var t=e,n=o(e);if(n){if(!n.path)return e;t=n.path}for(var r,a="/"===t.charAt(0),s=t.split(/\/+/),l=0,u=s.length-1;u>=0;u--)r=s[u],"."===r?s.splice(u,1):".."===r?l++:l>0&&(""===r?( -// The first part is blank if the path is absolute. Trying to go -// above the root is a no-op. Therefore we can remove all '..' parts -// directly after the root. -s.splice(u+1,l),l=0):(s.splice(u,2),l--));return t=s.join("/"),""===t&&(t=a?"/":"."),n?(n.path=t,i(n)):t}/** +function a(e){var t=e,n=i(e);if(n){if(!n.path)return e;t=n.path}for(var r,a="/"===t.charAt(0),s=t.split(/\/+/),u=0,l=s.length-1;l>=0;l--)r=s[l],"."===r?s.splice(l,1):".."===r?u++:u>0&&(""===r?(s.splice(l+1,u),u=0):(s.splice(l,2),u--));return t=s.join("/"),""===t&&(t=a?"/":"."),n?(n.path=t,o(n)):t}/** * Joins two paths/URLs. * * @param aRoot The root path or URL. @@ -979,19 +886,19 @@ s.splice(u+1,l),l=0):(s.splice(u,2),l--));return t=s.join("/"),""===t&&(t=a?"/": * - Otherwise the two paths are joined with a slash. * - Joining for example 'http://' and 'www.example.com' is also supported. */ -function s(e,t){""===e&&(e="."),""===t&&(t=".");var n=o(t),r=o(e); +function s(e,t){""===e&&(e="."),""===t&&(t=".");var n=i(t),r=i(e); // `join(foo, '//www.example.org')` -if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),i(n);if(n||t.match(h))return t; +if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),o(n);if(n||t.match(h))return t; // `join('http://', 'www.example.com')` -if(r&&!r.host&&!r.path)return r.host=t,i(r);var s="/"===t.charAt(0)?t:a(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=s,i(r)):s}/** +if(r&&!r.host&&!r.path)return r.host=t,o(r);var s="/"===t.charAt(0)?t:a(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=s,o(r)):s}/** * Make a path relative to a URL or another path. * * @param aRoot The root path or URL. * @param aPath The path or URL to be made relative to aRoot. */ -function l(e,t){""===e&&(e="."),e=e.replace(/\/$/,""); +function u(e,t){""===e&&(e="."),e=e.replace(/\/$/,""); // XXX: It is possible to remove this block, and the tests still pass! -var n=o(e);return"/"==t.charAt(0)&&n&&"/"==n.path?t.slice(1):0===t.indexOf(e+"/")?t.substr(e.length+1):t}/** +var n=i(e);return"/"==t.charAt(0)&&n&&"/"==n.path?t.slice(1):0===t.indexOf(e+"/")?t.substr(e.length+1):t}/** * Because behavior goes wacky when you set `__proto__` on objects, we * have to prefix all the strings in our set with an arbitrary character. * @@ -1000,7 +907,7 @@ var n=o(e);return"/"==t.charAt(0)&&n&&"/"==n.path?t.slice(1):0===t.indexOf(e+"/" * * @param String aStr */ -function u(e){return"$"+e}function c(e){return e.substr(1)}function f(e,t){var n=e||"",r=t||"";return(n>r)-(r>n)}/** +function l(e){return"$"+e}function c(e){return e.substr(1)}function f(e,t){var n=e||"",r=t||"";return(n>r)-(r>n)}/** * Comparator between two mappings where the original positions are compared. * * Optionally pass in `true` as `onlyCompareGenerated` to consider two @@ -1017,7 +924,7 @@ function p(e,t,n){var r;return(r=f(e.source,t.source))?r:(r=e.originalLine-t.ori * source/name/original line and column the same. Useful when searching for a * mapping with a stubbed out mapping. */ -function d(e,t,n){var r;return(r=e.generatedLine-t.generatedLine)?r:(r=e.generatedColumn-t.generatedColumn,r||n?r:(r=f(e.source,t.source))?r:(r=e.originalLine-t.originalLine)?r:(r=e.originalColumn-t.originalColumn,r?r:f(e.name,t.name)))}t.getArg=r;var m=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/,h=/^data:.+\,.+$/;t.urlParse=o,t.urlGenerate=i,t.normalize=a,t.join=s,t.relative=l,t.toSetString=u,t.fromSetString=c,t.compareByOriginalPositions=p,t.compareByGeneratedPositions=d})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/util.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"1YiZ5S":24,amdefine:17,buffer:20}],17:[function(e,t,n){(function(n,r,o,i,a,s,l,u,c){/** vim: et:ts=4:sw=4:sts=4 +function d(e,t,n){var r;return(r=e.generatedLine-t.generatedLine)?r:(r=e.generatedColumn-t.generatedColumn,r||n?r:(r=f(e.source,t.source))?r:(r=e.originalLine-t.originalLine)?r:(r=e.originalColumn-t.originalColumn,r?r:f(e.name,t.name)))}t.getArg=r;var m=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/,h=/^data:.+\,.+$/;t.urlParse=i,t.urlGenerate=o,t.normalize=a,t.join=s,t.relative=u,t.toSetString=l,t.fromSetString=c,t.compareByOriginalPositions=p,t.compareByGeneratedPositions=d})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/lib/source-map/util.js","/../node_modules/escodegen/node_modules/source-map/lib/source-map")},{"1YiZ5S":25,amdefine:18,buffer:21}],18:[function(e,t,n){(function(n,r,i,o,a,s,u,l,c){/** vim: et:ts=4:sw=4:sts=4 * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/jrburke/amdefine for details @@ -1043,37 +950,37 @@ function f(t,r){/** * NOTE: this method MODIFIES the input array. * @param {Array} ary the array of path segments. */ -function o(e){var t,n;for(t=0;e[t];t+=1)if(n=e[t],"."===n)e.splice(t,1),t-=1;else if(".."===n){if(1===t&&(".."===e[2]||".."===e[0])) +function i(e){var t,n;for(t=0;e[t];t+=1)if(n=e[t],"."===n)e.splice(t,1),t-=1;else if(".."===n){if(1===t&&(".."===e[2]||".."===e[0])) //End of the line. Keep at least one non-dot //path segment at the front so it can be mapped //correctly to disk. Otherwise, there is likely //no path mapping for a path starting with '..'. //This can still fail, but catches the most reasonable //uses of .. -break;t>0&&(e.splice(t-1,2),t-=2)}}function i(e,t){var n; +break;t>0&&(e.splice(t-1,2),t-=2)}}function o(e,t){var n; //Adjust any relative paths. -return e&&"."===e.charAt(0)&&t&&(n=t.split("/"),n=n.slice(0,n.length-1),n=n.concat(e.split("/")),o(n),e=n.join("/")),e}/** +return e&&"."===e.charAt(0)&&t&&(n=t.split("/"),n=n.slice(0,n.length-1),n=n.concat(e.split("/")),i(n),e=n.join("/")),e}/** * Create the normalize() function passed to a loader plugin's * normalize method. */ -function a(e){return function(t){return i(t,e)}}function s(e){function t(t){m[e]=t}return t.fromText=function(e,t){ +function a(e){return function(t){return o(t,e)}}function s(e){function t(t){m[e]=t}return t.fromText=function(e,t){ //This one is difficult because the text can/probably uses //define, and any relative paths and requires should be relative //to that id was it would be found on disk. But this would require //bootstrapping a module/require fairly deeply from node core. //Not sure how best to go about that yet. -throw new Error("amdefine does not implement load.fromText")},t}function l(e,n,o){var i,a,s,l;if(e)a=m[e]={},s={id:e,uri:u,exports:a},i=f(r,a,s,e);else{ +throw new Error("amdefine does not implement load.fromText")},t}function u(e,n,i){var o,a,s,u;if(e)a=m[e]={},s={id:e,uri:l,exports:a},o=f(r,a,s,e);else{ //Only support one define call per file if(h)throw new Error("amdefine with no module ID cannot be called more than once per file.");h=!0, //Use the real variables from node //Use module.exports for exports, since //the exports in here is amdefine exports. -a=t.exports,s=t,i=f(r,a,s,t.id)} +a=t.exports,s=t,o=f(r,a,s,t.id)} //If there are dependencies, they are strings, so need //to convert them to dependency values. -n&&(n=n.map(function(e){return i(e)})), +n&&(n=n.map(function(e){return o(e)})), //Call the factory with the right dependencies. -l="function"==typeof o?o.apply(s.exports,n):o,void 0!==l&&(s.exports=l,e&&(m[e]=s.exports))} +u="function"==typeof i?i.apply(s.exports,n):i,void 0!==u&&(s.exports=u,e&&(m[e]=s.exports))} //Create a define function specific to the module asking for amdefine. function c(e,t,n){Array.isArray(e)?(n=t,t=e,e=void 0):"string"!=typeof e&&(n=e,e=t=void 0),t&&!Array.isArray(t)&&(n=t,t=void 0),t||(t=["require","exports","module"]), //Set up properties for this module. If an ID, then use @@ -1082,24 +989,17 @@ function c(e,t,n){Array.isArray(e)?(n=t,t=e,e=void 0):"string"!=typeof e&&(n=e,e e? //Put the module in deep freeze until there is a //require call for it. -d[e]=[e,t,n]:l(e,t,n)}var f,p,d={},m={},h=!1,g=e("path"); +d[e]=[e,t,n]:u(e,t,n)}var f,p,d={},m={},h=!1,g=e("path"); //Favor explicit value, passed in if the module wants to support Node 0.4. //define.require, which has access to all the values in the //cache. Useful for AMD modules that all have IDs in the file, //but need to finally export a value to node based on one of those //IDs. -return f=function(e,t,r,o){function a(i,a){ +return f=function(e,t,r,i){function a(o,a){ //Array of dependencies with a callback. //Convert the dependencies to modules. //Wait for next tick to call back the require call. -return"string"==typeof i?p(e,t,r,i,o):(i=i.map(function(n){return p(e,t,r,n,o)}),void n.nextTick(function(){a.apply(null,i)}))}return a.toUrl=function(e){return 0===e.indexOf(".")?i(e,g.dirname(r.filename)):e},a},r=r||function(){return t.require.apply(t,arguments)},p=function(e,t,n,r,o){ -//Split the ID by a ! so that -var u,c,h=r.indexOf("!"),g=r;if(-1===h){ -//Straight module lookup. If it is one of the special dependencies, -//deal with it, otherwise, delegate to node. -if(r=i(r,o),"require"===r)return f(e,t,n,o);if("exports"===r)return t;if("module"===r)return n;if(m.hasOwnProperty(r))return m[r];if(d[r])return l.apply(null,d[r]),m[r];if(e)return e(g);throw new Error("No module with ID: "+r)} -//There is a plugin in play. -return u=r.substring(0,h),r=r.substring(h+1,r.length),c=p(e,t,n,u,o),r=c.normalize?c.normalize(r,a(o)):i(r,o),m[r]?m[r]:(c.load(r,f(e,t,n,o),s(r),{}),m[r])},c.require=function(e){return m[e]?m[e]:d[e]?(l.apply(null,d[e]),m[e]):void 0},c.amd={},c}t.exports=f}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/node_modules/amdefine/amdefine.js","/../node_modules/escodegen/node_modules/source-map/node_modules/amdefine")},{"1YiZ5S":24,buffer:20,path:23}],18:[function(e,t,n){t.exports={name:"escodegen",description:"ECMAScript code generator",homepage:"http://github.com/Constellation/escodegen",main:"escodegen.js",bin:{esgenerate:"./bin/esgenerate.js",escodegen:"./bin/escodegen.js"},version:"1.4.1",engines:{node:">=0.10.0"},maintainers:[{name:"constellation",email:"utatane.tea@gmail.com"}],repository:{type:"git",url:"http://github.com/Constellation/escodegen.git"},dependencies:{estraverse:"^1.5.1",esutils:"^1.1.4",esprima:"^1.2.2","source-map":"~0.1.37"},optionalDependencies:{"source-map":"~0.1.37"},devDependencies:{"esprima-moz":"*",semver:"^3.0.1",bluebird:"^2.2.2","jshint-stylish":"^0.4.0",chai:"^1.9.1","gulp-mocha":"^1.0.0","gulp-eslint":"^0.1.8",gulp:"^3.8.6","bower-registry-client":"^0.2.1","gulp-jshint":"^1.8.0","commonjs-everywhere":"^0.9.7"},licenses:[{type:"BSD",url:"http://github.com/Constellation/escodegen/raw/master/LICENSE.BSD"}],scripts:{test:"gulp travis","unit-test":"gulp test",lint:"gulp lint",release:"node tools/release.js","build-min":"cjsify -ma path: tools/entry-point.js > escodegen.browser.min.js",build:"cjsify -a path: tools/entry-point.js > escodegen.browser.js"},gitHead:"87296a9ac34dcaf6567bd7e3d351e4a227b434dc",bugs:{url:"https://github.com/Constellation/escodegen/issues"},_id:"escodegen@1.4.1",_shasum:"8c2562ff45da348975953e8c0a57f40848962ec7",_from:"escodegen@*",_npmVersion:"2.0.0-alpha-5",_npmUser:{name:"constellation",email:"utatane.tea@gmail.com"},dist:{shasum:"8c2562ff45da348975953e8c0a57f40848962ec7",tarball:"http://registry.npmjs.org/escodegen/-/escodegen-1.4.1.tgz"},directories:{},_resolved:"https://registry.npmjs.org/escodegen/-/escodegen-1.4.1.tgz"}},{}],19:[function(e,t,n){(function(e,t,r,o,i,a,s,l,u){/* +return"string"==typeof o?p(e,t,r,o,i):(o=o.map(function(n){return p(e,t,r,n,i)}),void(a&&n.nextTick(function(){a.apply(null,o)})))}return a.toUrl=function(e){return 0===e.indexOf(".")?o(e,g.dirname(r.filename)):e},a},r=r||function(){return t.require.apply(t,arguments)},p=function(e,t,n,r,i){var l,c,h=r.indexOf("!"),g=r;if(-1===h){if(r=o(r,i),"require"===r)return f(e,t,n,i);if("exports"===r)return t;if("module"===r)return n;if(m.hasOwnProperty(r))return m[r];if(d[r])return u.apply(null,d[r]),m[r];if(e)return e(g);throw new Error("No module with ID: "+r)}return l=r.substring(0,h),r=r.substring(h+1,r.length),c=p(e,t,n,l,i),r=c.normalize?c.normalize(r,a(i)):o(r,i),m[r]?m[r]:(c.load(r,f(e,t,n,i),s(r),{}),m[r])},c.require=function(e){return m[e]?m[e]:d[e]?(u.apply(null,d[e]),m[e]):void 0},c.amd={},c}t.exports=f}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/node_modules/source-map/node_modules/amdefine/amdefine.js","/../node_modules/escodegen/node_modules/source-map/node_modules/amdefine")},{"1YiZ5S":25,buffer:21,path:24}],19:[function(e,t,n){t.exports={name:"escodegen",description:"ECMAScript code generator",homepage:"http://github.com/estools/escodegen",main:"escodegen.js",bin:{esgenerate:"./bin/esgenerate.js",escodegen:"./bin/escodegen.js"},files:["LICENSE.BSD","LICENSE.source-map","README.md","bin","escodegen.js","package.json"],version:"1.6.1",engines:{node:">=0.10.0"},maintainers:[{name:"constellation",email:"utatane.tea@gmail.com"}],repository:{type:"git",url:"http://github.com/estools/escodegen.git"},dependencies:{estraverse:"^1.9.1",esutils:"^1.1.6",esprima:"^1.2.2",optionator:"^0.5.0","source-map":"~0.1.40"},optionalDependencies:{"source-map":"~0.1.40"},devDependencies:{"acorn-6to5":"^0.11.1-25",bluebird:"^2.3.11","bower-registry-client":"^0.2.1",chai:"^1.10.0","commonjs-everywhere":"^0.9.7","esprima-moz":"*",gulp:"^3.8.10","gulp-eslint":"^0.2.0","gulp-mocha":"^2.0.0",semver:"^4.1.0"},licenses:[{type:"BSD",url:"http://github.com/estools/escodegen/raw/master/LICENSE.BSD"}],scripts:{test:"gulp travis","unit-test":"gulp test",lint:"gulp lint",release:"node tools/release.js","build-min":"cjsify -ma path: tools/entry-point.js > escodegen.browser.min.js",build:"cjsify -a path: tools/entry-point.js > escodegen.browser.js"},gitHead:"1ca664f68dcf220b76c9dc562b2337c5e0b4227d",bugs:{url:"https://github.com/estools/escodegen/issues"},_id:"escodegen@1.6.1",_shasum:"367de17d8510540d12bc6dcb8b3f918391265815",_from:"escodegen@^1.4.1",_npmVersion:"2.0.0-alpha-5",_npmUser:{name:"constellation",email:"utatane.tea@gmail.com"},dist:{shasum:"367de17d8510540d12bc6dcb8b3f918391265815",tarball:"http://registry.npmjs.org/escodegen/-/escodegen-1.6.1.tgz"},directories:{},_resolved:"https://registry.npmjs.org/escodegen/-/escodegen-1.6.1.tgz",readme:"ERROR: No README data found!"}},{}],20:[function(e,t,n){(function(e,t,r,i,o,a,s,u,l){/* Copyright (C) 2013 Ariya Hidayat Copyright (C) 2013 Thaddee Tyl Copyright (C) 2013 Mathias Bynens @@ -1151,9 +1051,9 @@ parseStatement: true, parseSourceElement: true */ // to catch a logic error. The condition shall be fulfilled in normal case. // Do NOT use this to enforce a certain condition on any user input. function t(e,t){/* istanbul ignore if */ -if(!e)throw new Error("ASSERT: "+t)}function n(e){return e>=48&&57>=e}function r(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function o(e){return"01234567".indexOf(e)>=0} +if(!e)throw new Error("ASSERT: "+t)}function n(e){return e>=48&&57>=e}function r(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function i(e){return"01234567".indexOf(e)>=0} // 7.2 White Space -function i(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0} +function o(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0} // 7.3 Line Terminators function a(e){return 10===e||13===e||8232===e||8233===e} // 7.6 Identifier Names and Identifiers @@ -1161,52 +1061,47 @@ function s(e){// $ (dollar) and _ (underscore) // A..Z // a..z // \ (backslash) -return 36===e||95===e||e>=65&&90>=e||e>=97&&122>=e||92===e||e>=128&&ot.NonAsciiIdentifierStart.test(String.fromCharCode(e))}function l(e){// $ (dollar) and _ (underscore) +return 36===e||95===e||e>=65&&90>=e||e>=97&&122>=e||92===e||e>=128&&ot.NonAsciiIdentifierStart.test(String.fromCharCode(e))}function u(e){// $ (dollar) and _ (underscore) // A..Z // a..z // 0..9 // \ (backslash) return 36===e||95===e||e>=65&&90>=e||e>=97&&122>=e||e>=48&&57>=e||92===e||e>=128&&ot.NonAsciiIdentifierPart.test(String.fromCharCode(e))} // 7.6.1.2 Future Reserved Words -function u(e){switch(e){case"class":case"enum":case"export":case"extends":case"import":case"super":return!0;default:return!1}}function c(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}}function f(e){return"eval"===e||"arguments"===e} +function l(e){switch(e){case"class":case"enum":case"export":case"extends":case"import":case"super":return!0;default:return!1}}function c(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}}function f(e){return"eval"===e||"arguments"===e} // 7.6.1.1 Keywords -function p(e){if(st&&c(e))return!0; +function p(e){if(ut&&c(e))return!0; // 'const' is specialized as Keyword in V8. // 'yield' and 'let' are for compatiblity with SpiderMonkey and ES.next. // Some others are from future reserved words. switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e||"let"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}} // 7.4 Comments -function d(e,n,r,o,i){var a;t("number"==typeof r,"Comment must have valid position"), +function d(e,n,r,i,o){var a;t("number"==typeof r,"Comment must have valid position"), // Because the way the actual token is scanned, often the comments // (if any) are skipped twice during the lexical analysis. // Thus, we need to skip adding a comment if the comment array already // handled it. -mt.lastCommentStart>=r||(mt.lastCommentStart=r,a={type:e,value:n},ht.range&&(a.range=[r,o]),ht.loc&&(a.loc=i),ht.comments.push(a),ht.attachComment&&(ht.leadingComments.push(a),ht.trailingComments.push(a)))}function m(e){var t,n,r,o;for(t=lt-e,n={start:{line:ut,column:lt-ct-e}};ft>lt;)if(r=at.charCodeAt(lt),++lt,a(r))return ht.comments&&(o=at.slice(t+e,lt-1),n.end={line:ut,column:lt-ct-1},d("Line",o,t,lt-1,n)),13===r&&10===at.charCodeAt(lt)&&++lt,++ut,void(ct=lt);ht.comments&&(o=at.slice(t+e,lt),n.end={line:ut,column:lt-ct},d("Line",o,t,lt,n))}function h(){var e,t,n,r;for(ht.comments&&(e=lt-2,t={start:{line:ut,column:lt-ct-2}});ft>lt;)if(n=at.charCodeAt(lt),a(n))13===n&&10===at.charCodeAt(lt+1)&&++lt,++ut,++lt,ct=lt,lt>=ft&&j({},rt.UnexpectedToken,"ILLEGAL");else if(42===n){ +ht.lastCommentStart>=r||(ht.lastCommentStart=r,a={type:e,value:n},gt.range&&(a.range=[r,i]),gt.loc&&(a.loc=o),gt.comments.push(a),gt.attachComment&&(gt.leadingComments.push(a),gt.trailingComments.push(a)))}function m(e){var t,n,r,i;for(t=lt-e,n={start:{line:ct,column:lt-ft-e}};pt>lt;)if(r=st.charCodeAt(lt),++lt,a(r))return gt.comments&&(i=st.slice(t+e,lt-1),n.end={line:ct,column:lt-ft-1},d("Line",i,t,lt-1,n)),13===r&&10===st.charCodeAt(lt)&&++lt,++ct,void(ft=lt);gt.comments&&(i=st.slice(t+e,lt),n.end={line:ct,column:lt-ft},d("Line",i,t,lt,n))}function h(){var e,t,n,r;for(gt.comments&&(e=lt-2,t={start:{line:ct,column:lt-ft-2}});pt>lt;)if(n=st.charCodeAt(lt),a(n))13===n&&10===st.charCodeAt(lt+1)&&++lt,++ct,++lt,ft=lt,lt>=pt&&q({},it.UnexpectedToken,"ILLEGAL");else if(42===n){ // Block comment ends with '*/'. -if(47===at.charCodeAt(lt+1))return++lt,++lt,void(ht.comments&&(r=at.slice(e+2,lt-2),t.end={line:ut,column:lt-ct},d("Block",r,e,lt,t)));++lt}else++lt;j({},rt.UnexpectedToken,"ILLEGAL")}function g(){var e,t;for(t=0===lt;ft>lt;)if(e=at.charCodeAt(lt),i(e))++lt;else if(a(e))++lt,13===e&&10===at.charCodeAt(lt)&&++lt,++ut,ct=lt,t=!0;else if(47===e)if(// U+002F is '/' -e=at.charCodeAt(lt+1),47===e)++lt,++lt,m(2),t=!0;else{if(42!==e)break;// U+002A is '*' +if(47===st.charCodeAt(lt+1))return++lt,++lt,void(gt.comments&&(r=st.slice(e+2,lt-2),t.end={line:ct,column:lt-ft},d("Block",r,e,lt,t)));++lt}else++lt;q({},it.UnexpectedToken,"ILLEGAL")}function g(){var e,t;for(t=0===lt;pt>lt;)if(e=st.charCodeAt(lt),o(e))++lt;else if(a(e))++lt,13===e&&10===st.charCodeAt(lt)&&++lt,++ct,ft=lt,t=!0;else if(47===e)if(e=st.charCodeAt(lt+1),47===e)++lt,++lt,m(2),t=!0;else{if(42!==e)break;// U+002A is '*' ++lt,++lt,h()}else if(t&&45===e){// U+002D is '-' // U+003E is '>' -if(45!==at.charCodeAt(lt+1)||62!==at.charCodeAt(lt+2))break; -// '-->' is a single-line comment -lt+=3,m(3)}else{if(60!==e)break;// U+003C is '<' -if("!--"!==at.slice(lt+1,lt+4))break;++lt,// `<` +if(45!==st.charCodeAt(lt+1)||62!==st.charCodeAt(lt+2))break;lt+=3,m(3)}else{if(60!==e)break;// U+003C is '<' +if("!--"!==st.slice(lt+1,lt+4))break;++lt,// `<` ++lt,// `!` ++lt,// `-` ++lt,// `-` -m(4)}}function y(e){var t,n,o,i=0;for(n="u"===e?4:2,t=0;n>t;++t){if(!(ft>lt&&r(at[lt])))return"";o=at[lt++],i=16*i+"0123456789abcdef".indexOf(o.toLowerCase())}return String.fromCharCode(i)}function w(){var e,t;for(e=at.charCodeAt(lt++),t=String.fromCharCode(e), +m(4)}}function y(e){var t,n,i,o=0;for(n="u"===e?4:2,t=0;n>t;++t){if(!(pt>lt&&r(st[lt])))return"";i=st[lt++],o=16*o+"0123456789abcdef".indexOf(i.toLowerCase())}return String.fromCharCode(o)}function b(){var e,t;for(e=st.charCodeAt(lt++),t=String.fromCharCode(e), // '\u' (U+005C, U+0075) denotes an escaped character. -92===e&&(117!==at.charCodeAt(lt)&&j({},rt.UnexpectedToken,"ILLEGAL"),++lt,e=y("u"),e&&"\\"!==e&&s(e.charCodeAt(0))||j({},rt.UnexpectedToken,"ILLEGAL"),t=e);ft>lt&&(e=at.charCodeAt(lt),l(e));)++lt,t+=String.fromCharCode(e), -// '\u' (U+005C, U+0075) denotes an escaped character. -92===e&&(t=t.substr(0,t.length-1),117!==at.charCodeAt(lt)&&j({},rt.UnexpectedToken,"ILLEGAL"),++lt,e=y("u"),e&&"\\"!==e&&l(e.charCodeAt(0))||j({},rt.UnexpectedToken,"ILLEGAL"),t+=e);return t}function b(){var e,t;for(e=lt++;ft>lt;){if(t=at.charCodeAt(lt),92===t) +92===e&&(117!==st.charCodeAt(lt)&&q({},it.UnexpectedToken,"ILLEGAL"),++lt,e=y("u"),e&&"\\"!==e&&s(e.charCodeAt(0))||q({},it.UnexpectedToken,"ILLEGAL"),t=e);pt>lt&&(e=st.charCodeAt(lt),u(e));)++lt,t+=String.fromCharCode(e),92===e&&(t=t.substr(0,t.length-1),117!==st.charCodeAt(lt)&&q({},it.UnexpectedToken,"ILLEGAL"),++lt,e=y("u"),e&&"\\"!==e&&u(e.charCodeAt(0))||q({},it.UnexpectedToken,"ILLEGAL"),t+=e);return t}function v(){var e,t;for(e=lt++;pt>lt;){if(t=st.charCodeAt(lt),92===t) // Blackslash (U+005C) marks Unicode escape sequence. -return lt=e,w();if(!l(t))break;++lt}return at.slice(e,lt)}function S(){var e,t,n; +return lt=e,b();if(!u(t))break;++lt}return st.slice(e,lt)}function S(){var e,t,n; // Backslash (U+005C) starts an escaped character. // There is no keyword or literal with only one character. // Thus, it must be an identifier. -return e=lt,t=92===at.charCodeAt(lt)?w():b(),n=1===t.length?Xe.Identifier:p(t)?Xe.Keyword:"null"===t?Xe.NullLiteral:"true"===t||"false"===t?Xe.BooleanLiteral:Xe.Identifier,{type:n,value:t,lineNumber:ut,lineStart:ct,start:e,end:lt}} +return e=lt,t=92===st.charCodeAt(lt)?b():v(),n=1===t.length?Qe.Identifier:p(t)?Qe.Keyword:"null"===t?Qe.NullLiteral:"true"===t||"false"===t?Qe.BooleanLiteral:Qe.Identifier,{type:n,value:t,lineNumber:ct,lineStart:ft,start:e,end:lt}} // 7.7 Punctuators -function v(){var e,t,n,r,o=lt,i=at.charCodeAt(lt),a=at[lt];switch(i){ +function w(){var e,t,n,r,i=lt,o=st.charCodeAt(lt),a=st[lt];switch(o){ // Check for most common single-character punctuators. case 46:// . dot case 40:// ( open bracket @@ -1220,9 +1115,9 @@ case 93:// ] case 58:// : case 63:// ? case 126:// ~ -return++lt,ht.tokenize&&(40===i?ht.openParenToken=ht.tokens.length:123===i&&(ht.openCurlyToken=ht.tokens.length)),{type:Xe.Punctuator,value:String.fromCharCode(i),lineNumber:ut,lineStart:ct,start:o,end:lt};default: +return++lt,gt.tokenize&&(40===o?gt.openParenToken=gt.tokens.length:123===o&&(gt.openCurlyToken=gt.tokens.length)),{type:Qe.Punctuator,value:String.fromCharCode(o),lineNumber:ct,lineStart:ft,start:i,end:lt};default: // '=' (U+003D) marks an assignment or comparison operator. -if(e=at.charCodeAt(lt+1),61===e)switch(i){case 43:// + +if(e=st.charCodeAt(lt+1),61===e)switch(o){case 43:// + case 45:// - case 47:// / case 60:// < @@ -1232,108 +1127,90 @@ case 124:// | case 37:// % case 38:// & case 42:// * -return lt+=2,{type:Xe.Punctuator,value:String.fromCharCode(i)+String.fromCharCode(e),lineNumber:ut,lineStart:ct,start:o,end:lt};case 33:// ! +return lt+=2,{type:Qe.Punctuator,value:String.fromCharCode(o)+String.fromCharCode(e),lineNumber:ct,lineStart:ft,start:i,end:lt};case 33:// ! case 61:// = // !== and === -return lt+=2,61===at.charCodeAt(lt)&&++lt,{type:Xe.Punctuator,value:at.slice(o,lt),lineNumber:ut,lineStart:ct,start:o,end:lt}}} +return lt+=2,61===st.charCodeAt(lt)&&++lt,{type:Qe.Punctuator,value:st.slice(i,lt),lineNumber:ct,lineStart:ft,start:i,end:lt}}} // 4-character punctuator: >>>= // 3-character punctuators: === !== >>> <<= >>= // Other 2-character punctuators: ++ -- << >> && || // 1-character punctuators: < > = ! + - * % & | ^ / -return r=at.substr(lt,4),">>>="===r?(lt+=4,{type:Xe.Punctuator,value:r,lineNumber:ut,lineStart:ct,start:o,end:lt}):(n=r.substr(0,3),">>>"===n||"<<="===n||">>="===n?(lt+=3,{type:Xe.Punctuator,value:n,lineNumber:ut,lineStart:ct,start:o,end:lt}):(t=n.substr(0,2),a===t[1]&&"+-<>&|".indexOf(a)>=0||"=>"===t?(lt+=2,{type:Xe.Punctuator,value:t,lineNumber:ut,lineStart:ct,start:o,end:lt}):"<>=!+-*%&|^/".indexOf(a)>=0?(++lt,{type:Xe.Punctuator,value:a,lineNumber:ut,lineStart:ct,start:o,end:lt}):void j({},rt.UnexpectedToken,"ILLEGAL")))} +return r=st.substr(lt,4),">>>="===r?(lt+=4,{type:Qe.Punctuator,value:r,lineNumber:ct,lineStart:ft,start:i,end:lt}):(n=r.substr(0,3),">>>"===n||"<<="===n||">>="===n?(lt+=3,{type:Qe.Punctuator,value:n,lineNumber:ct,lineStart:ft,start:i,end:lt}):(t=n.substr(0,2),a===t[1]&&"+-<>&|".indexOf(a)>=0||"=>"===t?(lt+=2,{type:Qe.Punctuator,value:t,lineNumber:ct,lineStart:ft,start:i,end:lt}):"<>=!+-*%&|^/".indexOf(a)>=0?(++lt,{type:Qe.Punctuator,value:a,lineNumber:ct,lineStart:ft,start:i,end:lt}):void q({},it.UnexpectedToken,"ILLEGAL")))} // 7.8.3 Numeric Literals -function E(e){for(var t="";ft>lt&&r(at[lt]);)t+=at[lt++];return 0===t.length&&j({},rt.UnexpectedToken,"ILLEGAL"),s(at.charCodeAt(lt))&&j({},rt.UnexpectedToken,"ILLEGAL"),{type:Xe.NumericLiteral,value:parseInt("0x"+t,16),lineNumber:ut,lineStart:ct,start:e,end:lt}}function C(e){for(var t="0"+at[lt++];ft>lt&&o(at[lt]);)t+=at[lt++];return(s(at.charCodeAt(lt))||n(at.charCodeAt(lt)))&&j({},rt.UnexpectedToken,"ILLEGAL"),{type:Xe.NumericLiteral,value:parseInt(t,8),octal:!0,lineNumber:ut,lineStart:ct,start:e,end:lt}}function x(){var e,r,i;if(i=at[lt],t(n(i.charCodeAt(0))||"."===i,"Numeric literal must start with a decimal digit or a decimal point"),r=lt,e="","."!==i){ +function E(e){for(var t="";pt>lt&&r(st[lt]);)t+=st[lt++];return 0===t.length&&q({},it.UnexpectedToken,"ILLEGAL"),s(st.charCodeAt(lt))&&q({},it.UnexpectedToken,"ILLEGAL"),{type:Qe.NumericLiteral,value:parseInt("0x"+t,16),lineNumber:ct,lineStart:ft,start:e,end:lt}}function x(e){for(var t="0"+st[lt++];pt>lt&&i(st[lt]);)t+=st[lt++];return(s(st.charCodeAt(lt))||n(st.charCodeAt(lt)))&&q({},it.UnexpectedToken,"ILLEGAL"),{type:Qe.NumericLiteral,value:parseInt(t,8),octal:!0,lineNumber:ct,lineStart:ft,start:e,end:lt}}function _(){var e,t; +// Implicit octal, unless there is a non-octal digit. +// (Annex B.1.1 on Numeric Literals) +for(e=lt+1;pt>e;++e){if(t=st[e],"8"===t||"9"===t)return!1;if(!i(t))return!0}return!0}function C(){var e,r,o;if(o=st[lt],t(n(o.charCodeAt(0))||"."===o,"Numeric literal must start with a decimal digit or a decimal point"),r=lt,e="","."!==o){ // Hex number starts with '0x'. // Octal number starts with '0'. -if(e=at[lt++],i=at[lt],"0"===e){if("x"===i||"X"===i)return++lt,E(r);if(o(i))return C(r); -// decimal number starts with '0' such as '09' is illegal. -i&&n(i.charCodeAt(0))&&j({},rt.UnexpectedToken,"ILLEGAL")}for(;n(at.charCodeAt(lt));)e+=at[lt++];i=at[lt]}if("."===i){for(e+=at[lt++];n(at.charCodeAt(lt));)e+=at[lt++];i=at[lt]}if("e"===i||"E"===i)if(e+=at[lt++],i=at[lt],("+"===i||"-"===i)&&(e+=at[lt++]),n(at.charCodeAt(lt)))for(;n(at.charCodeAt(lt));)e+=at[lt++];else j({},rt.UnexpectedToken,"ILLEGAL");return s(at.charCodeAt(lt))&&j({},rt.UnexpectedToken,"ILLEGAL"),{type:Xe.NumericLiteral,value:parseFloat(e),lineNumber:ut,lineStart:ct,start:r,end:lt}} +if(e=st[lt++],o=st[lt],"0"===e){if("x"===o||"X"===o)return++lt,E(r);if(i(o)&&_())return x(r)}for(;n(st.charCodeAt(lt));)e+=st[lt++];o=st[lt]}if("."===o){for(e+=st[lt++];n(st.charCodeAt(lt));)e+=st[lt++];o=st[lt]}if("e"===o||"E"===o)if(e+=st[lt++],o=st[lt],("+"===o||"-"===o)&&(e+=st[lt++]),n(st.charCodeAt(lt)))for(;n(st.charCodeAt(lt));)e+=st[lt++];else q({},it.UnexpectedToken,"ILLEGAL");return s(st.charCodeAt(lt))&&q({},it.UnexpectedToken,"ILLEGAL"),{type:Qe.NumericLiteral,value:parseFloat(e),lineNumber:ct,lineStart:ft,start:r,end:lt}} // 7.8.4 String Literals -function _(){var e,n,r,i,s,l,u,c,f="",p=!1;for(u=ut,c=ct,e=at[lt],t("'"===e||'"'===e,"String literal must starts with a quote"),n=lt,++lt;ft>lt;){if(r=at[lt++],r===e){e="";break}if("\\"===r)if(r=at[lt++],r&&a(r.charCodeAt(0)))++ut,"\r"===r&&"\n"===at[lt]&&++lt,ct=lt;else switch(r){case"u":case"x":l=lt,s=y(r),s?f+=s:(lt=l,f+=r);break;case"n":f+="\n";break;case"r":f+="\r";break;case"t":f+=" ";break;case"b":f+="\b";break;case"f":f+="\f";break;case"v":f+=" ";break;default:o(r)?(i="01234567".indexOf(r), -// \0 is not octal escape sequence -0!==i&&(p=!0),ft>lt&&o(at[lt])&&(p=!0,i=8*i+"01234567".indexOf(at[lt++]), -// 3 digits are only allowed when string starts -// with 0, 1, 2, 3 -"0123".indexOf(r)>=0&&ft>lt&&o(at[lt])&&(i=8*i+"01234567".indexOf(at[lt++]))),f+=String.fromCharCode(i)):f+=r}else{if(a(r.charCodeAt(0)))break;f+=r}}return""!==e&&j({},rt.UnexpectedToken,"ILLEGAL"),{type:Xe.StringLiteral,value:f,octal:p,startLineNumber:u,startLineStart:c,lineNumber:ut,lineStart:ct,start:n,end:lt}}function k(e,t){var n;try{n=new RegExp(e,t)}catch(r){j({},rt.InvalidRegExp)}return n}function I(){var e,n,r,o,i;for(e=at[lt],t("/"===e,"Regular expression literal must start with a slash"),n=at[lt++],r=!1,o=!1;ft>lt;)if(e=at[lt++],n+=e,"\\"===e)e=at[lt++], -// ECMA-262 7.8.5 -a(e.charCodeAt(0))&&j({},rt.UnterminatedRegExp),n+=e;else if(a(e.charCodeAt(0)))j({},rt.UnterminatedRegExp);else if(r)"]"===e&&(r=!1);else{if("/"===e){o=!0;break}"["===e&&(r=!0)} +function k(){var e,n,r,o,s,u,l,c,f="",p=!1;for(l=ct,c=ft,e=st[lt],t("'"===e||'"'===e,"String literal must starts with a quote"),n=lt,++lt;pt>lt;){if(r=st[lt++],r===e){e="";break}if("\\"===r)if(r=st[lt++],r&&a(r.charCodeAt(0)))++ct,"\r"===r&&"\n"===st[lt]&&++lt,ft=lt;else switch(r){case"u":case"x":u=lt,s=y(r),s?f+=s:(lt=u,f+=r);break;case"n":f+="\n";break;case"r":f+="\r";break;case"t":f+=" ";break;case"b":f+="\b";break;case"f":f+="\f";break;case"v":f+="\x0B";break;default:i(r)?(o="01234567".indexOf(r),0!==o&&(p=!0),pt>lt&&i(st[lt])&&(p=!0,o=8*o+"01234567".indexOf(st[lt++]),"0123".indexOf(r)>=0&&pt>lt&&i(st[lt])&&(o=8*o+"01234567".indexOf(st[lt++]))),f+=String.fromCharCode(o)):f+=r}else{if(a(r.charCodeAt(0)))break;f+=r}}return""!==e&&q({},it.UnexpectedToken,"ILLEGAL"),{type:Qe.StringLiteral,value:f,octal:p,startLineNumber:l,startLineStart:c,lineNumber:ct,lineStart:ft,start:n,end:lt}}function A(e,t){var n;try{n=new RegExp(e,t)}catch(r){q({},it.InvalidRegExp)}return n}function I(){var e,n,r,i,o;for(e=st[lt],t("/"===e,"Regular expression literal must start with a slash"),n=st[lt++],r=!1,i=!1;pt>lt;)if(e=st[lt++],n+=e,"\\"===e)e=st[lt++],a(e.charCodeAt(0))&&q({},it.UnterminatedRegExp),n+=e;else if(a(e.charCodeAt(0)))q({},it.UnterminatedRegExp);else if(r)"]"===e&&(r=!1);else{if("/"===e){i=!0;break}"["===e&&(r=!0)} // Exclude leading and trailing slash. -return o||j({},rt.UnterminatedRegExp),i=n.substr(1,n.length-2),{value:i,literal:n}}function A(){var e,t,n,r;for(t="",n="";ft>lt&&(e=at[lt],l(e.charCodeAt(0)));)if(++lt,"\\"===e&&ft>lt)if(e=at[lt],"u"===e){if(++lt,r=lt,e=y("u"))for(n+=e,t+="\\u";lt>r;++r)t+=at[r];else lt=r,n+="u",t+="\\u";q({},rt.UnexpectedToken,"ILLEGAL")}else t+="\\",q({},rt.UnexpectedToken,"ILLEGAL");else n+=e,t+=e;return{value:n,literal:t}}function L(){var e,t,n,r;return dt=null,g(),e=lt,t=I(),n=A(),r=k(t.value,n.value),ht.tokenize?{type:Xe.RegularExpression,value:r,lineNumber:ut,lineStart:ct,start:e,end:lt}:{literal:t.literal+n.literal,value:r,start:e,end:lt}}function B(){var e,t,n,r;/* istanbul ignore next */ +return i||q({},it.UnterminatedRegExp),o=n.substr(1,n.length-2),{value:o,literal:n}}function L(){var e,t,n,r;for(t="",n="";pt>lt&&(e=st[lt],u(e.charCodeAt(0)));)if(++lt,"\\"===e&&pt>lt)if(e=st[lt],"u"===e){if(++lt,r=lt,e=y("u"))for(n+=e,t+="\\u";lt>r;++r)t+=st[r];else lt=r,n+="u",t+="\\u";W({},it.UnexpectedToken,"ILLEGAL")}else t+="\\",W({},it.UnexpectedToken,"ILLEGAL");else n+=e,t+=e;return{value:n,literal:t}}function B(){var e,t,n,r;return mt=null,g(),e=lt,t=I(),n=L(),r=A(t.value,n.value),gt.tokenize?{type:Qe.RegularExpression,value:r,lineNumber:ct,lineStart:ft,start:e,end:lt}:{literal:t.literal+n.literal,value:r,start:e,end:lt}}function R(){var e,t,n,r;/* istanbul ignore next */ // Pop the previous token, which is likely '/' or '/=' -return g(),e=lt,t={start:{line:ut,column:lt-ct}},n=L(),t.end={line:ut,column:lt-ct},ht.tokenize||(ht.tokens.length>0&&(r=ht.tokens[ht.tokens.length-1],r.range[0]===e&&"Punctuator"===r.type&&("/"===r.value||"/="===r.value)&&ht.tokens.pop()),ht.tokens.push({type:"RegularExpression",value:n.literal,range:[e,lt],loc:t})),n}function D(e){return e.type===Xe.Identifier||e.type===Xe.Keyword||e.type===Xe.BooleanLiteral||e.type===Xe.NullLiteral}function O(){var e,t;if( -// Using the following algorithm: -// https://github.com/mozilla/sweet.js/wiki/design -e=ht.tokens[ht.tokens.length-1],!e) +return g(),e=lt,t={start:{line:ct,column:lt-ft}},n=B(),t.end={line:ct,column:lt-ft},gt.tokenize||(gt.tokens.length>0&&(r=gt.tokens[gt.tokens.length-1],r.range[0]===e&&"Punctuator"===r.type&&("/"===r.value||"/="===r.value)&>.tokens.pop()),gt.tokens.push({type:"RegularExpression",value:n.literal,range:[e,lt],loc:t})),n}function M(e){return e.type===Qe.Identifier||e.type===Qe.Keyword||e.type===Qe.BooleanLiteral||e.type===Qe.NullLiteral}function P(){var e,t;if(e=gt.tokens[gt.tokens.length-1],!e) // Nothing before that: it cannot be a division. -return B();if("Punctuator"===e.type){if("]"===e.value)return v();if(")"===e.value)return t=ht.tokens[ht.openParenToken-1],!t||"Keyword"!==t.type||"if"!==t.value&&"while"!==t.value&&"for"!==t.value&&"with"!==t.value?v():B();if("}"===e.value){ +return R();if("Punctuator"===e.type){if("]"===e.value)return w();if(")"===e.value)return t=gt.tokens[gt.openParenToken-1],!t||"Keyword"!==t.type||"if"!==t.value&&"while"!==t.value&&"for"!==t.value&&"with"!==t.value?w():R();if("}"===e.value){ // Dividing a function by anything makes little sense, // but we have to check for that. -if(ht.tokens[ht.openCurlyToken-3]&&"Keyword"===ht.tokens[ht.openCurlyToken-3].type){if( -// Anonymous function. -t=ht.tokens[ht.openCurlyToken-4],!t)return v()}else{if(!ht.tokens[ht.openCurlyToken-4]||"Keyword"!==ht.tokens[ht.openCurlyToken-4].type)return v();if( -// Named function. -t=ht.tokens[ht.openCurlyToken-5],!t)return B()} +if(gt.tokens[gt.openCurlyToken-3]&&"Keyword"===gt.tokens[gt.openCurlyToken-3].type){if(t=gt.tokens[gt.openCurlyToken-4],!t)return w()}else{if(!gt.tokens[gt.openCurlyToken-4]||"Keyword"!==gt.tokens[gt.openCurlyToken-4].type)return w();if(t=gt.tokens[gt.openCurlyToken-5],!t)return R()} // checkToken determines whether the function is // a declaration or an expression. // checkToken determines whether the function is // a declaration or an expression. -return et.indexOf(t.value)>=0?v():B()}return B()}return"Keyword"===e.type?B():v()}function T(){var e; +return tt.indexOf(t.value)>=0?w():R()}return R()}return"Keyword"===e.type&&"this"!==e.value?R():w()}function O(){var e; // Very common: ( and ) and ; // String literal starts with single quote (U+0027) or double quote (U+0022). // Dot (.) U+002E can also start a floating-point number, hence the need // to check the next character. // Slash (/) U+002F can also start a regex. -return g(),lt>=ft?{type:Xe.EOF,lineNumber:ut,lineStart:ct,start:lt,end:lt}:(e=at.charCodeAt(lt),s(e)?S():40===e||41===e||59===e?v():39===e||34===e?_():46===e?n(at.charCodeAt(lt+1))?x():v():n(e)?x():ht.tokenize&&47===e?O():v())}function P(){var e,t,n;return g(),e={start:{line:ut,column:lt-ct}},t=T(),e.end={line:ut,column:lt-ct},t.type!==Xe.EOF&&(n=at.slice(t.start,t.end),ht.tokens.push({type:Qe[t.type],value:n,range:[t.start,t.end],loc:e})),t}function M(){var e;return e=dt,lt=e.end,ut=e.lineNumber,ct=e.lineStart,dt="undefined"!=typeof ht.tokens?P():T(),lt=e.end,ut=e.lineNumber,ct=e.lineStart,e}function R(){var e,t,n;e=lt,t=ut,n=ct,dt="undefined"!=typeof ht.tokens?P():T(),lt=e,ut=t,ct=n}function N(e,t){this.line=e,this.column=t}function F(e,t,n,r){this.start=new N(e,t),this.end=new N(n,r)} +return g(),lt>=pt?{type:Qe.EOF,lineNumber:ct,lineStart:ft,start:lt,end:lt}:(e=st.charCodeAt(lt),s(e)?S():40===e||41===e||59===e?w():39===e||34===e?k():46===e?n(st.charCodeAt(lt+1))?C():w():n(e)?C():gt.tokenize&&47===e?P():w())}function D(){var e,t,n;return g(),e={start:{line:ct,column:lt-ft}},t=O(),e.end={line:ct,column:lt-ft},t.type!==Qe.EOF&&(n=st.slice(t.start,t.end),gt.tokens.push({type:et[t.type],value:n,range:[t.start,t.end],loc:e})),t}function N(){var e;return e=mt,lt=e.end,ct=e.lineNumber,ft=e.lineStart,mt="undefined"!=typeof gt.tokens?D():O(),lt=e.end,ct=e.lineNumber,ft=e.lineStart,e}function T(){var e,t,n;e=lt,t=ct,n=ft,mt="undefined"!=typeof gt.tokens?D():O(),lt=e,ct=t,ft=n}function F(e,t){this.line=e,this.column=t}function j(e,t,n,r){this.start=new F(e,t),this.end=new F(n,r)} // Return true if there is a line terminator before the next token. -function U(){var e,t,n,r;return e=lt,t=ut,n=ct,g(),r=ut!==t,lt=e,ut=t,ct=n,r} +function U(){var e,t,n,r;return e=lt,t=ct,n=ft,g(),r=ct!==t,lt=e,ct=t,ft=n,r} // Throw an exception -function j(e,n){var r,o=Array.prototype.slice.call(arguments,2),i=n.replace(/%(\d)/g,function(e,n){return t(n>="===e||">>>="===e||"&="===e||"^="===e||"|="===e)}function H(){var e; +function K(){var e;return mt.type!==Qe.Punctuator?!1:(e=mt.value,"="===e||"*="===e||"/="===e||"%="===e||"+="===e||"-="===e||"<<="===e||">>="===e||">>>="===e||"&="===e||"^="===e||"|="===e)}function H(){var e,t=lt,n=ct,r=ft,i=mt; // Catch the very common case first: immediately a semicolon (U+003B). // Catch the very common case first: immediately a semicolon (U+003B). -return 59===at.charCodeAt(lt)||Z(";")?void M():(e=ut,g(),void(ut===e&&(dt.type===Xe.EOF||Z("}")||W(dt))))} +return 59===st.charCodeAt(lt)||V(";")?void N():(e=ct,g(),ct!==e?(lt=t,ct=n,ft=r,void(mt=i)):void(mt.type===Qe.EOF||V("}")||Y(mt)))} // Return true if provided expression is LeftHandSideExpression -function K(e){return e.type===tt.Identifier||e.type===tt.MemberExpression} +function $(e){return e.type===nt.Identifier||e.type===nt.MemberExpression} // 11.1.4 Array Initialiser -function $(){var e,t=[];for(e=dt,Y("[");!Z("]");)Z(",")?(M(),t.push(null)):(t.push(he()),Z("]")||Y(","));return M(),pt.markEnd(pt.createArrayExpression(t),e)} +function J(){var e,t=[];for(e=mt,G("[");!V("]");)V(",")?(N(),t.push(null)):(t.push(ge()),V("]")||G(","));return N(),dt.markEnd(dt.createArrayExpression(t),e)} // 11.1.5 Object Initialiser -function J(e,t){var n,r,o;return n=st,o=dt,r=We(),t&&st&&f(e[0].name)&&q(t,rt.StrictParamName),st=n,pt.markEnd(pt.createFunctionExpression(null,e,[],r),o)}function X(){var e,t; -// Note: This function is called only from parseObjectProperty(), where -// EOF and Punctuator tokens are already filtered out. -// Note: This function is called only from parseObjectProperty(), where -// EOF and Punctuator tokens are already filtered out. -return t=dt,e=M(),e.type===Xe.StringLiteral||e.type===Xe.NumericLiteral?(st&&e.octal&&q(e,rt.StrictOctalLiteral),pt.markEnd(pt.createLiteral(e),t)):pt.markEnd(pt.createIdentifier(e.value),t)}function Q(){var e,t,n,r,o,i; +function X(e,t){var n,r,i;return n=ut,i=mt,r=Ye(),t&&ut&&f(e[0].name)&&W(t,it.StrictParamName),ut=n,dt.markEnd(dt.createFunctionExpression(null,e,[],r),i)}function Q(){var e,t;return t=mt,e=N(),e.type===Qe.StringLiteral||e.type===Qe.NumericLiteral?(ut&&e.octal&&W(e,it.StrictOctalLiteral),dt.markEnd(dt.createLiteral(e),t)):dt.markEnd(dt.createIdentifier(e.value),t)}function ee(){var e,t,n,r,i,o; // Property Assignment: Getter and Setter. -return e=dt,i=dt,e.type===Xe.Identifier?(n=X(),"get"!==e.value||Z(":")?"set"!==e.value||Z(":")?(Y(":"),r=he(),pt.markEnd(pt.createProperty("init",n,r),i)):(t=X(),Y("("),e=dt,e.type!==Xe.Identifier?(Y(")"),q(e,rt.UnexpectedToken,e.value),r=J([])):(o=[be()],Y(")"),r=J(o,e)),pt.markEnd(pt.createProperty("set",t,r),i)):(t=X(),Y("("),Y(")"),r=J([]),pt.markEnd(pt.createProperty("get",t,r),i))):e.type!==Xe.EOF&&e.type!==Xe.Punctuator?(t=X(),Y(":"),r=he(),pt.markEnd(pt.createProperty("init",t,r),i)):void W(e)}function ee(){var e,t,n,r,o,i=[],a={},s=String;for(o=dt,Y("{");!Z("}");)e=Q(),t=e.key.type===tt.Identifier?e.key.name:s(e.key.value),r="init"===e.kind?nt.Data:"get"===e.kind?nt.Get:nt.Set,n="$"+t,Object.prototype.hasOwnProperty.call(a,n)?(a[n]===nt.Data?st&&r===nt.Data?q({},rt.StrictDuplicateProperty):r!==nt.Data&&q({},rt.AccessorDataProperty):r===nt.Data?q({},rt.AccessorDataProperty):a[n]&r&&q({},rt.AccessorGetSet),a[n]|=r):a[n]=r,i.push(e),Z("}")||Y(",");return Y("}"),pt.markEnd(pt.createObjectExpression(i),o)} +return e=mt,o=mt,e.type===Qe.Identifier?(n=Q(),"get"!==e.value||V(":")?"set"!==e.value||V(":")?(G(":"),r=ge(),dt.markEnd(dt.createProperty("init",n,r),o)):(t=Q(),G("("),e=mt,e.type!==Qe.Identifier?(G(")"),W(e,it.UnexpectedToken,e.value),r=X([])):(i=[Se()],G(")"),r=X(i,e)),dt.markEnd(dt.createProperty("set",t,r),o)):(t=Q(),G("("),G(")"),r=X([]),dt.markEnd(dt.createProperty("get",t,r),o))):e.type!==Qe.EOF&&e.type!==Qe.Punctuator?(t=Q(),G(":"),r=ge(),dt.markEnd(dt.createProperty("init",t,r),o)):void Y(e)}function te(){var e,t,n,r,i,o=[],a={},s=String;for(i=mt,G("{");!V("}");)e=ee(),t=e.key.type===nt.Identifier?e.key.name:s(e.key.value),r="init"===e.kind?rt.Data:"get"===e.kind?rt.Get:rt.Set,n="$"+t,Object.prototype.hasOwnProperty.call(a,n)?(a[n]===rt.Data?ut&&r===rt.Data?W({},it.StrictDuplicateProperty):r!==rt.Data&&W({},it.AccessorDataProperty):r===rt.Data?W({},it.AccessorDataProperty):a[n]&r&&W({},it.AccessorGetSet),a[n]|=r):a[n]=r,o.push(e),V("}")||G(",");return G("}"),dt.markEnd(dt.createObjectExpression(o),i)} // 11.1.6 The Grouping Operator -function te(){var e;return Y("("),e=ge(),Y(")"),e} +function ne(){var e;return G("("),e=ye(),G(")"),e} // 11.1 Primary Expressions -function ne(){var e,t,n,r;if(Z("("))return te();if(Z("["))return $();if(Z("{"))return ee();if(e=dt.type,r=dt,e===Xe.Identifier)n=pt.createIdentifier(M().value);else if(e===Xe.StringLiteral||e===Xe.NumericLiteral)st&&dt.octal&&q(dt,rt.StrictOctalLiteral),n=pt.createLiteral(M());else if(e===Xe.Keyword){if(z("function"))return Ze();z("this")?(M(),n=pt.createThisExpression()):W(M())}else e===Xe.BooleanLiteral?(t=M(),t.value="true"===t.value,n=pt.createLiteral(t)):e===Xe.NullLiteral?(t=M(),t.value=null,n=pt.createLiteral(t)):Z("/")||Z("/=")?(n=pt.createLiteral("undefined"!=typeof ht.tokens?B():L()),R()):W(M());return pt.markEnd(n,r)} +function re(){var e,t,n,r;if(V("("))return ne();if(V("["))return J();if(V("{"))return te();if(e=mt.type,r=mt,e===Qe.Identifier)n=dt.createIdentifier(N().value);else if(e===Qe.StringLiteral||e===Qe.NumericLiteral)ut&&mt.octal&&W(mt,it.StrictOctalLiteral),n=dt.createLiteral(N());else if(e===Qe.Keyword){if(z("function"))return Ve();z("this")?(N(),n=dt.createThisExpression()):Y(N())}else e===Qe.BooleanLiteral?(t=N(),t.value="true"===t.value,n=dt.createLiteral(t)):e===Qe.NullLiteral?(t=N(),t.value=null,n=dt.createLiteral(t)):V("/")||V("/=")?(n="undefined"!=typeof gt.tokens?dt.createLiteral(R()):dt.createLiteral(B()),T()):Y(N());return dt.markEnd(n,r)} // 11.2 Left-Hand-Side Expressions -function re(){var e=[];if(Y("("),!Z(")"))for(;ft>lt&&(e.push(he()),!Z(")"));)Y(",");return Y(")"),e}function oe(){var e,t;return t=dt,e=M(),D(e)||W(e),pt.markEnd(pt.createIdentifier(e.value),t)}function ie(){return Y("."),oe()}function ae(){var e;return Y("["),e=ge(),Y("]"),e}function se(){var e,t,n;return n=dt,G("new"),e=ue(),t=Z("(")?re():[],pt.markEnd(pt.createNewExpression(e,t),n)}function le(){var e,t,n,r,o;for(o=dt,e=mt.allowIn,mt.allowIn=!0,t=z("new")?se():ne(),mt.allowIn=e;;){if(Z("."))r=ie(),t=pt.createMemberExpression(".",t,r);else if(Z("("))n=re(),t=pt.createCallExpression(t,n);else{if(!Z("["))break;r=ae(),t=pt.createMemberExpression("[",t,r)}pt.markEnd(t,o)}return t}function ue(){var e,t,n,r;for(r=dt,e=mt.allowIn,t=z("new")?se():ne(),mt.allowIn=e;Z(".")||Z("[");)Z("[")?(n=ae(),t=pt.createMemberExpression("[",t,n)):(n=ie(),t=pt.createMemberExpression(".",t,n)),pt.markEnd(t,r);return t} +function ie(){var e=[];if(G("("),!V(")"))for(;pt>lt&&(e.push(ge()),!V(")"));)G(",");return G(")"),e}function oe(){var e,t;return t=mt,e=N(),M(e)||Y(e),dt.markEnd(dt.createIdentifier(e.value),t)}function ae(){return G("."),oe()}function se(){var e;return G("["),e=ye(),G("]"),e}function ue(){var e,t,n;return n=mt,Z("new"),e=ce(),t=V("(")?ie():[],dt.markEnd(dt.createNewExpression(e,t),n)}function le(){var e,t,n,r,i=ht.allowIn;for(r=mt,ht.allowIn=!0,e=z("new")?ue():re();;){if(V("."))n=ae(),e=dt.createMemberExpression(".",e,n);else if(V("("))t=ie(),e=dt.createCallExpression(e,t);else{if(!V("["))break;n=se(),e=dt.createMemberExpression("[",e,n)}dt.markEnd(e,r)}return ht.allowIn=i,e}function ce(){var e,n,r;for(t(ht.allowIn,"callee of new expression always allow in keyword."),r=mt,e=z("new")?ue():re();V(".")||V("[");)V("[")?(n=se(),e=dt.createMemberExpression("[",e,n)):(n=ae(),e=dt.createMemberExpression(".",e,n)),dt.markEnd(e,r);return e} // 11.3 Postfix Expressions -function ce(){var e,t,n=dt; +function fe(){var e,t,n=mt; // 11.3.1, 11.3.2 -return e=le(),dt.type===Xe.Punctuator&&(!Z("++")&&!Z("--")||U()||(st&&e.type===tt.Identifier&&f(e.name)&&q({},rt.StrictLHSPostfix),K(e)||q({},rt.InvalidLHSInAssignment),t=M(),e=pt.markEnd(pt.createPostfixExpression(t.value,e),n))),e} +return e=le(),mt.type===Qe.Punctuator&&(!V("++")&&!V("--")||U()||(ut&&e.type===nt.Identifier&&f(e.name)&&W({},it.StrictLHSPostfix),$(e)||W({},it.InvalidLHSInAssignment),t=N(),e=dt.markEnd(dt.createPostfixExpression(t.value,e),n))),e} // 11.4 Unary Operators -function fe(){var e,t,n; +function pe(){var e,t,n; // 11.4.4, 11.4.5 -return dt.type!==Xe.Punctuator&&dt.type!==Xe.Keyword?t=ce():Z("++")||Z("--")?(n=dt,e=M(),t=fe(),st&&t.type===tt.Identifier&&f(t.name)&&q({},rt.StrictLHSPrefix),K(t)||q({},rt.InvalidLHSInAssignment),t=pt.createUnaryExpression(e.value,t),t=pt.markEnd(t,n)):Z("+")||Z("-")||Z("~")||Z("!")?(n=dt,e=M(),t=fe(),t=pt.createUnaryExpression(e.value,t),t=pt.markEnd(t,n)):z("delete")||z("void")||z("typeof")?(n=dt,e=M(),t=fe(),t=pt.createUnaryExpression(e.value,t),t=pt.markEnd(t,n),st&&"delete"===t.operator&&t.argument.type===tt.Identifier&&q({},rt.StrictDelete)):t=ce(),t}function pe(e,t){var n=0;if(e.type!==Xe.Punctuator&&e.type!==Xe.Keyword)return 0;switch(e.value){case"||":n=1;break;case"&&":n=2;break;case"|":n=3;break;case"^":n=4;break;case"&":n=5;break;case"==":case"!=":case"===":case"!==":n=6;break;case"<":case">":case"<=":case">=":case"instanceof":n=7;break;case"in":n=t?7:0;break;case"<<":case">>":case">>>":n=8;break;case"+":case"-":n=9;break;case"*":case"/":case"%":n=11}return n} +return mt.type!==Qe.Punctuator&&mt.type!==Qe.Keyword?t=fe():V("++")||V("--")?(n=mt,e=N(),t=pe(),ut&&t.type===nt.Identifier&&f(t.name)&&W({},it.StrictLHSPrefix),$(t)||W({},it.InvalidLHSInAssignment),t=dt.createUnaryExpression(e.value,t),t=dt.markEnd(t,n)):V("+")||V("-")||V("~")||V("!")?(n=mt,e=N(),t=pe(),t=dt.createUnaryExpression(e.value,t),t=dt.markEnd(t,n)):z("delete")||z("void")||z("typeof")?(n=mt,e=N(),t=pe(),t=dt.createUnaryExpression(e.value,t),t=dt.markEnd(t,n),ut&&"delete"===t.operator&&t.argument.type===nt.Identifier&&W({},it.StrictDelete)):t=fe(),t}function de(e,t){var n=0;if(e.type!==Qe.Punctuator&&e.type!==Qe.Keyword)return 0;switch(e.value){case"||":n=1;break;case"&&":n=2;break;case"|":n=3;break;case"^":n=4;break;case"&":n=5;break;case"==":case"!=":case"===":case"!==":n=6;break;case"<":case">":case"<=":case">=":case"instanceof":n=7;break;case"in":n=t?7:0;break;case"<<":case">>":case">>>":n=8;break;case"+":case"-":n=9;break;case"*":case"/":case"%":n=11}return n} // 11.5 Multiplicative Operators // 11.6 Additive Operators // 11.7 Bitwise Shift Operators @@ -1341,107 +1218,84 @@ return dt.type!==Xe.Punctuator&&dt.type!==Xe.Keyword?t=ce():Z("++")||Z("--")?(n= // 11.9 Equality Operators // 11.10 Binary Bitwise Operators // 11.11 Binary Logical Operators -function de(){var e,t,n,r,o,i,a,s,l,u;if(e=dt,l=fe(),r=dt,o=pe(r,mt.allowIn),0===o)return l;for(r.prec=o,M(),t=[e,dt],a=fe(),i=[l,r,a];(o=pe(dt,mt.allowIn))>0;){ +function me(){var e,t,n,r,i,o,a,s,u,l;if(e=mt,u=pe(),r=mt,i=de(r,ht.allowIn),0===i)return u;for(r.prec=i,N(),t=[e,mt],a=pe(),o=[u,r,a];(i=de(mt,ht.allowIn))>0;){ // Reduce: make a binary expression from the three topmost entries. -for(;i.length>2&&o<=i[i.length-2].prec;)a=i.pop(),s=i.pop().value,l=i.pop(),n=pt.createBinaryExpression(s,l,a),t.pop(),e=t[t.length-1],pt.markEnd(n,e),i.push(n); +for(;o.length>2&&i<=o[o.length-2].prec;)a=o.pop(),s=o.pop().value,u=o.pop(),n=dt.createBinaryExpression(s,u,a),t.pop(),e=t[t.length-1],dt.markEnd(n,e),o.push(n); // Shift. -r=M(),r.prec=o,i.push(r),t.push(dt),n=fe(),i.push(n)}for( +r=N(),r.prec=i,o.push(r),t.push(mt),n=pe(),o.push(n)}for( // Final reduce to clean-up the stack. -u=i.length-1,n=i[u],t.pop();u>1;)n=pt.createBinaryExpression(i[u-1].value,i[u-2],n),u-=2,e=t.pop(),pt.markEnd(n,e);return n} +l=o.length-1,n=o[l],t.pop();l>1;)n=dt.createBinaryExpression(o[l-1].value,o[l-2],n),l-=2,e=t.pop(),dt.markEnd(n,e);return n} // 11.12 Conditional Operator -function me(){var e,t,n,r,o;return o=dt,e=de(),Z("?")&&(M(),t=mt.allowIn,mt.allowIn=!0,n=he(),mt.allowIn=t,Y(":"),r=he(),e=pt.createConditionalExpression(e,n,r),pt.markEnd(e,o)),e} +function he(){var e,t,n,r,i;return i=mt,e=me(),V("?")&&(N(),t=ht.allowIn,ht.allowIn=!0,n=ge(),ht.allowIn=t,G(":"),r=ge(),e=dt.createConditionalExpression(e,n,r),dt.markEnd(e,i)),e} // 11.13 Assignment Operators -function he(){var e,t,n,r,o; +function ge(){var e,t,n,r,i; // LeftHandSideExpression // 11.13.1 -return e=dt,o=dt,r=t=me(),V()&&(K(t)||q({},rt.InvalidLHSInAssignment),st&&t.type===tt.Identifier&&f(t.name)&&q(e,rt.StrictLHSAssignment),e=M(),n=he(),r=pt.markEnd(pt.createAssignmentExpression(e.value,t,n),o)),r} +return e=mt,i=mt,r=t=he(),K()&&($(t)||W({},it.InvalidLHSInAssignment),ut&&t.type===nt.Identifier&&f(t.name)&&W(e,it.StrictLHSAssignment),e=N(),n=ge(),r=dt.markEnd(dt.createAssignmentExpression(e.value,t,n),i)),r} // 11.14 Comma Operator -function ge(){var e,t=dt;if(e=he(),Z(",")){for(e=pt.createSequenceExpression([e]);ft>lt&&Z(",");)M(),e.expressions.push(he());pt.markEnd(e,t)}return e} +function ye(){var e,t=mt;if(e=ge(),V(",")){for(e=dt.createSequenceExpression([e]);pt>lt&&V(",");)N(),e.expressions.push(ge());dt.markEnd(e,t)}return e} // 12.1 Block -function ye(){for(var e,t=[];ft>lt&&!Z("}")&&(e=ze(),"undefined"!=typeof e);)t.push(e);return t}function we(){var e,t;return t=dt,Y("{"),e=ye(),Y("}"),pt.markEnd(pt.createBlockStatement(e),t)} +function be(){for(var e,t=[];pt>lt&&!V("}")&&(e=ze(),"undefined"!=typeof e);)t.push(e);return t}function ve(){var e,t;return t=mt,G("{"),e=be(),G("}"),dt.markEnd(dt.createBlockStatement(e),t)} // 12.2 Variable Statement -function be(){var e,t;return t=dt,e=M(),e.type!==Xe.Identifier&&W(e),pt.markEnd(pt.createIdentifier(e.value),t)}function Se(e){var t,n,r=null; +function Se(){var e,t;return t=mt,e=N(),e.type!==Qe.Identifier&&Y(e),dt.markEnd(dt.createIdentifier(e.value),t)}function we(e){var t,n,r=null; // 12.2.1 -return n=dt,t=be(),st&&f(t.name)&&q({},rt.StrictVarName),"const"===e?(Y("="),r=he()):Z("=")&&(M(),r=he()),pt.markEnd(pt.createVariableDeclarator(t,r),n)}function ve(e){var t=[];do{if(t.push(Se(e)),!Z(","))break;M()}while(ft>lt);return t}function Ee(){var e;return G("var"),e=ve(),H(),pt.createVariableDeclaration(e,"var")} +return n=mt,t=Se(),ut&&f(t.name)&&W({},it.StrictVarName),"const"===e?(G("="),r=ge()):V("=")&&(N(),r=ge()),dt.markEnd(dt.createVariableDeclarator(t,r),n)}function Ee(e){var t=[];do{if(t.push(we(e)),!V(","))break;N()}while(pt>lt);return t}function xe(){var e;return Z("var"),e=Ee(),H(),dt.createVariableDeclaration(e,"var")} // kind may be `const` or `let` // Both are experimental and not in the specification yet. // see http://wiki.ecmascript.org/doku.php?id=harmony:const // and http://wiki.ecmascript.org/doku.php?id=harmony:let -function Ce(e){var t,n;return n=dt,G(e),t=ve(e),H(),pt.markEnd(pt.createVariableDeclaration(t,e),n)} +function _e(e){var t,n;return n=mt,Z(e),t=Ee(e),H(),dt.markEnd(dt.createVariableDeclaration(t,e),n)} // 12.3 Empty Statement -function xe(){return Y(";"),pt.createEmptyStatement()} +function Ce(){return G(";"),dt.createEmptyStatement()} // 12.4 Expression Statement -function _e(){var e=ge();return H(),pt.createExpressionStatement(e)} +function ke(){var e=ye();return H(),dt.createExpressionStatement(e)} // 12.5 If statement -function ke(){var e,t,n;return G("if"),Y("("),e=ge(),Y(")"),t=qe(),z("else")?(M(),n=qe()):n=null,pt.createIfStatement(e,t,n)} +function Ae(){var e,t,n;return Z("if"),G("("),e=ye(),G(")"),t=We(),z("else")?(N(),n=We()):n=null,dt.createIfStatement(e,t,n)} // 12.6 Iteration Statements -function Ie(){var e,t,n;return G("do"),n=mt.inIteration,mt.inIteration=!0,e=qe(),mt.inIteration=n,G("while"),Y("("),t=ge(),Y(")"),Z(";")&&M(),pt.createDoWhileStatement(e,t)}function Ae(){var e,t,n;return G("while"),Y("("),e=ge(),Y(")"),n=mt.inIteration,mt.inIteration=!0,t=qe(),mt.inIteration=n,pt.createWhileStatement(e,t)}function Le(){var e,t,n;return n=dt,e=M(),t=ve(),pt.markEnd(pt.createVariableDeclaration(t,e.value),n)}function Be(){var e,t,n,r,o,i,a; +function Ie(){var e,t,n;return Z("do"),n=ht.inIteration,ht.inIteration=!0,e=We(),ht.inIteration=n,Z("while"),G("("),t=ye(),G(")"),V(";")&&N(),dt.createDoWhileStatement(e,t)}function Le(){var e,t,n;return Z("while"),G("("),e=ye(),G(")"),n=ht.inIteration,ht.inIteration=!0,t=We(),ht.inIteration=n,dt.createWhileStatement(e,t)}function Be(){var e,t,n;return n=mt,e=N(),t=Ee(),dt.markEnd(dt.createVariableDeclaration(t,e.value),n)}function Re(){var e,t,n,r,i,o,a,s=ht.allowIn; // LeftHandSideExpression -return e=t=n=null,G("for"),Y("("),Z(";")?M():(z("var")||z("let")?(mt.allowIn=!1,e=Le(),mt.allowIn=!0,1===e.declarations.length&&z("in")&&(M(),r=e,o=ge(),e=null)):(mt.allowIn=!1,e=ge(),mt.allowIn=!0,z("in")&&(K(e)||q({},rt.InvalidLHSInForIn),M(),r=e,o=ge(),e=null)),"undefined"==typeof r&&Y(";")),"undefined"==typeof r&&(Z(";")||(t=ge()),Y(";"),Z(")")||(n=ge())),Y(")"),a=mt.inIteration,mt.inIteration=!0,i=qe(),mt.inIteration=a,"undefined"==typeof r?pt.createForStatement(e,t,n,i):pt.createForInStatement(r,o,i)} +return e=t=n=null,Z("for"),G("("),V(";")?N():(z("var")||z("let")?(ht.allowIn=!1,e=Be(),ht.allowIn=s,1===e.declarations.length&&z("in")&&(N(),r=e,i=ye(),e=null)):(ht.allowIn=!1,e=ye(),ht.allowIn=s,z("in")&&($(e)||W({},it.InvalidLHSInForIn),N(),r=e,i=ye(),e=null)),"undefined"==typeof r&&G(";")),"undefined"==typeof r&&(V(";")||(t=ye()),G(";"),V(")")||(n=ye())),G(")"),a=ht.inIteration,ht.inIteration=!0,o=We(),ht.inIteration=a,"undefined"==typeof r?dt.createForStatement(e,t,n,o):dt.createForInStatement(r,i,o)} // 12.7 The continue statement -function De(){var e,t=null; +function Me(){var e,t=null; // Optimize the most common form: 'continue;'. // Optimize the most common form: 'continue;'. -return G("continue"),59===at.charCodeAt(lt)?(M(),mt.inIteration||j({},rt.IllegalContinue),pt.createContinueStatement(null)):U()?(mt.inIteration||j({},rt.IllegalContinue),pt.createContinueStatement(null)):(dt.type===Xe.Identifier&&(t=be(),e="$"+t.name,Object.prototype.hasOwnProperty.call(mt.labelSet,e)||j({},rt.UnknownLabel,t.name)),H(),null!==t||mt.inIteration||j({},rt.IllegalContinue),pt.createContinueStatement(t))} +return Z("continue"),59===st.charCodeAt(lt)?(N(),ht.inIteration||q({},it.IllegalContinue),dt.createContinueStatement(null)):U()?(ht.inIteration||q({},it.IllegalContinue),dt.createContinueStatement(null)):(mt.type===Qe.Identifier&&(t=Se(),e="$"+t.name,Object.prototype.hasOwnProperty.call(ht.labelSet,e)||q({},it.UnknownLabel,t.name)),H(),null!==t||ht.inIteration||q({},it.IllegalContinue),dt.createContinueStatement(t))} // 12.8 The break statement -function Oe(){var e,t=null; +function Pe(){var e,t=null; // Catch the very common case first: immediately a semicolon (U+003B). // Catch the very common case first: immediately a semicolon (U+003B). -return G("break"),59===at.charCodeAt(lt)?(M(),mt.inIteration||mt.inSwitch||j({},rt.IllegalBreak),pt.createBreakStatement(null)):U()?(mt.inIteration||mt.inSwitch||j({},rt.IllegalBreak),pt.createBreakStatement(null)):(dt.type===Xe.Identifier&&(t=be(),e="$"+t.name,Object.prototype.hasOwnProperty.call(mt.labelSet,e)||j({},rt.UnknownLabel,t.name)),H(),null!==t||mt.inIteration||mt.inSwitch||j({},rt.IllegalBreak),pt.createBreakStatement(t))} +return Z("break"),59===st.charCodeAt(lt)?(N(),ht.inIteration||ht.inSwitch||q({},it.IllegalBreak),dt.createBreakStatement(null)):U()?(ht.inIteration||ht.inSwitch||q({},it.IllegalBreak),dt.createBreakStatement(null)):(mt.type===Qe.Identifier&&(t=Se(),e="$"+t.name,Object.prototype.hasOwnProperty.call(ht.labelSet,e)||q({},it.UnknownLabel,t.name)),H(),null!==t||ht.inIteration||ht.inSwitch||q({},it.IllegalBreak),dt.createBreakStatement(t))} // 12.9 The return statement -function Te(){var e=null; +function Oe(){var e=null; // 'return' followed by a space and an identifier is very common. // 'return' followed by a space and an identifier is very common. -return G("return"),mt.inFunctionBody||q({},rt.IllegalReturn),32===at.charCodeAt(lt)&&s(at.charCodeAt(lt+1))?(e=ge(),H(),pt.createReturnStatement(e)):U()?pt.createReturnStatement(null):(Z(";")||Z("}")||dt.type===Xe.EOF||(e=ge()),H(),pt.createReturnStatement(e))} +return Z("return"),ht.inFunctionBody||W({},it.IllegalReturn),32===st.charCodeAt(lt)&&s(st.charCodeAt(lt+1))?(e=ye(),H(),dt.createReturnStatement(e)):U()?dt.createReturnStatement(null):(V(";")||V("}")||mt.type===Qe.EOF||(e=ye()),H(),dt.createReturnStatement(e))} // 12.10 The with statement -function Pe(){var e,t; +function De(){var e,t; // TODO(ikarienator): Should we update the test cases instead? -return st&&(g(),q({},rt.StrictModeWith)),G("with"),Y("("),e=ge(),Y(")"),t=qe(),pt.createWithStatement(e,t)} +return ut&&(g(),W({},it.StrictModeWith)),Z("with"),G("("),e=ye(),G(")"),t=We(),dt.createWithStatement(e,t)} // 12.10 The swith statement -function Me(){var e,t,n,r=[];for(n=dt,z("default")?(M(),e=null):(G("case"),e=ge()),Y(":");ft>lt&&!(Z("}")||z("default")||z("case"));)t=qe(),r.push(t);return pt.markEnd(pt.createSwitchCase(e,r),n)}function Re(){var e,t,n,r,o;if(G("switch"),Y("("),e=ge(),Y(")"),Y("{"),t=[],Z("}"))return M(),pt.createSwitchStatement(e,t);for(r=mt.inSwitch,mt.inSwitch=!0,o=!1;ft>lt&&!Z("}");)n=Me(),null===n.test&&(o&&j({},rt.MultipleDefaultsInSwitch),o=!0),t.push(n);return mt.inSwitch=r,Y("}"),pt.createSwitchStatement(e,t)} +function Ne(){var e,t,n,r=[];for(n=mt,z("default")?(N(),e=null):(Z("case"),e=ye()),G(":");pt>lt&&!(V("}")||z("default")||z("case"));)t=We(),r.push(t);return dt.markEnd(dt.createSwitchCase(e,r),n)}function Te(){var e,t,n,r,i;if(Z("switch"),G("("),e=ye(),G(")"),G("{"),t=[],V("}"))return N(),dt.createSwitchStatement(e,t);for(r=ht.inSwitch,ht.inSwitch=!0,i=!1;pt>lt&&!V("}");)n=Ne(),null===n.test&&(i&&q({},it.MultipleDefaultsInSwitch),i=!0),t.push(n);return ht.inSwitch=r,G("}"),dt.createSwitchStatement(e,t)} // 12.13 The throw statement -function Ne(){var e;return G("throw"),U()&&j({},rt.NewlineAfterThrow),e=ge(),H(),pt.createThrowStatement(e)} +function Fe(){var e;return Z("throw"),U()&&q({},it.NewlineAfterThrow),e=ye(),H(),dt.createThrowStatement(e)} // 12.14 The try statement -function Fe(){var e,t,n; +function je(){var e,t,n; // 12.14.1 -return n=dt,G("catch"),Y("("),Z(")")&&W(dt),e=be(),st&&f(e.name)&&q({},rt.StrictCatchVariable),Y(")"),t=we(),pt.markEnd(pt.createCatchClause(e,t),n)}function Ue(){var e,t=[],n=null;return G("try"),e=we(),z("catch")&&t.push(Fe()),z("finally")&&(M(),n=we()),0!==t.length||n||j({},rt.NoCatchOrFinally),pt.createTryStatement(e,[],t,n)} +return n=mt,Z("catch"),G("("),V(")")&&Y(mt),e=Se(),ut&&f(e.name)&&W({},it.StrictCatchVariable),G(")"),t=ve(),dt.markEnd(dt.createCatchClause(e,t),n)}function Ue(){var e,t=[],n=null;return Z("try"),e=ve(),z("catch")&&t.push(je()),z("finally")&&(N(),n=ve()),0!==t.length||n||q({},it.NoCatchOrFinally),dt.createTryStatement(e,[],t,n)} // 12.15 The debugger statement -function je(){return G("debugger"),H(),pt.createDebuggerStatement()} +function qe(){return Z("debugger"),H(),dt.createDebuggerStatement()} // 12 Statements -function qe(){var e,t,n,r,o=dt.type;if(o===Xe.EOF&&W(dt),o===Xe.Punctuator&&"{"===dt.value)return we();if(r=dt,o===Xe.Punctuator)switch(dt.value){case";":return pt.markEnd(xe(),r);case"(":return pt.markEnd(_e(),r)}if(o===Xe.Keyword)switch(dt.value){case"break":return pt.markEnd(Oe(),r);case"continue":return pt.markEnd(De(),r);case"debugger":return pt.markEnd(je(),r);case"do":return pt.markEnd(Ie(),r);case"for":return pt.markEnd(Be(),r);case"function":return pt.markEnd(Ge(),r);case"if":return pt.markEnd(ke(),r);case"return":return pt.markEnd(Te(),r);case"switch":return pt.markEnd(Re(),r);case"throw":return pt.markEnd(Ne(),r);case"try":return pt.markEnd(Ue(),r);case"var":return pt.markEnd(Ee(),r);case"while":return pt.markEnd(Ae(),r);case"with":return pt.markEnd(Pe(),r)} +function We(){var e,t,n,r,i=mt.type;if(i===Qe.EOF&&Y(mt),i===Qe.Punctuator&&"{"===mt.value)return ve();if(r=mt,i===Qe.Punctuator)switch(mt.value){case";":return dt.markEnd(Ce(),r);case"(":return dt.markEnd(ke(),r)}if(i===Qe.Keyword)switch(mt.value){case"break":return dt.markEnd(Pe(),r);case"continue":return dt.markEnd(Me(),r);case"debugger":return dt.markEnd(qe(),r);case"do":return dt.markEnd(Ie(),r);case"for":return dt.markEnd(Re(),r);case"function":return dt.markEnd(Ze(),r);case"if":return dt.markEnd(Ae(),r);case"return":return dt.markEnd(Oe(),r);case"switch":return dt.markEnd(Te(),r);case"throw":return dt.markEnd(Fe(),r);case"try":return dt.markEnd(Ue(),r);case"var":return dt.markEnd(xe(),r);case"while":return dt.markEnd(Le(),r);case"with":return dt.markEnd(De(),r)} // 12.12 Labelled Statements // 12.12 Labelled Statements -return e=ge(),e.type===tt.Identifier&&Z(":")?(M(),n="$"+e.name,Object.prototype.hasOwnProperty.call(mt.labelSet,n)&&j({},rt.Redeclaration,"Label",e.name),mt.labelSet[n]=!0,t=qe(),delete mt.labelSet[n],pt.markEnd(pt.createLabeledStatement(e,t),r)):(H(),pt.markEnd(pt.createExpressionStatement(e),r))} +return e=ye(),e.type===nt.Identifier&&V(":")?(N(),n="$"+e.name,Object.prototype.hasOwnProperty.call(ht.labelSet,n)&&q({},it.Redeclaration,"Label",e.name),ht.labelSet[n]=!0,t=We(),delete ht.labelSet[n],dt.markEnd(dt.createLabeledStatement(e,t),r)):(H(),dt.markEnd(dt.createExpressionStatement(e),r))} // 13 Function Definition -function We(){var e,t,n,r,o,i,a,s,l,u=[];for(l=dt,Y("{");ft>lt&&dt.type===Xe.StringLiteral&&(t=dt,e=ze(),u.push(e),e.expression.type===tt.Literal);)n=at.slice(t.start+1,t.end-1),"use strict"===n?(st=!0,r&&q(r,rt.StrictOctalLiteral)):!r&&t.octal&&(r=t);for(o=mt.labelSet,i=mt.inIteration,a=mt.inSwitch,s=mt.inFunctionBody,mt.labelSet={},mt.inIteration=!1,mt.inSwitch=!1,mt.inFunctionBody=!0;ft>lt&&!Z("}")&&(e=ze(),"undefined"!=typeof e);)u.push(e);return Y("}"),mt.labelSet=o,mt.inIteration=i,mt.inSwitch=a,mt.inFunctionBody=s,pt.markEnd(pt.createBlockStatement(u),l)}function Ye(e){var t,n,r,o,i,a,s=[];if(Y("("),!Z(")"))for(o={};ft>lt&&(n=dt,t=be(),i="$"+n.value,st?(f(n.value)&&(r=n,a=rt.StrictParamName),Object.prototype.hasOwnProperty.call(o,i)&&(r=n,a=rt.StrictParamDupe)):e||(f(n.value)?(e=n,a=rt.StrictParamName):c(n.value)?(e=n,a=rt.StrictReservedWord):Object.prototype.hasOwnProperty.call(o,i)&&(e=n,a=rt.StrictParamDupe)),s.push(t),o[i]=!0,!Z(")"));)Y(",");return Y(")"),{params:s,stricted:r,firstRestricted:e,message:a}}function Ge(){var e,t,n,r,o,i,a,s,l,u=[];return l=dt,G("function"),n=dt,e=be(),st?f(n.value)&&q(n,rt.StrictFunctionName):f(n.value)?(i=n,a=rt.StrictFunctionName):c(n.value)&&(i=n,a=rt.StrictReservedWord),o=Ye(i),u=o.params,r=o.stricted,i=o.firstRestricted,o.message&&(a=o.message),s=st,t=We(),st&&i&&j(i,a),st&&r&&q(r,a),st=s,pt.markEnd(pt.createFunctionDeclaration(e,u,[],t),l)}function Ze(){var e,t,n,r,o,i,a,s,l=null,u=[];return s=dt,G("function"),Z("(")||(e=dt,l=be(),st?f(e.value)&&q(e,rt.StrictFunctionName):f(e.value)?(n=e,r=rt.StrictFunctionName):c(e.value)&&(n=e,r=rt.StrictReservedWord)),o=Ye(n),u=o.params,t=o.stricted,n=o.firstRestricted,o.message&&(r=o.message),a=st,i=We(),st&&n&&j(n,r),st&&t&&q(t,r),st=a,pt.markEnd(pt.createFunctionExpression(l,u,[],i),s)} +function Ye(){var e,t,n,r,i,o,a,s,u,l=[];for(u=mt,G("{");pt>lt&&mt.type===Qe.StringLiteral&&(t=mt,e=ze(),l.push(e),e.expression.type===nt.Literal);)n=st.slice(t.start+1,t.end-1),"use strict"===n?(ut=!0,r&&W(r,it.StrictOctalLiteral)):!r&&t.octal&&(r=t);for(i=ht.labelSet,o=ht.inIteration,a=ht.inSwitch,s=ht.inFunctionBody,ht.labelSet={},ht.inIteration=!1,ht.inSwitch=!1,ht.inFunctionBody=!0;pt>lt&&!V("}")&&(e=ze(),"undefined"!=typeof e);)l.push(e);return G("}"),ht.labelSet=i,ht.inIteration=o,ht.inSwitch=a,ht.inFunctionBody=s,dt.markEnd(dt.createBlockStatement(l),u)}function Ge(e){var t,n,r,i,o,a,s=[];if(G("("),!V(")"))for(i={};pt>lt&&(n=mt,t=Se(),o="$"+n.value,ut?(f(n.value)&&(r=n,a=it.StrictParamName),Object.prototype.hasOwnProperty.call(i,o)&&(r=n,a=it.StrictParamDupe)):e||(f(n.value)?(e=n,a=it.StrictParamName):c(n.value)?(e=n,a=it.StrictReservedWord):Object.prototype.hasOwnProperty.call(i,o)&&(e=n,a=it.StrictParamDupe)),s.push(t),i[o]=!0,!V(")"));)G(",");return G(")"),{params:s,stricted:r,firstRestricted:e,message:a}}function Ze(){var e,t,n,r,i,o,a,s,u,l=[];return u=mt,Z("function"),n=mt,e=Se(),ut?f(n.value)&&W(n,it.StrictFunctionName):f(n.value)?(o=n,a=it.StrictFunctionName):c(n.value)&&(o=n,a=it.StrictReservedWord),i=Ge(o),l=i.params,r=i.stricted,o=i.firstRestricted,i.message&&(a=i.message),s=ut,t=Ye(),ut&&o&&q(o,a),ut&&r&&W(r,a),ut=s,dt.markEnd(dt.createFunctionDeclaration(e,l,[],t),u)}function Ve(){var e,t,n,r,i,o,a,s,u=null,l=[];return s=mt,Z("function"),V("(")||(e=mt,u=Se(),ut?f(e.value)&&W(e,it.StrictFunctionName):f(e.value)?(n=e,r=it.StrictFunctionName):c(e.value)&&(n=e,r=it.StrictReservedWord)),i=Ge(n),l=i.params,t=i.stricted,n=i.firstRestricted,i.message&&(r=i.message),a=ut,o=Ye(),ut&&n&&q(n,r),ut&&t&&W(t,r),ut=a,dt.markEnd(dt.createFunctionExpression(u,l,[],o),s)} // 14 Program -function ze(){if(dt.type===Xe.Keyword)switch(dt.value){case"const":case"let":return Ce(dt.value);case"function":return Ge();default:return qe()}return dt.type!==Xe.EOF?qe():void 0}function Ve(){for(var e,t,n,r,o=[];ft>lt&&(t=dt,t.type===Xe.StringLiteral)&&(e=ze(),o.push(e),e.expression.type===tt.Literal);)n=at.slice(t.start+1,t.end-1),"use strict"===n?(st=!0,r&&q(r,rt.StrictOctalLiteral)):!r&&t.octal&&(r=t);for(;ft>lt&&(e=ze(),"undefined"!=typeof e);)o.push(e);return o}function He(){var e,t;return g(),R(),t=dt,st=!1,e=Ve(),pt.markEnd(pt.createProgram(e),t)}function Ke(){var e,t,n,r=[];for(e=0;e0?1:0,ct=0,ft=at.length,dt=null,mt={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},ht={}, -// Options matching. -t=t||{}, -// Of course we collect tokens here. -t.tokens=!0,ht.tokens=[],ht.tokenize=!0, -// The following two fields are necessary to compute the Regex tokens. -ht.openParenToken=-1,ht.openCurlyToken=-1,ht.range="boolean"==typeof t.range&&t.range,ht.loc="boolean"==typeof t.loc&&t.loc,"boolean"==typeof t.comment&&t.comment&&(ht.comments=[]),"boolean"==typeof t.tolerant&&t.tolerant&&(ht.errors=[]);try{if(R(),dt.type===Xe.EOF)return ht.tokens;for(r=M();dt.type!==Xe.EOF;)try{r=M()}catch(i){if(r=dt,ht.errors){ht.errors.push(i); +function ze(){if(mt.type===Qe.Keyword)switch(mt.value){case"const":case"let":return _e(mt.value);case"function":return Ze();default:return We()}return mt.type!==Qe.EOF?We():void 0}function Ke(){for(var e,t,n,r,i=[];pt>lt&&(t=mt,t.type===Qe.StringLiteral)&&(e=ze(),i.push(e),e.expression.type===nt.Literal);)n=st.slice(t.start+1,t.end-1),"use strict"===n?(ut=!0,r&&W(r,it.StrictOctalLiteral)):!r&&t.octal&&(r=t);for(;pt>lt&&(e=ze(),"undefined"!=typeof e);)i.push(e);return i}function He(){var e,t;return g(),T(),t=mt,ut=!1,e=Ke(),dt.markEnd(dt.createProgram(e),t)}function $e(){var e,t,n,r=[];for(e=0;e0?1:0,ft=0,pt=st.length,mt=null,ht={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},gt={},t=t||{},t.tokens=!0,gt.tokens=[],gt.tokenize=!0,gt.openParenToken=-1,gt.openCurlyToken=-1,gt.range="boolean"==typeof t.range&&t.range,gt.loc="boolean"==typeof t.loc&&t.loc,"boolean"==typeof t.comment&&t.comment&&(gt.comments=[]),"boolean"==typeof t.tolerant&&t.tolerant&&(gt.errors=[]);try{if(T(),mt.type===Qe.EOF)return gt.tokens;for(r=N();mt.type!==Qe.EOF;)try{r=N()}catch(o){if(r=mt,gt.errors){gt.errors.push(o); // We have to break on the first error // to avoid infinite loops. -break}throw i}Ke(),o=ht.tokens,"undefined"!=typeof ht.comments&&(o.comments=ht.comments),"undefined"!=typeof ht.errors&&(o.errors=ht.errors)}catch(a){throw a}finally{ht={}}return o}function Je(e,t){var n,r;r=String,"string"==typeof e||e instanceof String||(e=r(e)),pt=it,at=e,lt=0,ut=at.length>0?1:0,ct=0,ft=at.length,dt=null,mt={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},ht={},"undefined"!=typeof t&&(ht.range="boolean"==typeof t.range&&t.range,ht.loc="boolean"==typeof t.loc&&t.loc,ht.attachComment="boolean"==typeof t.attachComment&&t.attachComment,ht.loc&&null!==t.source&&void 0!==t.source&&(ht.source=r(t.source)),"boolean"==typeof t.tokens&&t.tokens&&(ht.tokens=[]),"boolean"==typeof t.comment&&t.comment&&(ht.comments=[]),"boolean"==typeof t.tolerant&&t.tolerant&&(ht.errors=[]),ht.attachComment&&(ht.range=!0,ht.comments=[],ht.bottomRightStack=[],ht.trailingComments=[],ht.leadingComments=[]));try{n=He(),"undefined"!=typeof ht.comments&&(n.comments=ht.comments),"undefined"!=typeof ht.tokens&&(Ke(),n.tokens=ht.tokens),"undefined"!=typeof ht.errors&&(n.errors=ht.errors)}catch(o){throw o}finally{ht={}}return n}var Xe,Qe,et,tt,nt,rt,ot,it,at,st,lt,ut,ct,ft,pt,dt,mt,ht;Xe={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9},Qe={},Qe[Xe.BooleanLiteral]="Boolean",Qe[Xe.EOF]="",Qe[Xe.Identifier]="Identifier",Qe[Xe.Keyword]="Keyword",Qe[Xe.NullLiteral]="Null",Qe[Xe.NumericLiteral]="Numeric",Qe[Xe.Punctuator]="Punctuator",Qe[Xe.StringLiteral]="String",Qe[Xe.RegularExpression]="RegularExpression", -// A function following one of those tokens is an expression. -et=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void", -// assignment operators -"=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",", -// binary/unary operators -"+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="],tt={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"},nt={Data:1,Get:2,Set:4}, -// Error messages should be identical to V8. -rt={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"}, -// See also tools/generate-unicode-regex.py. -ot={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‌‍‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")},it={name:"SyntaxTree",processComment:function(e){var t,n;if(!(e.type===tt.Program&&e.body.length>0)){ -// Eating the stack. -for(ht.trailingComments.length>0?ht.trailingComments[0].range[0]>=e.range[1]?(n=ht.trailingComments,ht.trailingComments=[]):ht.trailingComments.length=0:ht.bottomRightStack.length>0&&ht.bottomRightStack[ht.bottomRightStack.length-1].trailingComments&&ht.bottomRightStack[ht.bottomRightStack.length-1].trailingComments[0].range[0]>=e.range[1]&&(n=ht.bottomRightStack[ht.bottomRightStack.length-1].trailingComments,delete ht.bottomRightStack[ht.bottomRightStack.length-1].trailingComments);ht.bottomRightStack.length>0&&ht.bottomRightStack[ht.bottomRightStack.length-1].range[0]>=e.range[0];)t=ht.bottomRightStack.pop();t?t.leadingComments&&t.leadingComments[t.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=t.leadingComments,delete t.leadingComments):ht.leadingComments.length>0&&ht.leadingComments[ht.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=ht.leadingComments,ht.leadingComments=[]),n&&(e.trailingComments=n),ht.bottomRightStack.push(e)}},markEnd:function(e,t){return ht.range&&(e.range=[t.start,lt]),ht.loc&&(e.loc=new F(void 0===t.startLineNumber?t.lineNumber:t.startLineNumber,t.start-(void 0===t.startLineStart?t.lineStart:t.startLineStart),ut,lt-ct),this.postProcess(e)),ht.attachComment&&this.processComment(e),e},postProcess:function(e){return ht.source&&(e.loc.source=ht.source),e},createArrayExpression:function(e){return{type:tt.ArrayExpression,elements:e}},createAssignmentExpression:function(e,t,n){return{type:tt.AssignmentExpression,operator:e,left:t,right:n}},createBinaryExpression:function(e,t,n){var r="||"===e||"&&"===e?tt.LogicalExpression:tt.BinaryExpression;return{type:r,operator:e,left:t,right:n}},createBlockStatement:function(e){return{type:tt.BlockStatement,body:e}},createBreakStatement:function(e){return{type:tt.BreakStatement,label:e}},createCallExpression:function(e,t){return{type:tt.CallExpression,callee:e,arguments:t}},createCatchClause:function(e,t){return{type:tt.CatchClause,param:e,body:t}},createConditionalExpression:function(e,t,n){return{type:tt.ConditionalExpression,test:e,consequent:t,alternate:n}},createContinueStatement:function(e){return{type:tt.ContinueStatement,label:e}},createDebuggerStatement:function(){return{type:tt.DebuggerStatement}},createDoWhileStatement:function(e,t){return{type:tt.DoWhileStatement,body:e,test:t}},createEmptyStatement:function(){return{type:tt.EmptyStatement}},createExpressionStatement:function(e){return{type:tt.ExpressionStatement,expression:e}},createForStatement:function(e,t,n,r){return{type:tt.ForStatement,init:e,test:t,update:n,body:r}},createForInStatement:function(e,t,n){return{type:tt.ForInStatement,left:e,right:t,body:n,each:!1}},createFunctionDeclaration:function(e,t,n,r){return{type:tt.FunctionDeclaration,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createFunctionExpression:function(e,t,n,r){return{type:tt.FunctionExpression,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createIdentifier:function(e){return{type:tt.Identifier,name:e}},createIfStatement:function(e,t,n){return{type:tt.IfStatement,test:e,consequent:t,alternate:n}},createLabeledStatement:function(e,t){return{type:tt.LabeledStatement,label:e,body:t}},createLiteral:function(e){return{type:tt.Literal,value:e.value,raw:at.slice(e.start,e.end)}},createMemberExpression:function(e,t,n){return{type:tt.MemberExpression,computed:"["===e,object:t,property:n}},createNewExpression:function(e,t){return{type:tt.NewExpression,callee:e,arguments:t}},createObjectExpression:function(e){return{type:tt.ObjectExpression,properties:e}},createPostfixExpression:function(e,t){return{type:tt.UpdateExpression,operator:e,argument:t,prefix:!1}},createProgram:function(e){return{type:tt.Program,body:e}},createProperty:function(e,t,n){return{type:tt.Property,key:t,value:n,kind:e}},createReturnStatement:function(e){return{type:tt.ReturnStatement,argument:e}},createSequenceExpression:function(e){return{type:tt.SequenceExpression,expressions:e}},createSwitchCase:function(e,t){return{type:tt.SwitchCase,test:e,consequent:t}},createSwitchStatement:function(e,t){return{type:tt.SwitchStatement,discriminant:e,cases:t}},createThisExpression:function(){return{type:tt.ThisExpression}},createThrowStatement:function(e){return{type:tt.ThrowStatement,argument:e}},createTryStatement:function(e,t,n,r){return{type:tt.TryStatement,block:e,guardedHandlers:t,handlers:n,finalizer:r}},createUnaryExpression:function(e,t){return"++"===e||"--"===e?{type:tt.UpdateExpression,operator:e,argument:t,prefix:!0}:{type:tt.UnaryExpression,operator:e,argument:t,prefix:!0}},createVariableDeclaration:function(e,t){return{type:tt.VariableDeclaration,declarations:e,kind:t}},createVariableDeclarator:function(e,t){return{type:tt.VariableDeclarator,id:e,init:t}},createWhileStatement:function(e,t){return{type:tt.WhileStatement,test:e,body:t}},createWithStatement:function(e,t){return{type:tt.WithStatement,object:e,body:t}}}, -// Sync with *.json manifests. -e.version="1.2.2",e.tokenize=$e,e.parse=Je, -// Deep copy. -/* istanbul ignore next */ -e.Syntax=function(){var e,t={};"function"==typeof Object.create&&(t=Object.create(null));for(e in tt)tt.hasOwnProperty(e)&&(t[e]=tt[e]);return"function"==typeof Object.freeze&&Object.freeze(t),t}()})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/esprima/esprima.js","/../node_modules/esprima")},{"1YiZ5S":24,buffer:20}],20:[function(e,t,n){(function(t,r,o,i,a,s,l,u,c){/** +break}throw o}$e(),i=gt.tokens,"undefined"!=typeof gt.comments&&(i.comments=gt.comments),"undefined"!=typeof gt.errors&&(i.errors=gt.errors)}catch(a){throw a}finally{gt={}}return i}function Xe(e,t){var n,r;r=String,"string"==typeof e||e instanceof String||(e=r(e)),dt=at,st=e,lt=0,ct=st.length>0?1:0,ft=0,pt=st.length,mt=null,ht={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},gt={},"undefined"!=typeof t&&(gt.range="boolean"==typeof t.range&&t.range,gt.loc="boolean"==typeof t.loc&&t.loc,gt.attachComment="boolean"==typeof t.attachComment&&t.attachComment,gt.loc&&null!==t.source&&void 0!==t.source&&(gt.source=r(t.source)),"boolean"==typeof t.tokens&&t.tokens&&(gt.tokens=[]),"boolean"==typeof t.comment&&t.comment&&(gt.comments=[]),"boolean"==typeof t.tolerant&&t.tolerant&&(gt.errors=[]),gt.attachComment&&(gt.range=!0,gt.comments=[],gt.bottomRightStack=[],gt.trailingComments=[],gt.leadingComments=[]));try{n=He(),"undefined"!=typeof gt.comments&&(n.comments=gt.comments),"undefined"!=typeof gt.tokens&&($e(),n.tokens=gt.tokens),"undefined"!=typeof gt.errors&&(n.errors=gt.errors)}catch(i){throw i}finally{gt={}}return n}var Qe,et,tt,nt,rt,it,ot,at,st,ut,lt,ct,ft,pt,dt,mt,ht,gt;Qe={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9},et={},et[Qe.BooleanLiteral]="Boolean",et[Qe.EOF]="",et[Qe.Identifier]="Identifier",et[Qe.Keyword]="Keyword",et[Qe.NullLiteral]="Null",et[Qe.NumericLiteral]="Numeric",et[Qe.Punctuator]="Punctuator",et[Qe.StringLiteral]="String",et[Qe.RegularExpression]="RegularExpression",tt=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="],nt={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"},rt={Data:1,Get:2,Set:4},it={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"},ot={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‌‍‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")},at={name:"SyntaxTree",processComment:function(e){var t,n;if(!(e.type===nt.Program&&e.body.length>0)){for(gt.trailingComments.length>0?gt.trailingComments[0].range[0]>=e.range[1]?(n=gt.trailingComments,gt.trailingComments=[]):gt.trailingComments.length=0:gt.bottomRightStack.length>0&>.bottomRightStack[gt.bottomRightStack.length-1].trailingComments&>.bottomRightStack[gt.bottomRightStack.length-1].trailingComments[0].range[0]>=e.range[1]&&(n=gt.bottomRightStack[gt.bottomRightStack.length-1].trailingComments,delete gt.bottomRightStack[gt.bottomRightStack.length-1].trailingComments);gt.bottomRightStack.length>0&>.bottomRightStack[gt.bottomRightStack.length-1].range[0]>=e.range[0];)t=gt.bottomRightStack.pop();t?t.leadingComments&&t.leadingComments[t.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=t.leadingComments,delete t.leadingComments):gt.leadingComments.length>0&>.leadingComments[gt.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=gt.leadingComments,gt.leadingComments=[]),n&&(e.trailingComments=n),gt.bottomRightStack.push(e)}},markEnd:function(e,t){return gt.range&&(e.range=[t.start,lt]),gt.loc&&(e.loc=new j(void 0===t.startLineNumber?t.lineNumber:t.startLineNumber,t.start-(void 0===t.startLineStart?t.lineStart:t.startLineStart),ct,lt-ft),this.postProcess(e)),gt.attachComment&&this.processComment(e),e},postProcess:function(e){return gt.source&&(e.loc.source=gt.source),e},createArrayExpression:function(e){return{type:nt.ArrayExpression,elements:e}},createAssignmentExpression:function(e,t,n){return{type:nt.AssignmentExpression,operator:e,left:t,right:n}},createBinaryExpression:function(e,t,n){var r="||"===e||"&&"===e?nt.LogicalExpression:nt.BinaryExpression;return{type:r,operator:e,left:t,right:n}},createBlockStatement:function(e){return{type:nt.BlockStatement,body:e}},createBreakStatement:function(e){return{type:nt.BreakStatement,label:e}},createCallExpression:function(e,t){return{type:nt.CallExpression,callee:e,arguments:t}},createCatchClause:function(e,t){return{type:nt.CatchClause,param:e,body:t}},createConditionalExpression:function(e,t,n){return{type:nt.ConditionalExpression,test:e,consequent:t,alternate:n}},createContinueStatement:function(e){return{type:nt.ContinueStatement,label:e}},createDebuggerStatement:function(){return{type:nt.DebuggerStatement}},createDoWhileStatement:function(e,t){return{type:nt.DoWhileStatement,body:e,test:t}},createEmptyStatement:function(){return{type:nt.EmptyStatement}},createExpressionStatement:function(e){return{type:nt.ExpressionStatement,expression:e}},createForStatement:function(e,t,n,r){return{type:nt.ForStatement,init:e,test:t,update:n,body:r}},createForInStatement:function(e,t,n){return{type:nt.ForInStatement,left:e,right:t,body:n,each:!1}},createFunctionDeclaration:function(e,t,n,r){return{type:nt.FunctionDeclaration,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createFunctionExpression:function(e,t,n,r){return{type:nt.FunctionExpression,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createIdentifier:function(e){return{type:nt.Identifier,name:e}},createIfStatement:function(e,t,n){return{type:nt.IfStatement,test:e,consequent:t,alternate:n}},createLabeledStatement:function(e,t){return{type:nt.LabeledStatement,label:e,body:t}},createLiteral:function(e){return{type:nt.Literal,value:e.value,raw:st.slice(e.start,e.end)}},createMemberExpression:function(e,t,n){return{type:nt.MemberExpression,computed:"["===e,object:t,property:n}},createNewExpression:function(e,t){return{type:nt.NewExpression,callee:e,arguments:t}},createObjectExpression:function(e){return{type:nt.ObjectExpression,properties:e}},createPostfixExpression:function(e,t){return{type:nt.UpdateExpression,operator:e,argument:t,prefix:!1}},createProgram:function(e){return{type:nt.Program,body:e}},createProperty:function(e,t,n){return{type:nt.Property,key:t,value:n,kind:e}},createReturnStatement:function(e){return{type:nt.ReturnStatement,argument:e}},createSequenceExpression:function(e){return{type:nt.SequenceExpression,expressions:e}},createSwitchCase:function(e,t){return{type:nt.SwitchCase,test:e,consequent:t}},createSwitchStatement:function(e,t){return{type:nt.SwitchStatement,discriminant:e,cases:t}},createThisExpression:function(){return{type:nt.ThisExpression}},createThrowStatement:function(e){return{type:nt.ThrowStatement,argument:e}},createTryStatement:function(e,t,n,r){return{type:nt.TryStatement,block:e,guardedHandlers:t,handlers:n,finalizer:r}},createUnaryExpression:function(e,t){return"++"===e||"--"===e?{type:nt.UpdateExpression,operator:e,argument:t,prefix:!0}:{type:nt.UnaryExpression,operator:e,argument:t,prefix:!0}},createVariableDeclaration:function(e,t){return{type:nt.VariableDeclaration,declarations:e,kind:t}},createVariableDeclarator:function(e,t){return{type:nt.VariableDeclarator,id:e,init:t}},createWhileStatement:function(e,t){return{type:nt.WhileStatement,test:e,body:t}},createWithStatement:function(e,t){return{type:nt.WithStatement,object:e,body:t}}},e.version="1.2.5",e.tokenize=Je,e.parse=Xe,e.Syntax=function(){var e,t={};"function"==typeof Object.create&&(t=Object.create(null));for(e in nt)nt.hasOwnProperty(e)&&(t[e]=nt[e]);return"function"==typeof Object.freeze&&Object.freeze(t),t}()})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/esprima/esprima.js","/../node_modules/esprima")},{"1YiZ5S":25,buffer:21}],21:[function(e,t,n){(function(t,r,i,o,a,s,u,l,c){/** * Class: Buffer * ============= * @@ -1453,53 +1307,51 @@ e.Syntax=function(){var e,t={};"function"==typeof Object.create&&(t=Object.creat * By augmenting the instances, we can avoid modifying the `Uint8Array` * prototype. */ -function o(e,t,n){if(!(this instanceof o))return new o(e,t,n);var r=typeof e; +function i(e,t,n){if(!(this instanceof i))return new i(e,t,n);var r=typeof e; // Workaround: node's base64 implementation allows for non-padded strings // while base64-js does not. -if("base64"===t&&"string"===r)for(e=M(e);e.length%4!==0;)e+="="; +if("base64"===t&&"string"===r)for(e=D(e);e.length%4!==0;)e+="="; // Find the length -var i;if("number"===r)i=N(e);else if("string"===r)i=o.byteLength(e,t);else{if("object"!==r)throw new Error("First argument needs to be a number, array or string.");i=N(e.length)}var a;o._useTypedArrays? +var o;if("number"===r)o=T(e);else if("string"===r)o=i.byteLength(e,t);else{if("object"!==r)throw new Error("First argument needs to be a number, array or string.");o=T(e.length)}var a;i._useTypedArrays? // Preferred: Return an augmented `Uint8Array` instance for best performance -a=o._augment(new Uint8Array(i)):( -// Fallback: Return THIS instance of Buffer (created by `new`) -a=this,a.length=i,a._isBuffer=!0);var s;if(o._useTypedArrays&&"number"==typeof e.byteLength) +a=i._augment(new Uint8Array(o)):(a=this,a.length=o,a._isBuffer=!0);var s;if(i._useTypedArrays&&"number"==typeof e.byteLength) // Speed optimization -- use set if we're copying from a typed array -a._set(e);else if(U(e)) +a._set(e);else if(j(e)) // Treat array-ish objects as a byte array -for(s=0;i>s;s++)a[s]=o.isBuffer(e)?e.readUInt8(s):e[s];else if("string"===r)a.write(e,0,t);else if("number"===r&&!o._useTypedArrays&&!n)for(s=0;i>s;s++)a[s]=0;return a} +for(s=0;o>s;s++)i.isBuffer(e)?a[s]=e.readUInt8(s):a[s]=e[s];else if("string"===r)a.write(e,0,t);else if("number"===r&&!i._useTypedArrays&&!n)for(s=0;o>s;s++)a[s]=0;return a} // BUFFER INSTANCE METHODS // ======================= -function f(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i; +function f(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r),r>o&&(r=o)):r=o; // must be an even number of digits -var a=t.length;$(a%2===0,"Invalid hex string"),r>a/2&&(r=a/2);for(var s=0;r>s;s++){var l=parseInt(t.substr(2*s,2),16);$(!isNaN(l),"Invalid hex string"),e[n+s]=l}return o._charsWritten=2*s,s}function p(e,t,n,r){var i=o._charsWritten=Z(q(t),e,n,r);return i}function d(e,t,n,r){var i=o._charsWritten=Z(W(t),e,n,r);return i}function m(e,t,n,r){return d(e,t,n,r)}function h(e,t,n,r){var i=o._charsWritten=Z(G(t),e,n,r);return i}function g(e,t,n,r){var i=o._charsWritten=Z(Y(t),e,n,r);return i}function y(e,t,n){return J.fromByteArray(0===t&&n===e.length?e:e.slice(t,n))}function w(e,t,n){var r="",o="";n=Math.min(e.length,n);for(var i=t;n>i;i++)e[i]<=127?(r+=z(o)+String.fromCharCode(e[i]),o=""):o+="%"+e[i].toString(16);return r+z(o)}function b(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;n>o;o++)r+=String.fromCharCode(e[o]);return r}function S(e,t,n){return b(e,t,n)}function v(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var o="",i=t;n>i;i++)o+=j(e[i]);return o}function E(e,t,n){for(var r=e.slice(t,n),o="",i=0;i=o)){var i;return n?(i=e[t],o>t+1&&(i|=e[t+1]<<8)):(i=e[t]<<8,o>t+1&&(i|=e[t+1])),i}}function x(e,t,n,r){r||($("boolean"==typeof n,"missing or invalid endian"),$(void 0!==t&&null!==t,"missing offset"),$(t+3=o)){var i;return n?(o>t+2&&(i=e[t+2]<<16),o>t+1&&(i|=e[t+1]<<8),i|=e[t],o>t+3&&(i+=e[t+3]<<24>>>0)):(o>t+1&&(i=e[t+1]<<16),o>t+2&&(i|=e[t+2]<<8),o>t+3&&(i|=e[t+3]),i+=e[t]<<24>>>0),i}}function _(e,t,n,r){r||($("boolean"==typeof n,"missing or invalid endian"),$(void 0!==t&&null!==t,"missing offset"),$(t+1=o)){var i=C(e,t,n,!0),a=32768&i;return a?-1*(65535-i+1):i}}function k(e,t,n,r){r||($("boolean"==typeof n,"missing or invalid endian"),$(void 0!==t&&null!==t,"missing offset"),$(t+3=o)){var i=x(e,t,n,!0),a=2147483648&i;return a?-1*(4294967295-i+1):i}}function I(e,t,n,r){return r||($("boolean"==typeof n,"missing or invalid endian"),$(t+3=i))for(var a=0,s=Math.min(i-n,2);s>a;a++)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function B(e,t,n,r,o){o||($(void 0!==t&&null!==t,"missing value"),$("boolean"==typeof r,"missing or invalid endian"),$(void 0!==n&&null!==n,"missing offset"),$(n+3=i))for(var a=0,s=Math.min(i-n,4);s>a;a++)e[n+a]=t>>>8*(r?a:3-a)&255}function D(e,t,n,r,o){o||($(void 0!==t&&null!==t,"missing value"),$("boolean"==typeof r,"missing or invalid endian"),$(void 0!==n&&null!==n,"missing offset"),$(n+1=i||(t>=0?L(e,t,n,r,o):L(e,65535+t+1,n,r,o))}function O(e,t,n,r,o){o||($(void 0!==t&&null!==t,"missing value"),$("boolean"==typeof r,"missing or invalid endian"),$(void 0!==n&&null!==n,"missing offset"),$(n+3=i||(t>=0?B(e,t,n,r,o):B(e,4294967295+t+1,n,r,o))}function T(e,t,n,r,o){o||($(void 0!==t&&null!==t,"missing value"),$("boolean"==typeof r,"missing or invalid endian"),$(void 0!==n&&null!==n,"missing offset"),$(n+3=i||X.write(e,t,n,r,23,4)}function P(e,t,n,r,o){o||($(void 0!==t&&null!==t,"missing value"),$("boolean"==typeof r,"missing or invalid endian"),$(void 0!==n&&null!==n,"missing offset"),$(n+7=i||X.write(e,t,n,r,52,8)} +var a=t.length;$(a%2===0,"Invalid hex string"),r>a/2&&(r=a/2);for(var s=0;r>s;s++){var u=parseInt(t.substr(2*s,2),16);$(!isNaN(u),"Invalid hex string"),e[n+s]=u}return i._charsWritten=2*s,s}function p(e,t,n,r){var o=i._charsWritten=Z(q(t),e,n,r);return o}function d(e,t,n,r){var o=i._charsWritten=Z(W(t),e,n,r);return o}function m(e,t,n,r){return d(e,t,n,r)}function h(e,t,n,r){var o=i._charsWritten=Z(G(t),e,n,r);return o}function g(e,t,n,r){var o=i._charsWritten=Z(Y(t),e,n,r);return o}function y(e,t,n){return 0===t&&n===e.length?J.fromByteArray(e):J.fromByteArray(e.slice(t,n))}function b(e,t,n){var r="",i="";n=Math.min(e.length,n);for(var o=t;n>o;o++)e[o]<=127?(r+=V(i)+String.fromCharCode(e[o]),i=""):i+="%"+e[o].toString(16);return r+V(i)}function v(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function S(e,t,n){return v(e,t,n)}function w(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=U(e[o]);return i}function E(e,t,n){for(var r=e.slice(t,n),i="",o=0;o=i)){var o;return n?(o=e[t],i>t+1&&(o|=e[t+1]<<8)):(o=e[t]<<8,i>t+1&&(o|=e[t+1])),o}}function _(e,t,n,r){r||($("boolean"==typeof n,"missing or invalid endian"),$(void 0!==t&&null!==t,"missing offset"),$(t+3=i)){var o;return n?(i>t+2&&(o=e[t+2]<<16),i>t+1&&(o|=e[t+1]<<8),o|=e[t],i>t+3&&(o+=e[t+3]<<24>>>0)):(i>t+1&&(o=e[t+1]<<16),i>t+2&&(o|=e[t+2]<<8),i>t+3&&(o|=e[t+3]),o+=e[t]<<24>>>0),o}}function C(e,t,n,r){r||($("boolean"==typeof n,"missing or invalid endian"),$(void 0!==t&&null!==t,"missing offset"),$(t+1=i)){var o=x(e,t,n,!0),a=32768&o;return a?-1*(65535-o+1):o}}function k(e,t,n,r){r||($("boolean"==typeof n,"missing or invalid endian"),$(void 0!==t&&null!==t,"missing offset"),$(t+3=i)){var o=_(e,t,n,!0),a=2147483648&o;return a?-1*(4294967295-o+1):o}}function A(e,t,n,r){return r||($("boolean"==typeof n,"missing or invalid endian"),$(t+3=o))for(var a=0,s=Math.min(o-n,2);s>a;a++)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function B(e,t,n,r,i){i||($(void 0!==t&&null!==t,"missing value"),$("boolean"==typeof r,"missing or invalid endian"),$(void 0!==n&&null!==n,"missing offset"),$(n+3=o))for(var a=0,s=Math.min(o-n,4);s>a;a++)e[n+a]=t>>>8*(r?a:3-a)&255}function R(e,t,n,r,i){i||($(void 0!==t&&null!==t,"missing value"),$("boolean"==typeof r,"missing or invalid endian"),$(void 0!==n&&null!==n,"missing offset"),$(n+1=o||(t>=0?L(e,t,n,r,i):L(e,65535+t+1,n,r,i))}function M(e,t,n,r,i){i||($(void 0!==t&&null!==t,"missing value"),$("boolean"==typeof r,"missing or invalid endian"),$(void 0!==n&&null!==n,"missing offset"),$(n+3=o||(t>=0?B(e,t,n,r,i):B(e,4294967295+t+1,n,r,i))}function P(e,t,n,r,i){i||($(void 0!==t&&null!==t,"missing value"),$("boolean"==typeof r,"missing or invalid endian"),$(void 0!==n&&null!==n,"missing offset"),$(n+3=o||X.write(e,t,n,r,23,4)}function O(e,t,n,r,i){i||($(void 0!==t&&null!==t,"missing value"),$("boolean"==typeof r,"missing or invalid endian"),$(void 0!==n&&null!==n,"missing offset"),$(n+7=o||X.write(e,t,n,r,52,8)} // HELPER FUNCTIONS // ================ -function M(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")} +function D(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")} // slice(start, end) -function R(e,t,n){// Coerce to integer. -return"number"!=typeof e?n:(e=~~e,e>=t?t:e>=0?e:(e+=t,e>=0?e:0))}function N(e){ +function N(e,t,n){// Coerce to integer. +return"number"!=typeof e?n:(e=~~e,e>=t?t:e>=0?e:(e+=t,e>=0?e:0))}function T(e){ // Coerce length to a number (possibly NaN), round up // in case it's fractional (e.g. 123.456) then do a // double negate to coerce a NaN to 0. Easy, right? -return e=~~Math.ceil(+e),0>e?0:e}function F(e){return(Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)})(e)}function U(e){return F(e)||o.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function j(e){return 16>e?"0"+e.toString(16):e.toString(16)}function q(e){for(var t=[],n=0;n=r)t.push(e.charCodeAt(n));else{var o=n;r>=55296&&57343>=r&&n++;for(var i=encodeURIComponent(e.slice(o,n+1)).substr(1).split("%"),a=0;ae?0:e}function F(e){return(Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)})(e)}function j(e){return F(e)||i.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function U(e){return 16>e?"0"+e.toString(16):e.toString(16)}function q(e){for(var t=[],n=0;n=r)t.push(e.charCodeAt(n));else{var i=n;r>=55296&&57343>=r&&n++;for(var o=encodeURIComponent(e.slice(i,n+1)).substr(1).split("%"),a=0;a>8,r=t%256,o.push(r),o.push(n);return o}function G(e){return J.toByteArray(e)}function Z(e,t,n,r){for(var o=0;r>o&&!(o+n>=t.length||o>=e.length);o++)t[o+n]=e[o];return o}function z(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}/* +t.push(255&e.charCodeAt(n));return t}function Y(e){for(var t,n,r,i=[],o=0;o>8,r=t%256,i.push(r),i.push(n);return i}function G(e){return J.toByteArray(e)}function Z(e,t,n,r){for(var i=0;r>i&&!(i+n>=t.length||i>=e.length);i++)t[i+n]=e[i];return i}function V(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}/* * We have to make sure that the value is a valid integer. This means that it * is non-negative. It has no fractional component and that it does not * exceed the maximum allowed value. */ -function V(e,t){$("number"==typeof e,"cannot write a non-number as a number"),$(e>=0,"specified a negative value for writing an unsigned value"),$(t>=e,"value is larger than maximum value for type"),$(Math.floor(e)===e,"value has a fractional component")}function H(e,t,n){$("number"==typeof e,"cannot write a non-number as a number"),$(t>=e,"value larger than maximum allowed value"),$(e>=n,"value smaller than minimum allowed value"),$(Math.floor(e)===e,"value has a fractional component")}function K(e,t,n){$("number"==typeof e,"cannot write a non-number as a number"),$(t>=e,"value larger than maximum allowed value"),$(e>=n,"value smaller than minimum allowed value")}function $(e,t){if(!e)throw new Error(t||"Failed assertion")}/*! +function z(e,t){$("number"==typeof e,"cannot write a non-number as a number"),$(e>=0,"specified a negative value for writing an unsigned value"),$(t>=e,"value is larger than maximum value for type"),$(Math.floor(e)===e,"value has a fractional component")}function K(e,t,n){$("number"==typeof e,"cannot write a non-number as a number"),$(t>=e,"value larger than maximum allowed value"),$(e>=n,"value smaller than minimum allowed value"),$(Math.floor(e)===e,"value has a fractional component")}function H(e,t,n){$("number"==typeof e,"cannot write a non-number as a number"),$(t>=e,"value larger than maximum allowed value"),$(e>=n,"value smaller than minimum allowed value")}function $(e,t){if(!e)throw new Error(t||"Failed assertion")}/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ -var J=e("base64-js"),X=e("ieee754");n.Buffer=o,n.SlowBuffer=o,n.INSPECT_MAX_BYTES=50,o.poolSize=8192,/** +var J=e("base64-js"),X=e("ieee754");n.Buffer=i,n.SlowBuffer=i,n.INSPECT_MAX_BYTES=50,i.poolSize=8192,/** * If `Buffer._useTypedArrays`: * === true Use Uint8Array implementation (fastest) * === false Use Object implementation (compatible down to IE6) */ -o._useTypedArrays=function(){ +i._useTypedArrays=function(){ // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+, // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support @@ -1508,57 +1360,53 @@ o._useTypedArrays=function(){ try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}catch(n){return!1}}(), // STATIC METHODS // ============== -o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.isBuffer=function(e){return!(null===e||void 0===e||!e._isBuffer)},o.byteLength=function(e,t){var n;switch(e+="",t||"utf8"){case"hex":n=e.length/2;break;case"utf8":case"utf-8":n=q(e).length;break;case"ascii":case"binary":case"raw":n=e.length;break;case"base64":n=G(e).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*e.length;break;default:throw new Error("Unknown encoding")}return n},o.concat=function(e,t){if($(F(e),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===e.length)return new o(0);if(1===e.length)return e[0];var n;if("number"!=typeof t)for(t=0,n=0;ni&&(n=i)):n=i,r=String(r||"utf8").toLowerCase();var a;switch(r){case"hex":a=f(this,e,t,n);break;case"utf8":case"utf-8":a=p(this,e,t,n);break;case"ascii":a=d(this,e,t,n);break;case"binary":a=m(this,e,t,n);break;case"base64":a=h(this,e,t,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":a=g(this,e,t,n);break;default:throw new Error("Unknown encoding")}return a},o.prototype.toString=function(e,t,n){var r=this; +var i=r;r=t,t=n,n=i}t=Number(t)||0;var o=this.length-t;n?(n=Number(n),n>o&&(n=o)):n=o,r=String(r||"utf8").toLowerCase();var a;switch(r){case"hex":a=f(this,e,t,n);break;case"utf8":case"utf-8":a=p(this,e,t,n);break;case"ascii":a=d(this,e,t,n);break;case"binary":a=m(this,e,t,n);break;case"base64":a=h(this,e,t,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":a=g(this,e,t,n);break;default:throw new Error("Unknown encoding")}return a},i.prototype.toString=function(e,t,n){var r=this; // Fastpath empty strings -if(e=String(e||"utf8").toLowerCase(),t=Number(t)||0,n=void 0!==n?Number(n):n=r.length,n===t)return"";var o;switch(e){case"hex":o=v(r,t,n);break;case"utf8":case"utf-8":o=w(r,t,n);break;case"ascii":o=b(r,t,n);break;case"binary":o=S(r,t,n);break;case"base64":o=y(r,t,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":o=E(r,t,n);break;default:throw new Error("Unknown encoding")}return o},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}}, +if(e=String(e||"utf8").toLowerCase(),t=Number(t)||0,n=void 0!==n?Number(n):n=r.length,n===t)return"";var i;switch(e){case"hex":i=w(r,t,n);break;case"utf8":case"utf-8":i=b(r,t,n);break;case"ascii":i=v(r,t,n);break;case"binary":i=S(r,t,n);break;case"base64":i=y(r,t,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=E(r,t,n);break;default:throw new Error("Unknown encoding")}return i},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}}, // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -o.prototype.copy=function(e,t,n,r){var i=this; +i.prototype.copy=function(e,t,n,r){var o=this; // Copy 0 bytes; we're done -if(n||(n=0),r||0===r||(r=this.length),t||(t=0),r!==n&&0!==e.length&&0!==i.length){ +if(n||(n=0),r||0===r||(r=this.length),t||(t=0),r!==n&&0!==e.length&&0!==o.length){ // Fatal error conditions -$(r>=n,"sourceEnd < sourceStart"),$(t>=0&&t=0&&n=0&&r<=i.length,"sourceEnd out of bounds"), +$(r>=n,"sourceEnd < sourceStart"),$(t>=0&&t=0&&n=0&&r<=o.length,"sourceEnd out of bounds"), // Are we oob? -r>this.length&&(r=this.length),e.length-ta||!o._useTypedArrays)for(var s=0;a>s;s++)e[s+t]=this[s+n];else e._set(this.subarray(n,n+a),t)}},o.prototype.slice=function(e,t){var n=this.length;if(e=R(e,n,0),t=R(t,n,n),o._useTypedArrays)return o._augment(this.subarray(e,t));for(var r=t-e,i=new o(r,void 0,!0),a=0;r>a;a++)i[a]=this[a+e];return i}, +r>this.length&&(r=this.length),e.length-ta||!i._useTypedArrays)for(var s=0;a>s;s++)e[s+t]=this[s+n];else e._set(this.subarray(n,n+a),t)}},i.prototype.slice=function(e,t){var n=this.length;if(e=N(e,n,0),t=N(t,n,n),i._useTypedArrays)return i._augment(this.subarray(e,t));for(var r=t-e,o=new i(r,void 0,!0),a=0;r>a;a++)o[a]=this[a+e];return o}, // `get` will be removed in Node 0.13+ -o.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)}, +i.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)}, // `set` will be removed in Node 0.13+ -o.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},o.prototype.readUInt8=function(e,t){return t||($(void 0!==e&&null!==e,"missing offset"),$(e=this.length?void 0:this[e]},o.prototype.readUInt16LE=function(e,t){return C(this,e,!0,t)},o.prototype.readUInt16BE=function(e,t){return C(this,e,!1,t)},o.prototype.readUInt32LE=function(e,t){return x(this,e,!0,t)},o.prototype.readUInt32BE=function(e,t){return x(this,e,!1,t)},o.prototype.readInt8=function(e,t){if(t||($(void 0!==e&&null!==e,"missing offset"),$(e=this.length)){var n=128&this[e];return n?-1*(255-this[e]+1):this[e]}},o.prototype.readInt16LE=function(e,t){return _(this,e,!0,t)},o.prototype.readInt16BE=function(e,t){return _(this,e,!1,t)},o.prototype.readInt32LE=function(e,t){return k(this,e,!0,t)},o.prototype.readInt32BE=function(e,t){return k(this,e,!1,t)},o.prototype.readFloatLE=function(e,t){return I(this,e,!0,t)},o.prototype.readFloatBE=function(e,t){return I(this,e,!1,t)},o.prototype.readDoubleLE=function(e,t){return A(this,e,!0,t)},o.prototype.readDoubleBE=function(e,t){return A(this,e,!1,t)},o.prototype.writeUInt8=function(e,t,n){n||($(void 0!==e&&null!==e,"missing value"),$(void 0!==t&&null!==t,"missing offset"),$(t=this.length||(this[t]=e)},o.prototype.writeUInt16LE=function(e,t,n){L(this,e,t,!0,n)},o.prototype.writeUInt16BE=function(e,t,n){L(this,e,t,!1,n)},o.prototype.writeUInt32LE=function(e,t,n){B(this,e,t,!0,n)},o.prototype.writeUInt32BE=function(e,t,n){B(this,e,t,!1,n)},o.prototype.writeInt8=function(e,t,n){n||($(void 0!==e&&null!==e,"missing value"),$(void 0!==t&&null!==t,"missing offset"),$(t=this.length||(e>=0?this.writeUInt8(e,t,n):this.writeUInt8(255+e+1,t,n))},o.prototype.writeInt16LE=function(e,t,n){D(this,e,t,!0,n)},o.prototype.writeInt16BE=function(e,t,n){D(this,e,t,!1,n)},o.prototype.writeInt32LE=function(e,t,n){O(this,e,t,!0,n)},o.prototype.writeInt32BE=function(e,t,n){O(this,e,t,!1,n)},o.prototype.writeFloatLE=function(e,t,n){T(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){T(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){P(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){P(this,e,t,!1,n)}, +i.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},i.prototype.readUInt8=function(e,t){return t||($(void 0!==e&&null!==e,"missing offset"),$(e=this.length?void 0:this[e]},i.prototype.readUInt16LE=function(e,t){return x(this,e,!0,t)},i.prototype.readUInt16BE=function(e,t){return x(this,e,!1,t)},i.prototype.readUInt32LE=function(e,t){return _(this,e,!0,t)},i.prototype.readUInt32BE=function(e,t){return _(this,e,!1,t)},i.prototype.readInt8=function(e,t){if(t||($(void 0!==e&&null!==e,"missing offset"),$(e=this.length)){var n=128&this[e];return n?-1*(255-this[e]+1):this[e]}},i.prototype.readInt16LE=function(e,t){return C(this,e,!0,t)},i.prototype.readInt16BE=function(e,t){return C(this,e,!1,t)},i.prototype.readInt32LE=function(e,t){return k(this,e,!0,t)},i.prototype.readInt32BE=function(e,t){return k(this,e,!1,t)},i.prototype.readFloatLE=function(e,t){return A(this,e,!0,t)},i.prototype.readFloatBE=function(e,t){return A(this,e,!1,t)},i.prototype.readDoubleLE=function(e,t){return I(this,e,!0,t)},i.prototype.readDoubleBE=function(e,t){return I(this,e,!1,t)},i.prototype.writeUInt8=function(e,t,n){n||($(void 0!==e&&null!==e,"missing value"),$(void 0!==t&&null!==t,"missing offset"),$(t=this.length||(this[t]=e)},i.prototype.writeUInt16LE=function(e,t,n){L(this,e,t,!0,n)},i.prototype.writeUInt16BE=function(e,t,n){L(this,e,t,!1,n)},i.prototype.writeUInt32LE=function(e,t,n){B(this,e,t,!0,n)},i.prototype.writeUInt32BE=function(e,t,n){B(this,e,t,!1,n)},i.prototype.writeInt8=function(e,t,n){n||($(void 0!==e&&null!==e,"missing value"),$(void 0!==t&&null!==t,"missing offset"),$(t=this.length||(e>=0?this.writeUInt8(e,t,n):this.writeUInt8(255+e+1,t,n))},i.prototype.writeInt16LE=function(e,t,n){R(this,e,t,!0,n)},i.prototype.writeInt16BE=function(e,t,n){R(this,e,t,!1,n)},i.prototype.writeInt32LE=function(e,t,n){M(this,e,t,!0,n)},i.prototype.writeInt32BE=function(e,t,n){M(this,e,t,!1,n)},i.prototype.writeFloatLE=function(e,t,n){P(this,e,t,!0,n)},i.prototype.writeFloatBE=function(e,t,n){P(this,e,t,!1,n)},i.prototype.writeDoubleLE=function(e,t,n){O(this,e,t,!0,n)},i.prototype.writeDoubleBE=function(e,t,n){O(this,e,t,!1,n)}, // fill(value, start=0, end=buffer.length) -o.prototype.fill=function(e,t,n){ +i.prototype.fill=function(e,t,n){ // Fill 0 bytes; we're done -if(e||(e=0),t||(t=0),n||(n=this.length),"string"==typeof e&&(e=e.charCodeAt(0)),$("number"==typeof e&&!isNaN(e),"value is not a number"),$(n>=t,"end < start"),n!==t&&0!==this.length){$(t>=0&&t=0&&n<=this.length,"end out of bounds");for(var r=t;n>r;r++)this[r]=e}},o.prototype.inspect=function(){for(var e=[],t=this.length,r=0;t>r;r++)if(e[r]=j(this[r]),r===n.INSPECT_MAX_BYTES){e[r+1]="...";break}return""},/** +if(e||(e=0),t||(t=0),n||(n=this.length),"string"==typeof e&&(e=e.charCodeAt(0)),$("number"==typeof e&&!isNaN(e),"value is not a number"),$(n>=t,"end < start"),n!==t&&0!==this.length){$(t>=0&&t=0&&n<=this.length,"end out of bounds");for(var r=t;n>r;r++)this[r]=e}},i.prototype.inspect=function(){for(var e=[],t=this.length,r=0;t>r;r++)if(e[r]=U(this[r]),r===n.INSPECT_MAX_BYTES){e[r+1]="...";break}return""},/** * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. * Added in Node 0.12. Only available in browsers that support ArrayBuffer. */ -o.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(o._useTypedArrays)return new o(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;n>t;t+=1)e[t]=this[t];return e.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var Q=o.prototype;/** +i.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(i._useTypedArrays)return new i(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;n>t;t+=1)e[t]=this[t];return e.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var Q=i.prototype;/** * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods */ -o._augment=function(e){ +i._augment=function(e){ // save reference to original Uint8Array get/set methods before overwriting // deprecated, will be removed in node 0.13+ -return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=Q.get,e.set=Q.set,e.write=Q.write,e.toString=Q.toString,e.toLocaleString=Q.toString,e.toJSON=Q.toJSON,e.copy=Q.copy,e.slice=Q.slice,e.readUInt8=Q.readUInt8,e.readUInt16LE=Q.readUInt16LE,e.readUInt16BE=Q.readUInt16BE,e.readUInt32LE=Q.readUInt32LE,e.readUInt32BE=Q.readUInt32BE,e.readInt8=Q.readInt8,e.readInt16LE=Q.readInt16LE,e.readInt16BE=Q.readInt16BE,e.readInt32LE=Q.readInt32LE,e.readInt32BE=Q.readInt32BE,e.readFloatLE=Q.readFloatLE,e.readFloatBE=Q.readFloatBE,e.readDoubleLE=Q.readDoubleLE,e.readDoubleBE=Q.readDoubleBE,e.writeUInt8=Q.writeUInt8,e.writeUInt16LE=Q.writeUInt16LE,e.writeUInt16BE=Q.writeUInt16BE,e.writeUInt32LE=Q.writeUInt32LE,e.writeUInt32BE=Q.writeUInt32BE,e.writeInt8=Q.writeInt8,e.writeInt16LE=Q.writeInt16LE,e.writeInt16BE=Q.writeInt16BE,e.writeInt32LE=Q.writeInt32LE,e.writeInt32BE=Q.writeInt32BE,e.writeFloatLE=Q.writeFloatLE,e.writeFloatBE=Q.writeFloatBE,e.writeDoubleLE=Q.writeDoubleLE,e.writeDoubleBE=Q.writeDoubleBE,e.fill=Q.fill,e.inspect=Q.inspect,e.toArrayBuffer=Q.toArrayBuffer,e}}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/index.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer")},{"1YiZ5S":24,"base64-js":21,buffer:20,ieee754:22}],21:[function(e,t,n){(function(e,t,r,o,i,a,s,l,u){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);// '+' +return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=Q.get,e.set=Q.set,e.write=Q.write,e.toString=Q.toString,e.toLocaleString=Q.toString,e.toJSON=Q.toJSON,e.copy=Q.copy,e.slice=Q.slice,e.readUInt8=Q.readUInt8,e.readUInt16LE=Q.readUInt16LE,e.readUInt16BE=Q.readUInt16BE,e.readUInt32LE=Q.readUInt32LE,e.readUInt32BE=Q.readUInt32BE,e.readInt8=Q.readInt8,e.readInt16LE=Q.readInt16LE,e.readInt16BE=Q.readInt16BE,e.readInt32LE=Q.readInt32LE,e.readInt32BE=Q.readInt32BE,e.readFloatLE=Q.readFloatLE,e.readFloatBE=Q.readFloatBE,e.readDoubleLE=Q.readDoubleLE,e.readDoubleBE=Q.readDoubleBE,e.writeUInt8=Q.writeUInt8,e.writeUInt16LE=Q.writeUInt16LE,e.writeUInt16BE=Q.writeUInt16BE,e.writeUInt32LE=Q.writeUInt32LE,e.writeUInt32BE=Q.writeUInt32BE,e.writeInt8=Q.writeInt8,e.writeInt16LE=Q.writeInt16LE,e.writeInt16BE=Q.writeInt16BE,e.writeInt32LE=Q.writeInt32LE,e.writeInt32BE=Q.writeInt32BE,e.writeFloatLE=Q.writeFloatLE,e.writeFloatBE=Q.writeFloatBE,e.writeDoubleLE=Q.writeDoubleLE,e.writeDoubleBE=Q.writeDoubleBE,e.fill=Q.fill,e.inspect=Q.inspect,e.toArrayBuffer=Q.toArrayBuffer,e}}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/index.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer")},{"1YiZ5S":25,"base64-js":22,buffer:21,ieee754:23}],22:[function(e,t,n){(function(e,t,r,i,o,a,s,u,l){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);// '+' // '/' //no match -return t===i?62:t===a?63:s>t?-1:s+10>t?t-s+26+26:u+26>t?t-u:l+26>t?t-l+26:void 0}function n(e){function n(e){u[f++]=e}var r,i,a,s,l,u;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4"); +return t===o||t===f?62:t===a||t===p?63:s>t?-1:s+10>t?t-s+26+26:l+26>t?t-l:u+26>t?t-u+26:void 0}function n(e){function n(e){l[f++]=e}var r,o,a,s,u,l;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4"); // the number of equal signs (place holders) // if there are two placeholders, than the two characters before it // represent one byte // if there is only one, then the three characters before it represent 2 bytes // this is just a cheap hack to not do indexOf twice -var c=e.length;l="="===e.charAt(c-2)?2:"="===e.charAt(c-1)?1:0, -// base64 is 4/3 + up to two characters of the original data -u=new o(3*e.length/4-l), -// if there are placeholders, only get up to the last complete 4 chars -a=l>0?e.length-4:e.length;var f=0;for(r=0,i=0;a>r;r+=4,i+=3)s=t(e.charAt(r))<<18|t(e.charAt(r+1))<<12|t(e.charAt(r+2))<<6|t(e.charAt(r+3)),n((16711680&s)>>16),n((65280&s)>>8),n(255&s);return 2===l?(s=t(e.charAt(r))<<2|t(e.charAt(r+1))>>4,n(255&s)):1===l&&(s=t(e.charAt(r))<<10|t(e.charAt(r+1))<<4|t(e.charAt(r+2))>>2,n(s>>8&255),n(255&s)),u}function r(e){function t(e){return c.charAt(e)}function n(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var r,o,i,a=e.length%3,// if we have 1 byte left, pad 2 bytes +var c=e.length;u="="===e.charAt(c-2)?2:"="===e.charAt(c-1)?1:0,l=new i(3*e.length/4-u),a=u>0?e.length-4:e.length;var f=0;for(r=0,o=0;a>r;r+=4,o+=3)s=t(e.charAt(r))<<18|t(e.charAt(r+1))<<12|t(e.charAt(r+2))<<6|t(e.charAt(r+3)),n((16711680&s)>>16),n((65280&s)>>8),n(255&s);return 2===u?(s=t(e.charAt(r))<<2|t(e.charAt(r+1))>>4,n(255&s)):1===u&&(s=t(e.charAt(r))<<10|t(e.charAt(r+1))<<4|t(e.charAt(r+2))>>2,n(s>>8&255),n(255&s)),l}function r(e){function t(e){return c.charAt(e)}function n(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var r,i,o,a=e.length%3,// if we have 1 byte left, pad 2 bytes s=""; // go through the array every three bytes, we'll deal with trailing stuff later -for(r=0,i=e.length-a;i>r;r+=3)o=(e[r]<<16)+(e[r+1]<<8)+e[r+2],s+=n(o); +for(r=0,o=e.length-a;o>r;r+=3)i=(e[r]<<16)+(e[r+1]<<8)+e[r+2],s+=n(i); // pad the end with zeros, but make sure to not forget the extra bytes -switch(a){case 1:o=e[e.length-1],s+=t(o>>2),s+=t(o<<4&63),s+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1],s+=t(o>>10),s+=t(o>>4&63),s+=t(o<<2&63),s+="="}return s}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="+".charCodeAt(0),a="/".charCodeAt(0),s="0".charCodeAt(0),l="a".charCodeAt(0),u="A".charCodeAt(0);e.toByteArray=n,e.fromByteArray=r}("undefined"==typeof n?this.base64js={}:n)}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib/b64.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib")},{"1YiZ5S":24,buffer:20}],22:[function(e,t,n){(function(e,t,r,o,i,a,s,l,u){n.read=function(e,t,n,r,o){var i,a,s=8*o-r-1,l=(1<>1,c=-7,f=n?o-1:0,p=n?-1:1,d=e[t+f];for(f+=p,i=d&(1<<-c)-1,d>>=-c,c+=s;c>0;i=256*i+e[t+f],f+=p,c-=8);for(a=i&(1<<-c)-1,i>>=-c,c+=r;c>0;a=256*a+e[t+f],f+=p,c-=8);if(0===i)i=1-u;else{if(i===l)return a?0/0:(d?-1:1)*(1/0);a+=Math.pow(2,r),i-=u}return(d?-1:1)*a*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var a,s,l,u=8*i-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,m=r?1:-1,h=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),t+=a+f>=1?p/l:p*Math.pow(2,1-f),t*l>=2&&(a++,l/=2),a+f>=c?(s=0,a=c):a+f>=1?(s=(t*l-1)*Math.pow(2,o),a+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,o),a=0));o>=8;e[n+d]=255&s,d+=m,s/=256,o-=8);for(a=a<0;e[n+d]=255&a,d+=m,a/=256,u-=8);e[n+d-m]|=128*h}}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754/index.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754")},{"1YiZ5S":24,buffer:20}],23:[function(e,t,n){(function(e,t,r,o,i,a,s,l,u){ +switch(a){case 1:i=e[e.length-1],s+=t(i>>2),s+=t(i<<4&63),s+="==";break;case 2:i=(e[e.length-2]<<8)+e[e.length-1],s+=t(i>>10),s+=t(i>>4&63),s+=t(i<<2&63),s+="="}return s}var i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="+".charCodeAt(0),a="/".charCodeAt(0),s="0".charCodeAt(0),u="a".charCodeAt(0),l="A".charCodeAt(0),f="-".charCodeAt(0),p="_".charCodeAt(0);e.toByteArray=n,e.fromByteArray=r}("undefined"==typeof n?this.base64js={}:n)}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib/b64.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib")},{"1YiZ5S":25,buffer:21}],23:[function(e,t,n){(function(e,t,r,i,o,a,s,u,l){n.read=function(e,t,n,r,i){var o,a,s=8*i-r-1,u=(1<>1,c=-7,f=n?i-1:0,p=n?-1:1,d=e[t+f];for(f+=p,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+e[t+f],f+=p,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+e[t+f],f+=p,c-=8);if(0===o)o=1-l;else{if(o===u)return a?NaN:(d?-1:1)*(1/0);a+=Math.pow(2,r),o-=l}return(d?-1:1)*a*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var a,s,u,l=8*o-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,m=r?1:-1,h=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),t+=a+f>=1?p/u:p*Math.pow(2,1-f),t*u>=2&&(a++,u/=2),a+f>=c?(s=0,a=c):a+f>=1?(s=(t*u-1)*Math.pow(2,i),a+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;e[n+d]=255&s,d+=m,s/=256,i-=8);for(a=a<0;e[n+d]=255&a,d+=m,a/=256,l-=8);e[n+d-m]|=128*h}}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754/index.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754")},{"1YiZ5S":25,buffer:21}],24:[function(e,t,n){(function(e,t,r,i,o,a,s,u,l){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -1583,7 +1431,7 @@ switch(a){case 1:o=e[e.length-1],s+=t(o>>2),s+=t(o<<4&63),s+="==";break;case 2:o // must be no slashes, empty elements, or device names (c:\) in the array // (so also no leading and trailing slashes - it does not distinguish // relative and absolute paths) -function c(e,t){for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)} +function c(e,t){for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];"."===i?e.splice(r,1):".."===i?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)} // if the path is allowed to go above the root, restore leading ..s if(t)for(;n--;n)e.unshift("..");return e}function f(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r=-1&&!n;r--){var o=r>=0?arguments[r]:e.cwd(); +n.resolve=function(){for(var t="",n=!1,r=arguments.length-1;r>=-1&&!n;r--){var i=r>=0?arguments[r]:e.cwd(); // Skip empty and invalid entries -if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(t=o+"/"+t,n="/"===o.charAt(0))} +if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");i&&(t=i+"/"+t,n="/"===i.charAt(0))} // At this point the path should be resolved to a full absolute path, but // handle relative paths to be safe (might happen when process.cwd() fails) // Normalize the path @@ -1609,14 +1457,14 @@ n.isAbsolute=function(e){return"/"===e.charAt(0)}, n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(f(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))}, // path.relative(from, to) // posix version -n.relative=function(e,t){function r(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var o=r(e.split("/")),i=r(t.split("/")),a=Math.min(o.length,i.length),s=a,l=0;a>l;l++)if(o[l]!==i[l]){s=l;break}for(var u=[],l=s;l=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),a=Math.min(i.length,o.length),s=a,u=0;a>u;u++)if(i[u]!==o[u]){s=u;break}for(var l=[],u=s;ut&&(t=e.length+t),e.substr(t,n)}}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/path-browserify/index.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/path-browserify")},{"1YiZ5S":24,buffer:20}],24:[function(e,t,n){(function(e,n,r,o,i,a,s,l,u){function c(){} +var m="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return 0>t&&(t=e.length+t),e.substr(t,n)}}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/path-browserify/index.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/path-browserify")},{"1YiZ5S":25,buffer:21}],25:[function(e,t,n){(function(e,n,r,i,o,a,s,u,l){function c(){} // shim for using process in browser var e=t.exports={};e.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),e.title="browser",e.browser=!0,e.env={},e.argv=[],e.on=c,e.addListener=c,e.once=c,e.off=c,e.removeListener=c,e.removeAllListeners=c,e.emit=c,e.binding=function(e){throw new Error("process.binding is not supported")}, // TODO(shtylman) -e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")}}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/process/browser.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/process")},{"1YiZ5S":24,buffer:20}]},{},[1]); \ No newline at end of file +e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")}}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/gulp-browserify/node_modules/browserify/node_modules/process/browser.js","/../node_modules/gulp-browserify/node_modules/browserify/node_modules/process")},{"1YiZ5S":25,buffer:21}]},{},[1]); \ No newline at end of file diff --git a/lib/overload.js b/lib/overload.js index 50192dd..e72a888 100644 --- a/lib/overload.js +++ b/lib/overload.js @@ -2,6 +2,7 @@ var esprima = require('esprima'); var escodegen = require('escodegen'); +var estraverse = require('estraverse'); var funcNames = { '+': '__plus', @@ -47,129 +48,68 @@ var funcNames = { }; //The AST Walker And Transformer -function visit(statement, index, program) { - switch (statement.type) { - case 'VariableDeclaration': - statement.declarations.forEach(function (declaration, idx) { - visit(declaration.init, idx, program); - }); - break; - case 'BinaryExpression': - case 'LogicalExpression': - if (statement.operator && funcNames[statement.operator]) { - statement.type = 'CallExpression'; - statement.callee = { - 'type': 'MemberExpression', - 'computed': false, - 'object': statement.right, - 'property': { - 'type': 'Identifier', - 'name': funcNames[statement.operator] +var visitor = { + enter: function(node, parent) { + switch(node.type) { + case 'BinaryExpression': + case 'LogicalExpression': + if (node.operator && funcNames[node.operator]) { + return { + type: 'CallExpression', + callee: { + 'type': 'MemberExpression', + 'computed': false, + 'object': node.right, + 'property': { + 'type': 'Identifier', + 'name': funcNames[node.operator] + } + }, + arguments: [node.left] + }; + } + break; + case 'AssignmentExpression': + if (node.operator && funcNames[node.operator]) { + return { + type: 'AssignmentExpression', + left: node.left, + right: { + type: 'CallExpression', + callee: { + 'type': 'MemberExpression', + 'computed': false, + 'object': node.left, + 'property': { + 'type': 'Identifier', + 'name': funcNames[node.operator] + } + }, + arguments: [node.right] + }, + operator: '=' } - }; - visit(statement.left, index, program); - visit(statement.right, index, program); - statement['arguments'] = [statement.left]; - } else { - visit(statement.left, index, program); - visit(statement.right, index, program); - } - break; - case 'ExpressionStatement': - visit(statement.expression, index, program); - break; - case 'CallExpression': - statement['arguments'].forEach(function (argument, idx) { - visit(argument, idx, program); - }); - visit(statement.callee, index, program); - break; - case 'AssignmentExpression': - if (statement.operator && funcNames[statement.operator]) { - statement.right = { - type: 'CallExpression', - callee: { - 'type': 'MemberExpression', - 'computed': false, - 'object': statement.left, - 'property': { - 'type': 'Identifier', - 'name': funcNames[statement.operator] - } - }, - arguments: [statement.right] - }; - statement.operator = '='; - - visit(statement.left, index, program); - visit(statement.right.arguments[0], index, program); - } else { - visit(statement.right, index, program); - } - break; - case 'UnaryExpression': - if (statement.operator && funcNames[statement.operator]) { - statement.type = 'CallExpression'; - statement.callee = { - 'type': 'MemberExpression', - 'computed': false, - 'object': statement.argument, - 'property': { - 'type': 'Identifier', - 'name': (statement.operator === '+' || statement.operator === '-') ? funcNames['u' + statement.operator] : funcNames[statement.operator] - } - }; - visit(statement.argument, index, program); - statement['arguments'] = []; - } else { - visit(statement.argument, index, program); - } - break; - case 'UpdateExpression': - if (statement.operator && funcNames[statement.operator]) { - statement.type = 'CallExpression'; - statement.callee = { - 'type': 'MemberExpression', - 'computed': false, - 'object': statement.argument, - 'property': { - 'type': 'Identifier', - 'name': funcNames[statement.operator] - } - }; - visit(statement.argument, index, program); - statement['arguments'] = []; - } - break; - case 'FunctionDeclaration': - case 'FunctionExpression': - visit(statement.body, index, program); - break; - case 'BlockStatement': - statement.body.forEach(function (statement) { - visit(statement, index, program); - }); - break; - case 'ReturnStatement': - visit(statement.argument, index, program); - break; - case 'MemberExpression': - visit(statement.object, index, program); - break; - case 'SwitchStatement': - statement.cases.forEach(function(_case, idx){ - visit(_case, idx, program); - }); - break; - case 'SwitchCase': - statement.consequent.forEach(function(con, idx){ - visit(con, idx, program); - }); - break; - //We don't ned to transform following nodes! Phew! - case 'Literal': - case 'Identifier': - break; + } + break; + case 'UnaryExpression': + case 'UpdateExpression': + if (node.operator && funcNames[node.operator]) { + return { + type: 'CallExpression', + callee: { + 'type': 'MemberExpression', + 'computed': false, + 'object': node.argument, + 'property': { + 'type': 'Identifier', + 'name': (node.operator === '+' || node.operator === '-') ? funcNames['u' + node.operator] : funcNames[node.operator] + } + }, + arguments: [] + }; + } + break; + } } } @@ -197,9 +137,7 @@ module.exports = exports = function (func) { }; //Transform - program.body.forEach(function (statement, index) { - visit(statement, index, program); - }); + estraverse.replace(program, visitor) //Build new function args args.push(escodegen.generate(program, {