sprockets-browserify 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +70 -0
- data/Rakefile +38 -0
- data/lib/sprockets/browserify/engine.rb +15 -0
- data/lib/sprockets/browserify.rb +37 -0
- data/lib/sprockets-browserify.rb +2 -0
- data/lib/tasks/sprockets-browserify_tasks.rake +4 -0
- data/node_modules/JSONStream/LICENSE.APACHE2 +15 -0
- data/node_modules/JSONStream/LICENSE.MIT +24 -0
- data/node_modules/JSONStream/examples/all_docs.js +13 -0
- data/node_modules/JSONStream/index.js +189 -0
- data/node_modules/JSONStream/node_modules/jsonparse/LICENSE +24 -0
- data/node_modules/JSONStream/node_modules/jsonparse/README.markdown +11 -0
- data/node_modules/JSONStream/node_modules/jsonparse/bench.js +26 -0
- data/node_modules/JSONStream/node_modules/jsonparse/examples/twitterfeed.js +30 -0
- data/node_modules/JSONStream/node_modules/jsonparse/jsonparse.js +379 -0
- data/node_modules/JSONStream/node_modules/jsonparse/package.json +34 -0
- data/node_modules/JSONStream/node_modules/jsonparse/samplejson/basic.json +167 -0
- data/node_modules/JSONStream/node_modules/jsonparse/samplejson/basic2.json +180 -0
- data/node_modules/JSONStream/node_modules/jsonparse/test/primitives.js +54 -0
- data/node_modules/JSONStream/node_modules/jsonparse/test/utf8.js +38 -0
- data/node_modules/JSONStream/package.json +38 -0
- data/node_modules/JSONStream/readme.markdown +145 -0
- data/node_modules/JSONStream/test/bool.js +41 -0
- data/node_modules/JSONStream/test/destroy_missing.js +22 -0
- data/node_modules/JSONStream/test/empty.js +44 -0
- data/node_modules/JSONStream/test/fixtures/all_npm.json +4030 -0
- data/node_modules/JSONStream/test/fn.js +39 -0
- data/node_modules/JSONStream/test/memory.js +69 -0
- data/node_modules/JSONStream/test/multiple_objects.js +42 -0
- data/node_modules/JSONStream/test/multiple_objects_error.js +35 -0
- data/node_modules/JSONStream/test/parsejson.js +28 -0
- data/node_modules/JSONStream/test/stringify.js +41 -0
- data/node_modules/JSONStream/test/stringify_object.js +47 -0
- data/node_modules/JSONStream/test/test.js +35 -0
- data/node_modules/JSONStream/test/test2.js +29 -0
- data/node_modules/JSONStream/test/two-ways.js +41 -0
- data/node_modules/browserify/LICENSE +63 -0
- data/node_modules/browserify/README.markdown +172 -0
- data/node_modules/browserify/bin/cmd.js +161 -0
- data/node_modules/browserify/builtins/__browserify_process.js +55 -0
- data/node_modules/browserify/builtins/assert.js +314 -0
- data/node_modules/browserify/builtins/child_process.js +2 -0
- data/node_modules/browserify/builtins/events.js +178 -0
- data/node_modules/browserify/builtins/fs.js +1 -0
- data/node_modules/browserify/builtins/https.js +1 -0
- data/node_modules/browserify/builtins/net.js +1 -0
- data/node_modules/browserify/builtins/path.js +175 -0
- data/node_modules/browserify/builtins/querystring.js +250 -0
- data/node_modules/browserify/builtins/stream.js +119 -0
- data/node_modules/browserify/builtins/string_decoder.js +161 -0
- data/node_modules/browserify/builtins/sys.js +1 -0
- data/node_modules/browserify/builtins/timers.js +39 -0
- data/node_modules/browserify/builtins/tls.js +1 -0
- data/node_modules/browserify/builtins/tty.js +2 -0
- data/node_modules/browserify/builtins/url.js +604 -0
- data/node_modules/browserify/builtins/util.js +351 -0
- data/node_modules/browserify/doc/methods.markdown +182 -0
- data/node_modules/browserify/doc/recipes.markdown +62 -0
- data/node_modules/browserify/example/debug/browserify.js +219 -0
- data/node_modules/browserify/example/debug/build.sh +3 -0
- data/node_modules/browserify/example/debug/index.html +7 -0
- data/node_modules/browserify/example/debug/js/entry.js +2 -0
- data/node_modules/browserify/example/debug/js/thrower.js +3 -0
- data/node_modules/browserify/example/debug/server.js +9 -0
- data/node_modules/browserify/example/simple-build/browserify.js +368 -0
- data/node_modules/browserify/example/simple-build/build.sh +3 -0
- data/node_modules/browserify/example/simple-build/index.html +9 -0
- data/node_modules/browserify/example/simple-build/js/bar.js +3 -0
- data/node_modules/browserify/example/simple-build/js/entry.js +5 -0
- data/node_modules/browserify/example/simple-build/js/foo.js +5 -0
- data/node_modules/browserify/example/simple-build/server.js +9 -0
- data/node_modules/browserify/example/test/b.js +5 -0
- data/node_modules/browserify/example/test/bar.js +3 -0
- data/node_modules/browserify/example/test/foo.js +3 -0
- data/node_modules/browserify/example/test/m.js +3 -0
- data/node_modules/browserify/example/test/n.js +3 -0
- data/node_modules/browserify/example/using-http/bundle.js +813 -0
- data/node_modules/browserify/example/using-http/entry.js +25 -0
- data/node_modules/browserify/example/using-http/index.html +9 -0
- data/node_modules/browserify/example/using-http/server.js +28 -0
- data/node_modules/browserify/index.js +202 -0
- data/node_modules/browserify/lib/watch.js +75 -0
- data/node_modules/browserify/lib/wrap.js +583 -0
- data/node_modules/browserify/lib/wrappers.js +10 -0
- data/node_modules/browserify/node_modules/buffer-browserify/README.md +11 -0
- data/node_modules/browserify/node_modules/buffer-browserify/buffer_ieee754.js +84 -0
- data/node_modules/browserify/node_modules/buffer-browserify/index.js +1317 -0
- data/node_modules/browserify/node_modules/buffer-browserify/node_modules/base64-js/README.md +14 -0
- data/node_modules/browserify/node_modules/buffer-browserify/node_modules/base64-js/lib/b64.js +84 -0
- data/node_modules/browserify/node_modules/buffer-browserify/node_modules/base64-js/package.json +26 -0
- data/node_modules/browserify/node_modules/buffer-browserify/node_modules/base64-js/test/runner.js +50 -0
- data/node_modules/browserify/node_modules/buffer-browserify/package.json +42 -0
- data/node_modules/browserify/node_modules/buffer-browserify/test/buffer.js +218 -0
- data/node_modules/browserify/node_modules/coffee-script/CNAME +1 -0
- data/node_modules/browserify/node_modules/coffee-script/CONTRIBUTING.md +9 -0
- data/node_modules/browserify/node_modules/coffee-script/LICENSE +22 -0
- data/node_modules/browserify/node_modules/coffee-script/README +51 -0
- data/node_modules/browserify/node_modules/coffee-script/Rakefile +79 -0
- data/node_modules/browserify/node_modules/coffee-script/bin/cake +7 -0
- data/node_modules/browserify/node_modules/coffee-script/bin/coffee +7 -0
- data/node_modules/browserify/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/browser.js +101 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/cake.js +113 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/coffee-script.js +218 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/command.js +506 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/grammar.js +623 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/helpers.js +150 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/lexer.js +905 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/nodes.js +3088 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/optparse.js +138 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/parser.js +608 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/repl.js +104 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/rewriter.js +478 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/scope.js +147 -0
- data/node_modules/browserify/node_modules/coffee-script/lib/coffee-script/sourcemap.js +237 -0
- data/node_modules/browserify/node_modules/coffee-script/package.json +48 -0
- data/node_modules/browserify/node_modules/commondir/README.markdown +45 -0
- data/node_modules/browserify/node_modules/commondir/example/base.js +3 -0
- data/node_modules/browserify/node_modules/commondir/example/dir.js +3 -0
- data/node_modules/browserify/node_modules/commondir/index.js +29 -0
- data/node_modules/browserify/node_modules/commondir/package.json +43 -0
- data/node_modules/browserify/node_modules/commondir/test/dirs.js +66 -0
- data/node_modules/browserify/node_modules/console-browserify/LICENCE +19 -0
- data/node_modules/browserify/node_modules/console-browserify/README.md +32 -0
- data/node_modules/browserify/node_modules/console-browserify/index.js +85 -0
- data/node_modules/browserify/node_modules/console-browserify/package.json +76 -0
- data/node_modules/browserify/node_modules/console-browserify/test/index.js +67 -0
- data/node_modules/browserify/node_modules/console-browserify/test/static/index.html +12 -0
- data/node_modules/browserify/node_modules/console-browserify/test/static/test-adapter.js +53 -0
- data/node_modules/browserify/node_modules/crypto-browserify/example/bundle.js +637 -0
- data/node_modules/browserify/node_modules/crypto-browserify/example/index.html +12 -0
- data/node_modules/browserify/node_modules/crypto-browserify/example/test.js +4 -0
- data/node_modules/browserify/node_modules/crypto-browserify/index.js +74 -0
- data/node_modules/browserify/node_modules/crypto-browserify/md5.js +384 -0
- data/node_modules/browserify/node_modules/crypto-browserify/package.json +30 -0
- data/node_modules/browserify/node_modules/crypto-browserify/readme.markdown +20 -0
- data/node_modules/browserify/node_modules/crypto-browserify/rng.js +37 -0
- data/node_modules/browserify/node_modules/crypto-browserify/sha.js +210 -0
- data/node_modules/browserify/node_modules/crypto-browserify/test/simple.js +35 -0
- data/node_modules/browserify/node_modules/deputy/README.markdown +55 -0
- data/node_modules/browserify/node_modules/deputy/example/cache.js +5 -0
- data/node_modules/browserify/node_modules/deputy/index.js +46 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/LICENSE +21 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/examples/pow.js +6 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/index.js +82 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/package.json +30 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/readme.markdown +63 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/chmod.js +38 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/clobber.js +37 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/mkdirp.js +28 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/perm.js +32 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/perm_sync.js +39 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/race.js +41 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/rel.js +32 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/return.js +25 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/return_sync.js +24 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/root.js +18 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/sync.js +32 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/umask.js +28 -0
- data/node_modules/browserify/node_modules/deputy/node_modules/mkdirp/test/umask_sync.js +32 -0
- data/node_modules/browserify/node_modules/deputy/package.json +43 -0
- data/node_modules/browserify/node_modules/deputy/test/cache.js +58 -0
- data/node_modules/browserify/node_modules/detective/README.markdown +66 -0
- data/node_modules/browserify/node_modules/detective/example/strings.js +6 -0
- data/node_modules/browserify/node_modules/detective/example/strings_src.js +3 -0
- data/node_modules/browserify/node_modules/detective/index.js +60 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/LICENSE.BSD +19 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/README.md +74 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/assets/codemirror/codemirror.css +112 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/assets/codemirror/codemirror.js +2972 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/assets/codemirror/javascript.js +360 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/assets/json2.js +487 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/assets/style.css +164 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/assets/yui/treeview-min.js +12 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/assets/yui/treeview-sprite.gif +0 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/assets/yui/treeview.css +7 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/assets/yui/yahoo-dom-event.js +14 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/bin/esparse.js +42 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/changes +92 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/cm +696 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/demo/checkenv.js +42 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/demo/collector.html +82 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/demo/collector.js +170 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/demo/functiontrace.html +106 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/demo/functiontrace.js +123 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/demo/parse.css +82 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/demo/parse.html +352 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/demo/precedence.html +225 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/demo/rewrite.html +120 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/demo/rewrite.js +71 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/esprima.js +3577 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/index.html +103 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/package.json +39 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/Tokenizer.js +646 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/XMLHttpRequest.js +509 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/ZeParser.js +2185 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/backbone-0.5.3.js +1158 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/benchmark.js +3261 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/escodegen.js +906 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/esmorph.js +240 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/ext-core-3.0.0.js +6579 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/ext-core-3.1.0.js +10255 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/jquery-1.6.4.js +9046 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/jquery-1.7.1.js +9266 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/jquery.mobile-1.0.js +6951 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/jsdefs.js +731 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/jslex.js +588 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/jsparse.js +1921 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/mootools-1.3.2.js +5952 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/mootools-1.4.1.js +6297 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/parse-js.js +1342 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/platform.js +878 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/prototype-1.6.1.js +4874 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/prototype-1.7.0.0.js +6082 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/3rdparty/underscore-1.2.3.js +981 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/benchmarks.html +58 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/benchmarks.js +328 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/compare.html +140 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/compare.js +270 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/compat.html +40 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/compat.js +239 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/coverage.footer.html +3 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/coverage.header.html +37 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/coverage.html +3617 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/index.html +36 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/reflect.js +403 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/run.js +66 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/test/test.js +16659 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/tools/generate-unicode-regex.py +164 -0
- data/node_modules/browserify/node_modules/detective/node_modules/esprima/tools/update-coverage.sh +28 -0
- data/node_modules/browserify/node_modules/detective/package.json +43 -0
- data/node_modules/browserify/node_modules/detective/test/both.js +11 -0
- data/node_modules/browserify/node_modules/detective/test/chained.js +9 -0
- data/node_modules/browserify/node_modules/detective/test/files/both.js +4 -0
- data/node_modules/browserify/node_modules/detective/test/files/chained.js +5 -0
- data/node_modules/browserify/node_modules/detective/test/files/nested.js +22 -0
- data/node_modules/browserify/node_modules/detective/test/files/skip.js +7 -0
- data/node_modules/browserify/node_modules/detective/test/files/strings.js +13 -0
- data/node_modules/browserify/node_modules/detective/test/files/word.js +13 -0
- data/node_modules/browserify/node_modules/detective/test/nested.js +9 -0
- data/node_modules/browserify/node_modules/detective/test/skip.js +9 -0
- data/node_modules/browserify/node_modules/detective/test/strings.js +9 -0
- data/node_modules/browserify/node_modules/detective/test/word.js +12 -0
- data/node_modules/browserify/node_modules/http-browserify/example/get/index.html +9 -0
- data/node_modules/browserify/node_modules/http-browserify/example/get/main.js +14 -0
- data/node_modules/browserify/node_modules/http-browserify/example/get/server.js +12 -0
- data/node_modules/browserify/node_modules/http-browserify/example/headers/index.html +9 -0
- data/node_modules/browserify/node_modules/http-browserify/example/headers/main.js +18 -0
- data/node_modules/browserify/node_modules/http-browserify/example/headers/server.js +15 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/data.json +139 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/index.html +9 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/main.js +13 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/LICENSE.APACHE2 +15 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/LICENSE.MIT +24 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/examples/all_docs.js +13 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/index.js +189 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/node_modules/jsonparse/LICENSE +24 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/node_modules/jsonparse/README.markdown +11 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/node_modules/jsonparse/bench.js +26 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/node_modules/jsonparse/examples/twitterfeed.js +30 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/node_modules/jsonparse/jsonparse.js +379 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/node_modules/jsonparse/package.json +36 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/node_modules/jsonparse/samplejson/basic.json +167 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/node_modules/jsonparse/samplejson/basic2.json +180 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/node_modules/jsonparse/test/primitives.js +54 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/node_modules/jsonparse/test/utf8.js +38 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/package.json +40 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/readme.markdown +145 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/bool.js +41 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/destroy_missing.js +22 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/empty.js +44 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/fixtures/all_npm.json +4030 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/fn.js +39 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/memory.js +69 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/multiple_objects.js +42 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/multiple_objects_error.js +35 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/parsejson.js +28 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/stringify.js +41 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/stringify_object.js +47 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/test.js +35 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/test2.js +29 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/node_modules/JSONStream/test/two-ways.js +41 -0
- data/node_modules/browserify/node_modules/http-browserify/example/json-stream/server.js +10 -0
- data/node_modules/browserify/node_modules/http-browserify/example/post/index.html +9 -0
- data/node_modules/browserify/node_modules/http-browserify/example/post/main.js +16 -0
- data/node_modules/browserify/node_modules/http-browserify/example/post/server.js +19 -0
- data/node_modules/browserify/node_modules/http-browserify/example/streaming/index.html +9 -0
- data/node_modules/browserify/node_modules/http-browserify/example/streaming/main.js +16 -0
- data/node_modules/browserify/node_modules/http-browserify/example/streaming/server.js +21 -0
- data/node_modules/browserify/node_modules/http-browserify/index.js +60 -0
- data/node_modules/browserify/node_modules/http-browserify/lib/request.js +128 -0
- data/node_modules/browserify/node_modules/http-browserify/lib/response.js +119 -0
- data/node_modules/browserify/node_modules/http-browserify/node_modules/concat-stream/index.js +48 -0
- data/node_modules/browserify/node_modules/http-browserify/node_modules/concat-stream/package.json +29 -0
- data/node_modules/browserify/node_modules/http-browserify/node_modules/concat-stream/readme.md +31 -0
- data/node_modules/browserify/node_modules/http-browserify/node_modules/concat-stream/test.js +34 -0
- data/node_modules/browserify/node_modules/http-browserify/package.json +42 -0
- data/node_modules/browserify/node_modules/http-browserify/readme.markdown +128 -0
- data/node_modules/browserify/node_modules/nub/README.markdown +23 -0
- data/node_modules/browserify/node_modules/nub/index.js +64 -0
- data/node_modules/browserify/node_modules/nub/package.json +42 -0
- data/node_modules/browserify/node_modules/nub/test/by.js +51 -0
- data/node_modules/browserify/node_modules/nub/test/nub.js +46 -0
- data/node_modules/browserify/node_modules/optimist/LICENSE +21 -0
- data/node_modules/browserify/node_modules/optimist/README.markdown +487 -0
- data/node_modules/browserify/node_modules/optimist/example/bool.js +10 -0
- data/node_modules/browserify/node_modules/optimist/example/boolean_double.js +7 -0
- data/node_modules/browserify/node_modules/optimist/example/boolean_single.js +7 -0
- data/node_modules/browserify/node_modules/optimist/example/default_hash.js +8 -0
- data/node_modules/browserify/node_modules/optimist/example/default_singles.js +7 -0
- data/node_modules/browserify/node_modules/optimist/example/divide.js +8 -0
- data/node_modules/browserify/node_modules/optimist/example/line_count.js +20 -0
- data/node_modules/browserify/node_modules/optimist/example/line_count_options.js +29 -0
- data/node_modules/browserify/node_modules/optimist/example/line_count_wrap.js +29 -0
- data/node_modules/browserify/node_modules/optimist/example/nonopt.js +4 -0
- data/node_modules/browserify/node_modules/optimist/example/reflect.js +2 -0
- data/node_modules/browserify/node_modules/optimist/example/short.js +3 -0
- data/node_modules/browserify/node_modules/optimist/example/string.js +11 -0
- data/node_modules/browserify/node_modules/optimist/example/usage-options.js +19 -0
- data/node_modules/browserify/node_modules/optimist/example/xup.js +10 -0
- data/node_modules/browserify/node_modules/optimist/index.js +475 -0
- data/node_modules/browserify/node_modules/optimist/node_modules/wordwrap/README.markdown +70 -0
- data/node_modules/browserify/node_modules/optimist/node_modules/wordwrap/example/center.js +10 -0
- data/node_modules/browserify/node_modules/optimist/node_modules/wordwrap/example/meat.js +3 -0
- data/node_modules/browserify/node_modules/optimist/node_modules/wordwrap/index.js +76 -0
- data/node_modules/browserify/node_modules/optimist/node_modules/wordwrap/package.json +41 -0
- data/node_modules/browserify/node_modules/optimist/node_modules/wordwrap/test/break.js +30 -0
- data/node_modules/browserify/node_modules/optimist/node_modules/wordwrap/test/idleness.txt +63 -0
- data/node_modules/browserify/node_modules/optimist/node_modules/wordwrap/test/wrap.js +31 -0
- data/node_modules/browserify/node_modules/optimist/package.json +47 -0
- data/node_modules/browserify/node_modules/optimist/test/_/argv.js +2 -0
- data/node_modules/browserify/node_modules/optimist/test/_/bin.js +3 -0
- data/node_modules/browserify/node_modules/optimist/test/_.js +71 -0
- data/node_modules/browserify/node_modules/optimist/test/parse.js +433 -0
- data/node_modules/browserify/node_modules/optimist/test/usage.js +292 -0
- data/node_modules/browserify/node_modules/optimist/x.js +1 -0
- data/node_modules/browserify/node_modules/resolve/LICENSE +18 -0
- data/node_modules/browserify/node_modules/resolve/README.markdown +47 -0
- data/node_modules/browserify/node_modules/resolve/index.js +109 -0
- data/node_modules/browserify/node_modules/resolve/package.json +41 -0
- data/node_modules/browserify/node_modules/resolve/test/core.js +12 -0
- data/node_modules/browserify/node_modules/resolve/test/filter.js +15 -0
- data/node_modules/browserify/node_modules/resolve/test/mock.js +68 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/bar/node_modules/foo/index.js +1 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/baz/doom.js +0 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/baz/package.json +3 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/baz/quux.js +1 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/biz/node_modules/grux/index.js +1 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/biz/node_modules/tiv/index.js +1 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/cup.coffee +1 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/foo.js +1 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/mug.coffee +0 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/mug.js +0 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/other_path/lib/other-lib.js +0 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver/other_path/root.js +0 -0
- data/node_modules/browserify/node_modules/resolve/test/resolver.js +157 -0
- data/node_modules/browserify/node_modules/syntax-error/LICENSE +18 -0
- data/node_modules/browserify/node_modules/syntax-error/example/check.js +12 -0
- data/node_modules/browserify/node_modules/syntax-error/example/src.js +9 -0
- data/node_modules/browserify/node_modules/syntax-error/index.js +54 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/LICENSE.BSD +19 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/README.md +74 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/assets/codemirror/codemirror.css +112 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/assets/codemirror/codemirror.js +2972 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/assets/codemirror/javascript.js +360 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/assets/json2.js +487 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/assets/style.css +164 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/assets/yui/treeview-min.js +12 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/assets/yui/treeview-sprite.gif +0 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/assets/yui/treeview.css +7 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/assets/yui/yahoo-dom-event.js +14 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/bin/esparse.js +42 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/changes +92 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/cm +696 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/demo/checkenv.js +42 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/demo/collector.html +82 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/demo/collector.js +170 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/demo/functiontrace.html +106 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/demo/functiontrace.js +123 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/demo/parse.css +82 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/demo/parse.html +352 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/demo/precedence.html +225 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/demo/rewrite.html +120 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/demo/rewrite.js +71 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/esprima.js +3577 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/index.html +103 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/package.json +39 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/Tokenizer.js +646 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/XMLHttpRequest.js +509 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/ZeParser.js +2185 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/backbone-0.5.3.js +1158 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/benchmark.js +3261 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/escodegen.js +906 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/esmorph.js +240 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/ext-core-3.0.0.js +6579 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/ext-core-3.1.0.js +10255 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/jquery-1.6.4.js +9046 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/jquery-1.7.1.js +9266 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/jquery.mobile-1.0.js +6951 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/jsdefs.js +731 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/jslex.js +588 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/jsparse.js +1921 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/mootools-1.3.2.js +5952 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/mootools-1.4.1.js +6297 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/parse-js.js +1342 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/platform.js +878 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/prototype-1.6.1.js +4874 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/prototype-1.7.0.0.js +6082 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/3rdparty/underscore-1.2.3.js +981 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/benchmarks.html +58 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/benchmarks.js +328 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/compare.html +140 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/compare.js +270 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/compat.html +40 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/compat.js +239 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/coverage.footer.html +3 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/coverage.header.html +37 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/coverage.html +3617 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/index.html +36 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/reflect.js +403 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/run.js +66 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/test/test.js +16659 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/tools/generate-unicode-regex.py +164 -0
- data/node_modules/browserify/node_modules/syntax-error/node_modules/esprima/tools/update-coverage.sh +28 -0
- data/node_modules/browserify/node_modules/syntax-error/package.json +46 -0
- data/node_modules/browserify/node_modules/syntax-error/readme.markdown +87 -0
- data/node_modules/browserify/node_modules/syntax-error/test/check.js +17 -0
- data/node_modules/browserify/node_modules/syntax-error/test/sources/check.js +9 -0
- data/node_modules/browserify/node_modules/vm-browserify/README.markdown +103 -0
- data/node_modules/browserify/node_modules/vm-browserify/example/run/bundle.js +473 -0
- data/node_modules/browserify/node_modules/vm-browserify/example/run/entry.js +6 -0
- data/node_modules/browserify/node_modules/vm-browserify/example/run/index.html +9 -0
- data/node_modules/browserify/node_modules/vm-browserify/example/run/server.js +6 -0
- data/node_modules/browserify/node_modules/vm-browserify/index.js +85 -0
- data/node_modules/browserify/node_modules/vm-browserify/package.json +39 -0
- data/node_modules/browserify/node_modules/vm-browserify/testling/run.js +22 -0
- data/node_modules/browserify/node_modules/vm-browserify/testling/test.sh +11 -0
- data/node_modules/browserify/package.json +71 -0
- data/node_modules/browserify/test/alias.js +58 -0
- data/node_modules/browserify/test/backbone.js +21 -0
- data/node_modules/browserify/test/bin.js +39 -0
- data/node_modules/browserify/test/buffer.js +99 -0
- data/node_modules/browserify/test/bundle.js +32 -0
- data/node_modules/browserify/test/cache.js +28 -0
- data/node_modules/browserify/test/coffee/bar.js +1 -0
- data/node_modules/browserify/test/coffee/baz.coffee +1 -0
- data/node_modules/browserify/test/coffee/entry.coffee +1 -0
- data/node_modules/browserify/test/coffee/foo.coffee +1 -0
- data/node_modules/browserify/test/coffee/index.coffee +5 -0
- data/node_modules/browserify/test/coffee/nested/nested.coffee +2 -0
- data/node_modules/browserify/test/coffee.js +39 -0
- data/node_modules/browserify/test/comment/main.js +2 -0
- data/node_modules/browserify/test/comment.js +17 -0
- data/node_modules/browserify/test/crypto.js +37 -0
- data/node_modules/browserify/test/dnode.js +27 -0
- data/node_modules/browserify/test/dollar/dollar/index.js +7 -0
- data/node_modules/browserify/test/dollar.js +19 -0
- data/node_modules/browserify/test/entry/main.js +1 -0
- data/node_modules/browserify/test/entry/one.js +1 -0
- data/node_modules/browserify/test/entry/two.js +1 -0
- data/node_modules/browserify/test/entry.js +36 -0
- data/node_modules/browserify/test/error_code/src.js +2 -0
- data/node_modules/browserify/test/error_code.js +24 -0
- data/node_modules/browserify/test/export/entry.js +1 -0
- data/node_modules/browserify/test/export.js +52 -0
- data/node_modules/browserify/test/field/miss.js +1 -0
- data/node_modules/browserify/test/field/node_modules/z-miss/browser.js +1 -0
- data/node_modules/browserify/test/field/node_modules/z-miss/main.js +1 -0
- data/node_modules/browserify/test/field/node_modules/z-miss/package.json +4 -0
- data/node_modules/browserify/test/field/node_modules/z-object/browser.js +1 -0
- data/node_modules/browserify/test/field/node_modules/z-object/main.js +1 -0
- data/node_modules/browserify/test/field/node_modules/z-object/package.json +6 -0
- data/node_modules/browserify/test/field/node_modules/z-string/browser.js +1 -0
- data/node_modules/browserify/test/field/node_modules/z-string/main.js +1 -0
- data/node_modules/browserify/test/field/node_modules/z-string/package.json +4 -0
- data/node_modules/browserify/test/field/node_modules/z-sub/browser/a.js +1 -0
- data/node_modules/browserify/test/field/node_modules/z-sub/browser/b.js +1 -0
- data/node_modules/browserify/test/field/node_modules/z-sub/main.js +1 -0
- data/node_modules/browserify/test/field/node_modules/z-sub/package.json +4 -0
- data/node_modules/browserify/test/field/object.js +1 -0
- data/node_modules/browserify/test/field/string.js +1 -0
- data/node_modules/browserify/test/field/sub.js +1 -0
- data/node_modules/browserify/test/field.js +64 -0
- data/node_modules/browserify/test/global/main.js +2 -0
- data/node_modules/browserify/test/global.js +19 -0
- data/node_modules/browserify/test/jade.js +35 -0
- data/node_modules/browserify/test/json/beep.json +4 -0
- data/node_modules/browserify/test/json/main.js +1 -0
- data/node_modules/browserify/test/json.js +17 -0
- data/node_modules/browserify/test/maxlisteners.js +8 -0
- data/node_modules/browserify/test/module.js +22 -0
- data/node_modules/browserify/test/multi_entry/a.js +2 -0
- data/node_modules/browserify/test/multi_entry/b.js +2 -0
- data/node_modules/browserify/test/multi_entry/c.js +3 -0
- data/node_modules/browserify/test/multi_entry.js +20 -0
- data/node_modules/browserify/test/multi_ignore.js +23 -0
- data/node_modules/browserify/test/node_modules/beep/index.js +1 -0
- data/node_modules/browserify/test/require_cache.js +18 -0
- data/node_modules/browserify/test/retarget.js +27 -0
- data/node_modules/browserify/test/seq.js +47 -0
- data/node_modules/browserify/test/subdep/index.js +1 -0
- data/node_modules/browserify/test/subdep/node_modules/qq/b.js +1 -0
- data/node_modules/browserify/test/subdep/node_modules/qq/ignore_me.js +1 -0
- data/node_modules/browserify/test/subdep/node_modules/qq/node_modules/a/index.js +1 -0
- data/node_modules/browserify/test/subdep/node_modules/qq/node_modules/a/package.json +5 -0
- data/node_modules/browserify/test/subdep/node_modules/qq/node_modules/c/index.js +1 -0
- data/node_modules/browserify/test/subdep/node_modules/qq/node_modules/c/package.json +5 -0
- data/node_modules/browserify/test/subdep/node_modules/qq/node_modules/f/index.js +1 -0
- data/node_modules/browserify/test/subdep/node_modules/qq/node_modules/z/index.js +1 -0
- data/node_modules/browserify/test/subdep/node_modules/qq/package.json +3 -0
- data/node_modules/browserify/test/subdep/package.json +6 -0
- data/node_modules/browserify/test/subdep.js +26 -0
- data/node_modules/browserify/test/util.js +48 -0
- data/node_modules/browserify/test/watch/a.js +1 -0
- data/node_modules/browserify/test/watch.js +91 -0
- data/node_modules/browserify/test/wrap/a.js +2 -0
- data/node_modules/browserify/test/wrap/c.js +1 -0
- data/node_modules/browserify/test/wrap/node_modules/b/main.js +1 -0
- data/node_modules/browserify/test/wrap/node_modules/b/package.json +3 -0
- data/node_modules/browserify/test/wrap/node_modules/skipmetoo/index.js +1 -0
- data/node_modules/browserify/test/wrap/skipme.js +1 -0
- data/node_modules/browserify/test/wrap/x.js +0 -0
- data/node_modules/browserify/test/wrap.js +43 -0
- data/node_modules/browserify/testling/README.markdown +29 -0
- data/node_modules/browserify/testling/test.sh +37 -0
- data/node_modules/browserify/testling/tick.js +9 -0
- data/node_modules/browserify/testling/timers.js +50 -0
- data/node_modules/browserify/testling/util.js +24 -0
- data/node_modules/browserify/v2.markdown +41 -0
- data/node_modules/browserify/wrappers/alias.js +1 -0
- data/node_modules/browserify/wrappers/body.js +2 -0
- data/node_modules/browserify/wrappers/body_debug.js +2 -0
- data/node_modules/browserify/wrappers/entry.js +3 -0
- data/node_modules/browserify/wrappers/entry_debug.js +3 -0
- data/node_modules/browserify/wrappers/package.js +3 -0
- data/node_modules/browserify/wrappers/prelude.js +196 -0
- data/node_modules/module-deps/LICENSE +18 -0
- data/node_modules/module-deps/cmd.js +8 -0
- data/node_modules/module-deps/example/deps.js +8 -0
- data/node_modules/module-deps/example/files/bar.js +3 -0
- data/node_modules/module-deps/example/files/foo.js +5 -0
- data/node_modules/module-deps/example/files/main.js +2 -0
- data/node_modules/module-deps/example/files/xyz.js +2 -0
- data/node_modules/module-deps/index.js +142 -0
- data/node_modules/module-deps/node_modules/browser-resolve/README.md +14 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/assert.js +314 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/child_process.js +2 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/events.js +183 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/fs.js +1 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/https.js +13 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/net.js +1 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/path.js +175 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/process.js +55 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/querystring.js +250 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/stream.js +119 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/string_decoder.js +161 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/sys.js +1 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/timers.js +39 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/tls.js +1 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/tty.js +2 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/url.js +604 -0
- data/node_modules/module-deps/node_modules/browser-resolve/builtin/util.js +351 -0
- data/node_modules/module-deps/node_modules/browser-resolve/index.js +144 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/buffer-browserify/README.md +11 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/buffer-browserify/buffer_ieee754.js +84 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/buffer-browserify/index.js +1282 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/buffer-browserify/node_modules/base64-js/README.md +14 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/buffer-browserify/node_modules/base64-js/lib/b64.js +84 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/buffer-browserify/node_modules/base64-js/package.json +26 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/buffer-browserify/node_modules/base64-js/test/runner.js +50 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/buffer-browserify/package.json +42 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/buffer-browserify/test/buffer.js +121 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/console-browserify/LICENCE +19 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/console-browserify/README.md +32 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/console-browserify/index.js +85 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/console-browserify/package.json +76 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/console-browserify/test/index.js +67 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/console-browserify/test/static/index.html +12 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/console-browserify/test/static/test-adapter.js +53 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/crypto-browserify/example/bundle.js +637 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/crypto-browserify/example/index.html +12 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/crypto-browserify/example/test.js +4 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/crypto-browserify/index.js +74 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/crypto-browserify/md5.js +384 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/crypto-browserify/package.json +30 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/crypto-browserify/readme.markdown +20 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/crypto-browserify/rng.js +37 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/crypto-browserify/sha.js +210 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/crypto-browserify/test/simple.js +35 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/README.markdown +128 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/get/index.html +9 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/get/main.js +14 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/get/server.js +12 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/headers/index.html +9 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/headers/main.js +18 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/headers/server.js +15 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/post/index.html +9 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/post/main.js +16 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/post/server.js +19 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/streaming/index.html +9 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/streaming/main.js +16 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/example/streaming/server.js +21 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/index.js +59 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/lib/request.js +122 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/lib/response.js +119 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/node_modules/concat-stream/index.js +48 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/node_modules/concat-stream/package.json +29 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/node_modules/concat-stream/readme.md +31 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/node_modules/concat-stream/test.js +34 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/http-browserify/package.json +42 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/vm-browserify/README.markdown +103 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/vm-browserify/example/run/bundle.js +473 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/vm-browserify/example/run/entry.js +6 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/vm-browserify/example/run/index.html +9 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/vm-browserify/example/run/server.js +6 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/vm-browserify/index.js +85 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/vm-browserify/package.json +39 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/vm-browserify/testling/run.js +22 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/vm-browserify/testling/test.sh +11 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/zlib-browserify/index.js +43 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/zlib-browserify/package.json +33 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/zlib-browserify/readme.md +1 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/zlib-browserify/test/zlib.test.js +65 -0
- data/node_modules/module-deps/node_modules/browser-resolve/node_modules/zlib-browserify/zlib.js +55 -0
- data/node_modules/module-deps/node_modules/browser-resolve/package.json +38 -0
- data/node_modules/module-deps/node_modules/browser-resolve/test/core.js +20 -0
- data/node_modules/module-deps/node_modules/browser-resolve/test/fixtures/foo.js +1 -0
- data/node_modules/module-deps/node_modules/browser-resolve/test/local.js +15 -0
- data/node_modules/module-deps/node_modules/browser-resolve/test/mocha.opts +1 -0
- data/node_modules/module-deps/node_modules/browser-resolve/test/modules.js +99 -0
- data/node_modules/module-deps/node_modules/detective/LICENSE +18 -0
- data/node_modules/module-deps/node_modules/detective/example/strings.js +6 -0
- data/node_modules/module-deps/node_modules/detective/example/strings_src.js +3 -0
- data/node_modules/module-deps/node_modules/detective/index.js +62 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/LICENSE.BSD +19 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/LICENSE.source-map +27 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/README.md +99 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/bin/escodegen.js +43 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/bin/esgenerate.js +43 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/escodegen.js +2245 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/LICENSE +28 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/Makefile.dryice.js +165 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/README.md +268 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/build/assert-shim.js +56 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/build/mini-require.js +152 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/build/prefix-source-map.jsm +20 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/build/prefix-utils.jsm +18 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/build/suffix-browser.js +8 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/build/suffix-source-map.jsm +6 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/build/suffix-utils.jsm +20 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/build/test-prefix.js +8 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/build/test-suffix.js +3 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/array-set.js +107 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/base64-vlq.js +144 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/base64.js +42 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/binary-search.js +81 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-consumer.js +379 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-generator.js +202 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/source-node.js +199 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map/util.js +40 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/lib/source-map.js +8 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/node_modules/amdefine/LICENSE +58 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/node_modules/amdefine/README.md +119 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/node_modules/amdefine/amdefine.js +299 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/node_modules/amdefine/package.json +29 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/package.json +38 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/run-tests.js +72 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/source-map/test-api.js +26 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/source-map/test-array-set.js +71 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/source-map/test-base64-vlq.js +24 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/source-map/test-base64.js +35 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/source-map/test-binary-search.js +54 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/source-map/test-dog-fooding.js +72 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/source-map/test-source-map-consumer.js +142 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/source-map/test-source-map-generator.js +187 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/source-map/test-source-node.js +163 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/node_modules/source-map/test/source-map/util.js +78 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/escodegen/package.json +48 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/ChangeLog +18 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/LICENSE.BSD +19 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/README.md +73 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/bin/esparse.js +117 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/bin/esvalidate.js +177 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/component.json +14 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/doc/index.html +473 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/esprima.js +3895 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/examples/detectnestedternary.js +106 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/examples/findbooleantrap.js +173 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/examples/tokendist.js +33 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/index.html +102 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/package.json +40 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/benchmarks.html +58 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/benchmarks.js +334 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/compare.html +69 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/compare.js +328 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/compat.html +40 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/compat.js +239 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/coverage.footer.html +3 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/coverage.header.html +37 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/coverage.html +4676 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/index.html +37 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/module.html +36 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/module.js +129 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/reflect.js +422 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/run.js +66 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/runner.js +387 -0
- data/node_modules/module-deps/node_modules/detective/node_modules/esprima/test/test.js +19764 -0
- data/node_modules/module-deps/node_modules/detective/package.json +36 -0
- data/node_modules/module-deps/node_modules/detective/readme.markdown +70 -0
- data/node_modules/module-deps/node_modules/detective/test/both.js +11 -0
- data/node_modules/module-deps/node_modules/detective/test/chained.js +9 -0
- data/node_modules/module-deps/node_modules/detective/test/files/both.js +4 -0
- data/node_modules/module-deps/node_modules/detective/test/files/chained.js +5 -0
- data/node_modules/module-deps/node_modules/detective/test/files/nested.js +22 -0
- data/node_modules/module-deps/node_modules/detective/test/files/shebang.js +5 -0
- data/node_modules/module-deps/node_modules/detective/test/files/strings.js +13 -0
- data/node_modules/module-deps/node_modules/detective/test/files/word.js +13 -0
- data/node_modules/module-deps/node_modules/detective/test/nested.js +9 -0
- data/node_modules/module-deps/node_modules/detective/test/shebang.js +9 -0
- data/node_modules/module-deps/node_modules/detective/test/strings.js +9 -0
- data/node_modules/module-deps/node_modules/detective/test/word.js +12 -0
- data/node_modules/module-deps/node_modules/resolve/LICENSE +18 -0
- data/node_modules/module-deps/node_modules/resolve/example/async.js +5 -0
- data/node_modules/module-deps/node_modules/resolve/example/sync.js +3 -0
- data/node_modules/module-deps/node_modules/resolve/index.js +5 -0
- data/node_modules/module-deps/node_modules/resolve/lib/async.js +131 -0
- data/node_modules/module-deps/node_modules/resolve/lib/core.js +4 -0
- data/node_modules/module-deps/node_modules/resolve/lib/core.json +38 -0
- data/node_modules/module-deps/node_modules/resolve/lib/sync.js +98 -0
- data/node_modules/module-deps/node_modules/resolve/package.json +32 -0
- data/node_modules/module-deps/node_modules/resolve/readme.markdown +134 -0
- data/node_modules/module-deps/node_modules/resolve/test/core.js +12 -0
- data/node_modules/module-deps/node_modules/resolve/test/filter.js +17 -0
- data/node_modules/module-deps/node_modules/resolve/test/filter_sync.js +15 -0
- data/node_modules/module-deps/node_modules/resolve/test/mock.js +68 -0
- data/node_modules/module-deps/node_modules/resolve/test/mock_sync.js +68 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/bar/node_modules/foo/index.js +1 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/baz/doom.js +0 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/baz/package.json +3 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/baz/quux.js +1 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/biz/node_modules/grux/index.js +1 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/biz/node_modules/tiv/index.js +1 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/cup.coffee +1 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/foo.js +1 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/mug.coffee +0 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/mug.js +0 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/other_path/lib/other-lib.js +0 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver/other_path/root.js +0 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver.js +144 -0
- data/node_modules/module-deps/node_modules/resolve/test/resolver_sync.js +157 -0
- data/node_modules/module-deps/package.json +47 -0
- data/node_modules/module-deps/readme.markdown +128 -0
- data/node_modules/module-deps/test/bundle.js +21 -0
- data/node_modules/module-deps/test/deps.js +42 -0
- data/node_modules/module-deps/test/files/bar.js +3 -0
- data/node_modules/module-deps/test/files/foo.js +5 -0
- data/node_modules/module-deps/test/files/main.js +2 -0
- data/node_modules/module-deps/test/files/tr_module/f.js +1 -0
- data/node_modules/module-deps/test/files/tr_module/main.js +7 -0
- data/node_modules/module-deps/test/files/tr_module/node_modules/g/index.js +1 -0
- data/node_modules/module-deps/test/files/tr_module/node_modules/g/node_modules/insert-ggg/index.js +7 -0
- data/node_modules/module-deps/test/files/tr_module/node_modules/g/package.json +6 -0
- data/node_modules/module-deps/test/files/tr_module/node_modules/insert-aaa/index.js +7 -0
- data/node_modules/module-deps/test/files/tr_module/node_modules/insert-bbb/index.js +7 -0
- data/node_modules/module-deps/test/files/tr_module/node_modules/m/index.js +3 -0
- data/node_modules/module-deps/test/files/tr_sh/f.js +1 -0
- data/node_modules/module-deps/test/files/tr_sh/main.js +7 -0
- data/node_modules/module-deps/test/files/tr_sh/node_modules/g/index.js +1 -0
- data/node_modules/module-deps/test/files/tr_sh/node_modules/g/package.json +6 -0
- data/node_modules/module-deps/test/files/tr_sh/node_modules/g/tr_g.js +6 -0
- data/node_modules/module-deps/test/files/tr_sh/node_modules/m/index.js +3 -0
- data/node_modules/module-deps/test/files/tr_sh/tr_a.js +6 -0
- data/node_modules/module-deps/test/files/tr_sh/tr_b.js +6 -0
- data/node_modules/module-deps/test/files/xyz.js +2 -0
- data/node_modules/module-deps/test/tr_fn.js +29 -0
- data/node_modules/module-deps/test/tr_module.js +21 -0
- data/node_modules/module-deps/test/tr_sh.js +21 -0
- data/node_modules/through/LICENSE.APACHE2 +15 -0
- data/node_modules/through/LICENSE.MIT +24 -0
- data/node_modules/through/index.js +103 -0
- data/node_modules/through/package.json +35 -0
- data/node_modules/through/readme.markdown +43 -0
- data/node_modules/through/test/buffering.js +71 -0
- data/node_modules/through/test/end.js +27 -0
- data/node_modules/through/test/index.js +113 -0
- data/package.json +11 -0
- metadata +846 -0
@@ -0,0 +1,3088 @@
|
|
1
|
+
// Generated by CoffeeScript 1.6.1
|
2
|
+
(function() {
|
3
|
+
var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, CodeFragment, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, last, locationDataToString, merge, multident, some, starts, unfoldSoak, utility, _ref, _ref1,
|
4
|
+
__hasProp = {}.hasOwnProperty,
|
5
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
6
|
+
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
7
|
+
__slice = [].slice;
|
8
|
+
|
9
|
+
Error.stackTraceLimit = Infinity;
|
10
|
+
|
11
|
+
Scope = require('./scope').Scope;
|
12
|
+
|
13
|
+
_ref = require('./lexer'), RESERVED = _ref.RESERVED, STRICT_PROSCRIBED = _ref.STRICT_PROSCRIBED;
|
14
|
+
|
15
|
+
_ref1 = require('./helpers'), compact = _ref1.compact, flatten = _ref1.flatten, extend = _ref1.extend, merge = _ref1.merge, del = _ref1.del, starts = _ref1.starts, ends = _ref1.ends, last = _ref1.last, some = _ref1.some, addLocationDataFn = _ref1.addLocationDataFn, locationDataToString = _ref1.locationDataToString;
|
16
|
+
|
17
|
+
exports.extend = extend;
|
18
|
+
|
19
|
+
exports.addLocationDataFn = addLocationDataFn;
|
20
|
+
|
21
|
+
YES = function() {
|
22
|
+
return true;
|
23
|
+
};
|
24
|
+
|
25
|
+
NO = function() {
|
26
|
+
return false;
|
27
|
+
};
|
28
|
+
|
29
|
+
THIS = function() {
|
30
|
+
return this;
|
31
|
+
};
|
32
|
+
|
33
|
+
NEGATE = function() {
|
34
|
+
this.negated = !this.negated;
|
35
|
+
return this;
|
36
|
+
};
|
37
|
+
|
38
|
+
exports.CodeFragment = CodeFragment = (function() {
|
39
|
+
|
40
|
+
function CodeFragment(parent, code) {
|
41
|
+
var _ref2;
|
42
|
+
this.code = "" + code;
|
43
|
+
this.locationData = parent != null ? parent.locationData : void 0;
|
44
|
+
this.type = (parent != null ? (_ref2 = parent.constructor) != null ? _ref2.name : void 0 : void 0) || 'unknown';
|
45
|
+
}
|
46
|
+
|
47
|
+
CodeFragment.prototype.toString = function() {
|
48
|
+
return "" + this.code + [this.locationData ? ": " + locationDataToString(this.locationData) : void 0];
|
49
|
+
};
|
50
|
+
|
51
|
+
return CodeFragment;
|
52
|
+
|
53
|
+
})();
|
54
|
+
|
55
|
+
fragmentsToText = function(fragments) {
|
56
|
+
var fragment;
|
57
|
+
return ((function() {
|
58
|
+
var _i, _len, _results;
|
59
|
+
_results = [];
|
60
|
+
for (_i = 0, _len = fragments.length; _i < _len; _i++) {
|
61
|
+
fragment = fragments[_i];
|
62
|
+
_results.push(fragment.code);
|
63
|
+
}
|
64
|
+
return _results;
|
65
|
+
})()).join('');
|
66
|
+
};
|
67
|
+
|
68
|
+
exports.Base = Base = (function() {
|
69
|
+
|
70
|
+
function Base() {}
|
71
|
+
|
72
|
+
Base.prototype.compile = function(o, lvl) {
|
73
|
+
return fragmentsToText(this.compileToFragments(o, lvl));
|
74
|
+
};
|
75
|
+
|
76
|
+
Base.prototype.compileToFragments = function(o, lvl) {
|
77
|
+
var node;
|
78
|
+
o = extend({}, o);
|
79
|
+
if (lvl) {
|
80
|
+
o.level = lvl;
|
81
|
+
}
|
82
|
+
node = this.unfoldSoak(o) || this;
|
83
|
+
node.tab = o.indent;
|
84
|
+
if (o.level === LEVEL_TOP || !node.isStatement(o)) {
|
85
|
+
return node.compileNode(o);
|
86
|
+
} else {
|
87
|
+
return node.compileClosure(o);
|
88
|
+
}
|
89
|
+
};
|
90
|
+
|
91
|
+
Base.prototype.compileClosure = function(o) {
|
92
|
+
if (this.jumps()) {
|
93
|
+
throw SyntaxError('cannot use a pure statement in an expression.');
|
94
|
+
}
|
95
|
+
o.sharedScope = true;
|
96
|
+
return Closure.wrap(this).compileNode(o);
|
97
|
+
};
|
98
|
+
|
99
|
+
Base.prototype.cache = function(o, level, reused) {
|
100
|
+
var ref, sub;
|
101
|
+
if (!this.isComplex()) {
|
102
|
+
ref = level ? this.compileToFragments(o, level) : this;
|
103
|
+
return [ref, ref];
|
104
|
+
} else {
|
105
|
+
ref = new Literal(reused || o.scope.freeVariable('ref'));
|
106
|
+
sub = new Assign(ref, this);
|
107
|
+
if (level) {
|
108
|
+
return [sub.compileToFragments(o, level), [this.makeCode(ref.value)]];
|
109
|
+
} else {
|
110
|
+
return [sub, ref];
|
111
|
+
}
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
Base.prototype.cacheToCodeFragments = function(cacheValues) {
|
116
|
+
return [fragmentsToText(cacheValues[0]), fragmentsToText(cacheValues[1])];
|
117
|
+
};
|
118
|
+
|
119
|
+
Base.prototype.makeReturn = function(res) {
|
120
|
+
var me;
|
121
|
+
me = this.unwrapAll();
|
122
|
+
if (res) {
|
123
|
+
return new Call(new Literal("" + res + ".push"), [me]);
|
124
|
+
} else {
|
125
|
+
return new Return(me);
|
126
|
+
}
|
127
|
+
};
|
128
|
+
|
129
|
+
Base.prototype.contains = function(pred) {
|
130
|
+
var contains;
|
131
|
+
contains = false;
|
132
|
+
this.traverseChildren(false, function(node) {
|
133
|
+
if (pred(node)) {
|
134
|
+
contains = true;
|
135
|
+
return false;
|
136
|
+
}
|
137
|
+
});
|
138
|
+
return contains;
|
139
|
+
};
|
140
|
+
|
141
|
+
Base.prototype.containsType = function(type) {
|
142
|
+
return this instanceof type || this.contains(function(node) {
|
143
|
+
return node instanceof type;
|
144
|
+
});
|
145
|
+
};
|
146
|
+
|
147
|
+
Base.prototype.lastNonComment = function(list) {
|
148
|
+
var i;
|
149
|
+
i = list.length;
|
150
|
+
while (i--) {
|
151
|
+
if (!(list[i] instanceof Comment)) {
|
152
|
+
return list[i];
|
153
|
+
}
|
154
|
+
}
|
155
|
+
return null;
|
156
|
+
};
|
157
|
+
|
158
|
+
Base.prototype.toString = function(idt, name) {
|
159
|
+
var location, tree;
|
160
|
+
if (idt == null) {
|
161
|
+
idt = '';
|
162
|
+
}
|
163
|
+
if (name == null) {
|
164
|
+
name = this.constructor.name;
|
165
|
+
}
|
166
|
+
location = this.locationData ? locationDataToString(this.locationData) : "??";
|
167
|
+
tree = '\n' + idt + location + ": " + name;
|
168
|
+
if (this.soak) {
|
169
|
+
tree += '?';
|
170
|
+
}
|
171
|
+
this.eachChild(function(node) {
|
172
|
+
return tree += node.toString(idt + TAB);
|
173
|
+
});
|
174
|
+
return tree;
|
175
|
+
};
|
176
|
+
|
177
|
+
Base.prototype.eachChild = function(func) {
|
178
|
+
var attr, child, _i, _j, _len, _len1, _ref2, _ref3;
|
179
|
+
if (!this.children) {
|
180
|
+
return this;
|
181
|
+
}
|
182
|
+
_ref2 = this.children;
|
183
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
184
|
+
attr = _ref2[_i];
|
185
|
+
if (this[attr]) {
|
186
|
+
_ref3 = flatten([this[attr]]);
|
187
|
+
for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
|
188
|
+
child = _ref3[_j];
|
189
|
+
if (func(child) === false) {
|
190
|
+
return this;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
return this;
|
196
|
+
};
|
197
|
+
|
198
|
+
Base.prototype.traverseChildren = function(crossScope, func) {
|
199
|
+
return this.eachChild(function(child) {
|
200
|
+
if (func(child) === false) {
|
201
|
+
return false;
|
202
|
+
}
|
203
|
+
return child.traverseChildren(crossScope, func);
|
204
|
+
});
|
205
|
+
};
|
206
|
+
|
207
|
+
Base.prototype.invert = function() {
|
208
|
+
return new Op('!', this);
|
209
|
+
};
|
210
|
+
|
211
|
+
Base.prototype.unwrapAll = function() {
|
212
|
+
var node;
|
213
|
+
node = this;
|
214
|
+
while (node !== (node = node.unwrap())) {
|
215
|
+
continue;
|
216
|
+
}
|
217
|
+
return node;
|
218
|
+
};
|
219
|
+
|
220
|
+
Base.prototype.children = [];
|
221
|
+
|
222
|
+
Base.prototype.isStatement = NO;
|
223
|
+
|
224
|
+
Base.prototype.jumps = NO;
|
225
|
+
|
226
|
+
Base.prototype.isComplex = YES;
|
227
|
+
|
228
|
+
Base.prototype.isChainable = NO;
|
229
|
+
|
230
|
+
Base.prototype.isAssignable = NO;
|
231
|
+
|
232
|
+
Base.prototype.unwrap = THIS;
|
233
|
+
|
234
|
+
Base.prototype.unfoldSoak = NO;
|
235
|
+
|
236
|
+
Base.prototype.assigns = NO;
|
237
|
+
|
238
|
+
Base.prototype.updateLocationDataIfMissing = function(locationData) {
|
239
|
+
if (!this.locationData) {
|
240
|
+
this.locationData = {};
|
241
|
+
extend(this.locationData, locationData);
|
242
|
+
}
|
243
|
+
return this.eachChild(function(child) {
|
244
|
+
return child.updateLocationDataIfMissing(locationData);
|
245
|
+
});
|
246
|
+
};
|
247
|
+
|
248
|
+
Base.prototype.makeCode = function(code) {
|
249
|
+
return new CodeFragment(this, code);
|
250
|
+
};
|
251
|
+
|
252
|
+
Base.prototype.wrapInBraces = function(fragments) {
|
253
|
+
return [].concat(this.makeCode('('), fragments, this.makeCode(')'));
|
254
|
+
};
|
255
|
+
|
256
|
+
Base.prototype.joinFragmentArrays = function(fragmentsList, joinStr) {
|
257
|
+
var answer, fragments, i, _i, _len;
|
258
|
+
answer = [];
|
259
|
+
for (i = _i = 0, _len = fragmentsList.length; _i < _len; i = ++_i) {
|
260
|
+
fragments = fragmentsList[i];
|
261
|
+
if (i) {
|
262
|
+
answer.push(this.makeCode(joinStr));
|
263
|
+
}
|
264
|
+
answer = answer.concat(fragments);
|
265
|
+
}
|
266
|
+
return answer;
|
267
|
+
};
|
268
|
+
|
269
|
+
return Base;
|
270
|
+
|
271
|
+
})();
|
272
|
+
|
273
|
+
exports.Block = Block = (function(_super) {
|
274
|
+
|
275
|
+
__extends(Block, _super);
|
276
|
+
|
277
|
+
function Block(nodes) {
|
278
|
+
this.expressions = compact(flatten(nodes || []));
|
279
|
+
}
|
280
|
+
|
281
|
+
Block.prototype.children = ['expressions'];
|
282
|
+
|
283
|
+
Block.prototype.push = function(node) {
|
284
|
+
this.expressions.push(node);
|
285
|
+
return this;
|
286
|
+
};
|
287
|
+
|
288
|
+
Block.prototype.pop = function() {
|
289
|
+
return this.expressions.pop();
|
290
|
+
};
|
291
|
+
|
292
|
+
Block.prototype.unshift = function(node) {
|
293
|
+
this.expressions.unshift(node);
|
294
|
+
return this;
|
295
|
+
};
|
296
|
+
|
297
|
+
Block.prototype.unwrap = function() {
|
298
|
+
if (this.expressions.length === 1) {
|
299
|
+
return this.expressions[0];
|
300
|
+
} else {
|
301
|
+
return this;
|
302
|
+
}
|
303
|
+
};
|
304
|
+
|
305
|
+
Block.prototype.isEmpty = function() {
|
306
|
+
return !this.expressions.length;
|
307
|
+
};
|
308
|
+
|
309
|
+
Block.prototype.isStatement = function(o) {
|
310
|
+
var exp, _i, _len, _ref2;
|
311
|
+
_ref2 = this.expressions;
|
312
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
313
|
+
exp = _ref2[_i];
|
314
|
+
if (exp.isStatement(o)) {
|
315
|
+
return true;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
return false;
|
319
|
+
};
|
320
|
+
|
321
|
+
Block.prototype.jumps = function(o) {
|
322
|
+
var exp, _i, _len, _ref2;
|
323
|
+
_ref2 = this.expressions;
|
324
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
325
|
+
exp = _ref2[_i];
|
326
|
+
if (exp.jumps(o)) {
|
327
|
+
return exp;
|
328
|
+
}
|
329
|
+
}
|
330
|
+
};
|
331
|
+
|
332
|
+
Block.prototype.makeReturn = function(res) {
|
333
|
+
var expr, len;
|
334
|
+
len = this.expressions.length;
|
335
|
+
while (len--) {
|
336
|
+
expr = this.expressions[len];
|
337
|
+
if (!(expr instanceof Comment)) {
|
338
|
+
this.expressions[len] = expr.makeReturn(res);
|
339
|
+
if (expr instanceof Return && !expr.expression) {
|
340
|
+
this.expressions.splice(len, 1);
|
341
|
+
}
|
342
|
+
break;
|
343
|
+
}
|
344
|
+
}
|
345
|
+
return this;
|
346
|
+
};
|
347
|
+
|
348
|
+
Block.prototype.compileToFragments = function(o, level) {
|
349
|
+
if (o == null) {
|
350
|
+
o = {};
|
351
|
+
}
|
352
|
+
if (o.scope) {
|
353
|
+
return Block.__super__.compileToFragments.call(this, o, level);
|
354
|
+
} else {
|
355
|
+
return this.compileRoot(o);
|
356
|
+
}
|
357
|
+
};
|
358
|
+
|
359
|
+
Block.prototype.compileNode = function(o) {
|
360
|
+
var answer, compiledNodes, fragments, index, node, top, _i, _len, _ref2;
|
361
|
+
this.tab = o.indent;
|
362
|
+
top = o.level === LEVEL_TOP;
|
363
|
+
compiledNodes = [];
|
364
|
+
_ref2 = this.expressions;
|
365
|
+
for (index = _i = 0, _len = _ref2.length; _i < _len; index = ++_i) {
|
366
|
+
node = _ref2[index];
|
367
|
+
node = node.unwrapAll();
|
368
|
+
node = node.unfoldSoak(o) || node;
|
369
|
+
if (node instanceof Block) {
|
370
|
+
compiledNodes.push(node.compileNode(o));
|
371
|
+
} else if (top) {
|
372
|
+
node.front = true;
|
373
|
+
fragments = node.compileToFragments(o);
|
374
|
+
if (!node.isStatement(o)) {
|
375
|
+
fragments.unshift(this.makeCode("" + this.tab));
|
376
|
+
fragments.push(this.makeCode(";"));
|
377
|
+
}
|
378
|
+
compiledNodes.push(fragments);
|
379
|
+
} else {
|
380
|
+
compiledNodes.push(node.compileToFragments(o, LEVEL_LIST));
|
381
|
+
}
|
382
|
+
}
|
383
|
+
if (top) {
|
384
|
+
if (this.spaced) {
|
385
|
+
return [].concat(this.makeCode("\n"), this.joinFragmentArrays(compiledNodes, '\n\n'), this.makeCode("\n"));
|
386
|
+
} else {
|
387
|
+
return this.joinFragmentArrays(compiledNodes, '\n');
|
388
|
+
}
|
389
|
+
}
|
390
|
+
if (compiledNodes.length) {
|
391
|
+
answer = this.joinFragmentArrays(compiledNodes, ', ');
|
392
|
+
} else {
|
393
|
+
answer = [this.makeCode("void 0")];
|
394
|
+
}
|
395
|
+
if (compiledNodes.length > 1 && o.level >= LEVEL_LIST) {
|
396
|
+
return this.wrapInBraces(answer);
|
397
|
+
} else {
|
398
|
+
return answer;
|
399
|
+
}
|
400
|
+
};
|
401
|
+
|
402
|
+
Block.prototype.compileRoot = function(o) {
|
403
|
+
var exp, fragments, i, prelude, preludeExps, rest;
|
404
|
+
o.indent = o.bare ? '' : TAB;
|
405
|
+
o.scope = new Scope(null, this, null);
|
406
|
+
o.level = LEVEL_TOP;
|
407
|
+
this.spaced = true;
|
408
|
+
prelude = [];
|
409
|
+
if (!o.bare) {
|
410
|
+
preludeExps = (function() {
|
411
|
+
var _i, _len, _ref2, _results;
|
412
|
+
_ref2 = this.expressions;
|
413
|
+
_results = [];
|
414
|
+
for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
|
415
|
+
exp = _ref2[i];
|
416
|
+
if (!(exp.unwrap() instanceof Comment)) {
|
417
|
+
break;
|
418
|
+
}
|
419
|
+
_results.push(exp);
|
420
|
+
}
|
421
|
+
return _results;
|
422
|
+
}).call(this);
|
423
|
+
rest = this.expressions.slice(preludeExps.length);
|
424
|
+
this.expressions = preludeExps;
|
425
|
+
if (preludeExps.length) {
|
426
|
+
prelude = this.compileNode(merge(o, {
|
427
|
+
indent: ''
|
428
|
+
}));
|
429
|
+
prelude.push(this.makeCode("\n"));
|
430
|
+
}
|
431
|
+
this.expressions = rest;
|
432
|
+
}
|
433
|
+
fragments = this.compileWithDeclarations(o);
|
434
|
+
if (o.bare) {
|
435
|
+
return fragments;
|
436
|
+
}
|
437
|
+
return [].concat(prelude, this.makeCode("(function() {\n"), fragments, this.makeCode("\n}).call(this);\n"));
|
438
|
+
};
|
439
|
+
|
440
|
+
Block.prototype.compileWithDeclarations = function(o) {
|
441
|
+
var assigns, declars, exp, fragments, i, post, rest, scope, spaced, _i, _len, _ref2, _ref3, _ref4;
|
442
|
+
fragments = [];
|
443
|
+
post = [];
|
444
|
+
_ref2 = this.expressions;
|
445
|
+
for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
|
446
|
+
exp = _ref2[i];
|
447
|
+
exp = exp.unwrap();
|
448
|
+
if (!(exp instanceof Comment || exp instanceof Literal)) {
|
449
|
+
break;
|
450
|
+
}
|
451
|
+
}
|
452
|
+
o = merge(o, {
|
453
|
+
level: LEVEL_TOP
|
454
|
+
});
|
455
|
+
if (i) {
|
456
|
+
rest = this.expressions.splice(i, 9e9);
|
457
|
+
_ref3 = [this.spaced, false], spaced = _ref3[0], this.spaced = _ref3[1];
|
458
|
+
_ref4 = [this.compileNode(o), spaced], fragments = _ref4[0], this.spaced = _ref4[1];
|
459
|
+
this.expressions = rest;
|
460
|
+
}
|
461
|
+
post = this.compileNode(o);
|
462
|
+
scope = o.scope;
|
463
|
+
if (scope.expressions === this) {
|
464
|
+
declars = o.scope.hasDeclarations();
|
465
|
+
assigns = scope.hasAssignments;
|
466
|
+
if (declars || assigns) {
|
467
|
+
if (i) {
|
468
|
+
fragments.push(this.makeCode('\n'));
|
469
|
+
}
|
470
|
+
fragments.push(this.makeCode("" + this.tab + "var "));
|
471
|
+
if (declars) {
|
472
|
+
fragments.push(this.makeCode(scope.declaredVariables().join(', ')));
|
473
|
+
}
|
474
|
+
if (assigns) {
|
475
|
+
if (declars) {
|
476
|
+
fragments.push(this.makeCode(",\n" + (this.tab + TAB)));
|
477
|
+
}
|
478
|
+
fragments.push(this.makeCode(scope.assignedVariables().join(",\n" + (this.tab + TAB))));
|
479
|
+
}
|
480
|
+
fragments.push(this.makeCode(';\n'));
|
481
|
+
}
|
482
|
+
}
|
483
|
+
return fragments.concat(post);
|
484
|
+
};
|
485
|
+
|
486
|
+
Block.wrap = function(nodes) {
|
487
|
+
if (nodes.length === 1 && nodes[0] instanceof Block) {
|
488
|
+
return nodes[0];
|
489
|
+
}
|
490
|
+
return new Block(nodes);
|
491
|
+
};
|
492
|
+
|
493
|
+
return Block;
|
494
|
+
|
495
|
+
})(Base);
|
496
|
+
|
497
|
+
exports.Literal = Literal = (function(_super) {
|
498
|
+
|
499
|
+
__extends(Literal, _super);
|
500
|
+
|
501
|
+
function Literal(value) {
|
502
|
+
this.value = value;
|
503
|
+
}
|
504
|
+
|
505
|
+
Literal.prototype.makeReturn = function() {
|
506
|
+
if (this.isStatement()) {
|
507
|
+
return this;
|
508
|
+
} else {
|
509
|
+
return Literal.__super__.makeReturn.apply(this, arguments);
|
510
|
+
}
|
511
|
+
};
|
512
|
+
|
513
|
+
Literal.prototype.isAssignable = function() {
|
514
|
+
return IDENTIFIER.test(this.value);
|
515
|
+
};
|
516
|
+
|
517
|
+
Literal.prototype.isStatement = function() {
|
518
|
+
var _ref2;
|
519
|
+
return (_ref2 = this.value) === 'break' || _ref2 === 'continue' || _ref2 === 'debugger';
|
520
|
+
};
|
521
|
+
|
522
|
+
Literal.prototype.isComplex = NO;
|
523
|
+
|
524
|
+
Literal.prototype.assigns = function(name) {
|
525
|
+
return name === this.value;
|
526
|
+
};
|
527
|
+
|
528
|
+
Literal.prototype.jumps = function(o) {
|
529
|
+
if (this.value === 'break' && !((o != null ? o.loop : void 0) || (o != null ? o.block : void 0))) {
|
530
|
+
return this;
|
531
|
+
}
|
532
|
+
if (this.value === 'continue' && !(o != null ? o.loop : void 0)) {
|
533
|
+
return this;
|
534
|
+
}
|
535
|
+
};
|
536
|
+
|
537
|
+
Literal.prototype.compileNode = function(o) {
|
538
|
+
var answer, code, _ref2;
|
539
|
+
code = this.value === 'this' ? ((_ref2 = o.scope.method) != null ? _ref2.bound : void 0) ? o.scope.method.context : this.value : this.value.reserved ? "\"" + this.value + "\"" : this.value;
|
540
|
+
answer = this.isStatement() ? "" + this.tab + code + ";" : code;
|
541
|
+
return [this.makeCode(answer)];
|
542
|
+
};
|
543
|
+
|
544
|
+
Literal.prototype.toString = function() {
|
545
|
+
return ' "' + this.value + '"';
|
546
|
+
};
|
547
|
+
|
548
|
+
return Literal;
|
549
|
+
|
550
|
+
})(Base);
|
551
|
+
|
552
|
+
exports.Undefined = (function(_super) {
|
553
|
+
|
554
|
+
__extends(Undefined, _super);
|
555
|
+
|
556
|
+
function Undefined() {
|
557
|
+
return Undefined.__super__.constructor.apply(this, arguments);
|
558
|
+
}
|
559
|
+
|
560
|
+
Undefined.prototype.isAssignable = NO;
|
561
|
+
|
562
|
+
Undefined.prototype.isComplex = NO;
|
563
|
+
|
564
|
+
Undefined.prototype.compileNode = function(o) {
|
565
|
+
return [this.makeCode(o.level >= LEVEL_ACCESS ? '(void 0)' : 'void 0')];
|
566
|
+
};
|
567
|
+
|
568
|
+
return Undefined;
|
569
|
+
|
570
|
+
})(Base);
|
571
|
+
|
572
|
+
exports.Null = (function(_super) {
|
573
|
+
|
574
|
+
__extends(Null, _super);
|
575
|
+
|
576
|
+
function Null() {
|
577
|
+
return Null.__super__.constructor.apply(this, arguments);
|
578
|
+
}
|
579
|
+
|
580
|
+
Null.prototype.isAssignable = NO;
|
581
|
+
|
582
|
+
Null.prototype.isComplex = NO;
|
583
|
+
|
584
|
+
Null.prototype.compileNode = function() {
|
585
|
+
return [this.makeCode("null")];
|
586
|
+
};
|
587
|
+
|
588
|
+
return Null;
|
589
|
+
|
590
|
+
})(Base);
|
591
|
+
|
592
|
+
exports.Bool = (function(_super) {
|
593
|
+
|
594
|
+
__extends(Bool, _super);
|
595
|
+
|
596
|
+
Bool.prototype.isAssignable = NO;
|
597
|
+
|
598
|
+
Bool.prototype.isComplex = NO;
|
599
|
+
|
600
|
+
Bool.prototype.compileNode = function() {
|
601
|
+
return [this.makeCode(this.val)];
|
602
|
+
};
|
603
|
+
|
604
|
+
function Bool(val) {
|
605
|
+
this.val = val;
|
606
|
+
}
|
607
|
+
|
608
|
+
return Bool;
|
609
|
+
|
610
|
+
})(Base);
|
611
|
+
|
612
|
+
exports.Return = Return = (function(_super) {
|
613
|
+
|
614
|
+
__extends(Return, _super);
|
615
|
+
|
616
|
+
function Return(expr) {
|
617
|
+
if (expr && !expr.unwrap().isUndefined) {
|
618
|
+
this.expression = expr;
|
619
|
+
}
|
620
|
+
}
|
621
|
+
|
622
|
+
Return.prototype.children = ['expression'];
|
623
|
+
|
624
|
+
Return.prototype.isStatement = YES;
|
625
|
+
|
626
|
+
Return.prototype.makeReturn = THIS;
|
627
|
+
|
628
|
+
Return.prototype.jumps = THIS;
|
629
|
+
|
630
|
+
Return.prototype.compileToFragments = function(o, level) {
|
631
|
+
var expr, _ref2;
|
632
|
+
expr = (_ref2 = this.expression) != null ? _ref2.makeReturn() : void 0;
|
633
|
+
if (expr && !(expr instanceof Return)) {
|
634
|
+
return expr.compileToFragments(o, level);
|
635
|
+
} else {
|
636
|
+
return Return.__super__.compileToFragments.call(this, o, level);
|
637
|
+
}
|
638
|
+
};
|
639
|
+
|
640
|
+
Return.prototype.compileNode = function(o) {
|
641
|
+
var answer;
|
642
|
+
answer = [];
|
643
|
+
answer.push(this.makeCode(this.tab + ("return" + [this.expression ? " " : void 0])));
|
644
|
+
if (this.expression) {
|
645
|
+
answer = answer.concat(this.expression.compileToFragments(o, LEVEL_PAREN));
|
646
|
+
}
|
647
|
+
answer.push(this.makeCode(";"));
|
648
|
+
return answer;
|
649
|
+
};
|
650
|
+
|
651
|
+
return Return;
|
652
|
+
|
653
|
+
})(Base);
|
654
|
+
|
655
|
+
exports.Value = Value = (function(_super) {
|
656
|
+
|
657
|
+
__extends(Value, _super);
|
658
|
+
|
659
|
+
function Value(base, props, tag) {
|
660
|
+
if (!props && base instanceof Value) {
|
661
|
+
return base;
|
662
|
+
}
|
663
|
+
this.base = base;
|
664
|
+
this.properties = props || [];
|
665
|
+
if (tag) {
|
666
|
+
this[tag] = true;
|
667
|
+
}
|
668
|
+
return this;
|
669
|
+
}
|
670
|
+
|
671
|
+
Value.prototype.children = ['base', 'properties'];
|
672
|
+
|
673
|
+
Value.prototype.add = function(props) {
|
674
|
+
this.properties = this.properties.concat(props);
|
675
|
+
return this;
|
676
|
+
};
|
677
|
+
|
678
|
+
Value.prototype.hasProperties = function() {
|
679
|
+
return !!this.properties.length;
|
680
|
+
};
|
681
|
+
|
682
|
+
Value.prototype.isArray = function() {
|
683
|
+
return !this.properties.length && this.base instanceof Arr;
|
684
|
+
};
|
685
|
+
|
686
|
+
Value.prototype.isComplex = function() {
|
687
|
+
return this.hasProperties() || this.base.isComplex();
|
688
|
+
};
|
689
|
+
|
690
|
+
Value.prototype.isAssignable = function() {
|
691
|
+
return this.hasProperties() || this.base.isAssignable();
|
692
|
+
};
|
693
|
+
|
694
|
+
Value.prototype.isSimpleNumber = function() {
|
695
|
+
return this.base instanceof Literal && SIMPLENUM.test(this.base.value);
|
696
|
+
};
|
697
|
+
|
698
|
+
Value.prototype.isString = function() {
|
699
|
+
return this.base instanceof Literal && IS_STRING.test(this.base.value);
|
700
|
+
};
|
701
|
+
|
702
|
+
Value.prototype.isAtomic = function() {
|
703
|
+
var node, _i, _len, _ref2;
|
704
|
+
_ref2 = this.properties.concat(this.base);
|
705
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
706
|
+
node = _ref2[_i];
|
707
|
+
if (node.soak || node instanceof Call) {
|
708
|
+
return false;
|
709
|
+
}
|
710
|
+
}
|
711
|
+
return true;
|
712
|
+
};
|
713
|
+
|
714
|
+
Value.prototype.isStatement = function(o) {
|
715
|
+
return !this.properties.length && this.base.isStatement(o);
|
716
|
+
};
|
717
|
+
|
718
|
+
Value.prototype.assigns = function(name) {
|
719
|
+
return !this.properties.length && this.base.assigns(name);
|
720
|
+
};
|
721
|
+
|
722
|
+
Value.prototype.jumps = function(o) {
|
723
|
+
return !this.properties.length && this.base.jumps(o);
|
724
|
+
};
|
725
|
+
|
726
|
+
Value.prototype.isObject = function(onlyGenerated) {
|
727
|
+
if (this.properties.length) {
|
728
|
+
return false;
|
729
|
+
}
|
730
|
+
return (this.base instanceof Obj) && (!onlyGenerated || this.base.generated);
|
731
|
+
};
|
732
|
+
|
733
|
+
Value.prototype.isSplice = function() {
|
734
|
+
return last(this.properties) instanceof Slice;
|
735
|
+
};
|
736
|
+
|
737
|
+
Value.prototype.unwrap = function() {
|
738
|
+
if (this.properties.length) {
|
739
|
+
return this;
|
740
|
+
} else {
|
741
|
+
return this.base;
|
742
|
+
}
|
743
|
+
};
|
744
|
+
|
745
|
+
Value.prototype.cacheReference = function(o) {
|
746
|
+
var base, bref, name, nref;
|
747
|
+
name = last(this.properties);
|
748
|
+
if (this.properties.length < 2 && !this.base.isComplex() && !(name != null ? name.isComplex() : void 0)) {
|
749
|
+
return [this, this];
|
750
|
+
}
|
751
|
+
base = new Value(this.base, this.properties.slice(0, -1));
|
752
|
+
if (base.isComplex()) {
|
753
|
+
bref = new Literal(o.scope.freeVariable('base'));
|
754
|
+
base = new Value(new Parens(new Assign(bref, base)));
|
755
|
+
}
|
756
|
+
if (!name) {
|
757
|
+
return [base, bref];
|
758
|
+
}
|
759
|
+
if (name.isComplex()) {
|
760
|
+
nref = new Literal(o.scope.freeVariable('name'));
|
761
|
+
name = new Index(new Assign(nref, name.index));
|
762
|
+
nref = new Index(nref);
|
763
|
+
}
|
764
|
+
return [base.add(name), new Value(bref || base.base, [nref || name])];
|
765
|
+
};
|
766
|
+
|
767
|
+
Value.prototype.compileNode = function(o) {
|
768
|
+
var fragments, prop, props, _i, _len;
|
769
|
+
this.base.front = this.front;
|
770
|
+
props = this.properties;
|
771
|
+
fragments = this.base.compileToFragments(o, (props.length ? LEVEL_ACCESS : null));
|
772
|
+
if ((this.base instanceof Parens || props.length) && SIMPLENUM.test(fragmentsToText(fragments))) {
|
773
|
+
fragments.push(this.makeCode('.'));
|
774
|
+
}
|
775
|
+
for (_i = 0, _len = props.length; _i < _len; _i++) {
|
776
|
+
prop = props[_i];
|
777
|
+
fragments.push.apply(fragments, prop.compileToFragments(o));
|
778
|
+
}
|
779
|
+
return fragments;
|
780
|
+
};
|
781
|
+
|
782
|
+
Value.prototype.unfoldSoak = function(o) {
|
783
|
+
var _ref2,
|
784
|
+
_this = this;
|
785
|
+
return (_ref2 = this.unfoldedSoak) != null ? _ref2 : this.unfoldedSoak = (function() {
|
786
|
+
var fst, i, ifn, prop, ref, snd, _i, _len, _ref3, _ref4;
|
787
|
+
if (ifn = _this.base.unfoldSoak(o)) {
|
788
|
+
(_ref3 = ifn.body.properties).push.apply(_ref3, _this.properties);
|
789
|
+
return ifn;
|
790
|
+
}
|
791
|
+
_ref4 = _this.properties;
|
792
|
+
for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) {
|
793
|
+
prop = _ref4[i];
|
794
|
+
if (!prop.soak) {
|
795
|
+
continue;
|
796
|
+
}
|
797
|
+
prop.soak = false;
|
798
|
+
fst = new Value(_this.base, _this.properties.slice(0, i));
|
799
|
+
snd = new Value(_this.base, _this.properties.slice(i));
|
800
|
+
if (fst.isComplex()) {
|
801
|
+
ref = new Literal(o.scope.freeVariable('ref'));
|
802
|
+
fst = new Parens(new Assign(ref, fst));
|
803
|
+
snd.base = ref;
|
804
|
+
}
|
805
|
+
return new If(new Existence(fst), snd, {
|
806
|
+
soak: true
|
807
|
+
});
|
808
|
+
}
|
809
|
+
return false;
|
810
|
+
})();
|
811
|
+
};
|
812
|
+
|
813
|
+
return Value;
|
814
|
+
|
815
|
+
})(Base);
|
816
|
+
|
817
|
+
exports.Comment = Comment = (function(_super) {
|
818
|
+
|
819
|
+
__extends(Comment, _super);
|
820
|
+
|
821
|
+
function Comment(comment) {
|
822
|
+
this.comment = comment;
|
823
|
+
}
|
824
|
+
|
825
|
+
Comment.prototype.isStatement = YES;
|
826
|
+
|
827
|
+
Comment.prototype.makeReturn = THIS;
|
828
|
+
|
829
|
+
Comment.prototype.compileNode = function(o, level) {
|
830
|
+
var code;
|
831
|
+
code = '/*' + multident(this.comment, this.tab) + ("\n" + this.tab + "*/\n");
|
832
|
+
if ((level || o.level) === LEVEL_TOP) {
|
833
|
+
code = o.indent + code;
|
834
|
+
}
|
835
|
+
return [this.makeCode(code)];
|
836
|
+
};
|
837
|
+
|
838
|
+
return Comment;
|
839
|
+
|
840
|
+
})(Base);
|
841
|
+
|
842
|
+
exports.Call = Call = (function(_super) {
|
843
|
+
|
844
|
+
__extends(Call, _super);
|
845
|
+
|
846
|
+
function Call(variable, args, soak) {
|
847
|
+
this.args = args != null ? args : [];
|
848
|
+
this.soak = soak;
|
849
|
+
this.isNew = false;
|
850
|
+
this.isSuper = variable === 'super';
|
851
|
+
this.variable = this.isSuper ? null : variable;
|
852
|
+
}
|
853
|
+
|
854
|
+
Call.prototype.children = ['variable', 'args'];
|
855
|
+
|
856
|
+
Call.prototype.newInstance = function() {
|
857
|
+
var base, _ref2;
|
858
|
+
base = ((_ref2 = this.variable) != null ? _ref2.base : void 0) || this.variable;
|
859
|
+
if (base instanceof Call && !base.isNew) {
|
860
|
+
base.newInstance();
|
861
|
+
} else {
|
862
|
+
this.isNew = true;
|
863
|
+
}
|
864
|
+
return this;
|
865
|
+
};
|
866
|
+
|
867
|
+
Call.prototype.superReference = function(o) {
|
868
|
+
var accesses, method;
|
869
|
+
method = o.scope.namedMethod();
|
870
|
+
if (method != null ? method.klass : void 0) {
|
871
|
+
accesses = [new Access(new Literal('__super__'))];
|
872
|
+
if (method["static"]) {
|
873
|
+
accesses.push(new Access(new Literal('constructor')));
|
874
|
+
}
|
875
|
+
accesses.push(new Access(new Literal(method.name)));
|
876
|
+
return (new Value(new Literal(method.klass), accesses)).compile(o);
|
877
|
+
} else if (method != null ? method.ctor : void 0) {
|
878
|
+
return "" + method.name + ".__super__.constructor";
|
879
|
+
} else {
|
880
|
+
throw SyntaxError('cannot call super outside of an instance method.');
|
881
|
+
}
|
882
|
+
};
|
883
|
+
|
884
|
+
Call.prototype.superThis = function(o) {
|
885
|
+
var method;
|
886
|
+
method = o.scope.method;
|
887
|
+
return (method && !method.klass && method.context) || "this";
|
888
|
+
};
|
889
|
+
|
890
|
+
Call.prototype.unfoldSoak = function(o) {
|
891
|
+
var call, ifn, left, list, rite, _i, _len, _ref2, _ref3;
|
892
|
+
if (this.soak) {
|
893
|
+
if (this.variable) {
|
894
|
+
if (ifn = unfoldSoak(o, this, 'variable')) {
|
895
|
+
return ifn;
|
896
|
+
}
|
897
|
+
_ref2 = new Value(this.variable).cacheReference(o), left = _ref2[0], rite = _ref2[1];
|
898
|
+
} else {
|
899
|
+
left = new Literal(this.superReference(o));
|
900
|
+
rite = new Value(left);
|
901
|
+
}
|
902
|
+
rite = new Call(rite, this.args);
|
903
|
+
rite.isNew = this.isNew;
|
904
|
+
left = new Literal("typeof " + (left.compile(o)) + " === \"function\"");
|
905
|
+
return new If(left, new Value(rite), {
|
906
|
+
soak: true
|
907
|
+
});
|
908
|
+
}
|
909
|
+
call = this;
|
910
|
+
list = [];
|
911
|
+
while (true) {
|
912
|
+
if (call.variable instanceof Call) {
|
913
|
+
list.push(call);
|
914
|
+
call = call.variable;
|
915
|
+
continue;
|
916
|
+
}
|
917
|
+
if (!(call.variable instanceof Value)) {
|
918
|
+
break;
|
919
|
+
}
|
920
|
+
list.push(call);
|
921
|
+
if (!((call = call.variable.base) instanceof Call)) {
|
922
|
+
break;
|
923
|
+
}
|
924
|
+
}
|
925
|
+
_ref3 = list.reverse();
|
926
|
+
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
927
|
+
call = _ref3[_i];
|
928
|
+
if (ifn) {
|
929
|
+
if (call.variable instanceof Call) {
|
930
|
+
call.variable = ifn;
|
931
|
+
} else {
|
932
|
+
call.variable.base = ifn;
|
933
|
+
}
|
934
|
+
}
|
935
|
+
ifn = unfoldSoak(o, call, 'variable');
|
936
|
+
}
|
937
|
+
return ifn;
|
938
|
+
};
|
939
|
+
|
940
|
+
Call.prototype.compileNode = function(o) {
|
941
|
+
var arg, argIndex, compiledArgs, compiledArray, fragments, preface, _i, _len, _ref2, _ref3;
|
942
|
+
if ((_ref2 = this.variable) != null) {
|
943
|
+
_ref2.front = this.front;
|
944
|
+
}
|
945
|
+
compiledArray = Splat.compileSplattedArray(o, this.args, true);
|
946
|
+
if (compiledArray.length) {
|
947
|
+
return this.compileSplat(o, compiledArray);
|
948
|
+
}
|
949
|
+
compiledArgs = [];
|
950
|
+
_ref3 = this.args;
|
951
|
+
for (argIndex = _i = 0, _len = _ref3.length; _i < _len; argIndex = ++_i) {
|
952
|
+
arg = _ref3[argIndex];
|
953
|
+
if (argIndex) {
|
954
|
+
compiledArgs.push(this.makeCode(", "));
|
955
|
+
}
|
956
|
+
compiledArgs.push.apply(compiledArgs, arg.compileToFragments(o, LEVEL_LIST));
|
957
|
+
}
|
958
|
+
fragments = [];
|
959
|
+
if (this.isSuper) {
|
960
|
+
preface = this.superReference(o) + (".call(" + (this.superThis(o)));
|
961
|
+
if (compiledArgs.length) {
|
962
|
+
preface += ", ";
|
963
|
+
}
|
964
|
+
fragments.push(this.makeCode(preface));
|
965
|
+
} else {
|
966
|
+
if (this.isNew) {
|
967
|
+
fragments.push(this.makeCode('new '));
|
968
|
+
}
|
969
|
+
fragments.push.apply(fragments, this.variable.compileToFragments(o, LEVEL_ACCESS));
|
970
|
+
fragments.push(this.makeCode("("));
|
971
|
+
}
|
972
|
+
fragments.push.apply(fragments, compiledArgs);
|
973
|
+
fragments.push(this.makeCode(")"));
|
974
|
+
return fragments;
|
975
|
+
};
|
976
|
+
|
977
|
+
Call.prototype.compileSplat = function(o, splatArgs) {
|
978
|
+
var answer, base, fun, idt, name, ref;
|
979
|
+
if (this.isSuper) {
|
980
|
+
return [].concat(this.makeCode("" + (this.superReference(o)) + ".apply(" + (this.superThis(o)) + ", "), splatArgs, this.makeCode(")"));
|
981
|
+
}
|
982
|
+
if (this.isNew) {
|
983
|
+
idt = this.tab + TAB;
|
984
|
+
return [].concat(this.makeCode("(function(func, args, ctor) {\n" + idt + "ctor.prototype = func.prototype;\n" + idt + "var child = new ctor, result = func.apply(child, args);\n" + idt + "return Object(result) === result ? result : child;\n" + this.tab + "})("), this.variable.compileToFragments(o, LEVEL_LIST), this.makeCode(", "), splatArgs, this.makeCode(", function(){})"));
|
985
|
+
}
|
986
|
+
answer = [];
|
987
|
+
base = new Value(this.variable);
|
988
|
+
if ((name = base.properties.pop()) && base.isComplex()) {
|
989
|
+
ref = o.scope.freeVariable('ref');
|
990
|
+
answer = answer.concat(this.makeCode("(" + ref + " = "), base.compileToFragments(o, LEVEL_LIST), this.makeCode(")"), name.compileToFragments(o));
|
991
|
+
} else {
|
992
|
+
fun = base.compileToFragments(o, LEVEL_ACCESS);
|
993
|
+
if (SIMPLENUM.test(fragmentsToText(fun))) {
|
994
|
+
fun = this.wrapInBraces(fun);
|
995
|
+
}
|
996
|
+
if (name) {
|
997
|
+
ref = fragmentsToText(fun);
|
998
|
+
fun.push.apply(fun, name.compileToFragments(o));
|
999
|
+
} else {
|
1000
|
+
ref = 'null';
|
1001
|
+
}
|
1002
|
+
answer = answer.concat(fun);
|
1003
|
+
}
|
1004
|
+
return answer = answer.concat(this.makeCode(".apply(" + ref + ", "), splatArgs, this.makeCode(")"));
|
1005
|
+
};
|
1006
|
+
|
1007
|
+
return Call;
|
1008
|
+
|
1009
|
+
})(Base);
|
1010
|
+
|
1011
|
+
exports.Extends = Extends = (function(_super) {
|
1012
|
+
|
1013
|
+
__extends(Extends, _super);
|
1014
|
+
|
1015
|
+
function Extends(child, parent) {
|
1016
|
+
this.child = child;
|
1017
|
+
this.parent = parent;
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
Extends.prototype.children = ['child', 'parent'];
|
1021
|
+
|
1022
|
+
Extends.prototype.compileToFragments = function(o) {
|
1023
|
+
return new Call(new Value(new Literal(utility('extends'))), [this.child, this.parent]).compileToFragments(o);
|
1024
|
+
};
|
1025
|
+
|
1026
|
+
return Extends;
|
1027
|
+
|
1028
|
+
})(Base);
|
1029
|
+
|
1030
|
+
exports.Access = Access = (function(_super) {
|
1031
|
+
|
1032
|
+
__extends(Access, _super);
|
1033
|
+
|
1034
|
+
function Access(name, tag) {
|
1035
|
+
this.name = name;
|
1036
|
+
this.name.asKey = true;
|
1037
|
+
this.soak = tag === 'soak';
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
Access.prototype.children = ['name'];
|
1041
|
+
|
1042
|
+
Access.prototype.compileToFragments = function(o) {
|
1043
|
+
var name;
|
1044
|
+
name = this.name.compileToFragments(o);
|
1045
|
+
if (IDENTIFIER.test(fragmentsToText(name))) {
|
1046
|
+
name.unshift(this.makeCode("."));
|
1047
|
+
} else {
|
1048
|
+
name.unshift(this.makeCode("["));
|
1049
|
+
name.push(this.makeCode("]"));
|
1050
|
+
}
|
1051
|
+
return name;
|
1052
|
+
};
|
1053
|
+
|
1054
|
+
Access.prototype.isComplex = NO;
|
1055
|
+
|
1056
|
+
return Access;
|
1057
|
+
|
1058
|
+
})(Base);
|
1059
|
+
|
1060
|
+
exports.Index = Index = (function(_super) {
|
1061
|
+
|
1062
|
+
__extends(Index, _super);
|
1063
|
+
|
1064
|
+
function Index(index) {
|
1065
|
+
this.index = index;
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
Index.prototype.children = ['index'];
|
1069
|
+
|
1070
|
+
Index.prototype.compileToFragments = function(o) {
|
1071
|
+
return [].concat(this.makeCode("["), this.index.compileToFragments(o, LEVEL_PAREN), this.makeCode("]"));
|
1072
|
+
};
|
1073
|
+
|
1074
|
+
Index.prototype.isComplex = function() {
|
1075
|
+
return this.index.isComplex();
|
1076
|
+
};
|
1077
|
+
|
1078
|
+
return Index;
|
1079
|
+
|
1080
|
+
})(Base);
|
1081
|
+
|
1082
|
+
exports.Range = Range = (function(_super) {
|
1083
|
+
|
1084
|
+
__extends(Range, _super);
|
1085
|
+
|
1086
|
+
Range.prototype.children = ['from', 'to'];
|
1087
|
+
|
1088
|
+
function Range(from, to, tag) {
|
1089
|
+
this.from = from;
|
1090
|
+
this.to = to;
|
1091
|
+
this.exclusive = tag === 'exclusive';
|
1092
|
+
this.equals = this.exclusive ? '' : '=';
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
Range.prototype.compileVariables = function(o) {
|
1096
|
+
var step, _ref2, _ref3, _ref4, _ref5;
|
1097
|
+
o = merge(o, {
|
1098
|
+
top: true
|
1099
|
+
});
|
1100
|
+
_ref2 = this.cacheToCodeFragments(this.from.cache(o, LEVEL_LIST)), this.fromC = _ref2[0], this.fromVar = _ref2[1];
|
1101
|
+
_ref3 = this.cacheToCodeFragments(this.to.cache(o, LEVEL_LIST)), this.toC = _ref3[0], this.toVar = _ref3[1];
|
1102
|
+
if (step = del(o, 'step')) {
|
1103
|
+
_ref4 = this.cacheToCodeFragments(step.cache(o, LEVEL_LIST)), this.step = _ref4[0], this.stepVar = _ref4[1];
|
1104
|
+
}
|
1105
|
+
_ref5 = [this.fromVar.match(SIMPLENUM), this.toVar.match(SIMPLENUM)], this.fromNum = _ref5[0], this.toNum = _ref5[1];
|
1106
|
+
if (this.stepVar) {
|
1107
|
+
return this.stepNum = this.stepVar.match(SIMPLENUM);
|
1108
|
+
}
|
1109
|
+
};
|
1110
|
+
|
1111
|
+
Range.prototype.compileNode = function(o) {
|
1112
|
+
var cond, condPart, from, gt, idx, idxName, known, lt, namedIndex, stepPart, to, varPart, _ref2, _ref3;
|
1113
|
+
if (!this.fromVar) {
|
1114
|
+
this.compileVariables(o);
|
1115
|
+
}
|
1116
|
+
if (!o.index) {
|
1117
|
+
return this.compileArray(o);
|
1118
|
+
}
|
1119
|
+
known = this.fromNum && this.toNum;
|
1120
|
+
idx = del(o, 'index');
|
1121
|
+
idxName = del(o, 'name');
|
1122
|
+
namedIndex = idxName && idxName !== idx;
|
1123
|
+
varPart = "" + idx + " = " + this.fromC;
|
1124
|
+
if (this.toC !== this.toVar) {
|
1125
|
+
varPart += ", " + this.toC;
|
1126
|
+
}
|
1127
|
+
if (this.step !== this.stepVar) {
|
1128
|
+
varPart += ", " + this.step;
|
1129
|
+
}
|
1130
|
+
_ref2 = ["" + idx + " <" + this.equals, "" + idx + " >" + this.equals], lt = _ref2[0], gt = _ref2[1];
|
1131
|
+
condPart = this.stepNum ? +this.stepNum > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref3 = [+this.fromNum, +this.toNum], from = _ref3[0], to = _ref3[1], _ref3), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = this.stepVar ? "" + this.stepVar + " > 0" : "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar);
|
1132
|
+
stepPart = this.stepVar ? "" + idx + " += " + this.stepVar : known ? namedIndex ? from <= to ? "++" + idx : "--" + idx : from <= to ? "" + idx + "++" : "" + idx + "--" : namedIndex ? "" + cond + " ? ++" + idx + " : --" + idx : "" + cond + " ? " + idx + "++ : " + idx + "--";
|
1133
|
+
if (namedIndex) {
|
1134
|
+
varPart = "" + idxName + " = " + varPart;
|
1135
|
+
}
|
1136
|
+
if (namedIndex) {
|
1137
|
+
stepPart = "" + idxName + " = " + stepPart;
|
1138
|
+
}
|
1139
|
+
return [this.makeCode("" + varPart + "; " + condPart + "; " + stepPart)];
|
1140
|
+
};
|
1141
|
+
|
1142
|
+
Range.prototype.compileArray = function(o) {
|
1143
|
+
var args, body, cond, hasArgs, i, idt, post, pre, range, result, vars, _i, _ref2, _ref3, _results;
|
1144
|
+
if (this.fromNum && this.toNum && Math.abs(this.fromNum - this.toNum) <= 20) {
|
1145
|
+
range = (function() {
|
1146
|
+
_results = [];
|
1147
|
+
for (var _i = _ref2 = +this.fromNum, _ref3 = +this.toNum; _ref2 <= _ref3 ? _i <= _ref3 : _i >= _ref3; _ref2 <= _ref3 ? _i++ : _i--){ _results.push(_i); }
|
1148
|
+
return _results;
|
1149
|
+
}).apply(this);
|
1150
|
+
if (this.exclusive) {
|
1151
|
+
range.pop();
|
1152
|
+
}
|
1153
|
+
return [this.makeCode("[" + (range.join(', ')) + "]")];
|
1154
|
+
}
|
1155
|
+
idt = this.tab + TAB;
|
1156
|
+
i = o.scope.freeVariable('i');
|
1157
|
+
result = o.scope.freeVariable('results');
|
1158
|
+
pre = "\n" + idt + result + " = [];";
|
1159
|
+
if (this.fromNum && this.toNum) {
|
1160
|
+
o.index = i;
|
1161
|
+
body = fragmentsToText(this.compileNode(o));
|
1162
|
+
} else {
|
1163
|
+
vars = ("" + i + " = " + this.fromC) + (this.toC !== this.toVar ? ", " + this.toC : '');
|
1164
|
+
cond = "" + this.fromVar + " <= " + this.toVar;
|
1165
|
+
body = "var " + vars + "; " + cond + " ? " + i + " <" + this.equals + " " + this.toVar + " : " + i + " >" + this.equals + " " + this.toVar + "; " + cond + " ? " + i + "++ : " + i + "--";
|
1166
|
+
}
|
1167
|
+
post = "{ " + result + ".push(" + i + "); }\n" + idt + "return " + result + ";\n" + o.indent;
|
1168
|
+
hasArgs = function(node) {
|
1169
|
+
return node != null ? node.contains(function(n) {
|
1170
|
+
return n instanceof Literal && n.value === 'arguments' && !n.asKey;
|
1171
|
+
}) : void 0;
|
1172
|
+
};
|
1173
|
+
if (hasArgs(this.from) || hasArgs(this.to)) {
|
1174
|
+
args = ', arguments';
|
1175
|
+
}
|
1176
|
+
return [this.makeCode("(function() {" + pre + "\n" + idt + "for (" + body + ")" + post + "}).apply(this" + (args != null ? args : '') + ")")];
|
1177
|
+
};
|
1178
|
+
|
1179
|
+
return Range;
|
1180
|
+
|
1181
|
+
})(Base);
|
1182
|
+
|
1183
|
+
exports.Slice = Slice = (function(_super) {
|
1184
|
+
|
1185
|
+
__extends(Slice, _super);
|
1186
|
+
|
1187
|
+
Slice.prototype.children = ['range'];
|
1188
|
+
|
1189
|
+
function Slice(range) {
|
1190
|
+
this.range = range;
|
1191
|
+
Slice.__super__.constructor.call(this);
|
1192
|
+
}
|
1193
|
+
|
1194
|
+
Slice.prototype.compileNode = function(o) {
|
1195
|
+
var compiled, compiledText, from, fromCompiled, to, toStr, _ref2;
|
1196
|
+
_ref2 = this.range, to = _ref2.to, from = _ref2.from;
|
1197
|
+
fromCompiled = from && from.compileToFragments(o, LEVEL_PAREN) || [this.makeCode('0')];
|
1198
|
+
if (to) {
|
1199
|
+
compiled = to.compileToFragments(o, LEVEL_PAREN);
|
1200
|
+
compiledText = fragmentsToText(compiled);
|
1201
|
+
if (!(!this.range.exclusive && +compiledText === -1)) {
|
1202
|
+
toStr = ', ' + (this.range.exclusive ? compiledText : SIMPLENUM.test(compiledText) ? "" + (+compiledText + 1) : (compiled = to.compileToFragments(o, LEVEL_ACCESS), "+" + (fragmentsToText(compiled)) + " + 1 || 9e9"));
|
1203
|
+
}
|
1204
|
+
}
|
1205
|
+
return [this.makeCode(".slice(" + (fragmentsToText(fromCompiled)) + (toStr || '') + ")")];
|
1206
|
+
};
|
1207
|
+
|
1208
|
+
return Slice;
|
1209
|
+
|
1210
|
+
})(Base);
|
1211
|
+
|
1212
|
+
exports.Obj = Obj = (function(_super) {
|
1213
|
+
|
1214
|
+
__extends(Obj, _super);
|
1215
|
+
|
1216
|
+
function Obj(props, generated) {
|
1217
|
+
this.generated = generated != null ? generated : false;
|
1218
|
+
this.objects = this.properties = props || [];
|
1219
|
+
}
|
1220
|
+
|
1221
|
+
Obj.prototype.children = ['properties'];
|
1222
|
+
|
1223
|
+
Obj.prototype.compileNode = function(o) {
|
1224
|
+
var answer, i, idt, indent, join, lastNoncom, node, prop, props, _i, _j, _len, _len1;
|
1225
|
+
props = this.properties;
|
1226
|
+
if (!props.length) {
|
1227
|
+
return [this.makeCode(this.front ? '({})' : '{}')];
|
1228
|
+
}
|
1229
|
+
if (this.generated) {
|
1230
|
+
for (_i = 0, _len = props.length; _i < _len; _i++) {
|
1231
|
+
node = props[_i];
|
1232
|
+
if (node instanceof Value) {
|
1233
|
+
throw new Error('cannot have an implicit value in an implicit object');
|
1234
|
+
}
|
1235
|
+
}
|
1236
|
+
}
|
1237
|
+
idt = o.indent += TAB;
|
1238
|
+
lastNoncom = this.lastNonComment(this.properties);
|
1239
|
+
answer = [];
|
1240
|
+
for (i = _j = 0, _len1 = props.length; _j < _len1; i = ++_j) {
|
1241
|
+
prop = props[i];
|
1242
|
+
join = i === props.length - 1 ? '' : prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n';
|
1243
|
+
indent = prop instanceof Comment ? '' : idt;
|
1244
|
+
if (prop instanceof Value && prop["this"]) {
|
1245
|
+
prop = new Assign(prop.properties[0].name, prop, 'object');
|
1246
|
+
}
|
1247
|
+
if (!(prop instanceof Comment)) {
|
1248
|
+
if (!(prop instanceof Assign)) {
|
1249
|
+
prop = new Assign(prop, prop, 'object');
|
1250
|
+
}
|
1251
|
+
(prop.variable.base || prop.variable).asKey = true;
|
1252
|
+
}
|
1253
|
+
if (indent) {
|
1254
|
+
answer.push(this.makeCode(indent));
|
1255
|
+
}
|
1256
|
+
answer.push.apply(answer, prop.compileToFragments(o, LEVEL_TOP));
|
1257
|
+
if (join) {
|
1258
|
+
answer.push(this.makeCode(join));
|
1259
|
+
}
|
1260
|
+
}
|
1261
|
+
answer.unshift(this.makeCode("{" + (props.length && '\n')));
|
1262
|
+
answer.push(this.makeCode("" + (props.length && '\n' + this.tab) + "}"));
|
1263
|
+
if (this.front) {
|
1264
|
+
return this.wrapInBraces(answer);
|
1265
|
+
} else {
|
1266
|
+
return answer;
|
1267
|
+
}
|
1268
|
+
};
|
1269
|
+
|
1270
|
+
Obj.prototype.assigns = function(name) {
|
1271
|
+
var prop, _i, _len, _ref2;
|
1272
|
+
_ref2 = this.properties;
|
1273
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
1274
|
+
prop = _ref2[_i];
|
1275
|
+
if (prop.assigns(name)) {
|
1276
|
+
return true;
|
1277
|
+
}
|
1278
|
+
}
|
1279
|
+
return false;
|
1280
|
+
};
|
1281
|
+
|
1282
|
+
return Obj;
|
1283
|
+
|
1284
|
+
})(Base);
|
1285
|
+
|
1286
|
+
exports.Arr = Arr = (function(_super) {
|
1287
|
+
|
1288
|
+
__extends(Arr, _super);
|
1289
|
+
|
1290
|
+
function Arr(objs) {
|
1291
|
+
this.objects = objs || [];
|
1292
|
+
}
|
1293
|
+
|
1294
|
+
Arr.prototype.children = ['objects'];
|
1295
|
+
|
1296
|
+
Arr.prototype.compileNode = function(o) {
|
1297
|
+
var answer, compiledObjs, fragments, index, obj, _i, _len;
|
1298
|
+
if (!this.objects.length) {
|
1299
|
+
return [this.makeCode('[]')];
|
1300
|
+
}
|
1301
|
+
o.indent += TAB;
|
1302
|
+
answer = Splat.compileSplattedArray(o, this.objects);
|
1303
|
+
if (answer.length) {
|
1304
|
+
return answer;
|
1305
|
+
}
|
1306
|
+
answer = [];
|
1307
|
+
compiledObjs = (function() {
|
1308
|
+
var _i, _len, _ref2, _results;
|
1309
|
+
_ref2 = this.objects;
|
1310
|
+
_results = [];
|
1311
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
1312
|
+
obj = _ref2[_i];
|
1313
|
+
_results.push(obj.compileToFragments(o, LEVEL_LIST));
|
1314
|
+
}
|
1315
|
+
return _results;
|
1316
|
+
}).call(this);
|
1317
|
+
for (index = _i = 0, _len = compiledObjs.length; _i < _len; index = ++_i) {
|
1318
|
+
fragments = compiledObjs[index];
|
1319
|
+
if (index) {
|
1320
|
+
answer.push(this.makeCode(", "));
|
1321
|
+
}
|
1322
|
+
answer.push.apply(answer, fragments);
|
1323
|
+
}
|
1324
|
+
if ((fragmentsToText(answer)).indexOf('\n') >= 0) {
|
1325
|
+
answer.unshift(this.makeCode("[\n" + o.indent));
|
1326
|
+
answer.push(this.makeCode("\n" + this.tab + "]"));
|
1327
|
+
} else {
|
1328
|
+
answer.unshift(this.makeCode("["));
|
1329
|
+
answer.push(this.makeCode("]"));
|
1330
|
+
}
|
1331
|
+
return answer;
|
1332
|
+
};
|
1333
|
+
|
1334
|
+
Arr.prototype.assigns = function(name) {
|
1335
|
+
var obj, _i, _len, _ref2;
|
1336
|
+
_ref2 = this.objects;
|
1337
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
1338
|
+
obj = _ref2[_i];
|
1339
|
+
if (obj.assigns(name)) {
|
1340
|
+
return true;
|
1341
|
+
}
|
1342
|
+
}
|
1343
|
+
return false;
|
1344
|
+
};
|
1345
|
+
|
1346
|
+
return Arr;
|
1347
|
+
|
1348
|
+
})(Base);
|
1349
|
+
|
1350
|
+
exports.Class = Class = (function(_super) {
|
1351
|
+
|
1352
|
+
__extends(Class, _super);
|
1353
|
+
|
1354
|
+
function Class(variable, parent, body) {
|
1355
|
+
this.variable = variable;
|
1356
|
+
this.parent = parent;
|
1357
|
+
this.body = body != null ? body : new Block;
|
1358
|
+
this.boundFuncs = [];
|
1359
|
+
this.body.classBody = true;
|
1360
|
+
}
|
1361
|
+
|
1362
|
+
Class.prototype.children = ['variable', 'parent', 'body'];
|
1363
|
+
|
1364
|
+
Class.prototype.determineName = function() {
|
1365
|
+
var decl, tail;
|
1366
|
+
if (!this.variable) {
|
1367
|
+
return null;
|
1368
|
+
}
|
1369
|
+
decl = (tail = last(this.variable.properties)) ? tail instanceof Access && tail.name.value : this.variable.base.value;
|
1370
|
+
if (__indexOf.call(STRICT_PROSCRIBED, decl) >= 0) {
|
1371
|
+
throw SyntaxError("variable name may not be " + decl);
|
1372
|
+
}
|
1373
|
+
return decl && (decl = IDENTIFIER.test(decl) && decl);
|
1374
|
+
};
|
1375
|
+
|
1376
|
+
Class.prototype.setContext = function(name) {
|
1377
|
+
return this.body.traverseChildren(false, function(node) {
|
1378
|
+
if (node.classBody) {
|
1379
|
+
return false;
|
1380
|
+
}
|
1381
|
+
if (node instanceof Literal && node.value === 'this') {
|
1382
|
+
return node.value = name;
|
1383
|
+
} else if (node instanceof Code) {
|
1384
|
+
node.klass = name;
|
1385
|
+
if (node.bound) {
|
1386
|
+
return node.context = name;
|
1387
|
+
}
|
1388
|
+
}
|
1389
|
+
});
|
1390
|
+
};
|
1391
|
+
|
1392
|
+
Class.prototype.addBoundFunctions = function(o) {
|
1393
|
+
var body, bound, func, lhs, name, rhs, _i, _len, _ref2, _ref3;
|
1394
|
+
if (this.boundFuncs.length) {
|
1395
|
+
o.scope.assign('_this', 'this');
|
1396
|
+
_ref2 = this.boundFuncs;
|
1397
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
1398
|
+
_ref3 = _ref2[_i], name = _ref3[0], func = _ref3[1];
|
1399
|
+
lhs = new Value(new Literal("this"), [new Access(name)]);
|
1400
|
+
body = new Block([new Return(new Literal("" + this.ctor.name + ".prototype." + name.value + ".apply(_this, arguments)"))]);
|
1401
|
+
rhs = new Code(func.params, body, 'boundfunc');
|
1402
|
+
bound = new Assign(lhs, rhs);
|
1403
|
+
this.ctor.body.unshift(bound);
|
1404
|
+
}
|
1405
|
+
}
|
1406
|
+
};
|
1407
|
+
|
1408
|
+
Class.prototype.addProperties = function(node, name, o) {
|
1409
|
+
var assign, base, exprs, func, props;
|
1410
|
+
props = node.base.properties.slice(0);
|
1411
|
+
exprs = (function() {
|
1412
|
+
var _results;
|
1413
|
+
_results = [];
|
1414
|
+
while (assign = props.shift()) {
|
1415
|
+
if (assign instanceof Assign) {
|
1416
|
+
base = assign.variable.base;
|
1417
|
+
delete assign.context;
|
1418
|
+
func = assign.value;
|
1419
|
+
if (base.value === 'constructor') {
|
1420
|
+
if (this.ctor) {
|
1421
|
+
throw new Error('cannot define more than one constructor in a class');
|
1422
|
+
}
|
1423
|
+
if (func.bound) {
|
1424
|
+
throw new Error('cannot define a constructor as a bound function');
|
1425
|
+
}
|
1426
|
+
if (func instanceof Code) {
|
1427
|
+
assign = this.ctor = func;
|
1428
|
+
} else {
|
1429
|
+
this.externalCtor = o.scope.freeVariable('class');
|
1430
|
+
assign = new Assign(new Literal(this.externalCtor), func);
|
1431
|
+
}
|
1432
|
+
} else {
|
1433
|
+
if (assign.variable["this"]) {
|
1434
|
+
func["static"] = true;
|
1435
|
+
if (func.bound) {
|
1436
|
+
func.context = name;
|
1437
|
+
}
|
1438
|
+
} else {
|
1439
|
+
assign.variable = new Value(new Literal(name), [new Access(new Literal('prototype')), new Access(base)]);
|
1440
|
+
if (func instanceof Code && func.bound) {
|
1441
|
+
this.boundFuncs.push([base, func]);
|
1442
|
+
func.bound = false;
|
1443
|
+
}
|
1444
|
+
}
|
1445
|
+
}
|
1446
|
+
}
|
1447
|
+
_results.push(assign);
|
1448
|
+
}
|
1449
|
+
return _results;
|
1450
|
+
}).call(this);
|
1451
|
+
return compact(exprs);
|
1452
|
+
};
|
1453
|
+
|
1454
|
+
Class.prototype.walkBody = function(name, o) {
|
1455
|
+
var _this = this;
|
1456
|
+
return this.traverseChildren(false, function(child) {
|
1457
|
+
var cont, exps, i, node, _i, _len, _ref2;
|
1458
|
+
cont = true;
|
1459
|
+
if (child instanceof Class) {
|
1460
|
+
return false;
|
1461
|
+
}
|
1462
|
+
if (child instanceof Block) {
|
1463
|
+
_ref2 = exps = child.expressions;
|
1464
|
+
for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
|
1465
|
+
node = _ref2[i];
|
1466
|
+
if (node instanceof Value && node.isObject(true)) {
|
1467
|
+
cont = false;
|
1468
|
+
exps[i] = _this.addProperties(node, name, o);
|
1469
|
+
}
|
1470
|
+
}
|
1471
|
+
child.expressions = exps = flatten(exps);
|
1472
|
+
}
|
1473
|
+
return cont && !(child instanceof Class);
|
1474
|
+
});
|
1475
|
+
};
|
1476
|
+
|
1477
|
+
Class.prototype.hoistDirectivePrologue = function() {
|
1478
|
+
var expressions, index, node;
|
1479
|
+
index = 0;
|
1480
|
+
expressions = this.body.expressions;
|
1481
|
+
while ((node = expressions[index]) && node instanceof Comment || node instanceof Value && node.isString()) {
|
1482
|
+
++index;
|
1483
|
+
}
|
1484
|
+
return this.directives = expressions.splice(0, index);
|
1485
|
+
};
|
1486
|
+
|
1487
|
+
Class.prototype.ensureConstructor = function(name) {
|
1488
|
+
if (!this.ctor) {
|
1489
|
+
this.ctor = new Code;
|
1490
|
+
if (this.parent) {
|
1491
|
+
this.ctor.body.push(new Literal("" + name + ".__super__.constructor.apply(this, arguments)"));
|
1492
|
+
}
|
1493
|
+
if (this.externalCtor) {
|
1494
|
+
this.ctor.body.push(new Literal("" + this.externalCtor + ".apply(this, arguments)"));
|
1495
|
+
}
|
1496
|
+
this.ctor.body.makeReturn();
|
1497
|
+
this.body.expressions.unshift(this.ctor);
|
1498
|
+
}
|
1499
|
+
this.ctor.ctor = this.ctor.name = name;
|
1500
|
+
this.ctor.klass = null;
|
1501
|
+
return this.ctor.noReturn = true;
|
1502
|
+
};
|
1503
|
+
|
1504
|
+
Class.prototype.compileNode = function(o) {
|
1505
|
+
var call, decl, klass, lname, name, params, _ref2;
|
1506
|
+
decl = this.determineName();
|
1507
|
+
name = decl || '_Class';
|
1508
|
+
if (name.reserved) {
|
1509
|
+
name = "_" + name;
|
1510
|
+
}
|
1511
|
+
lname = new Literal(name);
|
1512
|
+
this.hoistDirectivePrologue();
|
1513
|
+
this.setContext(name);
|
1514
|
+
this.walkBody(name, o);
|
1515
|
+
this.ensureConstructor(name);
|
1516
|
+
this.body.spaced = true;
|
1517
|
+
if (!(this.ctor instanceof Code)) {
|
1518
|
+
this.body.expressions.unshift(this.ctor);
|
1519
|
+
}
|
1520
|
+
this.body.expressions.push(lname);
|
1521
|
+
(_ref2 = this.body.expressions).unshift.apply(_ref2, this.directives);
|
1522
|
+
this.addBoundFunctions(o);
|
1523
|
+
call = Closure.wrap(this.body);
|
1524
|
+
if (this.parent) {
|
1525
|
+
this.superClass = new Literal(o.scope.freeVariable('super', false));
|
1526
|
+
this.body.expressions.unshift(new Extends(lname, this.superClass));
|
1527
|
+
call.args.push(this.parent);
|
1528
|
+
params = call.variable.params || call.variable.base.params;
|
1529
|
+
params.push(new Param(this.superClass));
|
1530
|
+
}
|
1531
|
+
klass = new Parens(call, true);
|
1532
|
+
if (this.variable) {
|
1533
|
+
klass = new Assign(this.variable, klass);
|
1534
|
+
}
|
1535
|
+
return klass.compileToFragments(o);
|
1536
|
+
};
|
1537
|
+
|
1538
|
+
return Class;
|
1539
|
+
|
1540
|
+
})(Base);
|
1541
|
+
|
1542
|
+
exports.Assign = Assign = (function(_super) {
|
1543
|
+
|
1544
|
+
__extends(Assign, _super);
|
1545
|
+
|
1546
|
+
function Assign(variable, value, context, options) {
|
1547
|
+
var forbidden, name, _ref2;
|
1548
|
+
this.variable = variable;
|
1549
|
+
this.value = value;
|
1550
|
+
this.context = context;
|
1551
|
+
this.param = options && options.param;
|
1552
|
+
this.subpattern = options && options.subpattern;
|
1553
|
+
forbidden = (_ref2 = (name = this.variable.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0);
|
1554
|
+
if (forbidden && this.context !== 'object') {
|
1555
|
+
throw SyntaxError("variable name may not be \"" + name + "\"");
|
1556
|
+
}
|
1557
|
+
}
|
1558
|
+
|
1559
|
+
Assign.prototype.children = ['variable', 'value'];
|
1560
|
+
|
1561
|
+
Assign.prototype.isStatement = function(o) {
|
1562
|
+
return (o != null ? o.level : void 0) === LEVEL_TOP && (this.context != null) && __indexOf.call(this.context, "?") >= 0;
|
1563
|
+
};
|
1564
|
+
|
1565
|
+
Assign.prototype.assigns = function(name) {
|
1566
|
+
return this[this.context === 'object' ? 'value' : 'variable'].assigns(name);
|
1567
|
+
};
|
1568
|
+
|
1569
|
+
Assign.prototype.unfoldSoak = function(o) {
|
1570
|
+
return unfoldSoak(o, this, 'variable');
|
1571
|
+
};
|
1572
|
+
|
1573
|
+
Assign.prototype.compileNode = function(o) {
|
1574
|
+
var answer, compiledName, isValue, match, name, val, varBase, _ref2, _ref3, _ref4, _ref5;
|
1575
|
+
if (isValue = this.variable instanceof Value) {
|
1576
|
+
if (this.variable.isArray() || this.variable.isObject()) {
|
1577
|
+
return this.compilePatternMatch(o);
|
1578
|
+
}
|
1579
|
+
if (this.variable.isSplice()) {
|
1580
|
+
return this.compileSplice(o);
|
1581
|
+
}
|
1582
|
+
if ((_ref2 = this.context) === '||=' || _ref2 === '&&=' || _ref2 === '?=') {
|
1583
|
+
return this.compileConditional(o);
|
1584
|
+
}
|
1585
|
+
}
|
1586
|
+
compiledName = this.variable.compileToFragments(o, LEVEL_LIST);
|
1587
|
+
name = fragmentsToText(compiledName);
|
1588
|
+
if (!this.context) {
|
1589
|
+
if (!(varBase = this.variable.unwrapAll()).isAssignable()) {
|
1590
|
+
throw SyntaxError("\"" + (this.variable.compile(o)) + "\" cannot be assigned.");
|
1591
|
+
}
|
1592
|
+
if (!(typeof varBase.hasProperties === "function" ? varBase.hasProperties() : void 0)) {
|
1593
|
+
if (this.param) {
|
1594
|
+
o.scope.add(name, 'var');
|
1595
|
+
} else {
|
1596
|
+
o.scope.find(name);
|
1597
|
+
}
|
1598
|
+
}
|
1599
|
+
}
|
1600
|
+
if (this.value instanceof Code && (match = METHOD_DEF.exec(name))) {
|
1601
|
+
if (match[1]) {
|
1602
|
+
this.value.klass = match[1];
|
1603
|
+
}
|
1604
|
+
this.value.name = (_ref3 = (_ref4 = (_ref5 = match[2]) != null ? _ref5 : match[3]) != null ? _ref4 : match[4]) != null ? _ref3 : match[5];
|
1605
|
+
}
|
1606
|
+
val = this.value.compileToFragments(o, LEVEL_LIST);
|
1607
|
+
if (this.context === 'object') {
|
1608
|
+
return compiledName.concat(this.makeCode(": "), val);
|
1609
|
+
}
|
1610
|
+
answer = compiledName.concat(this.makeCode(" " + (this.context || '=') + " "), val);
|
1611
|
+
if (o.level <= LEVEL_LIST) {
|
1612
|
+
return answer;
|
1613
|
+
} else {
|
1614
|
+
return this.wrapInBraces(answer);
|
1615
|
+
}
|
1616
|
+
};
|
1617
|
+
|
1618
|
+
Assign.prototype.compilePatternMatch = function(o) {
|
1619
|
+
var acc, assigns, code, fragments, i, idx, isObject, ivar, name, obj, objects, olen, ref, rest, splat, top, val, value, vvar, vvarText, _i, _len, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
|
1620
|
+
top = o.level === LEVEL_TOP;
|
1621
|
+
value = this.value;
|
1622
|
+
objects = this.variable.base.objects;
|
1623
|
+
if (!(olen = objects.length)) {
|
1624
|
+
code = value.compileToFragments(o);
|
1625
|
+
if (o.level >= LEVEL_OP) {
|
1626
|
+
return this.wrapInBraces(code);
|
1627
|
+
} else {
|
1628
|
+
return code;
|
1629
|
+
}
|
1630
|
+
}
|
1631
|
+
isObject = this.variable.isObject();
|
1632
|
+
if (top && olen === 1 && !((obj = objects[0]) instanceof Splat)) {
|
1633
|
+
if (obj instanceof Assign) {
|
1634
|
+
_ref2 = obj, (_ref3 = _ref2.variable, idx = _ref3.base), obj = _ref2.value;
|
1635
|
+
} else {
|
1636
|
+
idx = isObject ? obj["this"] ? obj.properties[0].name : obj : new Literal(0);
|
1637
|
+
}
|
1638
|
+
acc = IDENTIFIER.test(idx.unwrap().value || 0);
|
1639
|
+
value = new Value(value);
|
1640
|
+
value.properties.push(new (acc ? Access : Index)(idx));
|
1641
|
+
if (_ref4 = obj.unwrap().value, __indexOf.call(RESERVED, _ref4) >= 0) {
|
1642
|
+
throw new SyntaxError("assignment to a reserved word: " + (obj.compile(o)) + " = " + (value.compile(o)));
|
1643
|
+
}
|
1644
|
+
return new Assign(obj, value, null, {
|
1645
|
+
param: this.param
|
1646
|
+
}).compileToFragments(o, LEVEL_TOP);
|
1647
|
+
}
|
1648
|
+
vvar = value.compileToFragments(o, LEVEL_LIST);
|
1649
|
+
vvarText = fragmentsToText(vvar);
|
1650
|
+
assigns = [];
|
1651
|
+
splat = false;
|
1652
|
+
if (!IDENTIFIER.test(vvarText) || this.variable.assigns(vvarText)) {
|
1653
|
+
assigns.push([this.makeCode("" + (ref = o.scope.freeVariable('ref')) + " = ")].concat(__slice.call(vvar)));
|
1654
|
+
vvar = [this.makeCode(ref)];
|
1655
|
+
vvarText = ref;
|
1656
|
+
}
|
1657
|
+
for (i = _i = 0, _len = objects.length; _i < _len; i = ++_i) {
|
1658
|
+
obj = objects[i];
|
1659
|
+
idx = i;
|
1660
|
+
if (isObject) {
|
1661
|
+
if (obj instanceof Assign) {
|
1662
|
+
_ref5 = obj, (_ref6 = _ref5.variable, idx = _ref6.base), obj = _ref5.value;
|
1663
|
+
} else {
|
1664
|
+
if (obj.base instanceof Parens) {
|
1665
|
+
_ref7 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref7[0], idx = _ref7[1];
|
1666
|
+
} else {
|
1667
|
+
idx = obj["this"] ? obj.properties[0].name : obj;
|
1668
|
+
}
|
1669
|
+
}
|
1670
|
+
}
|
1671
|
+
if (!splat && obj instanceof Splat) {
|
1672
|
+
name = obj.name.unwrap().value;
|
1673
|
+
obj = obj.unwrap();
|
1674
|
+
val = "" + olen + " <= " + vvarText + ".length ? " + (utility('slice')) + ".call(" + vvarText + ", " + i;
|
1675
|
+
if (rest = olen - i - 1) {
|
1676
|
+
ivar = o.scope.freeVariable('i');
|
1677
|
+
val += ", " + ivar + " = " + vvarText + ".length - " + rest + ") : (" + ivar + " = " + i + ", [])";
|
1678
|
+
} else {
|
1679
|
+
val += ") : []";
|
1680
|
+
}
|
1681
|
+
val = new Literal(val);
|
1682
|
+
splat = "" + ivar + "++";
|
1683
|
+
} else {
|
1684
|
+
name = obj.unwrap().value;
|
1685
|
+
if (obj instanceof Splat) {
|
1686
|
+
obj = obj.name.compileToFragments(o);
|
1687
|
+
throw new SyntaxError("multiple splats are disallowed in an assignment: " + obj + "...");
|
1688
|
+
}
|
1689
|
+
if (typeof idx === 'number') {
|
1690
|
+
idx = new Literal(splat || idx);
|
1691
|
+
acc = false;
|
1692
|
+
} else {
|
1693
|
+
acc = isObject && IDENTIFIER.test(idx.unwrap().value || 0);
|
1694
|
+
}
|
1695
|
+
val = new Value(new Literal(vvarText), [new (acc ? Access : Index)(idx)]);
|
1696
|
+
}
|
1697
|
+
if ((name != null) && __indexOf.call(RESERVED, name) >= 0) {
|
1698
|
+
throw new SyntaxError("assignment to a reserved word: " + (obj.compile(o)) + " = " + (val.compile(o)));
|
1699
|
+
}
|
1700
|
+
assigns.push(new Assign(obj, val, null, {
|
1701
|
+
param: this.param,
|
1702
|
+
subpattern: true
|
1703
|
+
}).compileToFragments(o, LEVEL_LIST));
|
1704
|
+
}
|
1705
|
+
if (!(top || this.subpattern)) {
|
1706
|
+
assigns.push(vvar);
|
1707
|
+
}
|
1708
|
+
fragments = this.joinFragmentArrays(assigns, ', ');
|
1709
|
+
if (o.level < LEVEL_LIST) {
|
1710
|
+
return fragments;
|
1711
|
+
} else {
|
1712
|
+
return this.wrapInBraces(fragments);
|
1713
|
+
}
|
1714
|
+
};
|
1715
|
+
|
1716
|
+
Assign.prototype.compileConditional = function(o) {
|
1717
|
+
var left, right, _ref2;
|
1718
|
+
_ref2 = this.variable.cacheReference(o), left = _ref2[0], right = _ref2[1];
|
1719
|
+
if (!left.properties.length && left.base instanceof Literal && left.base.value !== "this" && !o.scope.check(left.base.value)) {
|
1720
|
+
throw new Error("the variable \"" + left.base.value + "\" can't be assigned with " + this.context + " because it has not been defined.");
|
1721
|
+
}
|
1722
|
+
if (__indexOf.call(this.context, "?") >= 0) {
|
1723
|
+
o.isExistentialEquals = true;
|
1724
|
+
}
|
1725
|
+
return new Op(this.context.slice(0, -1), left, new Assign(right, this.value, '=')).compileToFragments(o);
|
1726
|
+
};
|
1727
|
+
|
1728
|
+
Assign.prototype.compileSplice = function(o) {
|
1729
|
+
var answer, exclusive, from, fromDecl, fromRef, name, to, valDef, valRef, _ref2, _ref3, _ref4;
|
1730
|
+
_ref2 = this.variable.properties.pop().range, from = _ref2.from, to = _ref2.to, exclusive = _ref2.exclusive;
|
1731
|
+
name = this.variable.compile(o);
|
1732
|
+
if (from) {
|
1733
|
+
_ref3 = this.cacheToCodeFragments(from.cache(o, LEVEL_OP)), fromDecl = _ref3[0], fromRef = _ref3[1];
|
1734
|
+
} else {
|
1735
|
+
fromDecl = fromRef = '0';
|
1736
|
+
}
|
1737
|
+
if (to) {
|
1738
|
+
if ((from != null ? from.isSimpleNumber() : void 0) && to.isSimpleNumber()) {
|
1739
|
+
to = +to.compile(o) - +fromRef;
|
1740
|
+
if (!exclusive) {
|
1741
|
+
to += 1;
|
1742
|
+
}
|
1743
|
+
} else {
|
1744
|
+
to = to.compile(o, LEVEL_ACCESS) + ' - ' + fromRef;
|
1745
|
+
if (!exclusive) {
|
1746
|
+
to += ' + 1';
|
1747
|
+
}
|
1748
|
+
}
|
1749
|
+
} else {
|
1750
|
+
to = "9e9";
|
1751
|
+
}
|
1752
|
+
_ref4 = this.value.cache(o, LEVEL_LIST), valDef = _ref4[0], valRef = _ref4[1];
|
1753
|
+
answer = [].concat(this.makeCode("[].splice.apply(" + name + ", [" + fromDecl + ", " + to + "].concat("), valDef, this.makeCode(")), "), valRef);
|
1754
|
+
if (o.level > LEVEL_TOP) {
|
1755
|
+
return this.wrapInBraces(answer);
|
1756
|
+
} else {
|
1757
|
+
return answer;
|
1758
|
+
}
|
1759
|
+
};
|
1760
|
+
|
1761
|
+
return Assign;
|
1762
|
+
|
1763
|
+
})(Base);
|
1764
|
+
|
1765
|
+
exports.Code = Code = (function(_super) {
|
1766
|
+
|
1767
|
+
__extends(Code, _super);
|
1768
|
+
|
1769
|
+
function Code(params, body, tag) {
|
1770
|
+
this.params = params || [];
|
1771
|
+
this.body = body || new Block;
|
1772
|
+
this.bound = tag === 'boundfunc';
|
1773
|
+
if (this.bound) {
|
1774
|
+
this.context = '_this';
|
1775
|
+
}
|
1776
|
+
}
|
1777
|
+
|
1778
|
+
Code.prototype.children = ['params', 'body'];
|
1779
|
+
|
1780
|
+
Code.prototype.isStatement = function() {
|
1781
|
+
return !!this.ctor;
|
1782
|
+
};
|
1783
|
+
|
1784
|
+
Code.prototype.jumps = NO;
|
1785
|
+
|
1786
|
+
Code.prototype.compileNode = function(o) {
|
1787
|
+
var answer, code, exprs, i, idt, lit, name, p, param, params, ref, splats, uniqs, val, wasEmpty, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _len5, _len6, _m, _n, _o, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8;
|
1788
|
+
o.scope = new Scope(o.scope, this.body, this);
|
1789
|
+
o.scope.shared = del(o, 'sharedScope');
|
1790
|
+
o.indent += TAB;
|
1791
|
+
delete o.bare;
|
1792
|
+
delete o.isExistentialEquals;
|
1793
|
+
params = [];
|
1794
|
+
exprs = [];
|
1795
|
+
_ref2 = this.paramNames();
|
1796
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
1797
|
+
name = _ref2[_i];
|
1798
|
+
if (!o.scope.check(name)) {
|
1799
|
+
o.scope.parameter(name);
|
1800
|
+
}
|
1801
|
+
}
|
1802
|
+
_ref3 = this.params;
|
1803
|
+
for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
|
1804
|
+
param = _ref3[_j];
|
1805
|
+
if (!param.splat) {
|
1806
|
+
continue;
|
1807
|
+
}
|
1808
|
+
_ref4 = this.params;
|
1809
|
+
for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
|
1810
|
+
p = _ref4[_k].name;
|
1811
|
+
if (p["this"]) {
|
1812
|
+
p = p.properties[0].name;
|
1813
|
+
}
|
1814
|
+
if (p.value) {
|
1815
|
+
o.scope.add(p.value, 'var', true);
|
1816
|
+
}
|
1817
|
+
}
|
1818
|
+
splats = new Assign(new Value(new Arr((function() {
|
1819
|
+
var _l, _len3, _ref5, _results;
|
1820
|
+
_ref5 = this.params;
|
1821
|
+
_results = [];
|
1822
|
+
for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) {
|
1823
|
+
p = _ref5[_l];
|
1824
|
+
_results.push(p.asReference(o));
|
1825
|
+
}
|
1826
|
+
return _results;
|
1827
|
+
}).call(this))), new Value(new Literal('arguments')));
|
1828
|
+
break;
|
1829
|
+
}
|
1830
|
+
_ref5 = this.params;
|
1831
|
+
for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) {
|
1832
|
+
param = _ref5[_l];
|
1833
|
+
if (param.isComplex()) {
|
1834
|
+
val = ref = param.asReference(o);
|
1835
|
+
if (param.value) {
|
1836
|
+
val = new Op('?', ref, param.value);
|
1837
|
+
}
|
1838
|
+
exprs.push(new Assign(new Value(param.name), val, '=', {
|
1839
|
+
param: true
|
1840
|
+
}));
|
1841
|
+
} else {
|
1842
|
+
ref = param;
|
1843
|
+
if (param.value) {
|
1844
|
+
lit = new Literal(ref.name.value + ' == null');
|
1845
|
+
val = new Assign(new Value(param.name), param.value, '=');
|
1846
|
+
exprs.push(new If(lit, val));
|
1847
|
+
}
|
1848
|
+
}
|
1849
|
+
if (!splats) {
|
1850
|
+
params.push(ref);
|
1851
|
+
}
|
1852
|
+
}
|
1853
|
+
wasEmpty = this.body.isEmpty();
|
1854
|
+
if (splats) {
|
1855
|
+
exprs.unshift(splats);
|
1856
|
+
}
|
1857
|
+
if (exprs.length) {
|
1858
|
+
(_ref6 = this.body.expressions).unshift.apply(_ref6, exprs);
|
1859
|
+
}
|
1860
|
+
for (i = _m = 0, _len4 = params.length; _m < _len4; i = ++_m) {
|
1861
|
+
p = params[i];
|
1862
|
+
params[i] = p.compileToFragments(o);
|
1863
|
+
o.scope.parameter(fragmentsToText(params[i]));
|
1864
|
+
}
|
1865
|
+
uniqs = [];
|
1866
|
+
_ref7 = this.paramNames();
|
1867
|
+
for (_n = 0, _len5 = _ref7.length; _n < _len5; _n++) {
|
1868
|
+
name = _ref7[_n];
|
1869
|
+
if (__indexOf.call(uniqs, name) >= 0) {
|
1870
|
+
throw SyntaxError("multiple parameters named '" + name + "'");
|
1871
|
+
}
|
1872
|
+
uniqs.push(name);
|
1873
|
+
}
|
1874
|
+
if (!(wasEmpty || this.noReturn)) {
|
1875
|
+
this.body.makeReturn();
|
1876
|
+
}
|
1877
|
+
if (this.bound) {
|
1878
|
+
if ((_ref8 = o.scope.parent.method) != null ? _ref8.bound : void 0) {
|
1879
|
+
this.bound = this.context = o.scope.parent.method.context;
|
1880
|
+
} else if (!this["static"]) {
|
1881
|
+
o.scope.parent.assign('_this', 'this');
|
1882
|
+
}
|
1883
|
+
}
|
1884
|
+
idt = o.indent;
|
1885
|
+
code = 'function';
|
1886
|
+
if (this.ctor) {
|
1887
|
+
code += ' ' + this.name;
|
1888
|
+
}
|
1889
|
+
code += '(';
|
1890
|
+
answer = [this.makeCode(code)];
|
1891
|
+
for (i = _o = 0, _len6 = params.length; _o < _len6; i = ++_o) {
|
1892
|
+
p = params[i];
|
1893
|
+
if (i) {
|
1894
|
+
answer.push(this.makeCode(", "));
|
1895
|
+
}
|
1896
|
+
answer.push.apply(answer, p);
|
1897
|
+
}
|
1898
|
+
answer.push(this.makeCode(') {'));
|
1899
|
+
if (!this.body.isEmpty()) {
|
1900
|
+
answer = answer.concat(this.makeCode("\n"), this.body.compileWithDeclarations(o), this.makeCode("\n" + this.tab));
|
1901
|
+
}
|
1902
|
+
answer.push(this.makeCode('}'));
|
1903
|
+
if (this.ctor) {
|
1904
|
+
return [this.makeCode(this.tab)].concat(__slice.call(answer));
|
1905
|
+
}
|
1906
|
+
if (this.front || (o.level >= LEVEL_ACCESS)) {
|
1907
|
+
return this.wrapInBraces(answer);
|
1908
|
+
} else {
|
1909
|
+
return answer;
|
1910
|
+
}
|
1911
|
+
};
|
1912
|
+
|
1913
|
+
Code.prototype.paramNames = function() {
|
1914
|
+
var names, param, _i, _len, _ref2;
|
1915
|
+
names = [];
|
1916
|
+
_ref2 = this.params;
|
1917
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
1918
|
+
param = _ref2[_i];
|
1919
|
+
names.push.apply(names, param.names());
|
1920
|
+
}
|
1921
|
+
return names;
|
1922
|
+
};
|
1923
|
+
|
1924
|
+
Code.prototype.traverseChildren = function(crossScope, func) {
|
1925
|
+
if (crossScope) {
|
1926
|
+
return Code.__super__.traverseChildren.call(this, crossScope, func);
|
1927
|
+
}
|
1928
|
+
};
|
1929
|
+
|
1930
|
+
return Code;
|
1931
|
+
|
1932
|
+
})(Base);
|
1933
|
+
|
1934
|
+
exports.Param = Param = (function(_super) {
|
1935
|
+
|
1936
|
+
__extends(Param, _super);
|
1937
|
+
|
1938
|
+
function Param(name, value, splat) {
|
1939
|
+
var _ref2;
|
1940
|
+
this.name = name;
|
1941
|
+
this.value = value;
|
1942
|
+
this.splat = splat;
|
1943
|
+
if (_ref2 = (name = this.name.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0) {
|
1944
|
+
throw SyntaxError("parameter name \"" + name + "\" is not allowed");
|
1945
|
+
}
|
1946
|
+
}
|
1947
|
+
|
1948
|
+
Param.prototype.children = ['name', 'value'];
|
1949
|
+
|
1950
|
+
Param.prototype.compileToFragments = function(o) {
|
1951
|
+
return this.name.compileToFragments(o, LEVEL_LIST);
|
1952
|
+
};
|
1953
|
+
|
1954
|
+
Param.prototype.asReference = function(o) {
|
1955
|
+
var node;
|
1956
|
+
if (this.reference) {
|
1957
|
+
return this.reference;
|
1958
|
+
}
|
1959
|
+
node = this.name;
|
1960
|
+
if (node["this"]) {
|
1961
|
+
node = node.properties[0].name;
|
1962
|
+
if (node.value.reserved) {
|
1963
|
+
node = new Literal(o.scope.freeVariable(node.value));
|
1964
|
+
}
|
1965
|
+
} else if (node.isComplex()) {
|
1966
|
+
node = new Literal(o.scope.freeVariable('arg'));
|
1967
|
+
}
|
1968
|
+
node = new Value(node);
|
1969
|
+
if (this.splat) {
|
1970
|
+
node = new Splat(node);
|
1971
|
+
}
|
1972
|
+
return this.reference = node;
|
1973
|
+
};
|
1974
|
+
|
1975
|
+
Param.prototype.isComplex = function() {
|
1976
|
+
return this.name.isComplex();
|
1977
|
+
};
|
1978
|
+
|
1979
|
+
Param.prototype.names = function(name) {
|
1980
|
+
var atParam, names, obj, _i, _len, _ref2;
|
1981
|
+
if (name == null) {
|
1982
|
+
name = this.name;
|
1983
|
+
}
|
1984
|
+
atParam = function(obj) {
|
1985
|
+
var value;
|
1986
|
+
value = obj.properties[0].name.value;
|
1987
|
+
if (value.reserved) {
|
1988
|
+
return [];
|
1989
|
+
} else {
|
1990
|
+
return [value];
|
1991
|
+
}
|
1992
|
+
};
|
1993
|
+
if (name instanceof Literal) {
|
1994
|
+
return [name.value];
|
1995
|
+
}
|
1996
|
+
if (name instanceof Value) {
|
1997
|
+
return atParam(name);
|
1998
|
+
}
|
1999
|
+
names = [];
|
2000
|
+
_ref2 = name.objects;
|
2001
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
2002
|
+
obj = _ref2[_i];
|
2003
|
+
if (obj instanceof Assign) {
|
2004
|
+
names.push.apply(names, this.names(obj.value.unwrap()));
|
2005
|
+
} else if (obj instanceof Splat) {
|
2006
|
+
names.push(obj.name.unwrap().value);
|
2007
|
+
} else if (obj instanceof Value) {
|
2008
|
+
if (obj.isArray() || obj.isObject()) {
|
2009
|
+
names.push.apply(names, this.names(obj.base));
|
2010
|
+
} else if (obj["this"]) {
|
2011
|
+
names.push.apply(names, atParam(obj));
|
2012
|
+
} else {
|
2013
|
+
names.push(obj.base.value);
|
2014
|
+
}
|
2015
|
+
} else {
|
2016
|
+
throw SyntaxError("illegal parameter " + (obj.compile()));
|
2017
|
+
}
|
2018
|
+
}
|
2019
|
+
return names;
|
2020
|
+
};
|
2021
|
+
|
2022
|
+
return Param;
|
2023
|
+
|
2024
|
+
})(Base);
|
2025
|
+
|
2026
|
+
exports.Splat = Splat = (function(_super) {
|
2027
|
+
|
2028
|
+
__extends(Splat, _super);
|
2029
|
+
|
2030
|
+
Splat.prototype.children = ['name'];
|
2031
|
+
|
2032
|
+
Splat.prototype.isAssignable = YES;
|
2033
|
+
|
2034
|
+
function Splat(name) {
|
2035
|
+
this.name = name.compile ? name : new Literal(name);
|
2036
|
+
}
|
2037
|
+
|
2038
|
+
Splat.prototype.assigns = function(name) {
|
2039
|
+
return this.name.assigns(name);
|
2040
|
+
};
|
2041
|
+
|
2042
|
+
Splat.prototype.compileToFragments = function(o) {
|
2043
|
+
return this.name.compileToFragments(o);
|
2044
|
+
};
|
2045
|
+
|
2046
|
+
Splat.prototype.unwrap = function() {
|
2047
|
+
return this.name;
|
2048
|
+
};
|
2049
|
+
|
2050
|
+
Splat.compileSplattedArray = function(o, list, apply) {
|
2051
|
+
var args, base, compiledNode, concatPart, fragments, i, index, node, _i, _len;
|
2052
|
+
index = -1;
|
2053
|
+
while ((node = list[++index]) && !(node instanceof Splat)) {
|
2054
|
+
continue;
|
2055
|
+
}
|
2056
|
+
if (index >= list.length) {
|
2057
|
+
return [];
|
2058
|
+
}
|
2059
|
+
if (list.length === 1) {
|
2060
|
+
node = list[0];
|
2061
|
+
fragments = node.compileToFragments(o, LEVEL_LIST);
|
2062
|
+
if (apply) {
|
2063
|
+
return fragments;
|
2064
|
+
}
|
2065
|
+
return [].concat(node.makeCode("" + (utility('slice')) + ".call("), fragments, node.makeCode(")"));
|
2066
|
+
}
|
2067
|
+
args = list.slice(index);
|
2068
|
+
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) {
|
2069
|
+
node = args[i];
|
2070
|
+
compiledNode = node.compileToFragments(o, LEVEL_LIST);
|
2071
|
+
args[i] = node instanceof Splat ? [].concat(node.makeCode("" + (utility('slice')) + ".call("), compiledNode, node.makeCode(")")) : [].concat(node.makeCode("["), compiledNode, node.makeCode("]"));
|
2072
|
+
}
|
2073
|
+
if (index === 0) {
|
2074
|
+
node = list[0];
|
2075
|
+
concatPart = node.joinFragmentArrays(args.slice(1), ', ');
|
2076
|
+
return args[0].concat(node.makeCode(".concat("), concatPart, node.makeCode(")"));
|
2077
|
+
}
|
2078
|
+
base = (function() {
|
2079
|
+
var _j, _len1, _ref2, _results;
|
2080
|
+
_ref2 = list.slice(0, index);
|
2081
|
+
_results = [];
|
2082
|
+
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
2083
|
+
node = _ref2[_j];
|
2084
|
+
_results.push(node.compileToFragments(o, LEVEL_LIST));
|
2085
|
+
}
|
2086
|
+
return _results;
|
2087
|
+
})();
|
2088
|
+
base = list[0].joinFragmentArrays(base, ', ');
|
2089
|
+
concatPart = list[index].joinFragmentArrays(args, ', ');
|
2090
|
+
return [].concat(list[0].makeCode("["), base, list[index].makeCode("].concat("), concatPart, (last(list)).makeCode(")"));
|
2091
|
+
};
|
2092
|
+
|
2093
|
+
return Splat;
|
2094
|
+
|
2095
|
+
})(Base);
|
2096
|
+
|
2097
|
+
exports.While = While = (function(_super) {
|
2098
|
+
|
2099
|
+
__extends(While, _super);
|
2100
|
+
|
2101
|
+
function While(condition, options) {
|
2102
|
+
this.condition = (options != null ? options.invert : void 0) ? condition.invert() : condition;
|
2103
|
+
this.guard = options != null ? options.guard : void 0;
|
2104
|
+
}
|
2105
|
+
|
2106
|
+
While.prototype.children = ['condition', 'guard', 'body'];
|
2107
|
+
|
2108
|
+
While.prototype.isStatement = YES;
|
2109
|
+
|
2110
|
+
While.prototype.makeReturn = function(res) {
|
2111
|
+
if (res) {
|
2112
|
+
return While.__super__.makeReturn.apply(this, arguments);
|
2113
|
+
} else {
|
2114
|
+
this.returns = !this.jumps({
|
2115
|
+
loop: true
|
2116
|
+
});
|
2117
|
+
return this;
|
2118
|
+
}
|
2119
|
+
};
|
2120
|
+
|
2121
|
+
While.prototype.addBody = function(body) {
|
2122
|
+
this.body = body;
|
2123
|
+
return this;
|
2124
|
+
};
|
2125
|
+
|
2126
|
+
While.prototype.jumps = function() {
|
2127
|
+
var expressions, node, _i, _len;
|
2128
|
+
expressions = this.body.expressions;
|
2129
|
+
if (!expressions.length) {
|
2130
|
+
return false;
|
2131
|
+
}
|
2132
|
+
for (_i = 0, _len = expressions.length; _i < _len; _i++) {
|
2133
|
+
node = expressions[_i];
|
2134
|
+
if (node.jumps({
|
2135
|
+
loop: true
|
2136
|
+
})) {
|
2137
|
+
return node;
|
2138
|
+
}
|
2139
|
+
}
|
2140
|
+
return false;
|
2141
|
+
};
|
2142
|
+
|
2143
|
+
While.prototype.compileNode = function(o) {
|
2144
|
+
var answer, body, rvar, set;
|
2145
|
+
o.indent += TAB;
|
2146
|
+
set = '';
|
2147
|
+
body = this.body;
|
2148
|
+
if (body.isEmpty()) {
|
2149
|
+
body = '';
|
2150
|
+
} else {
|
2151
|
+
if (this.returns) {
|
2152
|
+
body.makeReturn(rvar = o.scope.freeVariable('results'));
|
2153
|
+
set = "" + this.tab + rvar + " = [];\n";
|
2154
|
+
}
|
2155
|
+
if (this.guard) {
|
2156
|
+
if (body.expressions.length > 1) {
|
2157
|
+
body.expressions.unshift(new If((new Parens(this.guard)).invert(), new Literal("continue")));
|
2158
|
+
} else {
|
2159
|
+
if (this.guard) {
|
2160
|
+
body = Block.wrap([new If(this.guard, body)]);
|
2161
|
+
}
|
2162
|
+
}
|
2163
|
+
}
|
2164
|
+
body = [].concat(this.makeCode("\n"), body.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab));
|
2165
|
+
}
|
2166
|
+
answer = [].concat(this.makeCode(set + this.tab + "while ("), this.condition.compileToFragments(o, LEVEL_PAREN), this.makeCode(") {"), body, this.makeCode("}"));
|
2167
|
+
if (this.returns) {
|
2168
|
+
answer.push(this.makeCode("\n" + this.tab + "return " + rvar + ";"));
|
2169
|
+
}
|
2170
|
+
return answer;
|
2171
|
+
};
|
2172
|
+
|
2173
|
+
return While;
|
2174
|
+
|
2175
|
+
})(Base);
|
2176
|
+
|
2177
|
+
exports.Op = Op = (function(_super) {
|
2178
|
+
var CONVERSIONS, INVERSIONS;
|
2179
|
+
|
2180
|
+
__extends(Op, _super);
|
2181
|
+
|
2182
|
+
function Op(op, first, second, flip) {
|
2183
|
+
if (op === 'in') {
|
2184
|
+
return new In(first, second);
|
2185
|
+
}
|
2186
|
+
if (op === 'do') {
|
2187
|
+
return this.generateDo(first);
|
2188
|
+
}
|
2189
|
+
if (op === 'new') {
|
2190
|
+
if (first instanceof Call && !first["do"] && !first.isNew) {
|
2191
|
+
return first.newInstance();
|
2192
|
+
}
|
2193
|
+
if (first instanceof Code && first.bound || first["do"]) {
|
2194
|
+
first = new Parens(first);
|
2195
|
+
}
|
2196
|
+
}
|
2197
|
+
this.operator = CONVERSIONS[op] || op;
|
2198
|
+
this.first = first;
|
2199
|
+
this.second = second;
|
2200
|
+
this.flip = !!flip;
|
2201
|
+
return this;
|
2202
|
+
}
|
2203
|
+
|
2204
|
+
CONVERSIONS = {
|
2205
|
+
'==': '===',
|
2206
|
+
'!=': '!==',
|
2207
|
+
'of': 'in'
|
2208
|
+
};
|
2209
|
+
|
2210
|
+
INVERSIONS = {
|
2211
|
+
'!==': '===',
|
2212
|
+
'===': '!=='
|
2213
|
+
};
|
2214
|
+
|
2215
|
+
Op.prototype.children = ['first', 'second'];
|
2216
|
+
|
2217
|
+
Op.prototype.isSimpleNumber = NO;
|
2218
|
+
|
2219
|
+
Op.prototype.isUnary = function() {
|
2220
|
+
return !this.second;
|
2221
|
+
};
|
2222
|
+
|
2223
|
+
Op.prototype.isComplex = function() {
|
2224
|
+
var _ref2;
|
2225
|
+
return !(this.isUnary() && ((_ref2 = this.operator) === '+' || _ref2 === '-')) || this.first.isComplex();
|
2226
|
+
};
|
2227
|
+
|
2228
|
+
Op.prototype.isChainable = function() {
|
2229
|
+
var _ref2;
|
2230
|
+
return (_ref2 = this.operator) === '<' || _ref2 === '>' || _ref2 === '>=' || _ref2 === '<=' || _ref2 === '===' || _ref2 === '!==';
|
2231
|
+
};
|
2232
|
+
|
2233
|
+
Op.prototype.invert = function() {
|
2234
|
+
var allInvertable, curr, fst, op, _ref2;
|
2235
|
+
if (this.isChainable() && this.first.isChainable()) {
|
2236
|
+
allInvertable = true;
|
2237
|
+
curr = this;
|
2238
|
+
while (curr && curr.operator) {
|
2239
|
+
allInvertable && (allInvertable = curr.operator in INVERSIONS);
|
2240
|
+
curr = curr.first;
|
2241
|
+
}
|
2242
|
+
if (!allInvertable) {
|
2243
|
+
return new Parens(this).invert();
|
2244
|
+
}
|
2245
|
+
curr = this;
|
2246
|
+
while (curr && curr.operator) {
|
2247
|
+
curr.invert = !curr.invert;
|
2248
|
+
curr.operator = INVERSIONS[curr.operator];
|
2249
|
+
curr = curr.first;
|
2250
|
+
}
|
2251
|
+
return this;
|
2252
|
+
} else if (op = INVERSIONS[this.operator]) {
|
2253
|
+
this.operator = op;
|
2254
|
+
if (this.first.unwrap() instanceof Op) {
|
2255
|
+
this.first.invert();
|
2256
|
+
}
|
2257
|
+
return this;
|
2258
|
+
} else if (this.second) {
|
2259
|
+
return new Parens(this).invert();
|
2260
|
+
} else if (this.operator === '!' && (fst = this.first.unwrap()) instanceof Op && ((_ref2 = fst.operator) === '!' || _ref2 === 'in' || _ref2 === 'instanceof')) {
|
2261
|
+
return fst;
|
2262
|
+
} else {
|
2263
|
+
return new Op('!', this);
|
2264
|
+
}
|
2265
|
+
};
|
2266
|
+
|
2267
|
+
Op.prototype.unfoldSoak = function(o) {
|
2268
|
+
var _ref2;
|
2269
|
+
return ((_ref2 = this.operator) === '++' || _ref2 === '--' || _ref2 === 'delete') && unfoldSoak(o, this, 'first');
|
2270
|
+
};
|
2271
|
+
|
2272
|
+
Op.prototype.generateDo = function(exp) {
|
2273
|
+
var call, func, param, passedParams, ref, _i, _len, _ref2;
|
2274
|
+
passedParams = [];
|
2275
|
+
func = exp instanceof Assign && (ref = exp.value.unwrap()) instanceof Code ? ref : exp;
|
2276
|
+
_ref2 = func.params || [];
|
2277
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
2278
|
+
param = _ref2[_i];
|
2279
|
+
if (param.value) {
|
2280
|
+
passedParams.push(param.value);
|
2281
|
+
delete param.value;
|
2282
|
+
} else {
|
2283
|
+
passedParams.push(param);
|
2284
|
+
}
|
2285
|
+
}
|
2286
|
+
call = new Call(exp, passedParams);
|
2287
|
+
call["do"] = true;
|
2288
|
+
return call;
|
2289
|
+
};
|
2290
|
+
|
2291
|
+
Op.prototype.compileNode = function(o) {
|
2292
|
+
var answer, isChain, _ref2, _ref3;
|
2293
|
+
isChain = this.isChainable() && this.first.isChainable();
|
2294
|
+
if (!isChain) {
|
2295
|
+
this.first.front = this.front;
|
2296
|
+
}
|
2297
|
+
if (this.operator === 'delete' && o.scope.check(this.first.unwrapAll().value)) {
|
2298
|
+
throw SyntaxError('delete operand may not be argument or var');
|
2299
|
+
}
|
2300
|
+
if (((_ref2 = this.operator) === '--' || _ref2 === '++') && (_ref3 = this.first.unwrapAll().value, __indexOf.call(STRICT_PROSCRIBED, _ref3) >= 0)) {
|
2301
|
+
throw SyntaxError('prefix increment/decrement may not have eval or arguments operand');
|
2302
|
+
}
|
2303
|
+
if (this.isUnary()) {
|
2304
|
+
return this.compileUnary(o);
|
2305
|
+
}
|
2306
|
+
if (isChain) {
|
2307
|
+
return this.compileChain(o);
|
2308
|
+
}
|
2309
|
+
if (this.operator === '?') {
|
2310
|
+
return this.compileExistence(o);
|
2311
|
+
}
|
2312
|
+
answer = [].concat(this.first.compileToFragments(o, LEVEL_OP), this.makeCode(' ' + this.operator + ' '), this.second.compileToFragments(o, LEVEL_OP));
|
2313
|
+
if (o.level <= LEVEL_OP) {
|
2314
|
+
return answer;
|
2315
|
+
} else {
|
2316
|
+
return this.wrapInBraces(answer);
|
2317
|
+
}
|
2318
|
+
};
|
2319
|
+
|
2320
|
+
Op.prototype.compileChain = function(o) {
|
2321
|
+
var fragments, fst, shared, _ref2;
|
2322
|
+
_ref2 = this.first.second.cache(o), this.first.second = _ref2[0], shared = _ref2[1];
|
2323
|
+
fst = this.first.compileToFragments(o, LEVEL_OP);
|
2324
|
+
fragments = fst.concat(this.makeCode(" " + (this.invert ? '&&' : '||') + " "), shared.compileToFragments(o), this.makeCode(" " + this.operator + " "), this.second.compileToFragments(o, LEVEL_OP));
|
2325
|
+
return this.wrapInBraces(fragments);
|
2326
|
+
};
|
2327
|
+
|
2328
|
+
Op.prototype.compileExistence = function(o) {
|
2329
|
+
var fst, ref;
|
2330
|
+
if (this.first.isComplex()) {
|
2331
|
+
ref = new Literal(o.scope.freeVariable('ref'));
|
2332
|
+
fst = new Parens(new Assign(ref, this.first));
|
2333
|
+
} else {
|
2334
|
+
fst = this.first;
|
2335
|
+
ref = fst;
|
2336
|
+
}
|
2337
|
+
return new If(new Existence(fst), ref, {
|
2338
|
+
type: 'if'
|
2339
|
+
}).addElse(this.second).compileToFragments(o);
|
2340
|
+
};
|
2341
|
+
|
2342
|
+
Op.prototype.compileUnary = function(o) {
|
2343
|
+
var op, parts, plusMinus;
|
2344
|
+
parts = [];
|
2345
|
+
op = this.operator;
|
2346
|
+
parts.push([this.makeCode(op)]);
|
2347
|
+
if (op === '!' && this.first instanceof Existence) {
|
2348
|
+
this.first.negated = !this.first.negated;
|
2349
|
+
return this.first.compileToFragments(o);
|
2350
|
+
}
|
2351
|
+
if (o.level >= LEVEL_ACCESS) {
|
2352
|
+
return (new Parens(this)).compileToFragments(o);
|
2353
|
+
}
|
2354
|
+
plusMinus = op === '+' || op === '-';
|
2355
|
+
if ((op === 'new' || op === 'typeof' || op === 'delete') || plusMinus && this.first instanceof Op && this.first.operator === op) {
|
2356
|
+
parts.push([this.makeCode(' ')]);
|
2357
|
+
}
|
2358
|
+
if ((plusMinus && this.first instanceof Op) || (op === 'new' && this.first.isStatement(o))) {
|
2359
|
+
this.first = new Parens(this.first);
|
2360
|
+
}
|
2361
|
+
parts.push(this.first.compileToFragments(o, LEVEL_OP));
|
2362
|
+
if (this.flip) {
|
2363
|
+
parts.reverse();
|
2364
|
+
}
|
2365
|
+
return this.joinFragmentArrays(parts, '');
|
2366
|
+
};
|
2367
|
+
|
2368
|
+
Op.prototype.toString = function(idt) {
|
2369
|
+
return Op.__super__.toString.call(this, idt, this.constructor.name + ' ' + this.operator);
|
2370
|
+
};
|
2371
|
+
|
2372
|
+
return Op;
|
2373
|
+
|
2374
|
+
})(Base);
|
2375
|
+
|
2376
|
+
exports.In = In = (function(_super) {
|
2377
|
+
|
2378
|
+
__extends(In, _super);
|
2379
|
+
|
2380
|
+
function In(object, array) {
|
2381
|
+
this.object = object;
|
2382
|
+
this.array = array;
|
2383
|
+
}
|
2384
|
+
|
2385
|
+
In.prototype.children = ['object', 'array'];
|
2386
|
+
|
2387
|
+
In.prototype.invert = NEGATE;
|
2388
|
+
|
2389
|
+
In.prototype.compileNode = function(o) {
|
2390
|
+
var hasSplat, obj, _i, _len, _ref2;
|
2391
|
+
if (this.array instanceof Value && this.array.isArray()) {
|
2392
|
+
_ref2 = this.array.base.objects;
|
2393
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
2394
|
+
obj = _ref2[_i];
|
2395
|
+
if (!(obj instanceof Splat)) {
|
2396
|
+
continue;
|
2397
|
+
}
|
2398
|
+
hasSplat = true;
|
2399
|
+
break;
|
2400
|
+
}
|
2401
|
+
if (!hasSplat) {
|
2402
|
+
return this.compileOrTest(o);
|
2403
|
+
}
|
2404
|
+
}
|
2405
|
+
return this.compileLoopTest(o);
|
2406
|
+
};
|
2407
|
+
|
2408
|
+
In.prototype.compileOrTest = function(o) {
|
2409
|
+
var cmp, cnj, i, item, ref, sub, tests, _i, _len, _ref2, _ref3, _ref4;
|
2410
|
+
if (this.array.base.objects.length === 0) {
|
2411
|
+
return [this.makeCode("" + (!!this.negated))];
|
2412
|
+
}
|
2413
|
+
_ref2 = this.object.cache(o, LEVEL_OP), sub = _ref2[0], ref = _ref2[1];
|
2414
|
+
_ref3 = this.negated ? [' !== ', ' && '] : [' === ', ' || '], cmp = _ref3[0], cnj = _ref3[1];
|
2415
|
+
tests = [];
|
2416
|
+
_ref4 = this.array.base.objects;
|
2417
|
+
for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) {
|
2418
|
+
item = _ref4[i];
|
2419
|
+
if (i) {
|
2420
|
+
tests.push(this.makeCode(cnj));
|
2421
|
+
}
|
2422
|
+
tests = tests.concat((i ? ref : sub), this.makeCode(cmp), item.compileToFragments(o, LEVEL_ACCESS));
|
2423
|
+
}
|
2424
|
+
if (o.level < LEVEL_OP) {
|
2425
|
+
return tests;
|
2426
|
+
} else {
|
2427
|
+
return this.wrapInBraces(tests);
|
2428
|
+
}
|
2429
|
+
};
|
2430
|
+
|
2431
|
+
In.prototype.compileLoopTest = function(o) {
|
2432
|
+
var fragments, ref, sub, _ref2;
|
2433
|
+
_ref2 = this.object.cache(o, LEVEL_LIST), sub = _ref2[0], ref = _ref2[1];
|
2434
|
+
fragments = [].concat(this.makeCode(utility('indexOf') + ".call("), this.array.compileToFragments(o, LEVEL_LIST), this.makeCode(", "), ref, this.makeCode(") " + (this.negated ? '< 0' : '>= 0')));
|
2435
|
+
if ((fragmentsToText(sub)) === (fragmentsToText(ref))) {
|
2436
|
+
return fragments;
|
2437
|
+
}
|
2438
|
+
fragments = sub.concat(this.makeCode(', '), fragments);
|
2439
|
+
if (o.level < LEVEL_LIST) {
|
2440
|
+
return fragments;
|
2441
|
+
} else {
|
2442
|
+
return this.wrapInBraces(fragments);
|
2443
|
+
}
|
2444
|
+
};
|
2445
|
+
|
2446
|
+
In.prototype.toString = function(idt) {
|
2447
|
+
return In.__super__.toString.call(this, idt, this.constructor.name + (this.negated ? '!' : ''));
|
2448
|
+
};
|
2449
|
+
|
2450
|
+
return In;
|
2451
|
+
|
2452
|
+
})(Base);
|
2453
|
+
|
2454
|
+
exports.Try = Try = (function(_super) {
|
2455
|
+
|
2456
|
+
__extends(Try, _super);
|
2457
|
+
|
2458
|
+
function Try(attempt, error, recovery, ensure) {
|
2459
|
+
this.attempt = attempt;
|
2460
|
+
this.error = error;
|
2461
|
+
this.recovery = recovery;
|
2462
|
+
this.ensure = ensure;
|
2463
|
+
}
|
2464
|
+
|
2465
|
+
Try.prototype.children = ['attempt', 'recovery', 'ensure'];
|
2466
|
+
|
2467
|
+
Try.prototype.isStatement = YES;
|
2468
|
+
|
2469
|
+
Try.prototype.jumps = function(o) {
|
2470
|
+
var _ref2;
|
2471
|
+
return this.attempt.jumps(o) || ((_ref2 = this.recovery) != null ? _ref2.jumps(o) : void 0);
|
2472
|
+
};
|
2473
|
+
|
2474
|
+
Try.prototype.makeReturn = function(res) {
|
2475
|
+
if (this.attempt) {
|
2476
|
+
this.attempt = this.attempt.makeReturn(res);
|
2477
|
+
}
|
2478
|
+
if (this.recovery) {
|
2479
|
+
this.recovery = this.recovery.makeReturn(res);
|
2480
|
+
}
|
2481
|
+
return this;
|
2482
|
+
};
|
2483
|
+
|
2484
|
+
Try.prototype.compileNode = function(o) {
|
2485
|
+
var catchPart, ensurePart, placeholder, tryPart;
|
2486
|
+
o.indent += TAB;
|
2487
|
+
tryPart = this.attempt.compileToFragments(o, LEVEL_TOP);
|
2488
|
+
catchPart = (function() {
|
2489
|
+
var _base, _ref2;
|
2490
|
+
if (this.recovery) {
|
2491
|
+
if (typeof (_base = this.error).isObject === "function" ? _base.isObject() : void 0) {
|
2492
|
+
placeholder = new Literal('_error');
|
2493
|
+
this.recovery.unshift(new Assign(this.error, placeholder));
|
2494
|
+
this.error = placeholder;
|
2495
|
+
}
|
2496
|
+
if (_ref2 = this.error.value, __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0) {
|
2497
|
+
throw SyntaxError("catch variable may not be \"" + this.error.value + "\"");
|
2498
|
+
}
|
2499
|
+
if (!o.scope.check(this.error.value)) {
|
2500
|
+
o.scope.add(this.error.value, 'param');
|
2501
|
+
}
|
2502
|
+
return [].concat(this.makeCode(" catch ("), this.error.compileToFragments(o), this.makeCode(") {\n"), this.recovery.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}"));
|
2503
|
+
} else if (!(this.ensure || this.recovery)) {
|
2504
|
+
return [this.makeCode(' catch (_error) {}')];
|
2505
|
+
} else {
|
2506
|
+
return [];
|
2507
|
+
}
|
2508
|
+
}).call(this);
|
2509
|
+
ensurePart = this.ensure ? [].concat(this.makeCode(" finally {\n"), this.ensure.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}")) : [];
|
2510
|
+
return [].concat(this.makeCode("" + this.tab + "try {\n"), tryPart, this.makeCode("\n" + this.tab + "}"), catchPart, ensurePart);
|
2511
|
+
};
|
2512
|
+
|
2513
|
+
return Try;
|
2514
|
+
|
2515
|
+
})(Base);
|
2516
|
+
|
2517
|
+
exports.Throw = Throw = (function(_super) {
|
2518
|
+
|
2519
|
+
__extends(Throw, _super);
|
2520
|
+
|
2521
|
+
function Throw(expression) {
|
2522
|
+
this.expression = expression;
|
2523
|
+
}
|
2524
|
+
|
2525
|
+
Throw.prototype.children = ['expression'];
|
2526
|
+
|
2527
|
+
Throw.prototype.isStatement = YES;
|
2528
|
+
|
2529
|
+
Throw.prototype.jumps = NO;
|
2530
|
+
|
2531
|
+
Throw.prototype.makeReturn = THIS;
|
2532
|
+
|
2533
|
+
Throw.prototype.compileNode = function(o) {
|
2534
|
+
return [].concat(this.makeCode(this.tab + "throw "), this.expression.compileToFragments(o), this.makeCode(";"));
|
2535
|
+
};
|
2536
|
+
|
2537
|
+
return Throw;
|
2538
|
+
|
2539
|
+
})(Base);
|
2540
|
+
|
2541
|
+
exports.Existence = Existence = (function(_super) {
|
2542
|
+
|
2543
|
+
__extends(Existence, _super);
|
2544
|
+
|
2545
|
+
function Existence(expression) {
|
2546
|
+
this.expression = expression;
|
2547
|
+
}
|
2548
|
+
|
2549
|
+
Existence.prototype.children = ['expression'];
|
2550
|
+
|
2551
|
+
Existence.prototype.invert = NEGATE;
|
2552
|
+
|
2553
|
+
Existence.prototype.compileNode = function(o) {
|
2554
|
+
var cmp, cnj, code, _ref2;
|
2555
|
+
this.expression.front = this.front;
|
2556
|
+
code = this.expression.compile(o, LEVEL_OP);
|
2557
|
+
if (IDENTIFIER.test(code) && !o.scope.check(code)) {
|
2558
|
+
_ref2 = this.negated ? ['===', '||'] : ['!==', '&&'], cmp = _ref2[0], cnj = _ref2[1];
|
2559
|
+
code = "typeof " + code + " " + cmp + " \"undefined\" " + cnj + " " + code + " " + cmp + " null";
|
2560
|
+
} else {
|
2561
|
+
code = "" + code + " " + (this.negated ? '==' : '!=') + " null";
|
2562
|
+
}
|
2563
|
+
return [this.makeCode(o.level <= LEVEL_COND ? code : "(" + code + ")")];
|
2564
|
+
};
|
2565
|
+
|
2566
|
+
return Existence;
|
2567
|
+
|
2568
|
+
})(Base);
|
2569
|
+
|
2570
|
+
exports.Parens = Parens = (function(_super) {
|
2571
|
+
|
2572
|
+
__extends(Parens, _super);
|
2573
|
+
|
2574
|
+
function Parens(body) {
|
2575
|
+
this.body = body;
|
2576
|
+
}
|
2577
|
+
|
2578
|
+
Parens.prototype.children = ['body'];
|
2579
|
+
|
2580
|
+
Parens.prototype.unwrap = function() {
|
2581
|
+
return this.body;
|
2582
|
+
};
|
2583
|
+
|
2584
|
+
Parens.prototype.isComplex = function() {
|
2585
|
+
return this.body.isComplex();
|
2586
|
+
};
|
2587
|
+
|
2588
|
+
Parens.prototype.compileNode = function(o) {
|
2589
|
+
var bare, expr, fragments;
|
2590
|
+
expr = this.body.unwrap();
|
2591
|
+
if (expr instanceof Value && expr.isAtomic()) {
|
2592
|
+
expr.front = this.front;
|
2593
|
+
return expr.compileToFragments(o);
|
2594
|
+
}
|
2595
|
+
fragments = expr.compileToFragments(o, LEVEL_PAREN);
|
2596
|
+
bare = o.level < LEVEL_OP && (expr instanceof Op || expr instanceof Call || (expr instanceof For && expr.returns));
|
2597
|
+
if (bare) {
|
2598
|
+
return fragments;
|
2599
|
+
} else {
|
2600
|
+
return this.wrapInBraces(fragments);
|
2601
|
+
}
|
2602
|
+
};
|
2603
|
+
|
2604
|
+
return Parens;
|
2605
|
+
|
2606
|
+
})(Base);
|
2607
|
+
|
2608
|
+
exports.For = For = (function(_super) {
|
2609
|
+
|
2610
|
+
__extends(For, _super);
|
2611
|
+
|
2612
|
+
function For(body, source) {
|
2613
|
+
var _ref2;
|
2614
|
+
this.source = source.source, this.guard = source.guard, this.step = source.step, this.name = source.name, this.index = source.index;
|
2615
|
+
this.body = Block.wrap([body]);
|
2616
|
+
this.own = !!source.own;
|
2617
|
+
this.object = !!source.object;
|
2618
|
+
if (this.object) {
|
2619
|
+
_ref2 = [this.index, this.name], this.name = _ref2[0], this.index = _ref2[1];
|
2620
|
+
}
|
2621
|
+
if (this.index instanceof Value) {
|
2622
|
+
throw SyntaxError('index cannot be a pattern matching expression');
|
2623
|
+
}
|
2624
|
+
this.range = this.source instanceof Value && this.source.base instanceof Range && !this.source.properties.length;
|
2625
|
+
this.pattern = this.name instanceof Value;
|
2626
|
+
if (this.range && this.index) {
|
2627
|
+
throw SyntaxError('indexes do not apply to range loops');
|
2628
|
+
}
|
2629
|
+
if (this.range && this.pattern) {
|
2630
|
+
throw SyntaxError('cannot pattern match over range loops');
|
2631
|
+
}
|
2632
|
+
this.returns = false;
|
2633
|
+
}
|
2634
|
+
|
2635
|
+
For.prototype.children = ['body', 'source', 'guard', 'step'];
|
2636
|
+
|
2637
|
+
For.prototype.compileNode = function(o) {
|
2638
|
+
var body, bodyFragments, compare, compareDown, declare, declareDown, defPart, defPartFragments, down, forPartFragments, guardPart, idt1, increment, index, ivar, kvar, kvarAssign, lastJumps, lvar, name, namePart, ref, resultPart, returnResult, rvar, scope, source, step, stepNum, stepVar, svar, varPart, _ref2, _ref3;
|
2639
|
+
body = Block.wrap([this.body]);
|
2640
|
+
lastJumps = (_ref2 = last(body.expressions)) != null ? _ref2.jumps() : void 0;
|
2641
|
+
if (lastJumps && lastJumps instanceof Return) {
|
2642
|
+
this.returns = false;
|
2643
|
+
}
|
2644
|
+
source = this.range ? this.source.base : this.source;
|
2645
|
+
scope = o.scope;
|
2646
|
+
name = this.name && (this.name.compile(o, LEVEL_LIST));
|
2647
|
+
index = this.index && (this.index.compile(o, LEVEL_LIST));
|
2648
|
+
if (name && !this.pattern) {
|
2649
|
+
scope.find(name);
|
2650
|
+
}
|
2651
|
+
if (index) {
|
2652
|
+
scope.find(index);
|
2653
|
+
}
|
2654
|
+
if (this.returns) {
|
2655
|
+
rvar = scope.freeVariable('results');
|
2656
|
+
}
|
2657
|
+
ivar = (this.object && index) || scope.freeVariable('i');
|
2658
|
+
kvar = (this.range && name) || index || ivar;
|
2659
|
+
kvarAssign = kvar !== ivar ? "" + kvar + " = " : "";
|
2660
|
+
if (this.step && !this.range) {
|
2661
|
+
_ref3 = this.cacheToCodeFragments(this.step.cache(o, LEVEL_LIST)), step = _ref3[0], stepVar = _ref3[1];
|
2662
|
+
stepNum = stepVar.match(SIMPLENUM);
|
2663
|
+
}
|
2664
|
+
if (this.pattern) {
|
2665
|
+
name = ivar;
|
2666
|
+
}
|
2667
|
+
varPart = '';
|
2668
|
+
guardPart = '';
|
2669
|
+
defPart = '';
|
2670
|
+
idt1 = this.tab + TAB;
|
2671
|
+
if (this.range) {
|
2672
|
+
forPartFragments = source.compileToFragments(merge(o, {
|
2673
|
+
index: ivar,
|
2674
|
+
name: name,
|
2675
|
+
step: this.step
|
2676
|
+
}));
|
2677
|
+
} else {
|
2678
|
+
svar = this.source.compile(o, LEVEL_LIST);
|
2679
|
+
if ((name || this.own) && !IDENTIFIER.test(svar)) {
|
2680
|
+
defPart += "" + this.tab + (ref = scope.freeVariable('ref')) + " = " + svar + ";\n";
|
2681
|
+
svar = ref;
|
2682
|
+
}
|
2683
|
+
if (name && !this.pattern) {
|
2684
|
+
namePart = "" + name + " = " + svar + "[" + kvar + "]";
|
2685
|
+
}
|
2686
|
+
if (!this.object) {
|
2687
|
+
if (step !== stepVar) {
|
2688
|
+
defPart += "" + this.tab + step + ";\n";
|
2689
|
+
}
|
2690
|
+
if (!(this.step && stepNum && (down = +stepNum < 0))) {
|
2691
|
+
lvar = scope.freeVariable('len');
|
2692
|
+
}
|
2693
|
+
declare = "" + kvarAssign + ivar + " = 0, " + lvar + " = " + svar + ".length";
|
2694
|
+
declareDown = "" + kvarAssign + ivar + " = " + svar + ".length - 1";
|
2695
|
+
compare = "" + ivar + " < " + lvar;
|
2696
|
+
compareDown = "" + ivar + " >= 0";
|
2697
|
+
if (this.step) {
|
2698
|
+
if (stepNum) {
|
2699
|
+
if (down) {
|
2700
|
+
compare = compareDown;
|
2701
|
+
declare = declareDown;
|
2702
|
+
}
|
2703
|
+
} else {
|
2704
|
+
compare = "" + stepVar + " > 0 ? " + compare + " : " + compareDown;
|
2705
|
+
declare = "(" + stepVar + " > 0 ? (" + declare + ") : " + declareDown + ")";
|
2706
|
+
}
|
2707
|
+
increment = "" + ivar + " += " + stepVar;
|
2708
|
+
} else {
|
2709
|
+
increment = "" + (kvar !== ivar ? "++" + ivar : "" + ivar + "++");
|
2710
|
+
}
|
2711
|
+
forPartFragments = [this.makeCode("" + declare + "; " + compare + "; " + kvarAssign + increment)];
|
2712
|
+
}
|
2713
|
+
}
|
2714
|
+
if (this.returns) {
|
2715
|
+
resultPart = "" + this.tab + rvar + " = [];\n";
|
2716
|
+
returnResult = "\n" + this.tab + "return " + rvar + ";";
|
2717
|
+
body.makeReturn(rvar);
|
2718
|
+
}
|
2719
|
+
if (this.guard) {
|
2720
|
+
if (body.expressions.length > 1) {
|
2721
|
+
body.expressions.unshift(new If((new Parens(this.guard)).invert(), new Literal("continue")));
|
2722
|
+
} else {
|
2723
|
+
if (this.guard) {
|
2724
|
+
body = Block.wrap([new If(this.guard, body)]);
|
2725
|
+
}
|
2726
|
+
}
|
2727
|
+
}
|
2728
|
+
if (this.pattern) {
|
2729
|
+
body.expressions.unshift(new Assign(this.name, new Literal("" + svar + "[" + kvar + "]")));
|
2730
|
+
}
|
2731
|
+
defPartFragments = [].concat(this.makeCode(defPart), this.pluckDirectCall(o, body));
|
2732
|
+
if (namePart) {
|
2733
|
+
varPart = "\n" + idt1 + namePart + ";";
|
2734
|
+
}
|
2735
|
+
if (this.object) {
|
2736
|
+
forPartFragments = [this.makeCode("" + kvar + " in " + svar)];
|
2737
|
+
if (this.own) {
|
2738
|
+
guardPart = "\n" + idt1 + "if (!" + (utility('hasProp')) + ".call(" + svar + ", " + kvar + ")) continue;";
|
2739
|
+
}
|
2740
|
+
}
|
2741
|
+
bodyFragments = body.compileToFragments(merge(o, {
|
2742
|
+
indent: idt1
|
2743
|
+
}), LEVEL_TOP);
|
2744
|
+
if (bodyFragments && (bodyFragments.length > 0)) {
|
2745
|
+
bodyFragments = [].concat(this.makeCode("\n"), bodyFragments, this.makeCode("\n"));
|
2746
|
+
}
|
2747
|
+
return [].concat(defPartFragments, this.makeCode("" + (resultPart || '') + this.tab + "for ("), forPartFragments, this.makeCode(") {" + guardPart + varPart), bodyFragments, this.makeCode("" + this.tab + "}" + (returnResult || '')));
|
2748
|
+
};
|
2749
|
+
|
2750
|
+
For.prototype.pluckDirectCall = function(o, body) {
|
2751
|
+
var base, defs, expr, fn, idx, ref, val, _i, _len, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
|
2752
|
+
defs = [];
|
2753
|
+
_ref2 = body.expressions;
|
2754
|
+
for (idx = _i = 0, _len = _ref2.length; _i < _len; idx = ++_i) {
|
2755
|
+
expr = _ref2[idx];
|
2756
|
+
expr = expr.unwrapAll();
|
2757
|
+
if (!(expr instanceof Call)) {
|
2758
|
+
continue;
|
2759
|
+
}
|
2760
|
+
val = expr.variable.unwrapAll();
|
2761
|
+
if (!((val instanceof Code) || (val instanceof Value && ((_ref3 = val.base) != null ? _ref3.unwrapAll() : void 0) instanceof Code && val.properties.length === 1 && ((_ref4 = (_ref5 = val.properties[0].name) != null ? _ref5.value : void 0) === 'call' || _ref4 === 'apply')))) {
|
2762
|
+
continue;
|
2763
|
+
}
|
2764
|
+
fn = ((_ref6 = val.base) != null ? _ref6.unwrapAll() : void 0) || val;
|
2765
|
+
ref = new Literal(o.scope.freeVariable('fn'));
|
2766
|
+
base = new Value(ref);
|
2767
|
+
if (val.base) {
|
2768
|
+
_ref7 = [base, val], val.base = _ref7[0], base = _ref7[1];
|
2769
|
+
}
|
2770
|
+
body.expressions[idx] = new Call(base, expr.args);
|
2771
|
+
defs = defs.concat(this.makeCode(this.tab), new Assign(ref, fn).compileToFragments(o, LEVEL_TOP), this.makeCode(';\n'));
|
2772
|
+
}
|
2773
|
+
return defs;
|
2774
|
+
};
|
2775
|
+
|
2776
|
+
return For;
|
2777
|
+
|
2778
|
+
})(While);
|
2779
|
+
|
2780
|
+
exports.Switch = Switch = (function(_super) {
|
2781
|
+
|
2782
|
+
__extends(Switch, _super);
|
2783
|
+
|
2784
|
+
function Switch(subject, cases, otherwise) {
|
2785
|
+
this.subject = subject;
|
2786
|
+
this.cases = cases;
|
2787
|
+
this.otherwise = otherwise;
|
2788
|
+
}
|
2789
|
+
|
2790
|
+
Switch.prototype.children = ['subject', 'cases', 'otherwise'];
|
2791
|
+
|
2792
|
+
Switch.prototype.isStatement = YES;
|
2793
|
+
|
2794
|
+
Switch.prototype.jumps = function(o) {
|
2795
|
+
var block, conds, _i, _len, _ref2, _ref3, _ref4;
|
2796
|
+
if (o == null) {
|
2797
|
+
o = {
|
2798
|
+
block: true
|
2799
|
+
};
|
2800
|
+
}
|
2801
|
+
_ref2 = this.cases;
|
2802
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
2803
|
+
_ref3 = _ref2[_i], conds = _ref3[0], block = _ref3[1];
|
2804
|
+
if (block.jumps(o)) {
|
2805
|
+
return block;
|
2806
|
+
}
|
2807
|
+
}
|
2808
|
+
return (_ref4 = this.otherwise) != null ? _ref4.jumps(o) : void 0;
|
2809
|
+
};
|
2810
|
+
|
2811
|
+
Switch.prototype.makeReturn = function(res) {
|
2812
|
+
var pair, _i, _len, _ref2, _ref3;
|
2813
|
+
_ref2 = this.cases;
|
2814
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
2815
|
+
pair = _ref2[_i];
|
2816
|
+
pair[1].makeReturn(res);
|
2817
|
+
}
|
2818
|
+
if (res) {
|
2819
|
+
this.otherwise || (this.otherwise = new Block([new Literal('void 0')]));
|
2820
|
+
}
|
2821
|
+
if ((_ref3 = this.otherwise) != null) {
|
2822
|
+
_ref3.makeReturn(res);
|
2823
|
+
}
|
2824
|
+
return this;
|
2825
|
+
};
|
2826
|
+
|
2827
|
+
Switch.prototype.compileNode = function(o) {
|
2828
|
+
var block, body, cond, conditions, expr, fragments, i, idt1, idt2, _i, _j, _len, _len1, _ref2, _ref3, _ref4;
|
2829
|
+
idt1 = o.indent + TAB;
|
2830
|
+
idt2 = o.indent = idt1 + TAB;
|
2831
|
+
fragments = [].concat(this.makeCode(this.tab + "switch ("), (this.subject ? this.subject.compileToFragments(o, LEVEL_PAREN) : this.makeCode("false")), this.makeCode(") {\n"));
|
2832
|
+
_ref2 = this.cases;
|
2833
|
+
for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
|
2834
|
+
_ref3 = _ref2[i], conditions = _ref3[0], block = _ref3[1];
|
2835
|
+
_ref4 = flatten([conditions]);
|
2836
|
+
for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) {
|
2837
|
+
cond = _ref4[_j];
|
2838
|
+
if (!this.subject) {
|
2839
|
+
cond = cond.invert();
|
2840
|
+
}
|
2841
|
+
fragments = fragments.concat(this.makeCode(idt1 + "case "), cond.compileToFragments(o, LEVEL_PAREN), this.makeCode(":\n"));
|
2842
|
+
}
|
2843
|
+
if ((body = block.compileToFragments(o, LEVEL_TOP)).length > 0) {
|
2844
|
+
fragments = fragments.concat(body, this.makeCode('\n'));
|
2845
|
+
}
|
2846
|
+
if (i === this.cases.length - 1 && !this.otherwise) {
|
2847
|
+
break;
|
2848
|
+
}
|
2849
|
+
expr = this.lastNonComment(block.expressions);
|
2850
|
+
if (expr instanceof Return || (expr instanceof Literal && expr.jumps() && expr.value !== 'debugger')) {
|
2851
|
+
continue;
|
2852
|
+
}
|
2853
|
+
fragments.push(cond.makeCode(idt2 + 'break;\n'));
|
2854
|
+
}
|
2855
|
+
if (this.otherwise && this.otherwise.expressions.length) {
|
2856
|
+
fragments.push.apply(fragments, [this.makeCode(idt1 + "default:\n")].concat(__slice.call(this.otherwise.compileToFragments(o, LEVEL_TOP)), [this.makeCode("\n")]));
|
2857
|
+
}
|
2858
|
+
fragments.push(this.makeCode(this.tab + '}'));
|
2859
|
+
return fragments;
|
2860
|
+
};
|
2861
|
+
|
2862
|
+
return Switch;
|
2863
|
+
|
2864
|
+
})(Base);
|
2865
|
+
|
2866
|
+
exports.If = If = (function(_super) {
|
2867
|
+
|
2868
|
+
__extends(If, _super);
|
2869
|
+
|
2870
|
+
function If(condition, body, options) {
|
2871
|
+
this.body = body;
|
2872
|
+
if (options == null) {
|
2873
|
+
options = {};
|
2874
|
+
}
|
2875
|
+
this.condition = options.type === 'unless' ? condition.invert() : condition;
|
2876
|
+
this.elseBody = null;
|
2877
|
+
this.isChain = false;
|
2878
|
+
this.soak = options.soak;
|
2879
|
+
}
|
2880
|
+
|
2881
|
+
If.prototype.children = ['condition', 'body', 'elseBody'];
|
2882
|
+
|
2883
|
+
If.prototype.bodyNode = function() {
|
2884
|
+
var _ref2;
|
2885
|
+
return (_ref2 = this.body) != null ? _ref2.unwrap() : void 0;
|
2886
|
+
};
|
2887
|
+
|
2888
|
+
If.prototype.elseBodyNode = function() {
|
2889
|
+
var _ref2;
|
2890
|
+
return (_ref2 = this.elseBody) != null ? _ref2.unwrap() : void 0;
|
2891
|
+
};
|
2892
|
+
|
2893
|
+
If.prototype.addElse = function(elseBody) {
|
2894
|
+
if (this.isChain) {
|
2895
|
+
this.elseBodyNode().addElse(elseBody);
|
2896
|
+
} else {
|
2897
|
+
this.isChain = elseBody instanceof If;
|
2898
|
+
this.elseBody = this.ensureBlock(elseBody);
|
2899
|
+
}
|
2900
|
+
return this;
|
2901
|
+
};
|
2902
|
+
|
2903
|
+
If.prototype.isStatement = function(o) {
|
2904
|
+
var _ref2;
|
2905
|
+
return (o != null ? o.level : void 0) === LEVEL_TOP || this.bodyNode().isStatement(o) || ((_ref2 = this.elseBodyNode()) != null ? _ref2.isStatement(o) : void 0);
|
2906
|
+
};
|
2907
|
+
|
2908
|
+
If.prototype.jumps = function(o) {
|
2909
|
+
var _ref2;
|
2910
|
+
return this.body.jumps(o) || ((_ref2 = this.elseBody) != null ? _ref2.jumps(o) : void 0);
|
2911
|
+
};
|
2912
|
+
|
2913
|
+
If.prototype.compileNode = function(o) {
|
2914
|
+
if (this.isStatement(o)) {
|
2915
|
+
return this.compileStatement(o);
|
2916
|
+
} else {
|
2917
|
+
return this.compileExpression(o);
|
2918
|
+
}
|
2919
|
+
};
|
2920
|
+
|
2921
|
+
If.prototype.makeReturn = function(res) {
|
2922
|
+
if (res) {
|
2923
|
+
this.elseBody || (this.elseBody = new Block([new Literal('void 0')]));
|
2924
|
+
}
|
2925
|
+
this.body && (this.body = new Block([this.body.makeReturn(res)]));
|
2926
|
+
this.elseBody && (this.elseBody = new Block([this.elseBody.makeReturn(res)]));
|
2927
|
+
return this;
|
2928
|
+
};
|
2929
|
+
|
2930
|
+
If.prototype.ensureBlock = function(node) {
|
2931
|
+
if (node instanceof Block) {
|
2932
|
+
return node;
|
2933
|
+
} else {
|
2934
|
+
return new Block([node]);
|
2935
|
+
}
|
2936
|
+
};
|
2937
|
+
|
2938
|
+
If.prototype.compileStatement = function(o) {
|
2939
|
+
var answer, body, child, cond, exeq, ifPart, indent;
|
2940
|
+
child = del(o, 'chainChild');
|
2941
|
+
exeq = del(o, 'isExistentialEquals');
|
2942
|
+
if (exeq) {
|
2943
|
+
return new If(this.condition.invert(), this.elseBodyNode(), {
|
2944
|
+
type: 'if'
|
2945
|
+
}).compileToFragments(o);
|
2946
|
+
}
|
2947
|
+
indent = o.indent + TAB;
|
2948
|
+
cond = this.condition.compileToFragments(o, LEVEL_PAREN);
|
2949
|
+
body = this.ensureBlock(this.body).compileToFragments(merge(o, {
|
2950
|
+
indent: indent
|
2951
|
+
}));
|
2952
|
+
ifPart = [].concat(this.makeCode("if ("), cond, this.makeCode(") {\n"), body, this.makeCode("\n" + this.tab + "}"));
|
2953
|
+
if (!child) {
|
2954
|
+
ifPart.unshift(this.makeCode(this.tab));
|
2955
|
+
}
|
2956
|
+
if (!this.elseBody) {
|
2957
|
+
return ifPart;
|
2958
|
+
}
|
2959
|
+
answer = ifPart.concat(this.makeCode(' else '));
|
2960
|
+
if (this.isChain) {
|
2961
|
+
o.chainChild = true;
|
2962
|
+
answer = answer.concat(this.elseBody.unwrap().compileToFragments(o, LEVEL_TOP));
|
2963
|
+
} else {
|
2964
|
+
answer = answer.concat(this.makeCode("{\n"), this.elseBody.compileToFragments(merge(o, {
|
2965
|
+
indent: indent
|
2966
|
+
}), LEVEL_TOP), this.makeCode("\n" + this.tab + "}"));
|
2967
|
+
}
|
2968
|
+
return answer;
|
2969
|
+
};
|
2970
|
+
|
2971
|
+
If.prototype.compileExpression = function(o) {
|
2972
|
+
var alt, body, cond, fragments;
|
2973
|
+
cond = this.condition.compileToFragments(o, LEVEL_COND);
|
2974
|
+
body = this.bodyNode().compileToFragments(o, LEVEL_LIST);
|
2975
|
+
alt = this.elseBodyNode() ? this.elseBodyNode().compileToFragments(o, LEVEL_LIST) : [this.makeCode('void 0')];
|
2976
|
+
fragments = cond.concat(this.makeCode(" ? "), body, this.makeCode(" : "), alt);
|
2977
|
+
if (o.level >= LEVEL_COND) {
|
2978
|
+
return this.wrapInBraces(fragments);
|
2979
|
+
} else {
|
2980
|
+
return fragments;
|
2981
|
+
}
|
2982
|
+
};
|
2983
|
+
|
2984
|
+
If.prototype.unfoldSoak = function() {
|
2985
|
+
return this.soak && this;
|
2986
|
+
};
|
2987
|
+
|
2988
|
+
return If;
|
2989
|
+
|
2990
|
+
})(Base);
|
2991
|
+
|
2992
|
+
Closure = {
|
2993
|
+
wrap: function(expressions, statement, noReturn) {
|
2994
|
+
var args, call, func, mentionsArgs, meth;
|
2995
|
+
if (expressions.jumps()) {
|
2996
|
+
return expressions;
|
2997
|
+
}
|
2998
|
+
func = new Code([], Block.wrap([expressions]));
|
2999
|
+
args = [];
|
3000
|
+
if ((mentionsArgs = expressions.contains(this.literalArgs)) || expressions.contains(this.literalThis)) {
|
3001
|
+
if (mentionsArgs && expressions.classBody) {
|
3002
|
+
throw SyntaxError("Class bodies shouldn't reference arguments");
|
3003
|
+
}
|
3004
|
+
meth = new Literal(mentionsArgs ? 'apply' : 'call');
|
3005
|
+
args = [new Literal('this')];
|
3006
|
+
if (mentionsArgs) {
|
3007
|
+
args.push(new Literal('arguments'));
|
3008
|
+
}
|
3009
|
+
func = new Value(func, [new Access(meth)]);
|
3010
|
+
}
|
3011
|
+
func.noReturn = noReturn;
|
3012
|
+
call = new Call(func, args);
|
3013
|
+
if (statement) {
|
3014
|
+
return Block.wrap([call]);
|
3015
|
+
} else {
|
3016
|
+
return call;
|
3017
|
+
}
|
3018
|
+
},
|
3019
|
+
literalArgs: function(node) {
|
3020
|
+
return node instanceof Literal && node.value === 'arguments' && !node.asKey;
|
3021
|
+
},
|
3022
|
+
literalThis: function(node) {
|
3023
|
+
return (node instanceof Literal && node.value === 'this' && !node.asKey) || (node instanceof Code && node.bound) || (node instanceof Call && node.isSuper);
|
3024
|
+
}
|
3025
|
+
};
|
3026
|
+
|
3027
|
+
unfoldSoak = function(o, parent, name) {
|
3028
|
+
var ifn;
|
3029
|
+
if (!(ifn = parent[name].unfoldSoak(o))) {
|
3030
|
+
return;
|
3031
|
+
}
|
3032
|
+
parent[name] = ifn.body;
|
3033
|
+
ifn.body = new Value(parent);
|
3034
|
+
return ifn;
|
3035
|
+
};
|
3036
|
+
|
3037
|
+
UTILITIES = {
|
3038
|
+
"extends": function() {
|
3039
|
+
return "function(child, parent) { for (var key in parent) { if (" + (utility('hasProp')) + ".call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }";
|
3040
|
+
},
|
3041
|
+
indexOf: function() {
|
3042
|
+
return "[].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }";
|
3043
|
+
},
|
3044
|
+
hasProp: function() {
|
3045
|
+
return '{}.hasOwnProperty';
|
3046
|
+
},
|
3047
|
+
slice: function() {
|
3048
|
+
return '[].slice';
|
3049
|
+
}
|
3050
|
+
};
|
3051
|
+
|
3052
|
+
LEVEL_TOP = 1;
|
3053
|
+
|
3054
|
+
LEVEL_PAREN = 2;
|
3055
|
+
|
3056
|
+
LEVEL_LIST = 3;
|
3057
|
+
|
3058
|
+
LEVEL_COND = 4;
|
3059
|
+
|
3060
|
+
LEVEL_OP = 5;
|
3061
|
+
|
3062
|
+
LEVEL_ACCESS = 6;
|
3063
|
+
|
3064
|
+
TAB = ' ';
|
3065
|
+
|
3066
|
+
IDENTIFIER_STR = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*";
|
3067
|
+
|
3068
|
+
IDENTIFIER = RegExp("^" + IDENTIFIER_STR + "$");
|
3069
|
+
|
3070
|
+
SIMPLENUM = /^[+-]?\d+$/;
|
3071
|
+
|
3072
|
+
METHOD_DEF = RegExp("^(?:(" + IDENTIFIER_STR + ")\\.prototype(?:\\.(" + IDENTIFIER_STR + ")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\]))|(" + IDENTIFIER_STR + ")$");
|
3073
|
+
|
3074
|
+
IS_STRING = /^['"]/;
|
3075
|
+
|
3076
|
+
utility = function(name) {
|
3077
|
+
var ref;
|
3078
|
+
ref = "__" + name;
|
3079
|
+
Scope.root.assign(ref, UTILITIES[name]());
|
3080
|
+
return ref;
|
3081
|
+
};
|
3082
|
+
|
3083
|
+
multident = function(code, tab) {
|
3084
|
+
code = code.replace(/\n/g, '$&' + tab);
|
3085
|
+
return code.replace(/\s+$/, '');
|
3086
|
+
};
|
3087
|
+
|
3088
|
+
}).call(this);
|