This is an automated email from the ASF dual-hosted git repository. davisp pushed a commit to branch gh-pages in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git
commit c6dc33c3c95b5bc149b130f4cab3c4df9c6cd143 Author: Constellation <[email protected]> AuthorDate: Wed Jan 23 10:13:12 2013 +0900 Update browser escodegen.js --- demo/index.html | 2 +- escodegen.js => escodegen.browser.js | 900 +++++++++++++++++++++++++++++++---- 2 files changed, 819 insertions(+), 83 deletions(-) diff --git a/demo/index.html b/demo/index.html index e25c485..134c497 100644 --- a/demo/index.html +++ b/demo/index.html @@ -5,7 +5,7 @@ <title>JS code generator demo: JS → AST → JS</title> <link rel="stylesheet" href="../assets/style.css" type="text/css" /> <script src='../assets/esprima.js'></script> - <script src='../escodegen.js'></script> + <script src='../escodegen.browser.js'></script> <script type="text/javascript"> function $D(elm) { var range = document.createRange(); diff --git a/escodegen.js b/escodegen.browser.js similarity index 76% rename from escodegen.js rename to escodegen.browser.js index 5d8400e..2961fd5 100644 --- a/escodegen.js +++ b/escodegen.browser.js @@ -1,4 +1,442 @@ -/* +// Generated by browserify +(function(){var require = function (file, cwd) { + var resolved = require.resolve(file, cwd || '/'); + var mod = require.modules[resolved]; + if (!mod) throw new Error( + 'Failed to resolve module ' + file + ', tried ' + resolved + ); + var cached = require.cache[resolved]; + var res = cached? cached.exports : mod(); + return res; +}; + +require.paths = []; +require.modules = {}; +require.cache = {}; +require.extensions = [".js",".coffee",".json"]; + +require._core = { + 'assert': true, + 'events': true, + 'fs': true, + 'path': true, + 'vm': true +}; + +require.resolve = (function () { + return function (x, cwd) { + if (!cwd) cwd = '/'; + + if (require._core[x]) return x; + var path = require.modules.path(); + cwd = path.resolve('/', cwd); + var y = cwd || '/'; + + if (x.match(/^(?:\.\.?\/|\/)/)) { + var m = loadAsFileSync(path.resolve(y, x)) + || loadAsDirectorySync(path.resolve(y, x)); + if (m) return m; + } + + var n = loadNodeModulesSync(x, y); + if (n) return n; + + throw new Error("Cannot find module '" + x + "'"); + + function loadAsFileSync (x) { + x = path.normalize(x); + if (require.modules[x]) { + return x; + } + + for (var i = 0; i < require.extensions.length; i++) { + var ext = require.extensions[i]; + if (require.modules[x + ext]) return x + ext; + } + } + + function loadAsDirectorySync (x) { + x = x.replace(/\/+$/, ''); + var pkgfile = path.normalize(x + '/package.json'); + if (require.modules[pkgfile]) { + var pkg = require.modules[pkgfile](); + var b = pkg.browserify; + if (typeof b === 'object' && b.main) { + var m = loadAsFileSync(path.resolve(x, b.main)); + if (m) return m; + } + else if (typeof b === 'string') { + var m = loadAsFileSync(path.resolve(x, b)); + if (m) return m; + } + else if (pkg.main) { + var m = loadAsFileSync(path.resolve(x, pkg.main)); + if (m) return m; + } + } + + return loadAsFileSync(x + '/index'); + } + + function loadNodeModulesSync (x, start) { + var dirs = nodeModulesPathsSync(start); + for (var i = 0; i < dirs.length; i++) { + var dir = dirs[i]; + var m = loadAsFileSync(dir + '/' + x); + if (m) return m; + var n = loadAsDirectorySync(dir + '/' + x); + if (n) return n; + } + + var m = loadAsFileSync(x); + if (m) return m; + } + + function nodeModulesPathsSync (start) { + var parts; + if (start === '/') parts = [ '' ]; + else parts = path.normalize(start).split('/'); + + var dirs = []; + for (var i = parts.length - 1; i >= 0; i--) { + if (parts[i] === 'node_modules') continue; + var dir = parts.slice(0, i + 1).join('/') + '/node_modules'; + dirs.push(dir); + } + + return dirs; + } + }; +})(); + +require.alias = function (from, to) { + var path = require.modules.path(); + var res = null; + try { + res = require.resolve(from + '/package.json', '/'); + } + catch (err) { + res = require.resolve(from, '/'); + } + var basedir = path.dirname(res); + + var keys = (Object.keys || function (obj) { + var res = []; + for (var key in obj) res.push(key); + return res; + })(require.modules); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if (key.slice(0, basedir.length + 1) === basedir + '/') { + var f = key.slice(basedir.length); + require.modules[to + f] = require.modules[basedir + f]; + } + else if (key === basedir) { + require.modules[to] = require.modules[basedir]; + } + } +}; + +(function () { + var process = {}; + var global = typeof window !== 'undefined' ? window : {}; + var definedProcess = false; + + require.define = function (filename, fn) { + if (!definedProcess && require.modules.__browserify_process) { + process = require.modules.__browserify_process(); + definedProcess = true; + } + + var dirname = require._core[filename] + ? '' + : require.modules.path().dirname(filename) + ; + + var require_ = function (file) { + var requiredModule = require(file, dirname); + var cached = require.cache[require.resolve(file, dirname)]; + + if (cached && cached.parent === null) { + cached.parent = module_; + } + + return requiredModule; + }; + require_.resolve = function (name) { + return require.resolve(name, dirname); + }; + require_.modules = require.modules; + require_.define = require.define; + require_.cache = require.cache; + var module_ = { + id : filename, + filename: filename, + exports : {}, + loaded : false, + parent: null + }; + + require.modules[filename] = function () { + require.cache[filename] = module_; + fn.call( + module_.exports, + require_, + module_, + module_.exports, + dirname, + filename, + process, + global + ); + module_.loaded = true; + return module_.exports; + }; + }; +})(); + + +require.define("path",function(require,module,exports,__dirname,__filename,process,global){function filter (xs, fn) { + var res = []; + for (var i = 0; i < xs.length; i++) { + if (fn(xs[i], i, xs)) res.push(xs[i]); + } + return res; +} + +// resolves . and .. elements in a path array with directory names there +// 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 normalizeArray(parts, allowAboveRoot) { + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = parts.length; i >= 0; i--) { + var last = parts[i]; + if (last == '.') { + parts.splice(i, 1); + } else if (last === '..') { + parts.splice(i, 1); + up++; + } else if (up) { + parts.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (allowAboveRoot) { + for (; up--; up) { + parts.unshift('..'); + } + } + + return parts; +} + +// Regex to split a filename into [*, dir, basename, ext] +// posix version +var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/; + +// path.resolve([from ...], to) +// posix version +exports.resolve = function() { +var resolvedPath = '', + resolvedAbsolute = false; + +for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) { + var path = (i >= 0) + ? arguments[i] + : process.cwd(); + + // Skip empty and invalid entries + if (typeof path !== 'string' || !path) { + continue; + } + + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path.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 +resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { + return !!p; + }), !resolvedAbsolute).join('/'); + + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; +}; + +// path.normalize(path) +// posix version +exports.normalize = function(path) { +var isAbsolute = path.charAt(0) === '/', + trailingSlash = path.slice(-1) === '/'; + +// Normalize the path +path = normalizeArray(filter(path.split('/'), function(p) { + return !!p; + }), !isAbsolute).join('/'); + + if (!path && !isAbsolute) { + path = '.'; + } + if (path && trailingSlash) { + path += '/'; + } + + return (isAbsolute ? '/' : '') + path; +}; + + +// posix version +exports.join = function() { + var paths = Array.prototype.slice.call(arguments, 0); + return exports.normalize(filter(paths, function(p, index) { + return p && typeof p === 'string'; + }).join('/')); +}; + + +exports.dirname = function(path) { + var dir = splitPathRe.exec(path)[1] || ''; + var isWindows = false; + if (!dir) { + // No dirname + return '.'; + } else if (dir.length === 1 || + (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) { + // It is just a slash or a drive letter with a slash + return dir; + } else { + // It is a full dirname, strip trailing slash + return dir.substring(0, dir.length - 1); + } +}; + + +exports.basename = function(path, ext) { + var f = splitPathRe.exec(path)[2] || ''; + // TODO: make this comparison case-insensitive on windows? + if (ext && f.substr(-1 * ext.length) === ext) { + f = f.substr(0, f.length - ext.length); + } + return f; +}; + + +exports.extname = function(path) { + return splitPathRe.exec(path)[3] || ''; +}; + +exports.relative = function(from, to) { + from = exports.resolve(from).substr(1); + to = exports.resolve(to).substr(1); + + function trim(arr) { + var start = 0; + for (; start < arr.length; start++) { + if (arr[start] !== '') break; + } + + var end = arr.length - 1; + for (; end >= 0; end--) { + if (arr[end] !== '') break; + } + + if (start > end) return []; + return arr.slice(start, end - start + 1); + } + + var fromParts = trim(from.split('/')); + var toParts = trim(to.split('/')); + + var length = Math.min(fromParts.length, toParts.length); + var samePartsLength = length; + for (var i = 0; i < length; i++) { + if (fromParts[i] !== toParts[i]) { + samePartsLength = i; + break; + } + } + + var outputParts = []; + for (var i = samePartsLength; i < fromParts.length; i++) { + outputParts.push('..'); + } + + outputParts = outputParts.concat(toParts.slice(samePartsLength)); + + return outputParts.join('/'); +}; + +}); + +require.define("__browserify_process",function(require,module,exports,__dirname,__filename,process,global){var process = module.exports = {}; + +process.nextTick = (function () { + var canSetImmediate = typeof window !== 'undefined' + && window.setImmediate; + var canPost = typeof window !== 'undefined' + && window.postMessage && window.addEventListener + ; + + if (canSetImmediate) { + return function (f) { return window.setImmediate(f) }; + } + + if (canPost) { + var queue = []; + window.addEventListener('message', function (ev) { + if (ev.source === window && ev.data === 'browserify-tick') { + ev.stopPropagation(); + if (queue.length > 0) { + var fn = queue.shift(); + fn(); + } + } + }, true); + + return function nextTick(fn) { + queue.push(fn); + window.postMessage('browserify-tick', '*'); + }; + } + + return function nextTick(fn) { + setTimeout(fn, 0); + }; +})(); + +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; + +process.binding = function (name) { + if (name === 'evals') return (require)('vm') + else throw new Error('No such module. (Possibly not yet loaded)') +}; + +(function () { + var cwd = '/'; + var path; + process.cwd = function () { return cwd }; + process.chdir = function (dir) { + if (!path) path = require('path'); + cwd = path.resolve(dir, cwd); + }; +})(); + +}); + +require.define("/package.json",function(require,module,exports,__dirname,__filename,process,global){module.exports = {"main":"escodegen.js"} +}); + +require.define("/escodegen.js",function(require,module,exports,__dirname,__filename,process,global){/* Copyright (C) 2012 Michael Ficarra <[email protected]> Copyright (C) 2012 Robert Gust-Bardon <[email protected]> Copyright (C) 2012 John Freeman <[email protected]> @@ -32,22 +470,7 @@ /*jslint bitwise:true */ /*global escodegen:true, exports:true, generateStatement:true, generateExpression:true, generateFunctionBody:true, process:true, require:true, define:true*/ - -(function (factory, global) { - 'use strict'; - - // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, - // and plain browser loading, - if (typeof define === 'function' && define.amd) { - define(['exports'], function (exports) { - factory(exports, global); - }); - } else if (typeof exports !== 'undefined') { - factory(exports, global); - } else { - factory((global.escodegen = {}), global); - } -}(function (exports, global) { +(function () { 'use strict'; var Syntax, @@ -73,7 +496,10 @@ directive, extra, parse, - sourceMap; + sourceMap, + traverse; + + traverse = require('estraverse').traverse; Syntax = { AssignmentExpression: 'AssignmentExpression', @@ -207,6 +633,7 @@ parenthesizedComprehensionBlock: false }, sourceMap: null, + sourceMapRoot: null, sourceMapWithCode: false, directive: false, verbatim: null @@ -806,17 +1233,18 @@ } function generateExpression(expr, option) { - var result, precedence, currentPrecedence, i, len, raw, fragment, multiline, leftChar, leftSource, rightChar, rightSource, allowIn, allowCall, allowUnparenthesizedNew, property, key, value; + var result, precedence, type, currentPrecedence, i, len, raw, fragment, multiline, leftChar, leftSource, rightChar, rightSource, allowIn, allowCall, allowUnparenthesizedNew, property, key, value; precedence = option.precedence; allowIn = option.allowIn; allowCall = option.allowCall; + type = expr.type || option.type; if (extra.verbatim && expr.hasOwnProperty(extra.verbatim)) { return generateVerbatim(expr, option); } - switch (expr.type) { + switch (type) { case Syntax.SequenceExpression: result = []; allowIn |= (Precedence.Sequence < precedence); @@ -1188,7 +1616,8 @@ fragment = generateExpression(expr.properties[0], { precedence: Precedence.Sequence, allowIn: true, - allowCall: true + allowCall: true, + type: Syntax.Property }); }); @@ -1216,7 +1645,8 @@ result.push(indent, generateExpression(expr.properties[i], { precedence: Precedence.Sequence, allowIn: true, - allowCall: true + allowCall: true, + type: Syntax.Property })); if (i + 1 < len) { result.push(',' + newline); @@ -1881,8 +2311,9 @@ extra = options; if (sourceMap) { - if (typeof process !== 'undefined') { + 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; @@ -1955,7 +2386,10 @@ return result.toString(); } - pair = result.toStringWithSourceMap({file: options.sourceMap}); + pair = result.toStringWithSourceMap({ + file: options.sourceMap, + sourceRoot: options.sourceMapRoot + }); if (options.sourceMapWithCode) { return pair; @@ -2017,62 +2451,6 @@ Skip: 2 }; - function traverse(top, visitor) { - var worklist, leavelist, node, ret, current, current2, candidates, candidate, marker = {}; - - worklist = [ top ]; - leavelist = [ null ]; - - while (worklist.length) { - node = worklist.pop(); - - if (node === marker) { - node = leavelist.pop(); - if (visitor.leave) { - ret = visitor.leave(node, leavelist[leavelist.length - 1]); - } else { - ret = undefined; - } - if (ret === VisitorOption.Break) { - return; - } - } else if (node) { - if (visitor.enter) { - ret = visitor.enter(node, leavelist[leavelist.length - 1]); - } else { - ret = undefined; - } - - if (ret === VisitorOption.Break) { - return; - } - - worklist.push(marker); - leavelist.push(node); - - if (ret !== VisitorOption.Skip) { - candidates = VisitorKeys[node.type]; - current = candidates.length; - while ((current -= 1) >= 0) { - candidate = node[candidates[current]]; - if (candidate) { - if (isArray(candidate)) { - current2 = candidate.length; - while ((current2 -= 1) >= 0) { - if (candidate[current2]) { - worklist.push(candidate[current2]); - } - } - } else { - worklist.push(candidate); - } - } - } - } - } - } - } - // based on LLVM libc++ upper_bound / lower_bound // MIT License @@ -2238,8 +2616,366 @@ exports.version = '0.0.16-dev'; exports.generate = generate; - exports.traverse = traverse; exports.attachComments = attachComments; + exports.browser = false; +}()); +/* vim: set sw=4 ts=4 et tw=80 : */ + +}); + +require.define("/node_modules/estraverse/package.json",function(require,module,exports,__dirname,__filename,process,global){module.exports = {"main":"estraverse.js"} +}); + +require.define("/node_modules/estraverse/estraverse.js",function(require,module,exports,__dirname,__filename,process,global){/* + Copyright (C) 2012 Yusuke Suzuki <[email protected]> + Copyright (C) 2012 Ariya Hidayat <[email protected]> + + 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. -}, 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 <COPYRIGHT HOLDER> 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 bitwise:true */ +/*global exports:true, define:true, window:true */ +(function (factory) { + 'use strict'; + + // 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((window.estraverse = {})); + } +}(function (exports) { + 'use strict'; + + var Syntax, + isArray, + VisitorOption, + VisitorKeys, + wrappers; + + Syntax = { + AssignmentExpression: 'AssignmentExpression', + ArrayExpression: 'ArrayExpression', + BlockStatement: 'BlockStatement', + BinaryExpression: 'BinaryExpression', + BreakStatement: 'BreakStatement', + CallExpression: 'CallExpression', + CatchClause: 'CatchClause', + ConditionalExpression: 'ConditionalExpression', + ContinueStatement: 'ContinueStatement', + DebuggerStatement: 'DebuggerStatement', + DirectiveStatement: 'DirectiveStatement', + DoWhileStatement: 'DoWhileStatement', + 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' + }; + + isArray = Array.isArray; + if (!isArray) { + isArray = function isArray(array) { + return Object.prototype.toString.call(array) === '[object Array]'; + }; + } + + VisitorKeys = { + AssignmentExpression: ['left', 'right'], + ArrayExpression: ['elements'], + BlockStatement: ['body'], + BinaryExpression: ['left', 'right'], + BreakStatement: ['label'], + CallExpression: ['callee', 'arguments'], + CatchClause: ['param', 'body'], + ConditionalExpression: ['test', 'consequent', 'alternate'], + ContinueStatement: ['label'], + DebuggerStatement: [], + DirectiveStatement: [], + DoWhileStatement: ['body', 'test'], + EmptyStatement: [], + ExpressionStatement: ['expression'], + ForStatement: ['init', 'test', 'update', 'body'], + ForInStatement: ['left', 'right', 'body'], + FunctionDeclaration: ['id', 'params', 'body'], + FunctionExpression: ['id', 'params', 'body'], + Identifier: [], + IfStatement: ['test', 'consequent', 'alternate'], + Literal: [], + LabeledStatement: ['label', 'body'], + LogicalExpression: ['left', 'right'], + MemberExpression: ['object', 'property'], + NewExpression: ['callee', 'arguments'], + ObjectExpression: ['properties'], + Program: ['body'], + Property: ['key', 'value'], + ReturnStatement: ['argument'], + SequenceExpression: ['expressions'], + SwitchStatement: ['discriminant', 'cases'], + SwitchCase: ['test', 'consequent'], + ThisExpression: [], + ThrowStatement: ['argument'], + TryStatement: ['block', 'handlers', 'finalizer'], + UnaryExpression: ['argument'], + UpdateExpression: ['argument'], + VariableDeclaration: ['declarations'], + VariableDeclarator: ['id', 'init'], + WhileStatement: ['test', 'body'], + WithStatement: ['object', 'body'] + }; + + VisitorOption = { + Break: 1, + Skip: 2 + }; + + wrappers = { + PropertyWrapper: 'Property' + }; + + function traverse(top, visitor) { + var worklist, leavelist, node, nodeType, ret, current, current2, candidates, candidate, marker = {}; + + worklist = [ top ]; + leavelist = [ null ]; + + while (worklist.length) { + node = worklist.pop(); + nodeType = node.type; + + if (node === marker) { + node = leavelist.pop(); + if (visitor.leave) { + ret = visitor.leave(node, leavelist[leavelist.length - 1]); + } else { + ret = undefined; + } + if (ret === VisitorOption.Break) { + return; + } + } else if (node) { + if (wrappers.hasOwnProperty(nodeType)) { + node = node.node; + nodeType = wrappers[nodeType]; + } + + if (visitor.enter) { + ret = visitor.enter(node, leavelist[leavelist.length - 1]); + } else { + ret = undefined; + } + + if (ret === VisitorOption.Break) { + return; + } + + worklist.push(marker); + leavelist.push(node); + + if (ret !== VisitorOption.Skip) { + candidates = VisitorKeys[nodeType]; + current = candidates.length; + while ((current -= 1) >= 0) { + candidate = node[candidates[current]]; + if (candidate) { + if (isArray(candidate)) { + current2 = candidate.length; + while ((current2 -= 1) >= 0) { + if (candidate[current2]) { + if(nodeType === Syntax.ObjectExpression && 'properties' === candidates[current] && null == candidates[current].type) { + worklist.push({type: 'PropertyWrapper', node: candidate[current2]}); + } else { + worklist.push(candidate[current2]); + } + } + } + } else { + worklist.push(candidate); + } + } + } + } + } + } + } + + function replace(top, visitor) { + var worklist, leavelist, node, nodeType, target, tuple, ret, current, current2, candidates, candidate, marker = {}, result; + + result = { + top: top + }; + + tuple = [ top, result, 'top' ]; + worklist = [ tuple ]; + leavelist = [ tuple ]; + + function notify(v) { + ret = v; + } + + while (worklist.length) { + tuple = worklist.pop(); + + if (tuple === marker) { + tuple = leavelist.pop(); + ret = undefined; + if (visitor.leave) { + node = tuple[0]; + target = visitor.leave(tuple[0], leavelist[leavelist.length - 1][0], notify); + if (target !== undefined) { + node = target; + } + tuple[1][tuple[2]] = node; + } + if (ret === VisitorOption.Break) { + return result.top; + } + } else if (tuple[0]) { + ret = undefined; + node = tuple[0]; + + nodeType = node.type; + if (wrappers.hasOwnProperty(nodeType)) { + tuple[0] = node = node.node; + nodeType = wrappers[nodeType]; + } + + if (visitor.enter) { + target = visitor.enter(tuple[0], leavelist[leavelist.length - 1][0], notify); + if (target !== undefined) { + node = target; + } + tuple[1][tuple[2]] = node; + tuple[0] = node; + } + + if (ret === VisitorOption.Break) { + return result.top; + } + + if (tuple[0]) { + worklist.push(marker); + leavelist.push(tuple); + + if (ret !== VisitorOption.Skip) { + candidates = VisitorKeys[nodeType]; + current = candidates.length; + while ((current -= 1) >= 0) { + candidate = node[candidates[current]]; + if (candidate) { + if (isArray(candidate)) { + current2 = candidate.length; + while ((current2 -= 1) >= 0) { + if (candidate[current2]) { + if(nodeType === Syntax.ObjectExpression && 'properties' === candidates[current] && null == candidates[current].type) { + worklist.push([{type: 'PropertyWrapper', node: candidate[current2]}, candidate, current2]); + } else { + worklist.push([candidate[current2], candidate, current2]); + } + } + } + } else { + worklist.push([candidate, node, candidates[current]]); + } + } + } + } + } + } + } + + return result.top; + } + + exports.version = '0.0.4'; + exports.Syntax = Syntax; + exports.traverse = traverse; + exports.replace = replace; + exports.VisitorKeys = VisitorKeys; + exports.VisitorOption = VisitorOption; +})); /* vim: set sw=4 ts=4 et tw=80 : */ + +}); + +require.define("/tools/entry-point.js",function(require,module,exports,__dirname,__filename,process,global){/* + Copyright (C) 2012 Yusuke Suzuki <[email protected]> + + 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. + + 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 <COPYRIGHT HOLDER> 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 escodegen; + escodegen = global.escodegen = require('../escodegen'); + escodegen.browser = true; +}()); + +}); +require("/tools/entry-point.js"); +})(); +
