├── LICENSE
├── Makefile
├── README.md
├── bin
├── dr.js
├── jsctags.js
└── rn.js
├── html
├── doctorjs
│ ├── ajax-loader.gif
│ ├── checked.png
│ ├── couch.gif
│ ├── go.jpg
│ ├── index.html
│ ├── jquery-1.3.2.min.js
│ ├── jquery.qtip-1.0.0-rc3.min.js
│ ├── jquery.spinner.js
│ ├── parse-type.js
│ ├── try.html
│ └── unchecked.png
└── parser.html
├── js
├── jquery-1.4.2.js
├── jstree
│ ├── jquery.tree.js
│ └── themes
│ │ └── default
│ │ ├── dot_for_ie.gif
│ │ ├── icons.png
│ │ ├── style.css
│ │ └── throbber.gif
├── packages.js
├── parser.js
└── tiki.js
├── lib
├── formidable
│ ├── formidable.js
│ ├── incoming_form.js
│ ├── index.js
│ ├── multipart_parser.js
│ └── querystring_parser.js
└── jsctags
│ ├── ctags
│ ├── index.js
│ ├── interp-old.js
│ ├── interp.js
│ ├── nativefn.js
│ ├── reader.js
│ └── writer.js
│ ├── examples
│ ├── .svn
│ │ ├── entries
│ │ └── text-base
│ │ │ ├── baseToObject.js.svn-base
│ │ │ ├── check-crypto-aes.js.svn-base
│ │ │ ├── constructor.js.svn-base
│ │ │ ├── exceptions.js.svn-base
│ │ │ ├── higher-order.js.svn-base
│ │ │ ├── inheritance.js.svn-base
│ │ │ ├── polymorphism.js.svn-base
│ │ │ └── recursion.js.svn-base
│ ├── baseToObject.js
│ ├── check-crypto-aes.js
│ ├── constructor.js
│ ├── exceptions.js
│ ├── higher-order.js
│ ├── higher-order.js~
│ ├── inheritance.js
│ ├── polymorphism.js
│ └── recursion.js
│ ├── getopt.js
│ ├── jstypes.html
│ ├── jstypes.js
│ ├── log.js
│ ├── narcissus
│ ├── index.js
│ ├── jscfa.js
│ ├── jsdefs.js
│ ├── jslex.js
│ ├── jsparse.js
│ ├── nonterms.txt
│ ├── run-tests
│ ├── run-tests.js
│ ├── sunspider
│ │ ├── check-3d-cube.js
│ │ ├── check-3d-cube.tags
│ │ ├── check-3d-morph.js
│ │ ├── check-3d-morph.tags
│ │ ├── check-3d-raytrace.js
│ │ ├── check-3d-raytrace.tags
│ │ ├── check-access-binary-trees.js
│ │ ├── check-access-binary-trees.tags
│ │ ├── check-access-fannkuch.js
│ │ ├── check-access-fannkuch.tags
│ │ ├── check-access-nbody.js
│ │ ├── check-access-nbody.tags
│ │ ├── check-access-nsieve.js
│ │ ├── check-access-nsieve.tags
│ │ ├── check-bitops-3bit-bits-in-byte.js
│ │ ├── check-bitops-3bit-bits-in-byte.tags
│ │ ├── check-bitops-bits-in-byte.js
│ │ ├── check-bitops-bits-in-byte.tags
│ │ ├── check-bitops-bitwise-and.js
│ │ ├── check-bitops-bitwise-and.tags
│ │ ├── check-bitops-nsieve-bits.js
│ │ ├── check-bitops-nsieve-bits.tags
│ │ ├── check-controlflow-recursive.js
│ │ ├── check-controlflow-recursive.tags
│ │ ├── check-crypto-aes.js
│ │ ├── check-crypto-aes.tags
│ │ ├── check-crypto-md5.js
│ │ ├── check-crypto-md5.tags
│ │ ├── check-crypto-sha1.js
│ │ ├── check-crypto-sha1.tags
│ │ ├── check-date-format-tofte.js
│ │ ├── check-date-format-tofte.tags
│ │ ├── check-date-format-xparb.js
│ │ ├── check-date-format-xparb.tags
│ │ ├── check-math-cordic.js
│ │ ├── check-math-cordic.tags
│ │ ├── check-math-partial-sums.js
│ │ ├── check-math-partial-sums.tags
│ │ ├── check-math-spectral-norm.js
│ │ ├── check-math-spectral-norm.tags
│ │ ├── check-mont.js
│ │ ├── check-mont.tags
│ │ ├── check-regexp-dna.js
│ │ ├── check-regexp-dna.tags
│ │ ├── check-string-fasta.js
│ │ ├── check-string-fasta.tags
│ │ ├── check-string-tagcloud.js
│ │ ├── check-string-tagcloud.tags
│ │ ├── check-string-unpack-code.js
│ │ ├── check-string-unpack-code.tags
│ │ └── getctags
│ ├── tests
│ │ ├── test1.js
│ │ ├── test10.js
│ │ ├── test100.js
│ │ ├── test101.js
│ │ ├── test102.js
│ │ ├── test103.js
│ │ ├── test104.js
│ │ ├── test105.js
│ │ ├── test106.js
│ │ ├── test107.js
│ │ ├── test108.js
│ │ ├── test109.js
│ │ ├── test11.js
│ │ ├── test110.js
│ │ ├── test111.js
│ │ ├── test112.js
│ │ ├── test113.js
│ │ ├── test114.js
│ │ ├── test115.js
│ │ ├── test116.js
│ │ ├── test117.js
│ │ ├── test118.js
│ │ ├── test119.js
│ │ ├── test12.js
│ │ ├── test120.js
│ │ ├── test121.js
│ │ ├── test122.js
│ │ ├── test123.js
│ │ ├── test124.js
│ │ ├── test125.js
│ │ ├── test126.js
│ │ ├── test127.js
│ │ ├── test128.js
│ │ ├── test129.js
│ │ ├── test13.js
│ │ ├── test130.js
│ │ ├── test131.js
│ │ ├── test132.js
│ │ ├── test133.js
│ │ ├── test134.js
│ │ ├── test135.js
│ │ ├── test136.js
│ │ ├── test137.js
│ │ ├── test138.js
│ │ ├── test139.js
│ │ ├── test14.js
│ │ ├── test140.js
│ │ ├── test141.js
│ │ ├── test142.js
│ │ ├── test143.js
│ │ ├── test144.js
│ │ ├── test145.js
│ │ ├── test146.js
│ │ ├── test147.js
│ │ ├── test148.js
│ │ ├── test149.js
│ │ ├── test15.js
│ │ ├── test150.js
│ │ ├── test151.js
│ │ ├── test152.js
│ │ ├── test153.js
│ │ ├── test154.js
│ │ ├── test155.js
│ │ ├── test156.js
│ │ ├── test157.js
│ │ ├── test158.js
│ │ ├── test159.js
│ │ ├── test16.js
│ │ ├── test160.js
│ │ ├── test161.js
│ │ ├── test162.js
│ │ ├── test163.js
│ │ ├── test164.js
│ │ ├── test165.js
│ │ ├── test166.js
│ │ ├── test167.js
│ │ ├── test168.js
│ │ ├── test169.js
│ │ ├── test17.js
│ │ ├── test170.js
│ │ ├── test18.js
│ │ ├── test19.js
│ │ ├── test2.js
│ │ ├── test20.js
│ │ ├── test21.js
│ │ ├── test22.js
│ │ ├── test23.js
│ │ ├── test24.js
│ │ ├── test25.js
│ │ ├── test26.js
│ │ ├── test27.js
│ │ ├── test28.js
│ │ ├── test29.js
│ │ ├── test3.js
│ │ ├── test30.js
│ │ ├── test31.js
│ │ ├── test32.js
│ │ ├── test33.js
│ │ ├── test34.js
│ │ ├── test35.js
│ │ ├── test36.js
│ │ ├── test37.js
│ │ ├── test38.js
│ │ ├── test39.js
│ │ ├── test4.js
│ │ ├── test40.js
│ │ ├── test41.js
│ │ ├── test42.js
│ │ ├── test43.js
│ │ ├── test44.js
│ │ ├── test45.js
│ │ ├── test46.js
│ │ ├── test47.js
│ │ ├── test48.js
│ │ ├── test49.js
│ │ ├── test5.js
│ │ ├── test50.js
│ │ ├── test51.js
│ │ ├── test52.js
│ │ ├── test53.js
│ │ ├── test54.js
│ │ ├── test55.js
│ │ ├── test56.js
│ │ ├── test57.js
│ │ ├── test58.js
│ │ ├── test59.js
│ │ ├── test6.js
│ │ ├── test60.js
│ │ ├── test61.js
│ │ ├── test62.js
│ │ ├── test63.js
│ │ ├── test64.js
│ │ ├── test65.js
│ │ ├── test66.js
│ │ ├── test67.js
│ │ ├── test68.js
│ │ ├── test69.js
│ │ ├── test7.js
│ │ ├── test70.js
│ │ ├── test71.js
│ │ ├── test72.js
│ │ ├── test73.js
│ │ ├── test74.js
│ │ ├── test75.js
│ │ ├── test76.js
│ │ ├── test77.js
│ │ ├── test78.js
│ │ ├── test79.js
│ │ ├── test8.js
│ │ ├── test80.js
│ │ ├── test81.js
│ │ ├── test82.js
│ │ ├── test83.js
│ │ ├── test84.js
│ │ ├── test85.js
│ │ ├── test86.js
│ │ ├── test87.js
│ │ ├── test88.js
│ │ ├── test89.js
│ │ ├── test9.js
│ │ ├── test90.js
│ │ ├── test91.js
│ │ ├── test92.js
│ │ ├── test93.js
│ │ ├── test94.js
│ │ ├── test95.js
│ │ ├── test96.js
│ │ ├── test97.js
│ │ ├── test98.js
│ │ └── test99.js
│ └── v8
│ │ ├── base.js
│ │ ├── crypto.js
│ │ ├── crypto.tags
│ │ ├── deltablue.js
│ │ ├── deltablue.tags
│ │ ├── earley-boyer.js
│ │ ├── earley-boyer.tags
│ │ ├── getctags
│ │ ├── google
│ │ ├── base.js
│ │ ├── crypto.js
│ │ ├── crypto.tags
│ │ ├── deltablue.js
│ │ ├── deltablue.tags
│ │ ├── earley-boyer.js
│ │ ├── earley-boyer.tags
│ │ ├── getctags
│ │ ├── raytrace.js
│ │ ├── raytrace.tags
│ │ ├── regexp.js
│ │ ├── regexp.tags
│ │ ├── richards.js
│ │ ├── richards.tags
│ │ ├── run.js
│ │ ├── splay.js
│ │ └── splay.tags
│ │ ├── raytrace.js
│ │ ├── raytrace.tags
│ │ ├── richards.js
│ │ ├── richards.tags
│ │ ├── run-crypto.js
│ │ ├── run-deltablue.js
│ │ ├── run-earley-boyer.js
│ │ ├── run-raytrace.js
│ │ ├── run-richards.js
│ │ └── run.js
│ ├── paperboy.js
│ ├── servetypes.js
│ ├── traits.js
│ └── underscore.js
├── package.json
├── serve.js
└── test
├── readtags.js
└── testcases
├── boot.js
├── jquery-pattern.js
├── simple.js
└── text.js
/Makefile:
--------------------------------------------------------------------------------
1 | PREFIX=/usr/local
2 | INSTALL=install
3 | NODE=node
4 |
5 | BIN_SRC=$(addprefix bin/,jsctags.js)
6 | LIB_SRC=$(addprefix lib/jsctags/,getopt.js log.js paperboy.js traits.js \
7 | underscore.js)
8 | LIB_CTAGS_SRC=$(addprefix lib/jsctags/ctags/,index.js interp.js nativefn.js \
9 | reader.js writer.js)
10 | LIB_NARCISSUS_SRC=$(addprefix lib/jsctags/narcissus/,index.js jscfa.js \
11 | jsdefs.js jslex.js jsparse.js)
12 |
13 | install:
14 | $(INSTALL) -d $(PREFIX)/bin
15 | $(INSTALL) $(BIN_SRC) $(BIN_SRC:%.js=$(PREFIX)/%)
16 | $(INSTALL) -d $(PREFIX)/lib/jsctags
17 | $(INSTALL) $(LIB_SRC) $(PREFIX)/lib/jsctags
18 | $(INSTALL) -d $(PREFIX)/lib/jsctags/ctags
19 | $(INSTALL) $(LIB_CTAGS_SRC) $(PREFIX)/lib/jsctags/ctags
20 | $(INSTALL) -d $(PREFIX)/lib/jsctags/narcissus
21 | $(INSTALL) $(LIB_NARCISSUS_SRC) $(PREFIX)/lib/jsctags/narcissus
22 |
23 | uninstall:
24 | rm -rf $(BIN_SRC:%.js=$(PREFIX)/%) $(PREFIX)/lib/jsctags
25 |
26 | serve:
27 | $(NODE) serve.js
28 |
29 | tags:
30 | $(NODE) bin/jsctags.js -Llib/jsctags js lib/jsctags
31 |
32 | .PHONY: all install uninstall serve tags
33 |
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Overview
2 | --------
3 | jsctags is a [ctags] [1]-compatible code indexing solution for JavaScript. Its
4 | interface and output are essentially identical to [Exuberant Ctags] [2], but,
5 | instead of simply parsing the JavaScript, jsctags uses a simple form of
6 | abstract interpretation to determine which symbols are exported. This allows
7 | jsctags to achieve much better results than Exuberant Ctags. Popular libraries
8 | such as jQuery and CommonJS modules can now be meaningfully indexed.
9 |
10 | You can use jsctags to create `tags` files that are usable in many editors,
11 | from Vim to TextMate (via the [CodeBrowser] [3] plugin). jsctags is slated to
12 | become a key component of the [Bespin] [4] IDE, where it will be used to
13 | provide code completion.
14 |
15 | jsctags is written entirely in JavaScript, using CommonJS modules, the
16 | [node.js] [5] framework, and the [Narcissus] [6] engine.
17 |
18 | License
19 | -------
20 | jsctags is tri-licensed under the Mozilla Public License 1.1, the GNU General
21 | Public License 2.0, and the GNU Lesser General Public License 2.1.
22 |
23 | Requirements
24 | ------------
25 | * node.js
26 | * `make`
27 |
28 | Building
29 | --------
30 | To install:
31 |
32 | * `make install`
33 |
34 | To uninstall:
35 |
36 | * `make uninstall`
37 |
38 | To play with Narcissus' parser:
39 |
40 | * `make serve`
41 | * Navigate to [`http://localhost:8080/html/parser.html`] [parser].
42 |
43 | Usage
44 | -----
45 | Simply go to your project root and invoke `jsctags lib` (replacing `lib` with
46 | the directory in which your JavaScript source files are stored). The `tags`
47 | file will be placed in the current directory.
48 |
49 | For more options, try `jsctags -h`.
50 |
51 | Directory structure
52 | -------------------
53 | The directory structure mostly follows the CommonJS packaging scheme:
54 |
55 | * `bin/`: tools runnable from node.js (should be directly executable in Unix)
56 | * `html/`: in-browser demo files
57 | * `js/`: support files for the HTML demos
58 | * `lib/`: CommonJS-compliant library files
59 | * `lib/ctags/`: the core jsctags code
60 | * `lib/narcissus/`: the Narcissus engine
61 | * `test/`: test cases for the indexer
62 |
63 | [1]: http://en.wikipedia.org/wiki/Ctags
64 | [2]: http://ctags.sourceforge.net/
65 | [3]: http://www.cocoabits.com/TmCodeBrowser/
66 | [4]: http://mozillalabs.com/bespin/
67 | [5]: http://nodejs.org/
68 | [6]: http://mxr.mozilla.org/mozilla/source/js/narcissus/
69 |
70 | [parser]: http://localhost:8080/html/parser.html
71 |
72 |
--------------------------------------------------------------------------------
/bin/rn.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /* ***** BEGIN LICENSE BLOCK *****
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | * http://www.mozilla.org/MPL/
9 | *
10 | * Software distributed under the License is distributed on an "AS IS" basis,
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 | * for the specific language governing rights and limitations under the
13 | * License.
14 | *
15 | * The Original Code is Bespin.
16 | *
17 | * The Initial Developer of the Original Code is
18 | * Mozilla.
19 | * Portions created by the Initial Developer are Copyright (C) 2009
20 | * the Initial Developer. All Rights Reserved.
21 | *
22 | * Contributor(s):
23 | * Bespin Team (bespin@mozilla.com)
24 | *
25 | * Alternatively, the contents of this file may be used under the terms of
26 | * either the GNU General Public License Version 2 or later (the "GPL"), or
27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 | * in which case the provisions of the GPL or the LGPL are applicable instead
29 | * of those above. If you wish to allow use of your version of this file only
30 | * under the terms of either the GPL or the LGPL, and not to allow others to
31 | * use your version of this file under the terms of the MPL, indicate your
32 | * decision by deleting the provisions above and replace them with the notice
33 | * and other provisions required by the GPL or the LGPL. If you do not delete
34 | * the provisions above, a recipient may use your version of this file under
35 | * the terms of any one of the MPL, the GPL or the LGPL.
36 | *
37 | * ***** END LICENSE BLOCK ***** */
38 |
39 | var argv = process.argv;
40 | var path = require('path');
41 |
42 | var cwd = path.dirname(argv[1]);
43 | var libdir = path.join(cwd, "..", "lib");
44 |
45 | require.paths.unshift(path.join(libdir, "jsctags"));
46 |
47 | var sys = require('sys');
48 | var _ = require('underscore')._;
49 | var getTags = require('narcissus/jscfa').getTags;
50 | var parse = require('narcissus/jsparse').parse;
51 |
52 | var stdin = process.openStdin();
53 |
54 | stdin.setEncoding("utf8");
55 |
56 | var buf = [];
57 | stdin.on("data", _(buf.push).bind(buf));
58 | stdin.on("end", function() {
59 | var src = buf.join("");
60 | var lines, ast;
61 | try {
62 | lines = src.split("\n");
63 | ast = parse(src, "js", 1);
64 | } catch (e) {
65 | sys.print(JSON.stringify({ error: e.message, stage: "parse" }));
66 | process.exit();
67 | }
68 |
69 | var json;
70 | try {
71 | json = getTags(ast, "js", lines, {});
72 | } catch (e) {
73 | json = { error: e.message, stage: "analysis" };
74 | }
75 |
76 | sys.print(JSON.stringify(json));
77 | process.exit();
78 | });
79 |
--------------------------------------------------------------------------------
/html/doctorjs/ajax-loader.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilpie/jsctags/8ccbd73f4b576b8a4f9ebdabccafce6714905dbb/html/doctorjs/ajax-loader.gif
--------------------------------------------------------------------------------
/html/doctorjs/checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilpie/jsctags/8ccbd73f4b576b8a4f9ebdabccafce6714905dbb/html/doctorjs/checked.png
--------------------------------------------------------------------------------
/html/doctorjs/couch.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilpie/jsctags/8ccbd73f4b576b8a4f9ebdabccafce6714905dbb/html/doctorjs/couch.gif
--------------------------------------------------------------------------------
/html/doctorjs/go.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilpie/jsctags/8ccbd73f4b576b8a4f9ebdabccafce6714905dbb/html/doctorjs/go.jpg
--------------------------------------------------------------------------------
/html/doctorjs/jquery.spinner.js:
--------------------------------------------------------------------------------
1 | /*
2 | Spinner provides a simple approach for adding and removing a preloader
3 | for your web applications. Usage is as simple as calling $('elem').spinner() and
4 | subsequently $('elem').spinner.remove(). You may create your own preloader
5 | at http://www.ajaxload.info. Please note that if you use a custom preloader,
6 | you must pass in the new height and width as options.
7 |
8 | Copyright (C) 2010 Corey Ballou
9 | Website: http://www.jqueryin.com
10 | Documentation: http://www.jqueryin.com/projects/spinner-jquery-preloader-plugin/
11 |
12 | This program is free software; you can redistribute it and/or modify
13 | it under the terms of the GNU General Public License as published by
14 | the Free Software Foundation; either version 2 of the License, or
15 | (at your option) any later version.
16 |
17 | This program is distributed in the hope that it will be useful,
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | GNU General Public License for more details.
21 |
22 | You should have received a copy of the GNU General Public License along
23 | with this program; if not, write to the Free Software Foundation, Inc.,
24 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | */
26 | (function($) {
27 | $.fn.spinner = function(options) {
28 | var opts = $.extend({}, $.fn.spinner.defaults, options);
29 |
30 | return this.each(function() {
31 | var l=0, t=0, w=0, h=0, shim=0, $s;
32 | var $this = $(this);
33 |
34 | // removal handling
35 | if (options == 'remove' || options == 'close') {
36 | var $s = $this.data('spinner');
37 | var o = $this.data('opts');
38 | if (typeof $s != 'undefined') {
39 | $s.remove();
40 | $this.removeData('spinner').removeData('opts');
41 | if (o.hide) $this.css('visibility', 'visible');
42 | o.onFinish.call(this);
43 | return;
44 | }
45 | }
46 |
47 | // retrieve element positioning
48 | var pos = $this.offset();
49 | w = $this.outerWidth();
50 | h = $this.outerHeight();
51 |
52 | // calculate vertical centering
53 | if (h > opts.height) shim = Math.round((h - opts.height)/ 2);
54 | else if (h < opts.height) shim = 0 - Math.round((opts.height - h) / 2);
55 | t = pos.top + shim + 'px';
56 |
57 | // calculate horizontal positioning
58 | if (opts.position == 'right') {
59 | l = pos.left + w + 10 + 'px';
60 | } else if (opts.position == 'left') {
61 | l = pos.left - opts.width - 10 + 'px';
62 | } else {
63 | l = pos.left + Math.round(.5 * w) - Math.round(.5 * opts.width) + 'px';
64 | }
65 |
66 | // call start callback
67 | opts.onStart.call(this);
68 |
69 | // hide element?
70 | if (opts.hide) $this.css('visibility', 'hidden');
71 |
72 | // create the spinner and attach
73 | $s = $('').appendTo('body');
74 |
75 | // removal handling
76 | $this.data('spinner', $s).data('opts', opts);
77 | });
78 | };
79 |
80 | // default spinner options
81 | $.fn.spinner.defaults = {
82 | position : 'right' // left, right, center
83 | , img : 'spinner.gif' // path to spinner img
84 | , height : 16 // height of spinner img
85 | , width : 16 // width of spinner img
86 | , zIndex : 1001 // z-index of spinner
87 | , hide : false // whether to hide the elem
88 | , onStart : function(){ } // start callback
89 | , onFinish : function(){ } // end callback
90 | };
91 | })(jQuery);
92 |
--------------------------------------------------------------------------------
/html/doctorjs/parse-type.js:
--------------------------------------------------------------------------------
1 | // quick-n-dirty parser of Dimitris's original type format
2 | function parseType(src) {
3 | function match(str) {
4 | var n = str.length;
5 | if (src.length && src.substring(0, n) === str) {
6 | src = src.substring(n).trim();
7 | return true;
8 | }
9 | return false;
10 | }
11 |
12 | function mustMatch(str, msg) {
13 | if (!match(str))
14 | throw new Error(msg + " (" + src + ")");
15 | }
16 |
17 | function Type() {
18 | var root;
19 | if (match("any")) {
20 | root = "any";
21 | } else if (match("string")) {
22 | root = "string";
23 | } else if (match("number")) {
24 | root = "number";
25 | } else if (match("Array")) {
26 | if (match("[")) {
27 | root = { kind: "array", elementType: Type() };
28 | mustMatch("]", "invalid array type");
29 | } else {
30 | root = { kind: "array", elementType: "any" };
31 | }
32 | } else if (src.length && src[0] === "<") {
33 | root = UnionType();
34 | } else {
35 | var re = /^([a-zA-Z_$][a-zA-Z_$0-9]*)/;
36 | var result = re.exec(src);
37 | if (!result)
38 | throw new Error("unrecognized type: " + src);
39 | root = result[0];
40 | src = src.substring(root.length).trim();
41 | }
42 |
43 | while (match("function")) {
44 | mustMatch("(", "invalid function type");
45 | var args = [];
46 | if (!match(")")) {
47 | do {
48 | args.push(Type());
49 | } while (match(","));
50 | mustMatch(")", "invalid function type");
51 | }
52 | root = { kind: "function", returnType: root, argTypes: args };
53 | }
54 |
55 | return root;
56 | }
57 |
58 | function UnionType() {
59 | mustMatch("<", "invalid union type");
60 | var variants = [];
61 | if (!match(">")) {
62 | do {
63 | variants.push(Type());
64 | } while (match("|"));
65 | mustMatch(">", "invalid union type");
66 | }
67 | return { kind: "union", variants: variants };
68 | }
69 |
70 | return Type();
71 | }
72 |
73 | // formatType : JSON type -> HTML source
74 | // render the JSON type as pretty HTML
75 | function formatType(type) {
76 | if (typeof type === "string")
77 | return type;
78 |
79 | if (type.kind === "function") {
80 | return "function(" +
81 | type.argTypes.map(formatType).join(", ") +
82 | ") → " +
83 | formatType(type.returnType);
84 | } else if (type.kind === "array") {
85 | return "Array[" + formatType(type.elementType) + "]";
86 | } else if (type.kind === "union") {
87 | return "<" + type.variants.map(formatType).join(" | ") + ">";
88 | }
89 |
90 | throw new Error("unrecognized type");
91 | }
92 |
--------------------------------------------------------------------------------
/html/doctorjs/unchecked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilpie/jsctags/8ccbd73f4b576b8a4f9ebdabccafce6714905dbb/html/doctorjs/unchecked.png
--------------------------------------------------------------------------------
/html/parser.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | JavaScript parser
5 |
6 |
7 |
8 |
JavaScript parser
9 |
10 |
11 |
12 |
13 |
14 | Paste in some JavaScript and the parse tree will be displayed over there!
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/js/jstree/themes/default/dot_for_ie.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilpie/jsctags/8ccbd73f4b576b8a4f9ebdabccafce6714905dbb/js/jstree/themes/default/dot_for_ie.gif
--------------------------------------------------------------------------------
/js/jstree/themes/default/icons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilpie/jsctags/8ccbd73f4b576b8a4f9ebdabccafce6714905dbb/js/jstree/themes/default/icons.png
--------------------------------------------------------------------------------
/js/jstree/themes/default/style.css:
--------------------------------------------------------------------------------
1 | /* LOCKED */
2 | .tree-default .locked li a { color:gray; }
3 | /* DOTS */
4 | .tree-default ul { background-position:6px 1px; background-repeat:repeat-y; background-image:url(data:image/gif;base64,R0lGODlhAgACAIAAAB4dGf///yH5BAEAAAEALAAAAAACAAIAAAICRF4AOw==); _background-image:url("dot_for_ie.gif"); *background-image:url("dot_for_ie.gif"); }
5 | .tree-default li { background-position:-64px -16px; background-repeat:no-repeat; background-image:url("icons.png"); }
6 | /* NO DOTS */
7 | .tree-default .no_dots, .tree-default .no_dots ul { background:transparent; }
8 | .tree-default .no_dots li.leaf { background-image:none; background-color:transparent; }
9 | /* OPEN or CLOSED */
10 | .tree-default li.open { background:url("icons.png") -32px -48px no-repeat; }
11 | .tree-default li.closed, #jstree-dragged.tree-default li li.open { background:url("icons.png") -48px -32px no-repeat; }
12 | #jstree-marker { background-image:url("icons.png"); }
13 | /* DEFAULT, HOVER, CLICKED, LOADING STATES */
14 | .tree-default li a, .tree-default li span { border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px; }
15 | .tree-default li a:hover, .tree-default li a.hover, .tree-default li span { background: #e7f4f9; border:1px solid #d8f0fa; padding:0px 3px 0px 3px; }
16 | .tree-default li a.clicked, .tree-default li a.clicked:hover, .tree-default li span.clicked { background: #beebff; border:1px solid #99defd; padding:0px 3px 0px 3px; }
17 | /* ICONS */
18 | .tree-default ins { background-image:url("icons.png"); background-position:0 0; background-repeat:no-repeat; }
19 | .tree-default ul li a.loading ins { background-image:url("throbber.gif") !important; background-position:0 0 !important; } /* UL is added to make selector stronger */
20 | .tree-default li a ins.forbidden { background-position:-16px -16px; }
21 | .tree-default .locked li a ins { background-position:0 -48px; }
22 | .tree-default li span ins { background-position:-16px 0; }
23 | #jstree-dragged.tree-default ins { background:url("icons.png") -16px -32px no-repeat; }
24 | #jstree-dragged.tree-default ins.forbidden { background:url("icons.png") -16px -16px no-repeat; }
25 |
26 | /* CONTEXT MENU */
27 | .tree-default-context a ins { background-image:url("icons.png"); background-repeat:no-repeat; background-position:-64px -64px; }
28 | .tree-default-context a ins.create { background-position:0 -16px; }
29 | .tree-default-context a ins.rename { background-position:-16px 0px; }
30 | .tree-default-context a ins.remove { background-position:0 -32px; }
--------------------------------------------------------------------------------
/js/jstree/themes/default/throbber.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilpie/jsctags/8ccbd73f4b576b8a4f9ebdabccafce6714905dbb/js/jstree/themes/default/throbber.gif
--------------------------------------------------------------------------------
/js/packages.js:
--------------------------------------------------------------------------------
1 | /* ***** BEGIN LICENSE BLOCK *****
2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 | *
4 | * The contents of this file are subject to the Mozilla Public License Version
5 | * 1.1 (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | * http://www.mozilla.org/MPL/
8 | *
9 | * Software distributed under the License is distributed on an "AS IS" basis,
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 | * for the specific language governing rights and limitations under the
12 | * License.
13 | *
14 | * The Original Code is Bespin.
15 | *
16 | * The Initial Developer of the Original Code is
17 | * Mozilla.
18 | * Portions created by the Initial Developer are Copyright (C) 2009
19 | * the Initial Developer. All Rights Reserved.
20 | *
21 | * Contributor(s):
22 | * Bespin Team (bespin@mozilla.com)
23 | *
24 | * Alternatively, the contents of this file may be used under the terms of
25 | * either the GNU General Public License Version 2 or later (the "GPL"), or
26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
28 | * of those above. If you wish to allow use of your version of this file only
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
30 | * use your version of this file under the terms of the MPL, indicate your
31 | * decision by deleting the provisions above and replace them with the notice
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
33 | * the provisions above, a recipient may use your version of this file under
34 | * the terms of any one of the MPL, the GPL or the LGPL.
35 | *
36 | * ***** END LICENSE BLOCK ***** */
37 |
38 | // This script exports the CommonJS packages in the lib/ directory to Tiki so
39 | // that they can be loaded in the browser.
40 |
41 | tiki.register('::narcissus', {
42 | name: 'narcissus',
43 | version: "0.0.0",
44 | 'tiki:resources': [
45 | {
46 | id: 'narcissus:index',
47 | name: 'index',
48 | url: "../lib/jsctags/narcissus/index.js",
49 | type: 'script'
50 | },
51 | {
52 | id: 'narcissus:jsdefs',
53 | name: 'jsdefs.js',
54 | url: "../lib/jsctags/narcissus/jsdefs.js",
55 | type: 'script'
56 | },
57 | {
58 | id: 'narcissus:jslex',
59 | name: 'jslex.js',
60 | url: "../lib/jsctags/narcissus/jslex.js",
61 | type: 'script'
62 | },
63 | {
64 | id: 'narcissus:jsparse',
65 | name: 'jsparse.js',
66 | url: "../lib/jsctags/narcissus/jsparse.js",
67 | type: 'script'
68 | } ,
69 | {
70 | id: 'narcissus:jscfa',
71 | name: 'jscfa.js',
72 | url: "../lib/jsctags/narcissus/jscfa.js",
73 | type: 'script'
74 | }
75 | ]
76 | });
77 |
78 | // Turn on autowrap so that the same .js files can be used both offline and in
79 | // Tiki.
80 | var browser = tiki.require.loader.sources[0];
81 | browser.xhr = true;
82 | browser.autowrap = true;
83 |
84 |
--------------------------------------------------------------------------------
/lib/formidable/formidable.js:
--------------------------------------------------------------------------------
1 | exports.IncomingForm = require('./incoming_form').IncomingForm;
--------------------------------------------------------------------------------
/lib/formidable/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./formidable');
--------------------------------------------------------------------------------
/lib/formidable/querystring_parser.js:
--------------------------------------------------------------------------------
1 | if (global.GENTLY) require = GENTLY.hijack(require);
2 |
3 | // This is a buffering parser, not quite as nice as the multipart one.
4 | // If I find time I'll rewrite this to be fully streaming as well
5 | var querystring = require('querystring');
6 |
7 | function QuerystringParser() {
8 | this.buffer = '';
9 | };
10 | exports.QuerystringParser = QuerystringParser;
11 |
12 | QuerystringParser.prototype.write = function(buffer) {
13 | this.buffer += buffer.toString('ascii');
14 | return buffer.length;
15 | };
16 |
17 | QuerystringParser.prototype.end = function() {
18 | var fields = querystring.parse(this.buffer);
19 | for (var field in fields) {
20 | this.onField(field, fields[field]);
21 | }
22 | this.buffer = '';
23 |
24 | this.onEnd();
25 | };
--------------------------------------------------------------------------------
/lib/jsctags/ctags/interp.js:
--------------------------------------------------------------------------------
1 | /* ***** BEGIN LICENSE BLOCK *****
2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 | *
4 | * The contents of this file are subject to the Mozilla Public License Version
5 | * 1.1 (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | * http://www.mozilla.org/MPL/
8 | *
9 | * Software distributed under the License is distributed on an "AS IS" basis,
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 | * for the specific language governing rights and limitations under the
12 | * License.
13 | *
14 | * The Original Code is Bespin.
15 | *
16 | * The Initial Developer of the Original Code is
17 | * Mozilla.
18 | * Portions created by the Initial Developer are Copyright (C) 2009
19 | * the Initial Developer. All Rights Reserved.
20 | *
21 | * Contributor(s):
22 | * Bespin Team (bespin@mozilla.com)
23 | *
24 | * Alternatively, the contents of this file may be used under the terms of
25 | * either the GNU General Public License Version 2 or later (the "GPL"), or
26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
28 | * of those above. If you wish to allow use of your version of this file only
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
30 | * use your version of this file under the terms of the MPL, indicate your
31 | * decision by deleting the provisions above and replace them with the notice
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
33 | * the provisions above, a recipient may use your version of this file under
34 | * the terms of any one of the MPL, the GPL or the LGPL.
35 | *
36 | * ***** END LICENSE BLOCK ***** */
37 |
38 | // Abstract interpreter, based on Narcissus.
39 |
40 | var getTags = require('narcissus/jscfa').getTags;
41 |
42 | //dimvar: opts stands for options. If we are using commonJS it gives
43 | //info about the module (see getModuleInfo@jsctags.js).
44 | exports.Interpreter = function(ast, file, lines, opts) {
45 | this.ast = ast;
46 | this.file = file;
47 | this.lines = lines;
48 | this.opts = opts;
49 | this.tags = [];
50 | };
51 |
52 | exports.Interpreter.prototype = {
53 | interpret: function() {
54 | this.tags = getTags(this.ast, this.file, this.lines, this.opts);
55 | }
56 | };
57 |
58 |
--------------------------------------------------------------------------------
/lib/jsctags/ctags/nativefn.js:
--------------------------------------------------------------------------------
1 | /* ***** BEGIN LICENSE BLOCK *****
2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 | *
4 | * The contents of this file are subject to the Mozilla Public License Version
5 | * 1.1 (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | * http://www.mozilla.org/MPL/
8 | *
9 | * Software distributed under the License is distributed on an "AS IS" basis,
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 | * for the specific language governing rights and limitations under the
12 | * License.
13 | *
14 | * The Original Code is Bespin.
15 | *
16 | * The Initial Developer of the Original Code is
17 | * Mozilla.
18 | * Portions created by the Initial Developer are Copyright (C) 2009
19 | * the Initial Developer. All Rights Reserved.
20 | *
21 | * Contributor(s):
22 | * Bespin Team (bespin@mozilla.com)
23 | *
24 | * Alternatively, the contents of this file may be used under the terms of
25 | * either the GNU General Public License Version 2 or later (the "GPL"), or
26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
28 | * of those above. If you wish to allow use of your version of this file only
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
30 | * use your version of this file under the terms of the MPL, indicate your
31 | * decision by deleting the provisions above and replace them with the notice
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
33 | * the provisions above, a recipient may use your version of this file under
34 | * the terms of any one of the MPL, the GPL or the LGPL.
35 | *
36 | * ***** END LICENSE BLOCK ***** */
37 |
38 | // Functions important for export detection that that we try to automatically
39 | // detect and implement.
40 |
41 | var sys = require('sys');
42 |
43 | // jQuery's "extend".
44 | function extend(interp, ctx, thisObject, args) {
45 | var objects = args.data.slice(0);
46 | if (objects.length === 0) {
47 | return interp.getNullValue();
48 | }
49 |
50 | var target = objects.length === 1 ? thisObject : objects.shift();
51 | interp.coerceToStorable(target);
52 |
53 | objects.forEach(function(obj) {
54 | for (var key in obj.data) {
55 | target.data[key] = obj.data[key];
56 | }
57 | });
58 |
59 | return target;
60 | }
61 |
62 | exports.nativeFns = {
63 | extend: extend, // jQuery
64 | mixin: extend // dojo, Bespin
65 | };
66 |
67 |
--------------------------------------------------------------------------------
/lib/jsctags/ctags/reader.js:
--------------------------------------------------------------------------------
1 | /* ***** BEGIN LICENSE BLOCK *****
2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 | *
4 | * The contents of this file are subject to the Mozilla Public License Version
5 | * 1.1 (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | * http://www.mozilla.org/MPL/
8 | *
9 | * Software distributed under the License is distributed on an "AS IS" basis,
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 | * for the specific language governing rights and limitations under the
12 | * License.
13 | *
14 | * The Original Code is Bespin.
15 | *
16 | * The Initial Developer of the Original Code is
17 | * Mozilla.
18 | * Portions created by the Initial Developer are Copyright (C) 2009
19 | * the Initial Developer. All Rights Reserved.
20 | *
21 | * Contributor(s):
22 | * Bespin Team (bespin@mozilla.com)
23 | *
24 | * Alternatively, the contents of this file may be used under the terms of
25 | * either the GNU General Public License Version 2 or later (the "GPL"), or
26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
28 | * of those above. If you wish to allow use of your version of this file only
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
30 | * use your version of this file under the terms of the MPL, indicate your
31 | * decision by deleting the provisions above and replace them with the notice
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
33 | * the provisions above, a recipient may use your version of this file under
34 | * the terms of any one of the MPL, the GPL or the LGPL.
35 | *
36 | * ***** END LICENSE BLOCK ***** */
37 |
38 | var _ = require('underscore')._;
39 | var Trait = require('traits').Trait;
40 |
41 | exports.TagReader = Trait({
42 | readLines: function(lines) {
43 | var tags = [];
44 |
45 | _(lines).each(function(line) {
46 | var parts = line.split("\t");
47 | if (parts.length < 3) {
48 | return;
49 | }
50 |
51 | var name = parts[0];
52 | if (/^!_TAG_/.test(name)) {
53 | return;
54 | }
55 |
56 | // TODO: cope with tab characters in the addr
57 | var tag = { name: name, tagfile: parts[1], addr: parts[2] };
58 |
59 | var fieldIndex;
60 | if (parts.length > 3 && parts[3].indexOf(":") === -1) {
61 | tag.kind = parts[3];
62 | fieldIndex = 4;
63 | } else {
64 | fieldIndex = 3;
65 | }
66 |
67 | var fields = {};
68 | _(parts.slice(fieldIndex)).each(function(field) {
69 | var match = /^([^:]+):(.*)/.exec(field);
70 | fields[match[1]] = match[2];
71 | });
72 | tag.fields = fields;
73 |
74 | tags.push(tag);
75 | });
76 |
77 | this.add(tags);
78 | },
79 |
80 | readString: function(str) {
81 | this.readLines(str.split("\n"));
82 | }
83 | });
84 |
85 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 59
5 | file:///home/dimvar/moz/moz-repo/demo/examples
6 | file:///home/dimvar/moz/moz-repo
7 |
8 |
9 |
10 | 2010-08-12T16:58:48.051040Z
11 | 59
12 | dimvar
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 5523cf2d-1304-4e5e-ab2c-8ab00989f7fa
28 |
29 | baseToObject.js
30 | file
31 |
32 |
33 |
34 |
35 | 2010-08-12T07:34:31.832936Z
36 | dc3dc46ffdcc6df1fbf8dd914dfa83ff
37 | 2010-08-12T16:58:48.051040Z
38 | 59
39 | dimvar
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 110
62 |
63 | constructor.js
64 | file
65 |
66 |
67 |
68 |
69 | 2010-08-12T05:35:47.582344Z
70 | 304b4e8e8c42e2fca241a271397c0947
71 | 2010-08-12T16:58:48.051040Z
72 | 59
73 | dimvar
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | 118
96 |
97 | inheritance.js
98 | file
99 |
100 |
101 |
102 |
103 | 2010-08-12T05:36:07.491969Z
104 | 42759be90026614ce13533cfc5ac6fe3
105 | 2010-08-12T16:58:48.051040Z
106 | 59
107 | dimvar
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | 172
130 |
131 | recursion.js
132 | file
133 |
134 |
135 |
136 |
137 | 2010-08-12T05:29:04.552036Z
138 | 3a477f9565b504135f84f70f79ad4e13
139 | 2010-08-12T16:58:48.051040Z
140 | 59
141 | dimvar
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 | 449
164 |
165 | higher-order.js
166 | file
167 | 62
168 |
169 |
170 |
171 | 2010-08-12T23:24:56.323056Z
172 | 5d582b93917d67da42d753a1cd30d7d1
173 | 2010-08-13T19:15:08.606507Z
174 | 62
175 | dimvar
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 | 204
198 |
199 | exceptions.js
200 | file
201 |
202 |
203 |
204 |
205 | 2010-08-12T05:36:28.281138Z
206 | affa83abe6553ac7494818d112b3bac6
207 | 2010-08-12T16:58:48.051040Z
208 | 59
209 | dimvar
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 | 359
232 |
233 | check-crypto-aes.js
234 | file
235 |
236 |
237 |
238 |
239 | 2010-08-12T00:19:06.164897Z
240 | 6e7621d30b3e862b8469e16ebc4fae5c
241 | 2010-08-12T16:58:48.051040Z
242 | 59
243 | dimvar
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 | 17083
266 |
267 | polymorphism.js
268 | file
269 |
270 |
271 |
272 |
273 | 2010-08-12T05:35:18.072349Z
274 | 33159a59c49f5ab0f1f30264de4865ff
275 | 2010-08-12T16:58:48.051040Z
276 | 59
277 | dimvar
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 | 70
300 |
301 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/.svn/text-base/baseToObject.js.svn-base:
--------------------------------------------------------------------------------
1 | // automatic conversion of a base value to an object to call a method on it
2 | var n = 1;
3 |
4 | var s = n.toString();
5 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/.svn/text-base/constructor.js.svn-base:
--------------------------------------------------------------------------------
1 | var x;
2 |
3 | function foo() {
4 | x = 123;
5 | }
6 |
7 | var u = foo();
8 |
9 | function Bar(x) {
10 | this.x = x;
11 | }
12 |
13 | var b = (new Bar(4)).x;
14 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/.svn/text-base/exceptions.js.svn-base:
--------------------------------------------------------------------------------
1 | function findLargest(a) {
2 | if (a.length === 0) throw new Error("empty array");
3 | var max = a[0];
4 | for (var i = 1, l = a.length; i < l; i++)
5 | if (a[i] > max)
6 | max = a[i];
7 | return max;
8 | }
9 |
10 | function foo() {
11 | var a = [1,2,3];
12 |
13 | try {
14 | return findLargest(a);
15 | }
16 | catch (e) {
17 | return e.message;
18 | }
19 | }
20 |
21 | foo();
22 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/.svn/text-base/higher-order.js.svn-base:
--------------------------------------------------------------------------------
1 | function app(f, x) {
2 | return f(x);
3 | }
4 |
5 | function add5(x) {
6 | return x + 5;
7 | }
8 |
9 | function butLast(x) {
10 | return x.substring(0, x.length - 1);
11 | }
12 |
13 | var n = app(add5, 123);
14 |
15 | var s = app(butLast, "abcd");
16 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/.svn/text-base/inheritance.js.svn-base:
--------------------------------------------------------------------------------
1 | function Rectangle(w, h) {
2 | this.w = w;
3 | this.h = h;
4 | }
5 |
6 | Rectangle.prototype.area = function() {
7 | return this.w * this.h;
8 | };
9 |
10 | var a = (new Rectangle(2, 3)).area();
11 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/.svn/text-base/polymorphism.js.svn-base:
--------------------------------------------------------------------------------
1 | function id(x) {
2 | return x;
3 | }
4 |
5 | var n = id(9);
6 |
7 | var s = id("asdf");
8 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/.svn/text-base/recursion.js.svn-base:
--------------------------------------------------------------------------------
1 | //SunSpider
2 |
3 | function ack(m,n){
4 | if (m==0) { return n+1; }
5 | if (n==0) { return ack(m-1,1); }
6 | return ack(m-1, ack(m,n-1) );
7 | }
8 |
9 | function fib(n) {
10 | if (n < 2){ return 1; }
11 | return fib(n-2) + fib(n-1);
12 | }
13 |
14 | function tak(x,y,z) {
15 | if (y >= x) return z;
16 | return tak(tak(x-1,y,z), tak(y-1,z,x), tak(z-1,x,y));
17 | }
18 |
19 | var ret = 0;
20 | for ( var i = 3; i <= 5; i++ ) {
21 | ret += ack(3,i);
22 | ret += fib(17.0+i);
23 | ret += tak(3*i+3,2*i+2,i+1);
24 | }
25 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/baseToObject.js:
--------------------------------------------------------------------------------
1 | // automatic conversion of a base value to an object to call a method on it
2 | var n = 1;
3 |
4 | var s = n.toString();
5 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/constructor.js:
--------------------------------------------------------------------------------
1 | var x;
2 |
3 | function foo() {
4 | x = 123;
5 | }
6 |
7 | var u = foo();
8 |
9 | function Bar(x) {
10 | this.x = x;
11 | }
12 |
13 | var b = (new Bar(4)).x;
14 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/exceptions.js:
--------------------------------------------------------------------------------
1 | function findLargest(a) {
2 | if (a.length === 0) throw new Error("empty array");
3 | var max = a[0];
4 | for (var i = 1, l = a.length; i < l; i++)
5 | if (a[i] > max)
6 | max = a[i];
7 | return max;
8 | }
9 |
10 | function foo() {
11 | var a = [1,2,3];
12 |
13 | try {
14 | return findLargest(a);
15 | }
16 | catch (e) {
17 | return e.message;
18 | }
19 | }
20 |
21 | foo();
22 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/higher-order.js:
--------------------------------------------------------------------------------
1 | function app(f, x) {
2 | return f(x);
3 | }
4 |
5 | function add5(x) {
6 | return x + 5;
7 | }
8 |
9 | function butLast(x) {
10 | return x.substring(0, x.length - 1);
11 | }
12 |
13 | var n = app(add5, 123);
14 |
15 | var s = app(butLast, "abcd");
16 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/higher-order.js~:
--------------------------------------------------------------------------------
1 | function app(f, x) {
2 | return f(x);
3 | }
4 |
5 | function add5(x) {
6 | return x + 5;
7 | }
8 |
9 | function butLast(x) {
10 | return x.substring(0, x.length - 1);
11 | }
12 |
13 | var n = app(add5, 123);
14 |
15 | var s = app(butLast, "abcd");
16 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/inheritance.js:
--------------------------------------------------------------------------------
1 | function Rectangle(w, h) {
2 | this.w = w;
3 | this.h = h;
4 | }
5 |
6 | Rectangle.prototype.area = function() {
7 | return this.w * this.h;
8 | };
9 |
10 | var a = (new Rectangle(2, 3)).area();
11 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/polymorphism.js:
--------------------------------------------------------------------------------
1 | function id(x) {
2 | return x;
3 | }
4 |
5 | var n = id(9);
6 |
7 | var s = id("asdf");
8 |
--------------------------------------------------------------------------------
/lib/jsctags/examples/recursion.js:
--------------------------------------------------------------------------------
1 | //SunSpider
2 |
3 | function ack(m,n){
4 | if (m==0) { return n+1; }
5 | if (n==0) { return ack(m-1,1); }
6 | return ack(m-1, ack(m,n-1) );
7 | }
8 |
9 | function fib(n) {
10 | if (n < 2){ return 1; }
11 | return fib(n-2) + fib(n-1);
12 | }
13 |
14 | function tak(x,y,z) {
15 | if (y >= x) return z;
16 | return tak(tak(x-1,y,z), tak(y-1,z,x), tak(z-1,x,y));
17 | }
18 |
19 | var ret = 0;
20 | for ( var i = 3; i <= 5; i++ ) {
21 | ret += ack(3,i);
22 | ret += fib(17.0+i);
23 | ret += tak(3*i+3,2*i+2,i+1);
24 | }
25 |
--------------------------------------------------------------------------------
/lib/jsctags/jstypes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | JavaScript Type Inference
5 |
6 |
7 |
8 |
9 |
10 |
58 |
59 |
60 |
61 |
62 | Examples:
63 |
64 |
polymorphism
65 |
convert to object
66 |
new vs no new
67 |
inheritance
68 |
recursion
69 |
first-class functions
70 |
exceptions
71 |
check-crypto-aes
72 |
73 |
74 |
75 |
76 |
77 | JavaScript type inference
78 |
79 |
80 |
81 | The type inference algorithm is based on the CFA2 control-flow
82 | analysis.
83 | Currently, it handles core JavaScript only (DOM support will be added
84 | soon). For comments and suggestions, email:
85 | dvardoulakis at mozilla dot com.
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
96 |
97 |
98 |
99 |
100 |
Line
Name
Type
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/lib/jsctags/jstypes.js:
--------------------------------------------------------------------------------
1 | function fill(s) {
2 | var req = new XMLHttpRequest();
3 | req.open("GET", s, false);
4 | req.send(null);
5 | if ((req.status == 200) || (req.status == 0)) {
6 | var textarea = document.getElementById("js");
7 | textarea.value = req.responseText;
8 | }
9 | }
10 |
11 | function gettypes() {
12 | var textarea = document.getElementById("js");
13 | var src = document.getElementById("js").value;
14 | var lines = src.split("\n");
15 | var ast = parse(src, "js", 1);
16 | var tags = getTags(ast, "js", lines, {});
17 | var result = document.getElementById("types");
18 |
19 | tags.sort(function(t1, t2) {
20 | var l1 = t1.lineno, l2 = t2.lineno;
21 | return l1 - l2;
22 | });
23 |
24 | var colnames = document.getElementById("colnames");
25 | colnames.style.visibility = "visible";
26 |
27 | for (var i = 1, l = result.rows.length; i < l; i++)
28 | result.deleteRow(-1);
29 |
30 | result.style.fontFamily = "sans-serif";
31 | tags.forEach(function(t) {
32 | var row = result.insertRow(-1);
33 | var cell = row.insertCell(0);
34 | cell.textContent = t.lineno;
35 | cell = row.insertCell(1);
36 | cell.textContent = t.name;
37 | cell = row.insertCell(2);
38 | cell.textContent = t.type;
39 | });
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/lib/jsctags/log.js:
--------------------------------------------------------------------------------
1 | /* ***** BEGIN LICENSE BLOCK *****
2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 | *
4 | * The contents of this file are subject to the Mozilla Public License Version
5 | * 1.1 (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | * http://www.mozilla.org/MPL/
8 | *
9 | * Software distributed under the License is distributed on an "AS IS" basis,
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 | * for the specific language governing rights and limitations under the
12 | * License.
13 | *
14 | * The Original Code is Bespin.
15 | *
16 | * The Initial Developer of the Original Code is
17 | * Mozilla.
18 | * Portions created by the Initial Developer are Copyright (C) 2009
19 | * the Initial Developer. All Rights Reserved.
20 | *
21 | * Contributor(s):
22 | * Bespin Team (bespin@mozilla.com)
23 | *
24 | * Alternatively, the contents of this file may be used under the terms of
25 | * either the GNU General Public License Version 2 or later (the "GPL"), or
26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
28 | * of those above. If you wish to allow use of your version of this file only
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
30 | * use your version of this file under the terms of the MPL, indicate your
31 | * decision by deleting the provisions above and replace them with the notice
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
33 | * the provisions above, a recipient may use your version of this file under
34 | * the terms of any one of the MPL, the GPL or the LGPL.
35 | *
36 | * ***** END LICENSE BLOCK ***** */
37 |
38 | var sys = require('sys');
39 |
40 | function log(level, args) {
41 | if (level >= exports.level) {
42 | sys.puts(Array.prototype.join.call(args, " "));
43 | }
44 | }
45 |
46 | var levels = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
47 | exports.levels = levels;
48 |
49 | exports.level = levels.ERROR;
50 |
51 | exports.debug = function() { log(levels.DEBUG, arguments); };
52 | exports.warn = function() { log(levels.WARN, arguments); };
53 | exports.info = function() { log(levels.INFO, arguments); };
54 | exports.error = function() { log(levels.ERROR, arguments); };
55 |
56 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/index.js:
--------------------------------------------------------------------------------
1 | /* ***** BEGIN LICENSE BLOCK *****
2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 | *
4 | * The contents of this file are subject to the Mozilla Public License Version
5 | * 1.1 (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | * http://www.mozilla.org/MPL/
8 | *
9 | * Software distributed under the License is distributed on an "AS IS" basis,
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 | * for the specific language governing rights and limitations under the
12 | * License.
13 | *
14 | * The Original Code is the Narcissus JavaScript engine.
15 | *
16 | * The Initial Developer of the Original Code is
17 | * Brendan Eich .
18 | * Portions created by the Initial Developer are Copyright (C) 2004
19 | * the Initial Developer. All Rights Reserved.
20 | *
21 | * Contributor(s):
22 | *
23 | * Alternatively, the contents of this file may be used under the terms of
24 | * either the GNU General Public License Version 2 or later (the "GPL"), or
25 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 | * in which case the provisions of the GPL or the LGPL are applicable instead
27 | * of those above. If you wish to allow use of your version of this file only
28 | * under the terms of either the GPL or the LGPL, and not to allow others to
29 | * use your version of this file under the terms of the MPL, indicate your
30 | * decision by deleting the provisions above and replace them with the notice
31 | * and other provisions required by the GPL or the LGPL. If you do not delete
32 | * the provisions above, a recipient may use your version of this file under
33 | * the terms of any one of the MPL, the GPL or the LGPL.
34 | *
35 | * ***** END LICENSE BLOCK ***** */
36 |
37 | /*
38 | * This package consists of enough of the Narcissus metacircular JavaScript
39 | * engine to parse JavaScript, packaged up into a CommonJS module for your own
40 | * pleasure.
41 | */
42 |
43 | require('./jsdefs');
44 | require('./jslex');
45 |
46 | var jscfa = require('./jscfa');
47 | var jsparse = require('./jsparse');
48 |
49 | exports.cfa2 = jscfa.cfa2;
50 | exports.jscfa = jscfa;
51 | exports.parse = jsparse.parse;
52 |
53 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/nonterms.txt:
--------------------------------------------------------------------------------
1 | END 0
2 | NEWLINE 1
3 | SEMICOLON 2
4 | COMMA 3
5 | ASSIGN 4
6 | HOOK 5
7 | COLON 6
8 | CONDITIONAL 7
9 | OR 8
10 | AND 9
11 | BITWISE_OR 10
12 | BITWISE_XOR 11
13 | BITWISE_AND 12
14 | EQ 13
15 | NE 14
16 | STRICT_EQ 15
17 | STRICT_NE 16
18 | LT 17
19 | LE 18
20 | GE 19
21 | GT 20
22 | LSH 21
23 | RSH 22
24 | URSH 23
25 | PLUS 24
26 | MINUS 25
27 | MUL 26
28 | DIV 27
29 | MOD 28
30 | NOT 29
31 | BITWISE_NOT 30
32 | UNARY_PLUS 31
33 | UNARY_MINUS 32
34 | INCREMENT 33
35 | DECREMENT 34
36 | DOT 35
37 | LEFT_BRACKET 36
38 | RIGHT_BRACKET 37
39 | LEFT_CURLY 38
40 | RIGHT_CURLY 39
41 | LEFT_PAREN 40
42 | RIGHT_PAREN 41
43 | SCRIPT 42
44 | BLOCK 43
45 | LABEL 44
46 | FOR_IN 45
47 | CALL 46
48 | NEW_WITH_ARGS 47
49 | INDEX 48
50 | ARRAY_INIT 49
51 | OBJECT_INIT 50
52 | PROPERTY_INIT 51
53 | GETTER 52
54 | SETTER 53
55 | GROUP 54
56 | LIST 55
57 | LET_STM 56
58 | LET_EXP 57
59 | LET_DEF 58
60 | IDENTIFIER 59
61 | NUMBER 60
62 | STRING 61
63 | REGEXP 62
64 | BREAK 63
65 | CASE 64
66 | CATCH 65
67 | CONST 66
68 | CONTINUE 67
69 | DEBUGGER 68
70 | DEFAULT 69
71 | DELETE 70
72 | DO 71
73 | ELSE 72
74 | ENUM 73
75 | FALSE 74
76 | FINALLY 75
77 | FOR 76
78 | FUNCTION 77
79 | IF 78
80 | IN 79
81 | INSTANCEOF 80
82 | LET 81
83 | NEW 82
84 | NULL 83
85 | RETURN 84
86 | SWITCH 85
87 | THIS 86
88 | THROW 87
89 | TRUE 88
90 | TRY 89
91 | TYPEOF 90
92 | VAR 91
93 | VOID 92
94 | YIELD 93
95 | WHILE 94
96 | WITH 95
97 | END 0
98 | NEWLINE 1
99 | SEMICOLON 2
100 | COMMA 3
101 | ASSIGN 4
102 | HOOK 5
103 | COLON 6
104 | CONDITIONAL 7
105 | OR 8
106 | AND 9
107 | BITWISE_OR 10
108 | BITWISE_XOR 11
109 | BITWISE_AND 12
110 | EQ 13
111 | NE 14
112 | STRICT_EQ 15
113 | STRICT_NE 16
114 | LT 17
115 | LE 18
116 | GE 19
117 | GT 20
118 | LSH 21
119 | RSH 22
120 | URSH 23
121 | PLUS 24
122 | MINUS 25
123 | MUL 26
124 | DIV 27
125 | MOD 28
126 | NOT 29
127 | BITWISE_NOT 30
128 | UNARY_PLUS 31
129 | UNARY_MINUS 32
130 | INCREMENT 33
131 | DECREMENT 34
132 | DOT 35
133 | LEFT_BRACKET 36
134 | RIGHT_BRACKET 37
135 | LEFT_CURLY 38
136 | RIGHT_CURLY 39
137 | LEFT_PAREN 40
138 | RIGHT_PAREN 41
139 | SCRIPT 42
140 | BLOCK 43
141 | LABEL 44
142 | FOR_IN 45
143 | CALL 46
144 | NEW_WITH_ARGS 47
145 | INDEX 48
146 | ARRAY_INIT 49
147 | OBJECT_INIT 50
148 | PROPERTY_INIT 51
149 | GETTER 52
150 | SETTER 53
151 | GROUP 54
152 | LIST 55
153 | LET_STM 56
154 | LET_EXP 57
155 | LET_DEF 58
156 | IDENTIFIER 59
157 | NUMBER 60
158 | STRING 61
159 | REGEXP 62
160 | BREAK 63
161 | CASE 64
162 | CATCH 65
163 | CONST 66
164 | CONTINUE 67
165 | DEBUGGER 68
166 | DEFAULT 69
167 | DELETE 70
168 | DO 71
169 | ELSE 72
170 | ENUM 73
171 | FALSE 74
172 | FINALLY 75
173 | FOR 76
174 | FUNCTION 77
175 | IF 78
176 | IN 79
177 | INSTANCEOF 80
178 | LET 81
179 | NEW 82
180 | NULL 83
181 | RETURN 84
182 | SWITCH 85
183 | THIS 86
184 | THROW 87
185 | TRUE 88
186 | TRY 89
187 | TYPEOF 90
188 | VAR 91
189 | VOID 92
190 | YIELD 93
191 | WHILE 94
192 | WITH 95
193 | END 0
194 | NEWLINE 1
195 | SEMICOLON 2
196 | COMMA 3
197 | ASSIGN 4
198 | HOOK 5
199 | COLON 6
200 | CONDITIONAL 7
201 | OR 8
202 | AND 9
203 | BITWISE_OR 10
204 | BITWISE_XOR 11
205 | BITWISE_AND 12
206 | EQ 13
207 | NE 14
208 | STRICT_EQ 15
209 | STRICT_NE 16
210 | LT 17
211 | LE 18
212 | GE 19
213 | GT 20
214 | LSH 21
215 | RSH 22
216 | URSH 23
217 | PLUS 24
218 | MINUS 25
219 | MUL 26
220 | DIV 27
221 | MOD 28
222 | NOT 29
223 | BITWISE_NOT 30
224 | UNARY_PLUS 31
225 | UNARY_MINUS 32
226 | INCREMENT 33
227 | DECREMENT 34
228 | DOT 35
229 | LEFT_BRACKET 36
230 | RIGHT_BRACKET 37
231 | LEFT_CURLY 38
232 | RIGHT_CURLY 39
233 | LEFT_PAREN 40
234 | RIGHT_PAREN 41
235 | SCRIPT 42
236 | BLOCK 43
237 | LABEL 44
238 | FOR_IN 45
239 | CALL 46
240 | NEW_WITH_ARGS 47
241 | INDEX 48
242 | ARRAY_INIT 49
243 | OBJECT_INIT 50
244 | PROPERTY_INIT 51
245 | GETTER 52
246 | SETTER 53
247 | GROUP 54
248 | LIST 55
249 | LET_STM 56
250 | LET_EXP 57
251 | LET_DEF 58
252 | IDENTIFIER 59
253 | NUMBER 60
254 | STRING 61
255 | REGEXP 62
256 | BREAK 63
257 | CASE 64
258 | CATCH 65
259 | CONST 66
260 | CONTINUE 67
261 | DEBUGGER 68
262 | DEFAULT 69
263 | DELETE 70
264 | DO 71
265 | ELSE 72
266 | ENUM 73
267 | FALSE 74
268 | FINALLY 75
269 | FOR 76
270 | FUNCTION 77
271 | IF 78
272 | IN 79
273 | INSTANCEOF 80
274 | LET 81
275 | NEW 82
276 | NULL 83
277 | RETURN 84
278 | SWITCH 85
279 | THIS 86
280 | THROW 87
281 | TRUE 88
282 | TRY 89
283 | TYPEOF 90
284 | VAR 91
285 | VOID 92
286 | YIELD 93
287 | WHILE 94
288 | WITH 95
289 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/run-tests:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | rm tests/test*~ 2>/dev/null
4 | if test "$1"
5 | then
6 | node run-tests.js some `ls tests/test* | wc -l` "$1"
7 | else
8 | node run-tests.js all `ls tests/test* | wc -l`
9 | fi
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/run-tests.js:
--------------------------------------------------------------------------------
1 | // How to write a test:
2 | // Have one toplevel function called test that takes one argument.
3 | // The type of the argument is the expected type of the result.
4 | // The argument should not be used in the body of the function.
5 | // Put your test in the body of "test" and return a value.
6 | // The type of the return value is compared to the type of the argument.
7 |
8 | var readFileSync = require('fs').readFileSync;
9 | var print = require('sys').puts;
10 | var runtest = require('./jscfa').runtest;
11 | var parse = require('./jsparse').parse;
12 | var numAll = process.argv[3], start, end;
13 |
14 | function testname(num) { return "./tests/test" + num + ".js"; }
15 |
16 | if (process.argv[2] === "some") {
17 | var range = process.argv[4], dash = range.indexOf("-");
18 | if (dash === -1)
19 | start = end = range; // run a single test
20 | else { // run a susbet of the tests
21 | start = Number(range.substring(0, dash)) || 1;
22 | if (dash === (range.length - 1))
23 | end = numAll;
24 | else
25 | end = Number(range.substring(dash + 1, range.length));
26 | }
27 | }
28 | else { // run all tests
29 | start = 1;
30 | end = numAll;
31 | }
32 |
33 | var failed_tests = [];
34 | for (var i = start; i <= end; i++) {
35 | var tn = testname(i);
36 | if (!runtest(parse(readFileSync(tn), tn, 1))) failed_tests.push(i);
37 | }
38 |
39 | print("\n");
40 | print("Number of tests: " + (end - start + 1));
41 | var numFailed = failed_tests.length;
42 | if (numFailed !== 0) {
43 | print("Number of failed tests: " + numFailed);
44 | for (var i = 0, len = numFailed; i < len; i++) print(failed_tests[i]);
45 | }
46 | else print("All tests passed.");
47 | print("\n");
48 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-3d-cube.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | CalcCross check-3d-cube.js /^function CalcCross(V0, V1) {$/;" f lineno:70 type:Array[number] function(Array[number], Array[number])
8 | CalcNormal check-3d-cube.js /^function CalcNormal(V0, V1, V2) {$/;" f lineno:78 type:Array[number] function(Array[number], Array[number], Array[number])
9 | CreateP check-3d-cube.js /^function CreateP(X,Y,Z) {$/;" f lineno:91 type: function(number, number, number)
10 | DisplArea check-3d-cube.js /^var DisplArea = new Object();$/;" v lineno:13 type:
11 | DrawLine check-3d-cube.js /^function DrawLine(From, To) {$/;" f lineno:17 type:void function(CreateP, CreateP)
12 | DrawQube check-3d-cube.js /^function DrawQube() {$/;" f lineno:186 type:void function()
13 | I check-3d-cube.js /^var I = new Array(); \/\/ entity matrix$/;" v lineno:8 type:
14 | Init check-3d-cube.js /^function Init(CubeSize) {$/;" f lineno:251 type:void function(number)
15 | Loop check-3d-cube.js /^function Loop() {$/;" f lineno:232 type:void function()
16 | LoopTimer check-3d-cube.js /^var LoopTimer;$/;" v lineno:11 type:any
17 | MAdd check-3d-cube.js /^function MAdd(M1, M2) {$/;" f lineno:123 type:Array[Array] function(any, any)
18 | MMulti check-3d-cube.js /^function MMulti(M1, M2) {$/;" f lineno:96 type:Array[Array[number]] function(, )
19 | MQube check-3d-cube.js /^var MQube = new Array(); \/\/ position information of qube$/;" v lineno:7 type:
20 | MTrans check-3d-cube.js /^var MTrans = new Array(); \/\/ transformation matrix$/;" v lineno:6 type:
21 | Origin check-3d-cube.js /^var Origin = new Object();$/;" v lineno:9 type:
22 | Q check-3d-cube.js /^var Q = new Array();$/;" v lineno:5 type:
23 | RotateX check-3d-cube.js /^function RotateX(M, Phi) {$/;" f lineno:144 type:Array[Array[number]] function(, number)
24 | RotateY check-3d-cube.js /^function RotateY(M, Phi) {$/;" f lineno:158 type:Array[Array[number]] function(, number)
25 | RotateZ check-3d-cube.js /^function RotateZ(M, Phi) {$/;" f lineno:172 type:Array[Array[number]] function(, number)
26 | Testing check-3d-cube.js /^var Testing = new Object();$/;" v lineno:10 type:
27 | Translate check-3d-cube.js /^function Translate(M, Dx, Dy, Dz) {$/;" f lineno:134 type:Array[Array[number]] function(, number, number, number)
28 | VMulti check-3d-cube.js /^function VMulti(M, V) {$/;" f lineno:108 type:Array[number] function(, Array[number])
29 | VMulti2 check-3d-cube.js /^function VMulti2(M, V) {$/;" f lineno:115 type:Array[number] function(, Array[number])
30 | actual check-3d-cube.js /^var actual = '';$/;" v lineno:330 type:string
31 | expected check-3d-cube.js /^var expected = "-116.618229186398,212.51135212951073,62.5094191967962,1;127.83701023614447,417.11611179082263,90.41153816299942,1;293.9570894432935,196.58093046570656,252.17789153139591,1;49.501850020750915,-8.02382919560505,224.275772565193,1;6.042910556709444,103.41906953429206,-212.1778915313964,1;250.49814997925202,308.02382919560387,-184.27577256519325,1;416.61822918640064,87.48864787048812,-22.509419196796493,1;172.1629897638581,-117.1161117908236,-50.41153816299975,1;150.0000000000007,149.99999999999952,20,1;";$/;" v lineno:334 type:string
32 | i check-3d-cube.js /^for ( var i = 20; i <= 160; i *= 2 ) {$/;" v lineno:326 type:any
33 | i check-3d-cube.js /^for (var i = 0; i < Q.length; ++i) {$/;" v lineno:331 type:number
34 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-3d-morph.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2007 Apple Inc. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * 1. Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * 2. Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | var loops = 15
27 | var nx = 120
28 | var nz = 120
29 |
30 | function morph(a, f) {
31 | var PI2nx = Math.PI * 8/nx
32 | var sin = Math.sin
33 | var f30 = -(50 * sin(f*Math.PI*2))
34 |
35 | for (var i = 0; i < nz; ++i) {
36 | for (var j = 0; j < nx; ++j) {
37 | a[3*(i*nx+j)+1] = sin((j-1) * PI2nx ) * -f30
38 | }
39 | }
40 | }
41 |
42 |
43 | var a = Array()
44 | for (var i=0; i < nx*nz*3; ++i)
45 | a[i] = 0
46 |
47 | for (var i = 0; i < loops; ++i) {
48 | morph(a, i/loops)
49 | }
50 |
51 | testOutput = 0;
52 | for (var i = 0; i < nx; i++)
53 | testOutput += a[3*(i*nx+i)+1];
54 | a = null;
55 |
56 | /* not based on any mathematical error calculation.*/
57 | acceptableDelta = 4e-15;
58 |
59 | assertEq((testOutput - 6.394884621840902e-14) < acceptableDelta, true);
60 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-3d-morph.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | a check-3d-morph.js /^var a = Array()$/;" v lineno:43 type:
8 | i check-3d-morph.js /^for (var i = 0; i < loops; ++i) {$/;" v lineno:47 type:any
9 | i check-3d-morph.js /^for (var i = 0; i < nx; i++)$/;" v lineno:52 type:number
10 | i check-3d-morph.js /^for (var i=0; i < nx*nz*3; ++i) $/;" v lineno:44 type:any
11 | loops check-3d-morph.js /^var loops = 15$/;" v lineno:26 type:number
12 | morph check-3d-morph.js /^function morph(a, f) {$/;" f lineno:30 type:void function(Array[number], number)
13 | nx check-3d-morph.js /^var nx = 120$/;" v lineno:27 type:number
14 | nz check-3d-morph.js /^var nz = 120$/;" v lineno:28 type:number
15 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-3d-raytrace.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | Camera check-3d-raytrace.js /^function Camera(origin, lookat, up) {$/;" f lineno:261 type:Camera function(Array[number], Array[number], Array[number])
8 | Scene check-3d-raytrace.js /^function Scene(a_triangles) {$/;" f lineno:181 type:Scene function(Array[Triangle])
9 | Triangle check-3d-raytrace.js /^function Triangle(p1, p2, p3) {$/;" f lineno:125 type:Triangle function(Array[number], Array[number], Array[number])
10 | add check-3d-raytrace.js /^function add(v1, v2) {$/;" f lineno:67 type:Array[number] function(Array[number], Array[number])
11 | addVector check-3d-raytrace.js /^function addVector(self, v) {$/;" f lineno:38 type:Array[number] function(Array[number], )
12 | arrayToCanvasCommands check-3d-raytrace.js /^function arrayToCanvasCommands(pixels)$/;" f lineno:405 type:string function(Array[Array])
13 | blocked check-3d-raytrace.js /^Scene.prototype.blocked = function(O, D, far) {$/;" f lineno:244 type:boolean function(Array[number], Array[number], number)
14 | createVector check-3d-raytrace.js /^function createVector(x,y,z) {$/;" f lineno:26 type:Array[number] function(number, number, number)
15 | cross check-3d-raytrace.js /^function cross(v1, v2) {$/;" f lineno:87 type:Array[number] function(Array[number], Array[number])
16 | dot check-3d-raytrace.js /^function dot(v1, v2) {$/;" f lineno:79 type:number function(Array[number], Array[number])
17 | floorShader check-3d-raytrace.js /^ var floorShader = function(tri, pos, view) {$/;" f lineno:357 type:Array[number] function(, Array[number], Array[number])
18 | generateRayPair check-3d-raytrace.js /^Camera.prototype.generateRayPair = function(y) {$/;" f lineno:283 type:Array[Object] function(number)
19 | intersect check-3d-raytrace.js /^Scene.prototype.intersect = function(origin, dir, near, far) {$/;" f lineno:189 type: function(Array[number], Array[number], , )
20 | intersect check-3d-raytrace.js /^Triangle.prototype.intersect = function(orig, dir, near, far) {$/;" f lineno:160 type: function(Array[number], Array[number], , )
21 | invertMatrix check-3d-raytrace.js /^function invertMatrix(self) {$/;" f lineno:107 type:Array[number] function(Array[number])
22 | lengthVector check-3d-raytrace.js /^function lengthVector(self) {$/;" f lineno:34 type:number function(Array[number])
23 | normalise check-3d-raytrace.js /^function normalise(v) {$/;" f lineno:94 type:Array[number] function(Array[number])
24 | normaliseVector check-3d-raytrace.js /^function normaliseVector(self) {$/;" f lineno:59 type:Array[number] function(Array[number])
25 | raytraceScene check-3d-raytrace.js /^function raytraceScene()$/;" f lineno:313 type:Array[Array] function()
26 | render check-3d-raytrace.js /^Camera.prototype.render = function(scene, pixels, width, height) {$/;" f lineno:305 type:void function(Scene, Array[Array], number, number)
27 | renderRows check-3d-raytrace.js /^function renderRows(camera, scene, pixels, width, height, starty, stopy) {$/;" f lineno:292 type:void function(Camera, Scene, Array[Array], number, number, number, number)
28 | scale check-3d-raytrace.js /^function scale(v, scale) {$/;" f lineno:83 type:Array[number] function(Array[number], )
29 | scaleVector check-3d-raytrace.js /^function scaleVector(self, scale) {$/;" f lineno:52 type: function(, )
30 | scalev check-3d-raytrace.js /^function scalev(v1, v2) {$/;" f lineno:75 type:Array[number] function(Array[number], )
31 | sqrLengthVector check-3d-raytrace.js /^function sqrLengthVector(self) {$/;" f lineno:30 type:number function(any)
32 | sub check-3d-raytrace.js /^function sub(v1, v2) {$/;" f lineno:71 type:Array[number] function(Array[number], Array[number])
33 | subVector check-3d-raytrace.js /^function subVector(self, v) {$/;" f lineno:45 type:Array[number] function(Array[number], Array[number])
34 | transformMatrix check-3d-raytrace.js /^function transformMatrix(self, v) {$/;" f lineno:99 type:Array[number] function(Array[number], Array[number])
35 | zero check-3d-raytrace.js /^var zero = new Array(0,0,0);$/;" v lineno:187 type:Array[number]
36 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-access-binary-trees.js:
--------------------------------------------------------------------------------
1 | /* The Great Computer Language Shootout
2 | http://shootout.alioth.debian.org/
3 | contributed by Isaac Gouy */
4 |
5 | function TreeNode(left,right,item){
6 | this.left = left;
7 | this.right = right;
8 | this.item = item;
9 | }
10 |
11 | TreeNode.prototype.itemCheck = function(){
12 | if (this.left==null) return this.item;
13 | else return this.item + this.left.itemCheck() - this.right.itemCheck();
14 | }
15 |
16 | function bottomUpTree(item,depth){
17 | if (depth>0){
18 | return new TreeNode(
19 | bottomUpTree(2*item-1, depth-1)
20 | ,bottomUpTree(2*item, depth-1)
21 | ,item
22 | );
23 | }
24 | else {
25 | return new TreeNode(null,null,item);
26 | }
27 | }
28 |
29 | var ret;
30 |
31 | for ( var n = 4; n <= 7; n += 1 ) {
32 | var minDepth = 4;
33 | var maxDepth = Math.max(minDepth + 2, n);
34 | var stretchDepth = maxDepth + 1;
35 |
36 | var check = bottomUpTree(0,stretchDepth).itemCheck();
37 |
38 | var longLivedTree = bottomUpTree(0,maxDepth);
39 | for (var depth=minDepth; depth<=maxDepth; depth+=2){
40 | var iterations = 1 << (maxDepth - depth + minDepth);
41 |
42 | check = 0;
43 | for (var i=1; i<=iterations; i++){
44 | check += bottomUpTree(i,depth).itemCheck();
45 | check += bottomUpTree(-i,depth).itemCheck();
46 | }
47 | }
48 |
49 | ret = longLivedTree.itemCheck();
50 | }
51 |
52 | assertEq(ret, -1)
53 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-access-binary-trees.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | TreeNode check-access-binary-trees.js /^function TreeNode(left,right,item){$/;" f lineno:5 type:TreeNode function(, , number)
8 | bottomUpTree check-access-binary-trees.js /^function bottomUpTree(item,depth){$/;" f lineno:16 type:TreeNode function(number, number)
9 | check check-access-binary-trees.js /^ var check = bottomUpTree(0,stretchDepth).itemCheck();$/;" v lineno:36 type:number
10 | depth check-access-binary-trees.js /^ for (var depth=minDepth; depth<=maxDepth; depth+=2){$/;" v lineno:39 type:number
11 | i check-access-binary-trees.js /^ for (var i=1; i<=iterations; i++){$/;" v lineno:43 type:number
12 | itemCheck check-access-binary-trees.js /^TreeNode.prototype.itemCheck = function(){$/;" f lineno:11 type:number function()
13 | iterations check-access-binary-trees.js /^ var iterations = 1 << (maxDepth - depth + minDepth);$/;" v lineno:40 type:number
14 | longLivedTree check-access-binary-trees.js /^ var longLivedTree = bottomUpTree(0,maxDepth);$/;" v lineno:38 type:TreeNode
15 | maxDepth check-access-binary-trees.js /^ var maxDepth = Math.max(minDepth + 2, n);$/;" v lineno:33 type:number
16 | minDepth check-access-binary-trees.js /^ var minDepth = 4;$/;" v lineno:32 type:number
17 | n check-access-binary-trees.js /^for ( var n = 4; n <= 7; n += 1 ) {$/;" v lineno:31 type:number
18 | ret check-access-binary-trees.js /^var ret;$/;" v lineno:29 type:number
19 | stretchDepth check-access-binary-trees.js /^ var stretchDepth = maxDepth + 1;$/;" v lineno:34 type:number
20 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-access-fannkuch.js:
--------------------------------------------------------------------------------
1 | /* The Great Computer Language Shootout
2 | http://shootout.alioth.debian.org/
3 | contributed by Isaac Gouy */
4 |
5 | function fannkuch(n) {
6 | var check = 0;
7 | var perm = Array(n);
8 | var perm1 = Array(n);
9 | var count = Array(n);
10 | var maxPerm = Array(n);
11 | var maxFlipsCount = 0;
12 | var m = n - 1;
13 |
14 | for (var i = 0; i < n; i++) perm1[i] = i;
15 | var r = n;
16 |
17 | while (true) {
18 | // write-out the first 30 permutations
19 | if (check < 30){
20 | var s = "";
21 | for(var i=0; i> 1;
34 | for (var i = 0; i < k2; i++) {
35 | var temp = perm[i]; perm[i] = perm[k - i]; perm[k - i] = temp;
36 | }
37 | flipsCount++;
38 | }
39 |
40 | if (flipsCount > maxFlipsCount) {
41 | maxFlipsCount = flipsCount;
42 | for (var i = 0; i < n; i++) maxPerm[i] = perm1[i];
43 | }
44 | }
45 |
46 | while (true) {
47 | if (r == n) return maxFlipsCount;
48 | var perm0 = perm1[0];
49 | var i = 0;
50 | while (i < r) {
51 | var j = i + 1;
52 | perm1[i] = perm1[j];
53 | i = j;
54 | }
55 | perm1[r] = perm0;
56 |
57 | count[r] = count[r] - 1;
58 | if (count[r] > 0) break;
59 | r++;
60 | }
61 | }
62 | }
63 |
64 | var n = 8;
65 | var ret = fannkuch(n);
66 | assertEq(ret, 22)
67 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-access-fannkuch.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | fannkuch check-access-fannkuch.js /^function fannkuch(n) {$/;" f lineno:5 type:number function(number)
8 | n check-access-fannkuch.js /^var n = 8;$/;" v lineno:64 type:number
9 | ret check-access-fannkuch.js /^var ret = fannkuch(n);$/;" v lineno:65 type:number
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-access-nbody.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | %anonymous_function check-access-nbody.js /^ (function(){$/;" f lineno:157 type:void function()
8 | Body check-access-nbody.js /^function Body(x,y,z,vx,vy,vz,mass){$/;" f lineno:9 type:Body function(number, number, number, number, number, number, number)
9 | DAYS_PER_YEAR check-access-nbody.js /^var DAYS_PER_YEAR = 365.24;$/;" v lineno:7 type:number
10 | Jupiter check-access-nbody.js /^function Jupiter(){$/;" f lineno:26 type:Body function()
11 | NBodySystem check-access-nbody.js /^function NBodySystem(bodies){$/;" f lineno:79 type:NBodySystem function(Array[Body])
12 | Neptune check-access-nbody.js /^function Neptune(){$/;" f lineno:62 type:Body function()
13 | PI check-access-nbody.js /^var PI = 3.141592653589793;$/;" v lineno:5 type:number
14 | SOLAR_MASS check-access-nbody.js /^var SOLAR_MASS = 4 * PI * PI;$/;" v lineno:6 type:number
15 | Saturn check-access-nbody.js /^function Saturn(){$/;" f lineno:38 type:Body function()
16 | Sun check-access-nbody.js /^function Sun(){$/;" f lineno:74 type:Body function()
17 | Uranus check-access-nbody.js /^function Uranus(){$/;" f lineno:50 type:Body function()
18 | advance check-access-nbody.js /^NBodySystem.prototype.advance = function(dt){$/;" f lineno:95 type:void function(number)
19 | energy check-access-nbody.js /^NBodySystem.prototype.energy = function(){$/;" f lineno:128 type:number function()
20 | n check-access-nbody.js /^for ( var n = 3; n <= 24; n *= 2 ) {$/;" v lineno:156 type:number
21 | offsetMomentum check-access-nbody.js /^Body.prototype.offsetMomentum = function(px,py,pz) {$/;" f lineno:19 type:Body function(number, number, number)
22 | ret check-access-nbody.js /^var ret;$/;" v lineno:154 type:number
23 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-access-nsieve.js:
--------------------------------------------------------------------------------
1 | // The Great Computer Language Shootout
2 | // http://shootout.alioth.debian.org/
3 | //
4 | // modified by Isaac Gouy
5 |
6 | function pad(number,width){
7 | var s = number.toString();
8 | var prefixWidth = width - s.length;
9 | if (prefixWidth>0){
10 | for (var i=1; i<=prefixWidth; i++) s = " " + s;
11 | }
12 | return s;
13 | }
14 |
15 | function nsieve(m, isPrime){
16 | var i, k, count;
17 |
18 | for (i=2; i<=m; i++) { isPrime[i] = true; }
19 | count = 0;
20 |
21 | for (i=2; i<=m; i++){
22 | if (isPrime[i]) {
23 | for (k=i+i; k<=m; k+=i) isPrime[k] = false;
24 | count++;
25 | }
26 | }
27 | return count;
28 | }
29 |
30 | var ret = 0;
31 | function sieve() {
32 | for (var i = 1; i <= 3; i++ ) {
33 | var m = (1<> ((b << 1) & 14));
8 | c += 3 & (bi3b >> ((b >> 2) & 14));
9 | c += 3 & (bi3b >> ((b >> 5) & 6));
10 | return c;
11 |
12 | /*
13 | lir4,0xE994; 9 instructions, no memory access, minimal register dependence, 6 shifts, 2 adds, 1 inline assign
14 | rlwinmr5,r3,1,28,30
15 | rlwinmr6,r3,30,28,30
16 | rlwinmr7,r3,27,29,30
17 | rlwnmr8,r4,r5,30,31
18 | rlwnmr9,r4,r6,30,31
19 | rlwnmr10,r4,r7,30,31
20 | addr3,r8,r9
21 | addr3,r3,r10
22 | */
23 | }
24 |
25 | var ret = 0;
26 | function TimeFunc(func) {
27 | var x, y, t;
28 | for(var x=0; x<500; x++)
29 | for(var y=0; y<256; y++) {
30 | ret += func(y);
31 | }
32 | }
33 |
34 | TimeFunc(fast3bitlookup);
35 | assertEq(ret, 512000)
36 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-bitops-3bit-bits-in-byte.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | TimeFunc check-bitops-3bit-bits-in-byte.js /^function TimeFunc(func) {$/;" f lineno:26 type:void function(number function(number))
8 | fast3bitlookup check-bitops-3bit-bits-in-byte.js /^function fast3bitlookup(b) {$/;" f lineno:5 type:number function(number)
9 | ret check-bitops-3bit-bits-in-byte.js /^var ret = 0;$/;" v lineno:25 type:number
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-bitops-bits-in-byte.js:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2004 by Arthur Langereis (arthur_ext at domain xfinitegames, tld com)
2 |
3 |
4 | // 1 op = 2 assigns, 16 compare/branches, 8 ANDs, (0-8) ADDs, 8 SHLs
5 | // O(n)
6 | function bitsinbyte(b) {
7 | var m = 1, c = 0;
8 | while(m<0x100) {
9 | if(b & m) c++;
10 | m <<= 1;
11 | }
12 | return c;
13 | }
14 |
15 | var ret = 0;
16 | function TimeFunc(func) {
17 | var x, y, t;
18 | for(var x=0; x<350; x++)
19 | for(var y=0; y<256; y++)
20 | ret += func(y);
21 | }
22 |
23 | TimeFunc(bitsinbyte);
24 | assertEq(ret, 358400)
25 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-bitops-bits-in-byte.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | TimeFunc check-bitops-bits-in-byte.js /^function TimeFunc(func) {$/;" f lineno:16 type:void function(number function(number))
8 | bitsinbyte check-bitops-bits-in-byte.js /^function bitsinbyte(b) {$/;" f lineno:6 type:number function(number)
9 | ret check-bitops-bits-in-byte.js /^var ret = 0;$/;" v lineno:15 type:number
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-bitops-bitwise-and.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2007 Apple Inc. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * 1. Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * 2. Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | bitwiseAndValue = 4294967296;
27 | for (var i = 0; i < 60; i++)
28 | bitwiseAndValue = bitwiseAndValue & i;
29 | assertEq(bitwiseAndValue, 0)
30 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-bitops-bitwise-and.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | i check-bitops-bitwise-and.js /^for (var i = 0; i < 60; i++)$/;" v lineno:27 type:number
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-bitops-nsieve-bits.js:
--------------------------------------------------------------------------------
1 | // The Great Computer Language Shootout
2 | // http://shootout.alioth.debian.org
3 | //
4 | // Contributed by Ian Osgood
5 |
6 | var result = [];
7 |
8 | function pad(n,width) {
9 | var s = n.toString();
10 | while (s.length < width) s = ' ' + s;
11 | return s;
12 | }
13 |
14 | function primes(isPrime, n) {
15 | var i, count = 0, m = 10000<>5;
16 |
17 | for (i=0; i>5] & 1<<(i&31)) {
21 | for (var j=i+i; j>5] &= ~(1<<(j&31)));
23 | count++;
24 | }
25 | }
26 |
27 | function sieve() {
28 | for (var i = 4; i <= 4; i++) {
29 | var isPrime = new Array((10000<>5);
30 | primes(isPrime, i);
31 | }
32 | }
33 |
34 | sieve();
35 |
36 | var ret = 0;
37 | for (var i = 0; i < result.length; ++i)
38 | ret += result[i];
39 |
40 | assertEq(ret, -211235557404919)
41 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-bitops-nsieve-bits.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | i check-bitops-nsieve-bits.js /^for (var i = 0; i < result.length; ++i)$/;" v lineno:37 type:number
8 | pad check-bitops-nsieve-bits.js /^function pad(n,width) {$/;" f lineno:8 type:string function(any, any)
9 | primes check-bitops-nsieve-bits.js /^function primes(isPrime, n) {$/;" f lineno:14 type:void function(Array[number], number)
10 | result check-bitops-nsieve-bits.js /^var result = [];$/;" v lineno:6 type:Array[number]
11 | ret check-bitops-nsieve-bits.js /^var ret = 0;$/;" v lineno:36 type:number
12 | sieve check-bitops-nsieve-bits.js /^function sieve() {$/;" f lineno:27 type:void function()
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-controlflow-recursive.js:
--------------------------------------------------------------------------------
1 | // The Computer Language Shootout
2 | // http://shootout.alioth.debian.org/
3 | // contributed by Isaac Gouy
4 |
5 | function ack(m,n){
6 | if (m==0) { return n+1; }
7 | if (n==0) { return ack(m-1,1); }
8 | return ack(m-1, ack(m,n-1) );
9 | }
10 |
11 | function fib(n) {
12 | if (n < 2){ return 1; }
13 | return fib(n-2) + fib(n-1);
14 | }
15 |
16 | function tak(x,y,z) {
17 | if (y >= x) return z;
18 | return tak(tak(x-1,y,z), tak(y-1,z,x), tak(z-1,x,y));
19 | }
20 |
21 | var ret = 0;
22 | for ( var i = 3; i <= 5; i++ ) {
23 | ret += ack(3,i);
24 | ret += fib(17.0+i);
25 | ret += tak(3*i+3,2*i+2,i+1);
26 | }
27 | assertEq(ret, 57775);
28 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-controlflow-recursive.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | ack check-controlflow-recursive.js /^function ack(m,n){$/;" f lineno:5 type:number function(number, number)
8 | fib check-controlflow-recursive.js /^function fib(n) {$/;" f lineno:11 type:number function(number)
9 | i check-controlflow-recursive.js /^for ( var i = 3; i <= 5; i++ ) {$/;" v lineno:22 type:number
10 | ret check-controlflow-recursive.js /^var ret = 0;$/;" v lineno:21 type:number
11 | tak check-controlflow-recursive.js /^function tak(x,y,z) {$/;" f lineno:16 type:number function(number, number, number)
12 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-crypto-md5.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | b64_hmac_md5 check-crypto-md5.js /^function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }$/;" f lineno:26 type:string function(any, any)
8 | b64_md5 check-crypto-md5.js /^function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}$/;" f lineno:23 type:string function(any)
9 | b64pad check-crypto-md5.js /^var b64pad = ""; \/* base-64 pad character. "=" for strict RFC compliance *\/$/;" v lineno:15 type:string
10 | binl2b64 check-crypto-md5.js /^function binl2b64(binarray)$/;" f lineno:240 type:string function(Array[number])
11 | binl2hex check-crypto-md5.js /^function binl2hex(binarray)$/;" f lineno:225 type:string function(Array[number])
12 | binl2str check-crypto-md5.js /^function binl2str(bin)$/;" f lineno:213 type:string function(Array[number])
13 | bit_rol check-crypto-md5.js /^function bit_rol(num, cnt)$/;" f lineno:192 type:number function(number, number)
14 | chrsz check-crypto-md5.js /^var chrsz = 8; \/* bits per input character. 8 - ASCII; 16 - Unicode *\/$/;" v lineno:16 type:number
15 | core_hmac_md5 check-crypto-md5.js /^function core_hmac_md5(key, data)$/;" f lineno:162 type:Array[number] function(any, any)
16 | core_md5 check-crypto-md5.js /^function core_md5(x, len)$/;" f lineno:40 type:Array[number] function(Array[number], number)
17 | hex_hmac_md5 check-crypto-md5.js /^function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }$/;" f lineno:25 type:string function(any, any)
18 | hex_md5 check-crypto-md5.js /^function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}$/;" f lineno:22 type:string function(string)
19 | hexcase check-crypto-md5.js /^var hexcase = 0; \/* hex output format. 0 - lowercase; 1 - uppercase *\/$/;" v lineno:14 type:number
20 | i check-crypto-md5.js /^Will they not hear? What, ho! you men, you beasts,\\n\\$/;" v lineno:260 type:number
21 | md5Output check-crypto-md5.js /^Throw your mistemper'd weapons to the ground,\\n\\$/;" v lineno:264 type:string
22 | md5_cmn check-crypto-md5.js /^function md5_cmn(q, a, b, x, s, t)$/;" f lineno:138 type:number function(number, number, number, number, number, number)
23 | md5_ff check-crypto-md5.js /^function md5_ff(a, b, c, d, x, s, t)$/;" f lineno:142 type:number function(number, number, number, number, number, number, number)
24 | md5_gg check-crypto-md5.js /^function md5_gg(a, b, c, d, x, s, t)$/;" f lineno:146 type:number function(number, number, number, number, number, number, number)
25 | md5_hh check-crypto-md5.js /^function md5_hh(a, b, c, d, x, s, t)$/;" f lineno:150 type:number function(number, number, number, number, number, number, number)
26 | md5_ii check-crypto-md5.js /^function md5_ii(a, b, c, d, x, s, t)$/;" f lineno:154 type:number function(number, number, number, number, number, number, number)
27 | md5_vm_test check-crypto-md5.js /^function md5_vm_test()$/;" f lineno:32 type:boolean function()
28 | plainText check-crypto-md5.js /^var plainText = "Rebellious subjects, enemies to peace,\\n\\$/;" v lineno:258 type:string
29 | safe_add check-crypto-md5.js /^function safe_add(x, y)$/;" f lineno:182 type:number function(number, number)
30 | str2binl check-crypto-md5.js /^function str2binl(str)$/;" f lineno:201 type:Array[number] function(string)
31 | str_hmac_md5 check-crypto-md5.js /^function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }$/;" f lineno:27 type:string function(any, any)
32 | str_md5 check-crypto-md5.js /^function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}$/;" f lineno:24 type:string function(any)
33 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-crypto-sha1.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | b64_hmac_sha1 check-crypto-sha1.js /^function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}$/;" f lineno:26 type:string function(any, any)
8 | b64_sha1 check-crypto-sha1.js /^function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}$/;" f lineno:23 type:string function(any)
9 | b64pad check-crypto-sha1.js /^var b64pad = ""; \/* base-64 pad character. "=" for strict RFC compliance *\/$/;" v lineno:15 type:string
10 | binb2b64 check-crypto-sha1.js /^function binb2b64(binarray)$/;" f lineno:186 type:string function(Array[number])
11 | binb2hex check-crypto-sha1.js /^function binb2hex(binarray)$/;" f lineno:171 type:string function(Array[number])
12 | binb2str check-crypto-sha1.js /^function binb2str(bin)$/;" f lineno:159 type:string function(Array[number])
13 | chrsz check-crypto-sha1.js /^var chrsz = 8; \/* bits per input character. 8 - ASCII; 16 - Unicode *\/$/;" v lineno:16 type:number
14 | core_hmac_sha1 check-crypto-sha1.js /^function core_hmac_sha1(key, data)$/;" f lineno:108 type:Array[number] function(any, any)
15 | core_sha1 check-crypto-sha1.js /^function core_sha1(x, len)$/;" f lineno:40 type:Array[number] function(Array[number], number)
16 | hex_hmac_sha1 check-crypto-sha1.js /^function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}$/;" f lineno:25 type:string function(any, any)
17 | hex_sha1 check-crypto-sha1.js /^function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}$/;" f lineno:22 type:string function(string)
18 | hexcase check-crypto-sha1.js /^var hexcase = 0; \/* hex output format. 0 - lowercase; 1 - uppercase *\/$/;" v lineno:14 type:number
19 | i check-crypto-sha1.js /^From ancient grudge break to new mutiny,\\n\\$/;" v lineno:207 type:number
20 | plainText check-crypto-sha1.js /^var plainText = "Two households, both alike in dignity,\\n\\$/;" v lineno:205 type:string
21 | rol check-crypto-sha1.js /^function rol(num, cnt)$/;" f lineno:138 type:number function(number, number)
22 | safe_add check-crypto-sha1.js /^function safe_add(x, y)$/;" f lineno:128 type:number function(number, number)
23 | sha1Output check-crypto-sha1.js /^Whole misadventured piteous overthrows\\n\\$/;" v lineno:211 type:string
24 | sha1_ft check-crypto-sha1.js /^function sha1_ft(t, b, c, d)$/;" f lineno:88 type:number function(number, number, number, number)
25 | sha1_kt check-crypto-sha1.js /^function sha1_kt(t)$/;" f lineno:99 type:number function(number)
26 | sha1_vm_test check-crypto-sha1.js /^function sha1_vm_test()$/;" f lineno:32 type:boolean function()
27 | str2binb check-crypto-sha1.js /^function str2binb(str)$/;" f lineno:147 type:Array[number] function(string)
28 | str_hmac_sha1 check-crypto-sha1.js /^function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}$/;" f lineno:27 type:string function(any, any)
29 | str_sha1 check-crypto-sha1.js /^function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}$/;" f lineno:24 type:string function(any)
30 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-date-format-xparb.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | createNewFormat check-date-format-xparb.js /^Date.createNewFormat = function(format) {$/;" f lineno:26 type:void function(string)
8 | createParser check-date-format-xparb.js /^Date.createParser = function(format) {$/;" f lineno:117 type:void function(any)
9 | date check-date-format-xparb.js /^var date = new Date("1\/1\/2007 1:11:11");$/;" v lineno:411 type:Date
10 | dateFormat check-date-format-xparb.js /^Date.prototype.dateFormat = function(format) {$/;" f lineno:18 type:any function(string)
11 | escape check-date-format-xparb.js /^String.escape = function(string) {$/;" f lineno:347 type:string function(string)
12 | formatCodeToRegex check-date-format-xparb.js /^Date.formatCodeToRegex = function(character, currentGroup) {$/;" f lineno:172 type:Object function(string, number)
13 | getDayOfYear check-date-format-xparb.js /^Date.prototype.getDayOfYear = function() {$/;" f lineno:291 type:number function()
14 | getDaysInMonth check-date-format-xparb.js /^Date.prototype.getDaysInMonth = function() {$/;" f lineno:325 type:any function()
15 | getFirstDayOfMonth check-date-format-xparb.js /^Date.prototype.getFirstDayOfMonth = function() {$/;" f lineno:315 type:number function()
16 | getFormatCode check-date-format-xparb.js /^Date.getFormatCode = function(character) {$/;" f lineno:48 type:string function(string)
17 | getGMTOffset check-date-format-xparb.js /^Date.prototype.getGMTOffset = function() {$/;" f lineno:285 type: function()
18 | getLastDayOfMonth check-date-format-xparb.js /^Date.prototype.getLastDayOfMonth = function() {$/;" f lineno:320 type:number function()
19 | getSuffix check-date-format-xparb.js /^Date.prototype.getSuffix = function() {$/;" f lineno:330 type:string function()
20 | getTimezone check-date-format-xparb.js /^Date.prototype.getTimezone = function() {$/;" f lineno:279 type:any function()
21 | getWeekOfYear check-date-format-xparb.js /^Date.prototype.getWeekOfYear = function() {$/;" f lineno:300 type: function()
22 | isLeapYear check-date-format-xparb.js /^Date.prototype.isLeapYear = function() {$/;" f lineno:310 type: function()
23 | leftPad check-date-format-xparb.js /^String.leftPad = function (val, size, ch) {$/;" f lineno:351 type: function(number, number, string)
24 | longFormat check-date-format-xparb.js /^ var longFormat = date.dateFormat("l, F d, Y g:i:s A");$/;" v lineno:416 type:any
25 | parseDate check-date-format-xparb.js /^Date.parseDate = function(input, format) {$/;" f lineno:109 type:any function(any, any)
26 | ret check-date-format-xparb.js /^var ret;$/;" v lineno:413 type:any
27 | shortFormat check-date-format-xparb.js /^ var shortFormat = date.dateFormat("Y-m-d");$/;" v lineno:415 type:any
28 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-math-cordic.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Rich Moore. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * 1. Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * 2. Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | /////. Start CORDIC
27 |
28 | var AG_CONST = 0.6072529350;
29 |
30 | function FIXED(X)
31 | {
32 | return X * 65536.0;
33 | }
34 |
35 | function FLOAT(X)
36 | {
37 | return X / 65536.0;
38 | }
39 |
40 | function DEG2RAD(X)
41 | {
42 | return 0.017453 * (X);
43 | }
44 |
45 | var Angles = [
46 | FIXED(45.0), FIXED(26.565), FIXED(14.0362), FIXED(7.12502),
47 | FIXED(3.57633), FIXED(1.78991), FIXED(0.895174), FIXED(0.447614),
48 | FIXED(0.223811), FIXED(0.111906), FIXED(0.055953),
49 | FIXED(0.027977)
50 | ];
51 |
52 |
53 | function cordicsincos() {
54 | var X;
55 | var Y;
56 | var TargetAngle;
57 | var CurrAngle;
58 | var Step;
59 |
60 | X = FIXED(AG_CONST); /* AG_CONST * cos(0) */
61 | Y = 0; /* AG_CONST * sin(0) */
62 |
63 | TargetAngle = FIXED(28.027);
64 | CurrAngle = 0;
65 | for (Step = 0; Step < 12; Step++) {
66 | var NewX;
67 | if (TargetAngle > CurrAngle) {
68 | NewX = X - (Y >> Step);
69 | Y = (X >> Step) + Y;
70 | X = NewX;
71 | CurrAngle += Angles[Step];
72 | } else {
73 | NewX = X + (Y >> Step);
74 | Y = -(X >> Step) + Y;
75 | X = NewX;
76 | CurrAngle -= Angles[Step];
77 | }
78 | }
79 | return CurrAngle;
80 | }
81 |
82 | ///// End CORDIC
83 |
84 | function cordic( runs ) {
85 | var actual;
86 |
87 | var start = new Date();
88 |
89 | for ( var i = 0 ; i < runs ; i++ ) {
90 | actual = cordicsincos();
91 | }
92 |
93 | var end = new Date();
94 |
95 | assertEq(actual, 1834995.3515519998)
96 |
97 | return end.getTime() - start.getTime();
98 | }
99 |
100 | cordic(25000);
101 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-math-cordic.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | AG_CONST check-math-cordic.js /^var AG_CONST = 0.6072529350;$/;" v lineno:28 type:number
8 | Angles check-math-cordic.js /^var Angles = [$/;" v lineno:45 type:Array[number]
9 | DEG2RAD check-math-cordic.js /^function DEG2RAD(X)$/;" f lineno:40 type:number function(any)
10 | FIXED check-math-cordic.js /^function FIXED(X)$/;" f lineno:30 type:number function(number)
11 | FLOAT check-math-cordic.js /^function FLOAT(X)$/;" f lineno:35 type:number function(any)
12 | cordic check-math-cordic.js /^function cordic( runs ) {$/;" f lineno:84 type:number function(number)
13 | cordicsincos check-math-cordic.js /^function cordicsincos() {$/;" f lineno:53 type:number function()
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-math-partial-sums.js:
--------------------------------------------------------------------------------
1 | // The Computer Language Shootout
2 | // http://shootout.alioth.debian.org/
3 | // contributed by Isaac Gouy
4 |
5 | function partial(n){
6 | var a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0.0;
7 | var twothirds = 2.0/3.0;
8 | var alt = -1.0;
9 | var k2 = k3 = sk = ck = 0.0;
10 |
11 | for (var k = 1; k <= n; k++){
12 | k2 = k*k;
13 | k3 = k2*k;
14 | sk = Math.sin(k);
15 | ck = Math.cos(k);
16 | alt = -alt;
17 |
18 | a1 += Math.pow(twothirds,k-1);
19 | a2 += Math.pow(k,-0.5);
20 | a3 += 1.0/(k*(k+1.0));
21 | a4 += 1.0/(k3 * sk*sk);
22 | a5 += 1.0/(k3 * ck*ck);
23 | a6 += 1.0/k;
24 | a7 += 1.0/k2;
25 | a8 += alt/k;
26 | a9 += alt/(2*k -1);
27 | }
28 |
29 | return [ a1, a2, a3, a4, a5, a6, a7, a8, a9 ];
30 | }
31 |
32 | var actual = [];
33 | for (var i = 1024; i <= 16384; i *= 2)
34 | Array.prototype.push.apply(actual, partial(i));
35 |
36 | var eps = 1e-12;
37 | var expect = [2.9999999999999987,62.555269219624684,0.9990243902439033,30.174793391263677,42.99468748637077,7.509175672278132,1.6439579810301654,0.6926591377284127,0.785154022830656,2.9999999999999987,89.06036157695789,0.9995119570522216,30.30796333494624,42.99485339033617,8.202078771817716,1.6444459047881168,0.6929030995395857,0.7852760930922243,2.9999999999999987,126.54745783224483,0.999755918965097,30.314167756318135,42.994888939123,8.89510389696629,1.6446899560231332,0.6930251251486118,0.7853371282421086,2.9999999999999987,179.56450569047874,0.9998779445868421,30.314499725429847,42.99489723774016,9.588190046095265,1.644812003986005,0.693086149128997,0.785367645819433,2.9999999999999987,254.54355172132264,0.9999389685688135,30.31451920492601,42.99489939769195,10.281306710008463,1.6448730335545856,0.6931166639131536,0.7853829046083998];
38 |
39 | assertEq(actual.length, expect.length);
40 | for (var i = 0; i < expect.length; ++i)
41 | assertEq(Math.abs(actual[i] - expect[i]) < eps, true);
42 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-math-partial-sums.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | actual check-math-partial-sums.js /^var actual = [];$/;" v lineno:32 type:Array[number]
8 | eps check-math-partial-sums.js /^var eps = 1e-12;$/;" v lineno:36 type:number
9 | expect check-math-partial-sums.js /^var expect = [2.9999999999999987,62.555269219624684,0.9990243902439033,30.174793391263677,42.99468748637077,7.509175672278132,1.6439579810301654,0.6926591377284127,0.785154022830656,2.9999999999999987,89.06036157695789,0.9995119570522216,30.30796333494624,42.99485339033617,8.202078771817716,1.6444459047881168,0.6929030995395857,0.7852760930922243,2.9999999999999987,126.54745783224483,0.999755918965097,30.314167756318135,42.994888939123,8.89510389696629,1.6446899560231332,0.6930251251486118,0.7853371282421086,2.9999999999999987,179.56450569047874,0.9998779445868421,30.314499725429847,42.99489723774016,9.588190046095265,1.644812003986005,0.693086149128997,0.785367645819433,2.9999999999999987,254.54355172132264,0.9999389685688135,30.31451920492601,42.99489939769195,10.281306710008463,1.6448730335545856,0.6931166639131536,0.7853829046083998];$/;" v lineno:37 type:Array[number]
10 | i check-math-partial-sums.js /^for (var i = 0; i < expect.length; ++i)$/;" v lineno:40 type:number
11 | i check-math-partial-sums.js /^for (var i = 1024; i <= 16384; i *= 2)$/;" v lineno:33 type:any
12 | partial check-math-partial-sums.js /^function partial(n){$/;" f lineno:5 type:Array[number] function(number)
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-math-spectral-norm.js:
--------------------------------------------------------------------------------
1 | // The Great Computer Language Shootout
2 | // http://shootout.alioth.debian.org/
3 | //
4 | // contributed by Ian Osgood
5 |
6 | function A(i,j) {
7 | return 1/((i+j)*(i+j+1)/2+i+1);
8 | }
9 |
10 | function Au(u,v) {
11 | for (var i=0; i (1<>=1; //bpe=number of bits in one element of the array representing the bigInt
15 | mask=(1<>=bpe;
38 | }
39 | }
40 |
41 | //is x > y? (x and y both nonnegative)
42 | function greater(x,y) {
43 | var i;
44 | var k=(x.length=0;i--)
55 | if (x[i]>y[i])
56 | return 1;
57 | else if (x[i]0 && n[kn-1]==0;kn--); //ignore leading zeros of n
82 | for (;ky>0 && y[ky-1]==0;ky--); //ignore leading zeros of y
83 |
84 | copyInt_(sa,0);
85 |
86 | //the following loop consumes 95% of the runtime for randTruePrime_() and powMod_() for large keys
87 | for (i=0; i> bpe;
91 | t=x[i];
92 |
93 | //do sa=(sa+x[i]*y+ui*n)/b where b=2**bpe
94 | for (j=1;j>=bpe;
98 | }
99 | for (;j>=bpe;
103 | }
104 | sa[j-1]=c & mask;
105 | }
106 |
107 | if (!greater(n,sa))
108 | sub_(sa,n);
109 | copy_(x,sa);
110 | }
111 |
112 | mont_(x, x, n, np);
113 |
114 | var passed = expected.length == x.length;
115 | for (var i = 0; i < expected.length; i++) {
116 | if (passed)
117 | passed = expected[i] == x[i];
118 | }
119 | assertEq(passed, true);
120 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-mont.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | copyInt_ check-mont.js /^function copyInt_(x,n) {$/;" f lineno:33 type:void function(Array[number], number)
8 | copy_ check-mont.js /^function copy_(x,y) {$/;" f lineno:23 type:void function(Array[number], Array[number])
9 | expected check-mont.js /^var expected = [18770, 31456, 17999, 32635, 27508, 29131, 2856, 16233, 5439, 27580, 7093, 18192, 30804, 5472, 8529, 28649, 14852, 0, 0, 0];$/;" v lineno:6 type:Array[number]
10 | greater check-mont.js /^function greater(x,y) {$/;" f lineno:42 type:number function(Array[number], Array[number])
11 | i check-mont.js /^for (var i = 0; i < expected.length; i++) {$/;" v lineno:115 type:number
12 | mont_ check-mont.js /^function mont_(x,y,n,np) {$/;" f lineno:73 type:void function(Array[number], Array[number], Array[number], number)
13 | n check-mont.js /^var n = [27875, 25925, 30422, 12227, 27798, 32170, 10873, 21748, 30629, 26296, 20697, 5125, 4815, 2221, 14392, 23369, 5560, 2, 0, 0];$/;" v lineno:4 type:Array[number]
14 | np check-mont.js /^var np = 18229;$/;" v lineno:5 type:number
15 | passed check-mont.js /^var passed = expected.length == x.length;$/;" v lineno:114 type:boolean
16 | x check-mont.js /^var x = [9385, 32112, 25383, 16317, 30138, 14565, 17812, 24500, 2719, 30174, 3546, 9096, 15352, 19120, 20648, 14334, 7426, 0, 0, 0];$/;" v lineno:3 type:Array[number]
17 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-regexp-dna.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | clen check-regexp-dna.js /^GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG\\n\\$/;" v lineno:12 type:undefined
8 | dnaInput check-regexp-dna.js /^var dnaInput = ">ONE Homo sapiens alu\\n\\$/;" v lineno:8 type:string
9 | dnaOutputString check-regexp-dna.js /^TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA\\n\\$/;" v lineno:34 type:string
10 | ilen check-regexp-dna.js /^GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG\\n\\$/;" v lineno:12 type:undefined
11 | l check-regexp-dna.js /^var l;$/;" v lineno:7 type:any
12 | seqs check-regexp-dna.js /^CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT\\n\\$/;" v lineno:13 type:Array[RegExp]
13 | subs check-regexp-dna.js /^AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT\\n\\$/;" v lineno:23 type:Object
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/check-string-fasta.js:
--------------------------------------------------------------------------------
1 | // The Great Computer Language Shootout
2 | // http://shootout.alioth.debian.org
3 | //
4 | // Contributed by Ian Osgood
5 |
6 | var last = 42, A = 3877, C = 29573, M = 139968;
7 |
8 | function rand(max) {
9 | last = (last * A + C) % M;
10 | return max * last / M;
11 | }
12 |
13 | var ALU =
14 | "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
15 | "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
16 | "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
17 | "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
18 | "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
19 | "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
20 | "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
21 |
22 | var IUB = {
23 | a:0.27, c:0.12, g:0.12, t:0.27,
24 | B:0.02, D:0.02, H:0.02, K:0.02,
25 | M:0.02, N:0.02, R:0.02, S:0.02,
26 | V:0.02, W:0.02, Y:0.02
27 | }
28 |
29 | var HomoSap = {
30 | a: 0.3029549426680,
31 | c: 0.1979883004921,
32 | g: 0.1975473066391,
33 | t: 0.3015094502008
34 | }
35 |
36 | function makeCumulative(table) {
37 | var last = null;
38 | for (var c in table) {
39 | if (last) table[c] += table[last];
40 | last = c;
41 | }
42 | }
43 |
44 | function fastaRepeat(n, seq) {
45 | var seqi = 0, lenOut = 60;
46 | while (n>0) {
47 | if (n0) {
65 | if (n
17 | tagInfoJSON check-string-tagcloud.js /^var tagInfoJSON = "";$/;" v lineno:226 type:string
18 | tagcloud check-string-tagcloud.js /^var tagcloud = makeTagCloud(tagInfo);$/;" v lineno:264 type:string
19 | tagcloud_norm check-string-tagcloud.js /^var tagcloud_norm = tagcloud.replace(\/([0-9.]+)px\/g, function(str, p1) { return p1.substr(0, 10) + 'px' })$/;" v lineno:269 type:string
20 | toJSONString check-string-tagcloud.js /^ s.toJSONString = function () {$/;" f lineno:208 type:string function()
21 | toJSONString check-string-tagcloud.js /^ Array.prototype.toJSONString = function (w) {$/;" f lineno:40 type:string function(any)
22 | toJSONString check-string-tagcloud.js /^ Boolean.prototype.toJSONString = function () {$/;" f lineno:72 type:string function()
23 | toJSONString check-string-tagcloud.js /^ Date.prototype.toJSONString = function () {$/;" f lineno:77 type:string function()
24 | toJSONString check-string-tagcloud.js /^ Number.prototype.toJSONString = function () {$/;" f lineno:93 type:string function()
25 | toJSONString check-string-tagcloud.js /^ Object.prototype.toJSONString = function (w) {$/;" f lineno:99 type:string function(any)
26 | walk check-string-tagcloud.js /^ function walk(k, v) {$/;" f lineno:180 type:number function(string, any)
27 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/sunspider/getctags:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | for file in `ls *js`
4 | do
5 | /home/dimvar/moz/jsctags-wcopy/bin/jsctags.js "$file"
6 | mv tags `basename "$file" .js`.tags
7 | done
8 |
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test1.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | return 123;
3 | }
4 |
5 | test(0);
6 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test10.js:
--------------------------------------------------------------------------------
1 | // "that" mutated in heap before accessed from stack, tricky case
2 | function test(expected) {
3 | var that;
4 |
5 | function Foo(x) {
6 | this.x = x;
7 | that = this;
8 | return 42;
9 | }
10 |
11 | var num = new Foo(0);
12 | return that.x + num;
13 | }
14 |
15 | test(0);
16 |
17 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test100.js:
--------------------------------------------------------------------------------
1 | // silly test
2 | function test(expected) {
3 | return null;
4 | }
5 |
6 | test(null);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test101.js:
--------------------------------------------------------------------------------
1 | // void
2 | function test(expected) {
3 | return void 0;
4 | }
5 |
6 | test((new Object()).nonexistentproperty);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test102.js:
--------------------------------------------------------------------------------
1 | // void throws
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try { void t() }
6 | catch (e) { return e.message; }
7 | }
8 |
9 | test("");
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test103.js:
--------------------------------------------------------------------------------
1 | // delete
2 | function test(expected) {
3 | var b = true;
4 | b = void 0;
5 | return delete b;
6 | }
7 |
8 | var boolOrUndef;
9 | boolOrUndef = false;
10 | boolOrUndef = (new Object()).nonexistentproperty;
11 | test(boolOrUndef);
12 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test104.js:
--------------------------------------------------------------------------------
1 | // delete throws
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try {
6 | delete t();
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test105.js:
--------------------------------------------------------------------------------
1 | // hook
2 | function test(expected) {
3 | return true ? 123 : "";
4 | }
5 |
6 | var numOrStr;
7 | numOrStr = 0;
8 | numOrStr = "";
9 | test(numOrStr);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test106.js:
--------------------------------------------------------------------------------
1 | // hook throws
2 | function test(expected) {
3 | function E1() { this.foo = 0; }
4 | E1.prototype = new Error();
5 |
6 | function E2() { this.foo = ""; }
7 | E2.prototype = new Error();
8 |
9 | function t(e) { throw e; }
10 |
11 | try {
12 | false ? t(new E1()) : t(new E2());
13 | }
14 | catch (e) {
15 | return e.foo;
16 | }
17 | }
18 |
19 | var numOrStr;
20 | numOrStr = 0;
21 | numOrStr = "";
22 | test(numOrStr);
23 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test107.js:
--------------------------------------------------------------------------------
1 | // OBJECT_INIT
2 | function test(expected) {
3 | return ({a:1, b:2, c:3}).a;
4 | }
5 |
6 | test(0);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test108.js:
--------------------------------------------------------------------------------
1 | // OBJECT_INIT throws
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try {
6 | ({a:1, b:2, c:t()}).a;
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test109.js:
--------------------------------------------------------------------------------
1 | // ARRAY_INIT
2 | function test(expected) {
3 | return [1, 2, "asdf"][2];
4 | }
5 |
6 | test("");
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test11.js:
--------------------------------------------------------------------------------
1 | // test funs in expr context, method calls
2 | function test(expected) {
3 | function Foo() {}
4 | var o = new Foo();
5 | o.m = function id(x) {return x;}
6 | return o.m(0);
7 | }
8 |
9 | test(0)
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test110.js:
--------------------------------------------------------------------------------
1 | // ARRAY_INIT throws
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try {
6 | [21, t()];
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test111.js:
--------------------------------------------------------------------------------
1 | // RegExp and RegExp.prototype
2 | function test(expected) {
3 | Object.prototype.foo = 123;
4 | Function.prototype.bar = 123;
5 |
6 | return (new RegExp()).foo + RegExp.bar;
7 | }
8 |
9 | test(0);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test112.js:
--------------------------------------------------------------------------------
1 | // RegExp.prototype.test
2 | function test(expected) {
3 | return (new RegExp()).test("asfasdf") || /abc/.test("a");
4 | }
5 |
6 | test(true);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test113.js:
--------------------------------------------------------------------------------
1 | // test op-and-assign operators
2 | function test(expected) {
3 | var x = 0;
4 | x += 123;
5 | x -= 123;
6 | x *= 123;
7 | x /= 123;
8 | x %= 123;
9 | x <<= 123;
10 | x >>= 123;
11 | x >>>= 123;
12 | x &= 123;
13 | x ^= 123;
14 | x |= 123;
15 | return x;
16 | }
17 |
18 | test(0);
19 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test114.js:
--------------------------------------------------------------------------------
1 | // test += on strings
2 | function test(expected) {
3 | var x = 0;
4 | x += "asdf";
5 |
6 | return x;
7 | }
8 |
9 | var numOrStr;
10 | numOrStr = 0;
11 | numOrStr = "";
12 | test(numOrStr);
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test115.js:
--------------------------------------------------------------------------------
1 | // test += on strings
2 | function test(expected) {
3 | var x = "asdf";
4 | x += 0;
5 |
6 | return x;
7 | }
8 |
9 | test("");
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test116.js:
--------------------------------------------------------------------------------
1 | // += lhs throws
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try {
6 | (new Array(123))[t()] += 123;
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test117.js:
--------------------------------------------------------------------------------
1 | // SWITCH
2 | function test(expected) {
3 | var x;
4 | switch (123) {
5 | case (x = 1):
6 | break;
7 | case 2:
8 | break;
9 | default:
10 | x = "";
11 | break;
12 | }
13 | return x;
14 | }
15 |
16 | var numOrStr;
17 | numOrStr = 0;
18 | numOrStr = "";
19 | test(numOrStr);
20 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test118.js:
--------------------------------------------------------------------------------
1 | // FOR_IN
2 | function test(expected) {
3 | var a = {}, s, ret, p;
4 |
5 | s = "foo";
6 | s = "bar";
7 | a[s] = 123;
8 |
9 | for (p in a) ret = a[p];
10 |
11 | return ret;
12 | }
13 |
14 | test(0);
15 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test119.js:
--------------------------------------------------------------------------------
1 | // FOR_IN: imprecise, considers the "length-" property
2 | function test(expected) {
3 | var a = new Array(), i, ret, p;
4 |
5 | i = 0;
6 | a[i] = 123;
7 |
8 | for (p in a) ret = a[p];
9 |
10 | return ret;
11 | }
12 |
13 | var numOrUndef;
14 | numOrUndef = 0;
15 | numOrUndef = (function(){})();
16 | test(numOrUndef);
17 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test12.js:
--------------------------------------------------------------------------------
1 | // test function calls
2 | function test(expected) {
3 | function n() {return 0;}
4 | function s() {return "0";}
5 |
6 | var f;
7 | f = n;
8 | f = s;
9 | return f();
10 | }
11 |
12 | var numOrStr;
13 | numOrStr = 0;
14 | numOrStr = "0";
15 | test(numOrStr);
16 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test120.js:
--------------------------------------------------------------------------------
1 | // FOR_IN with VAR
2 | function test(expected) {
3 | var a = {}, s, ret;
4 |
5 | s = "foo";
6 | s = "bar";
7 | a[s] = 123;
8 |
9 | for (var p in a) ret = a[p];
10 |
11 | return ret;
12 | }
13 |
14 | test(0);
15 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test121.js:
--------------------------------------------------------------------------------
1 | // recursive calls return bottom, not undefined
2 | function test(expected) {
3 | function ack(m,n){
4 | if (m==0) { return n+1; }
5 | if (n==0) { return ack(m-1,1); }
6 | return ack(m-1, ack(m,n-1));
7 | }
8 |
9 | var ret = 0;
10 | for (var i = 3; i <= 5; i++)
11 | ret += ack(3, i);
12 | return ret;
13 | }
14 |
15 | test(0);
16 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test122.js:
--------------------------------------------------------------------------------
1 | // the type of a must be Array[number]
2 | function test(expected) {
3 | var a = new Array(10);
4 | for (var i = 0; i < 10; i++) a[i] = 123;
5 |
6 | function f(i, a) { return a[i]; }
7 |
8 | return f(2, a);
9 | }
10 |
11 | test(0);
12 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test123.js:
--------------------------------------------------------------------------------
1 | // convert a number to an object automatically
2 | function test(expected) {
3 | var n = 2134;
4 | return n.toString();
5 | }
6 |
7 | test("");
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test124.js:
--------------------------------------------------------------------------------
1 | // convert a string to an object automatically
2 | function test(expected) {
3 | var s = "";
4 | return s.substring(0, 1);
5 | }
6 |
7 | test("");
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test125.js:
--------------------------------------------------------------------------------
1 | // test FINALLY
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | var ret;
6 |
7 | try {
8 | t();
9 | }
10 | catch (e) {
11 | ret = e.message;
12 | }
13 | finally {
14 | ret = 123;
15 | }
16 |
17 | return ret;
18 | }
19 |
20 | var numOrStr;
21 | numOrStr = 0;
22 | numOrStr = "";
23 | test(numOrStr);
24 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test126.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | try {
3 | if (123)
4 | throw 123;
5 | else
6 | throw "";
7 | }
8 | catch (e) {
9 | return e;
10 | }
11 | }
12 |
13 | var numOrStr;
14 | numOrStr = 0;
15 | numOrStr = "";
16 | test(numOrStr);
17 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test127.js:
--------------------------------------------------------------------------------
1 | // test the undefined identifier
2 | function test(expected) {
3 | return undefined;
4 | }
5 |
6 | test(void 0);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test128.js:
--------------------------------------------------------------------------------
1 | // test Math inheritance
2 | function test(expected) {
3 | Object.prototype.foo = 3;
4 | Object.bar = 4;
5 |
6 | return Math.constructor.bar + Math.foo;
7 | }
8 |
9 | test(0);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test129.js:
--------------------------------------------------------------------------------
1 | // test Math methods and constants
2 | function test(expected) {
3 | return Math.E +
4 | Math.LN10 +
5 | Math.LN2 +
6 | Math.LOG10E +
7 | Math.LOG2E +
8 | Math.PI +
9 | Math.SQRT1_2 +
10 | Math.SQRT2 +
11 | Math.abs(4) +
12 | Math.acos(4) +
13 | Math.asin(4) +
14 | Math.atan(4) +
15 | Math.atan2(4) +
16 | Math.ceil(4) +
17 | Math.cos(4) +
18 | Math.exp(4) +
19 | Math.floor(4) +
20 | Math.log(4) +
21 | Math.max(4, 4) +
22 | Math.min(4, 4) +
23 | Math.pow(4, 4) +
24 | Math.random() +
25 | Math.round(4) +
26 | Math.sin(4) +
27 | Math.sqrt(4) +
28 | Math.tan(4);
29 | }
30 |
31 | test(0);
32 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test13.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | function recur(n) {
3 | if (123)
4 | return 1;
5 | else
6 | return n + recur(n - 1);
7 | }
8 |
9 | return recur(0);
10 | }
11 |
12 | test(0);
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test130.js:
--------------------------------------------------------------------------------
1 | // test Boolean inheritance
2 | function test(expected) {
3 | Object.prototype.foo = 3;
4 | Function.prototype.bar = 4;
5 |
6 | return (new Boolean(123)).foo + Boolean.bar
7 | }
8 |
9 | test(0);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test131.js:
--------------------------------------------------------------------------------
1 | // test Boolean toString
2 | function test(expected) {
3 | return (new Boolean()).toString();
4 | }
5 |
6 | test("");
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test132.js:
--------------------------------------------------------------------------------
1 | // test Boolean valueOf
2 | function test(expected) {
3 | return (new Boolean()).valueOf();
4 | }
5 |
6 | test(true);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test133.js:
--------------------------------------------------------------------------------
1 | // test String.prototype.replace
2 | function test(expected) {
3 | return "asdf".replace("a", "b");
4 | }
5 |
6 | test("");
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test134.js:
--------------------------------------------------------------------------------
1 | // test String.fromCharCode
2 | function test(expected) {
3 | return String.fromCharCode(123);
4 | }
5 |
6 | test("");
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test135.js:
--------------------------------------------------------------------------------
1 | // global variable
2 | function test(expected) {
3 | x = 0;
4 |
5 | return x;
6 | }
7 |
8 | test(0);
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test136.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | return Infinity + NaN + parseInt("asdf");
3 | }
4 |
5 | test(0);
6 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test137.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | return isNaN("sadf");
3 | }
4 |
5 | test(true);
6 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test138.js:
--------------------------------------------------------------------------------
1 | // this in fun calls bound to global obj
2 | function test(expected) {
3 | this.Array.prototype.foo = 3;
4 |
5 | return (new Array()).foo;
6 | }
7 |
8 | test(0);
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test139.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | var a = [1, 2, 3];
3 |
4 | return a.slice(2)[0];
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test14.js:
--------------------------------------------------------------------------------
1 | // test prototype property in evalExp
2 | function test(expected) {
3 | function F(){}
4 | F.prototype.num = 0;
5 |
6 | var x = new F();
7 | x.prototype = 431;
8 |
9 | return F.prototype.num + x.prototype;
10 | }
11 |
12 | test(0);
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test140.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | var a = [1, 2, 3];
3 |
4 | return a.splice(2)[0];
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test141.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | var a = [1, 2, 3];
3 |
4 | return a.concat(4, ["5", "6"])[0];
5 | }
6 |
7 | var numOrStr;
8 | numOrStr = 0;
9 | numOrStr = "";
10 | test(numOrStr);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test142.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | return [0,1,-7].sort()[1];
3 | }
4 |
5 | test(0);
6 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test143.js:
--------------------------------------------------------------------------------
1 | // assignment to stack ref updates heap as well
2 | var a = [];
3 |
4 | function test(expected) {
5 | return a.push(0);
6 | }
7 |
8 | test(0);
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test144.js:
--------------------------------------------------------------------------------
1 | // stack ref of a heap var updated, heap ref gets the correct value
2 | function test(expected) {
3 | function f(x) {
4 | x = 42;
5 | return (function g() { return x; });
6 | }
7 |
8 | return f("")();
9 | }
10 |
11 | var numOrStr;
12 | numOrStr = 0;
13 | numOrStr = "";
14 | test(numOrStr);
15 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test145.js:
--------------------------------------------------------------------------------
1 | // apply
2 | function test(expected) {
3 | function f(x) {return x;}
4 |
5 | function G(y) { this.y = y; }
6 |
7 | return f.apply(new G(1), [4, 5, 6]);
8 | }
9 |
10 | test(0);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test146.js:
--------------------------------------------------------------------------------
1 | // apply, the obj bound to this is affected
2 | function test(expected) {
3 | function f() {
4 | this.foo = "asdf";
5 | }
6 |
7 | function G(y) { this.y = y; }
8 |
9 | var g = new G(1);
10 | f.apply(g);
11 | return g.foo;
12 | }
13 |
14 | test("");
15 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test147.js:
--------------------------------------------------------------------------------
1 | // apply, test fewer arguments
2 | function test(expected) {
3 | function f(x, y, z) { return z; }
4 |
5 | function G(y) { this.y = y; }
6 |
7 | return f.apply(new G(1), [0, 1]);
8 | }
9 |
10 | test(undefined);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test148.js:
--------------------------------------------------------------------------------
1 | // apply, test more arguments
2 | function test(expected) {
3 | function f(x) { return arguments[2]; }
4 |
5 | function G(y) { this.y = y; }
6 |
7 | return f.apply(new G(1), [0, 1, 2]);
8 | }
9 |
10 | test(0);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test149.js:
--------------------------------------------------------------------------------
1 | // apply, when the array properties have been merged
2 | function test(expected) {
3 | function f(x) { return x; }
4 |
5 | function G(y) { this.y = y; }
6 |
7 | var a = [];
8 | a.push(0);
9 | a.push("");
10 |
11 | return f.apply(new G(1), a);
12 | }
13 |
14 | var numOrStr;
15 | numOrStr = 0;
16 | numOrStr = "";
17 | test(numOrStr);
18 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test15.js:
--------------------------------------------------------------------------------
1 | // property lookup in proto chain
2 | function test(expected) {
3 | function Dad() {this.x = 5;}
4 | function Kid() {}
5 |
6 | Kid.prototype = new Dad();
7 | var k = new Kid();
8 |
9 | return k.x;
10 | }
11 |
12 | test(0);
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test150.js:
--------------------------------------------------------------------------------
1 | // apply, when functions with different arities can be applied
2 | function test(expected) {
3 | function f(x) { return x; }
4 |
5 | function h(x, y) { return y; }
6 |
7 | function G(y) { this.y = y; }
8 |
9 | var fun;
10 | fun = f;
11 | fun = h;
12 |
13 | return fun.apply(new G(1), [123]);
14 | }
15 |
16 | var numOrUndef;
17 | numOrUndef = 0;
18 | numOrUndef = undefined;
19 | test(numOrUndef);
20 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test151.js:
--------------------------------------------------------------------------------
1 | // apply, one of the functions throws
2 | function test(expected) {
3 | function f(x) { return x; }
4 |
5 | function h(x, y) { throw new Error("adasaf"); }
6 |
7 | function G(y) { this.y = y; }
8 |
9 | var fun;
10 | fun = f;
11 | fun = h;
12 |
13 | try {
14 | return fun.apply(new G(1), [123]);
15 | }
16 | catch(e) {
17 | return e.message;
18 | }
19 | }
20 |
21 | var numOrStrOrUndef;
22 | numOrStrOrUndef = 0;
23 | numOrStrOrUndef = "";
24 | numOrStrOrUndef = undefined;
25 | test(numOrStrOrUndef);
26 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test152.js:
--------------------------------------------------------------------------------
1 | // a function that doesn't use return returns undefined. Because of relaxed
2 | // control-flow we can't tell that t never returns.
3 | function test(expected) {
4 | function t() { throw new Error(); }
5 |
6 | try {
7 | return t();
8 | }
9 | catch (e) {
10 |
11 | }
12 | }
13 |
14 | test(undefined);
15 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test153.js:
--------------------------------------------------------------------------------
1 | // Function.prototype.call
2 | function test(expected) {
3 | function f(x) { return x; }
4 |
5 | return f.call(new Object(), 3);
6 | }
7 |
8 | test(0);
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test154.js:
--------------------------------------------------------------------------------
1 | // Function.prototype.call, fewer arguments
2 | function test(expected) {
3 | function f(x) { return x; }
4 |
5 | return f.call(new Object());
6 | }
7 |
8 | test(undefined);
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test155.js:
--------------------------------------------------------------------------------
1 | // Function.prototype.call, more arguments
2 | function test(expected) {
3 | function f(x) { return arguments[1]; }
4 |
5 | return f.call(new Object(), 2, "123");
6 | }
7 |
8 | test("");
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test156.js:
--------------------------------------------------------------------------------
1 | // String.prototype.match
2 | function test(expected) {
3 | return "asdafa".match(/foo/)[0];
4 | }
5 |
6 | test("");
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test157.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | return "asdfaf".toLowerCase() + "fasaffd".toUpperCase();
3 | }
4 |
5 | test("");
6 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test158.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | return /asdaf/.exec("safafaf")[0];
3 | }
4 |
5 | test("");
6 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test159.js:
--------------------------------------------------------------------------------
1 | // properties of array literals defined correctly
2 | function test(expected) {
3 | return [].length;
4 | }
5 |
6 | test(0);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test16.js:
--------------------------------------------------------------------------------
1 | // default prototype
2 | function test(expected) {
3 | function Foo(x) {
4 | this.x = x;
5 | }
6 |
7 | var o1 = new Foo(3);
8 | var o2 = new o1.constructor(123);
9 |
10 | return o2.x;
11 | }
12 |
13 | test(0);
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test160.js:
--------------------------------------------------------------------------------
1 | // apply a built-in, arity 1
2 | function test(expected) {
3 | return isNaN.apply(new Object(), "sdf");
4 | }
5 |
6 | test(true);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test161.js:
--------------------------------------------------------------------------------
1 | // apply a built-in, arity 0
2 | function test(expected) {
3 | return Array.prototype.pop.apply([123, 123]);
4 | }
5 |
6 | test(0);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test162.js:
--------------------------------------------------------------------------------
1 | // apply a built-in, arity 0 (variable arity function)
2 | function test(expected) {
3 | var a = [];
4 | Array.prototype.push.apply(a, [2, 3, "4"]);
5 | return a[2];
6 | }
7 |
8 | var numOrStr;
9 | numOrStr = 0;
10 | numOrStr = "";
11 | test(numOrStr);
12 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test163.js:
--------------------------------------------------------------------------------
1 | // apply a built-in, arity 2
2 | function test(expected) {
3 | var a = [1, 1, 1, 1];
4 | Array.prototype.slice.apply(a, [2, 3]);
5 | return a[2];
6 | }
7 |
8 | test(0);
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test164.js:
--------------------------------------------------------------------------------
1 | // properties of regexps defined correctly
2 | function test(expected) {
3 | return /asdf/.global;
4 | }
5 |
6 | test(true);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test165.js:
--------------------------------------------------------------------------------
1 | // at the 2nd call to t the summary is used, exception must be in summary
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try { t(); } catch (e) { }
6 |
7 | try { t(); } catch (e) { return e.message; }
8 | }
9 |
10 | test("");
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test166.js:
--------------------------------------------------------------------------------
1 | // define a highly recursive function to exercise the exception
2 | // throwing part of the analysis
3 | function test(expected) {
4 | var o = new Object();
5 |
6 | function r(x) {
7 | o.foo = x;
8 | if (123)
9 | r("");
10 | else
11 | r(true);
12 | o.bar = x + 431;
13 | return r([]);
14 | }
15 |
16 | r(123);
17 | return o.bar;
18 | }
19 |
20 | var numOrStr;
21 | numOrStr = 0;
22 | numOrStr = "";
23 | test(numOrStr);
24 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test167.js:
--------------------------------------------------------------------------------
1 | // type presentation of id shouldn't blow up for this example
2 | function test(expected) {
3 | function id(x) {
4 | return x;
5 | }
6 |
7 | id(id(id));
8 |
9 | return 0;
10 | }
11 |
12 | test(0);
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test168.js:
--------------------------------------------------------------------------------
1 | //no problem to analyze this, but printing its type causes looping.
2 | function test(expected) {
3 | function id(x) {
4 | return x;
5 | }
6 |
7 | var x = [];
8 | x[0] = x;
9 |
10 | id(x);
11 | }
12 |
13 | test(foo);
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test169.js:
--------------------------------------------------------------------------------
1 | // forces funToType to be called with a built-in function
2 | function test(expected) {
3 | function foo(x) {
4 | return 123;
5 | }
6 |
7 | return foo(Object);
8 | }
9 |
10 | test(0);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test17.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | function Foo(x) {this.x = x;}
3 |
4 | var o = new Foo(3);
5 | return o["x"];
6 | }
7 |
8 | test(0);
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test170.js:
--------------------------------------------------------------------------------
1 | // test that the toplevel env binds THIS
2 | function test(expected) {
3 | return 123;
4 | }
5 |
6 | var globalobj = this;
7 | test(123);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test18.js:
--------------------------------------------------------------------------------
1 | // properties correctly not merged
2 | function test(expected) {
3 | function Foo(){}
4 |
5 | var o = new Foo();
6 | o[1] = 123;
7 | o[2] = "asdf";
8 | return o[1];
9 | }
10 |
11 | test(0);
12 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test19.js:
--------------------------------------------------------------------------------
1 | // test merging of numeric properties
2 | function test(expected) {
3 | function Foo(){}
4 |
5 | var o = new Foo();
6 | var i = 1;
7 | o[1] = 123;
8 | o[i] = "asdf";
9 | return o[i];
10 | }
11 |
12 | var numOrStr;
13 | numOrStr = 0;
14 | numOrStr = "";
15 | test(numOrStr);
16 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test2.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | return "123";
3 | }
4 |
5 | test("foo");
6 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test20.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | function Foo(){}
3 |
4 | var o = new Foo();
5 | var i = 1;
6 | o[i] = 123;
7 | return o[i];
8 | }
9 |
10 | test(0);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test21.js:
--------------------------------------------------------------------------------
1 | // doesn't merge generic num & str properties
2 | function test(expected) {
3 | function Foo(){}
4 |
5 | var o = new Foo();
6 | var i = 1, s = "asdf";
7 | o[i] = 123;
8 | o[s] = "foo";
9 |
10 | return o[s];
11 | }
12 |
13 | test("0");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test22.js:
--------------------------------------------------------------------------------
1 | // unsoundness due to not detecting implicit "return undefined"
2 | function test(expected) {
3 | if (2 - 2)
4 | return 1;
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test23.js:
--------------------------------------------------------------------------------
1 | // unsoundness because loops aren't iterated to fixpt
2 | function test(expected) {
3 | var x, y;
4 | for (;;) {
5 | x = 1;
6 | y = x;
7 | x = "asdf";
8 | }
9 |
10 | return y;
11 | }
12 |
13 | test(0);
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test24.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | var x = Object.prototype;
3 | x.foo = 0;
4 | return x.foo;
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test25.js:
--------------------------------------------------------------------------------
1 | // test Object constructor
2 | function test(expected) {
3 | var x = Object.prototype;
4 | x.foo = 0;
5 | var o = new Object();
6 | return o.foo;
7 | }
8 |
9 | test(0);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test26.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | return Object.hasOwnProperty("asdf");
3 | }
4 |
5 | test(true);
6 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test27.js:
--------------------------------------------------------------------------------
1 | // it's Function.prototype.toString, not Object.prototype.toString
2 | function test(expected) {
3 | return Object.toString();
4 | }
5 |
6 | test("");
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test28.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | var o = new Object();
3 | o.foo = 123;
4 | return o.valueOf().foo;
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test29.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | var o = new Object();
3 | o.foo = 123;
4 | var o2 = new o.valueOf();
5 | o2.bar = "123";
6 | return o2.bar;
7 | }
8 |
9 | test("");
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test3.js:
--------------------------------------------------------------------------------
1 | // test stack reference
2 | function test(expected) {
3 | var x;
4 | x = 45;
5 | return x;
6 | }
7 |
8 | test(0);
9 |
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test30.js:
--------------------------------------------------------------------------------
1 | // test Function and Function.prototype.prototype
2 | function test(expected) {
3 | Function.prototype.foo = 3;
4 | Object.prototype.foo = "3";
5 | Object.prototype.bar = 3;
6 |
7 | return Function.foo + Function.prototype.prototype.bar;
8 | }
9 |
10 | test(0);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test31.js:
--------------------------------------------------------------------------------
1 | // test Object constructor w/out new
2 | function test(expected) {
3 | var x = Object.prototype;
4 | x.foo = 0;
5 | var o = Object();
6 | return o.foo;
7 | }
8 |
9 | test(0);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test32.js:
--------------------------------------------------------------------------------
1 | // test inheritance in Array and Array.prototype
2 | function test(expected) {
3 | Function.prototype.foo = 0;
4 | Object.prototype.bar = 0;
5 | return Array.foo + Array.prototype.bar;
6 | }
7 |
8 | test(0);
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test33.js:
--------------------------------------------------------------------------------
1 | // test Array constructors with new
2 | function test(expected) {
3 | var a1 = new Array();
4 | var a2 = new Array(123);
5 | var a3 = new Array(0, "asdf");
6 | return a3[0]; // array elms aren't merged
7 | }
8 |
9 | test(0);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test34.js:
--------------------------------------------------------------------------------
1 | // test Array constructor without new
2 | function test(expected) {
3 | var a1 = Array(0, 1);
4 | var a2 = Array("asdf", "adf");
5 | return a2[0]; // a1 and a2 are merged
6 | }
7 |
8 | var numOrStr;
9 | numOrStr = 0;
10 | numOrStr = "0";
11 | test(numOrStr);
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test35.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | var a = new Array();
3 | return a.join();
4 | }
5 |
6 | test("");
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test36.js:
--------------------------------------------------------------------------------
1 | // unsoundness in Array.prototype.pop
2 | function test(expected) {
3 | var a = new Array("1","2","3");
4 | a.pop();
5 | return a[2];
6 | }
7 |
8 | test("");
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test37.js:
--------------------------------------------------------------------------------
1 | // Array.prototype.push
2 | function test(expected) {
3 | var a = new Array();
4 | a.push(0, "");
5 | var i = 0;
6 | return a[i];
7 | }
8 |
9 | var numOrStr;
10 | numOrStr = 0;
11 | numOrStr = "";
12 | test(numOrStr);
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test38.js:
--------------------------------------------------------------------------------
1 | // Array.prototype.push
2 | function test(expected) {
3 | var a = new Array();
4 | return a.push(0, "");
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test39.js:
--------------------------------------------------------------------------------
1 | // a[0] could contain two types.
2 | function test(expected) {
3 | var a = new Array();
4 | a.push(1, 2);
5 | a[0] = "";
6 | return a[0];
7 | }
8 |
9 | var numOrStr;
10 | numOrStr = 0;
11 | numOrStr = "";
12 | test(numOrStr);
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test4.js:
--------------------------------------------------------------------------------
1 | // test heap reference
2 | function test(expected) {
3 | var x;
4 |
5 | function foo(y) {
6 | x = y;
7 | return x;
8 | }
9 |
10 | foo(23);
11 | return foo("asdfasf");
12 | }
13 |
14 | var numOrStr;
15 | numOrStr = 0;
16 | numOrStr = "0";
17 | test(numOrStr);
18 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test40.js:
--------------------------------------------------------------------------------
1 | // Array.prototype.shift
2 | function test(expected) {
3 | var a = new Array(10, 1, 2);
4 | return a.shift();
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test41.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 | var a = new Array(10, "1");
3 | a.shift();
4 | return a[0];
5 | }
6 |
7 | var numOrStr;
8 | numOrStr = 0;
9 | numOrStr = "";
10 | test(numOrStr);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test42.js:
--------------------------------------------------------------------------------
1 | // Array.prototype.unshift
2 | function test(expected) {
3 | var a = new Array();
4 | a.unshift(1, "");
5 | var i = 0;
6 | return a[i];
7 | }
8 |
9 | var numOrStr;
10 | numOrStr = 0;
11 | numOrStr = "";
12 | test(numOrStr);
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test43.js:
--------------------------------------------------------------------------------
1 | // Array.prototype.unshift
2 | function test(expected) {
3 | var a = new Array();
4 | return a.unshift(1, "");
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test44.js:
--------------------------------------------------------------------------------
1 | // test Number & Number.prototype
2 | function test(expected) {
3 | Object.prototype.foo = "";
4 | Object.prototype.bar = 123;
5 | Function.prototype.foo = 123;
6 |
7 | return Number.foo + Number.prototype.bar;
8 | }
9 |
10 | test(0);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test45.js:
--------------------------------------------------------------------------------
1 | // test Number constructor
2 | function test(expected) {
3 | var n = new Number(123);
4 | return n.valueOf() + Number("foobar");
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test46.js:
--------------------------------------------------------------------------------
1 | // Number.prototype.toString
2 | function test(expected) {
3 | var n = new Number(123);
4 | return n.toString();
5 | }
6 |
7 | test("");
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test47.js:
--------------------------------------------------------------------------------
1 | // test String & String.prototype
2 | function test(expected) {
3 | Object.prototype.foo = "";
4 | Object.prototype.bar = 123;
5 | Function.prototype.foo = 123;
6 |
7 | return String.foo + String.prototype.bar;
8 | }
9 |
10 | test(0);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test48.js:
--------------------------------------------------------------------------------
1 | // test String constructor
2 | function test(expected) {
3 | var s = new String("asdfaf");
4 | return s.valueOf() + s.toString();
5 | }
6 |
7 | test("");
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test49.js:
--------------------------------------------------------------------------------
1 | // String.prototype methods that return a string
2 | function test(expected) {
3 | var s = new String("asdfaf");
4 | return s.charAt() + s.slice(0,0) + s.substr(0,0) + s.substring(0,0);
5 | }
6 |
7 | test("");
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test5.js:
--------------------------------------------------------------------------------
1 | // test plus
2 | function test(expected) {
3 | return 2 + 3;
4 | }
5 |
6 | test(0);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test50.js:
--------------------------------------------------------------------------------
1 | // String.prototype methods that return a number
2 | function test(expected) {
3 | var s = new String("asdfaf");
4 | return s.charCodeAt(0) + s.indexOf("f") + s.lastIndexOf("f");
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test51.js:
--------------------------------------------------------------------------------
1 | // reorder branches to put recursion in the THEN branch.
2 | function test(expected) {
3 | function recur(n) {
4 | if (123)
5 | return n + recur(n - 1);
6 | else
7 | return 1;
8 | }
9 |
10 | return recur(0);
11 | }
12 |
13 | test(0);
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test52.js:
--------------------------------------------------------------------------------
1 | // catch-var isn't merged in frame with other vars of the same name.
2 | function test(expected) {
3 | var e = "adfasdf";
4 | try {
5 | throw 0;
6 | }
7 | catch (e) {
8 | return e;
9 | }
10 | }
11 |
12 | test(0);
13 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test53.js:
--------------------------------------------------------------------------------
1 | // unsound: can't tell that x may not be init'd, so we may return undefined.
2 | function test(expected) {
3 | var x;
4 | try {
5 | throw 0;
6 | x = "fadas";
7 | }
8 | catch (e) {
9 | }
10 | return x;
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test54.js:
--------------------------------------------------------------------------------
1 | // Error and properties
2 | function test(expected) {
3 | try {
4 | throw new Error("asdfadf");
5 | }
6 | catch (e) {
7 | return e.toString() + e.name + e.message;
8 | }
9 | }
10 |
11 | test("");
12 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test55.js:
--------------------------------------------------------------------------------
1 | // Array.length
2 | function test(expected) {
3 | var a = new Array();
4 | return a.length;
5 | }
6 |
7 | test(0);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test56.js:
--------------------------------------------------------------------------------
1 | // Error and inheritance
2 | function test(expected) {
3 | Error.prototype.foo = 123;
4 | Error.bar = 345;
5 | try {
6 | throw new Error("asdfadf");
7 | }
8 | catch (e) {
9 | return e.foo + e.constructor.bar;
10 | }
11 | }
12 |
13 | test(0);
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test57.js:
--------------------------------------------------------------------------------
1 | // expr that throws: function call
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | try {
6 | t();
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test58.js:
--------------------------------------------------------------------------------
1 | // plus-right throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | try {
6 | 123 + t();
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test59.js:
--------------------------------------------------------------------------------
1 | // plus-left throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | try {
6 | t() + 123;
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test6.js:
--------------------------------------------------------------------------------
1 | // test plus
2 | function test(expected) {
3 | return "2" + "3";
4 | }
5 |
6 | test("0");
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test60.js:
--------------------------------------------------------------------------------
1 | // minus-left throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | try {
6 | t() - 123;
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test61.js:
--------------------------------------------------------------------------------
1 | // minus-right throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | try {
6 | 123 - t();
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test62.js:
--------------------------------------------------------------------------------
1 | // evalLval: rval throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | try {
6 | var x = t();
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test63.js:
--------------------------------------------------------------------------------
1 | // evalExp/INDEX: n[0] throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | function Foo() {this.foo = 123;}
6 |
7 | try {
8 | (function(){
9 | if (123)
10 | return new Foo();
11 | else
12 | t();}())["foo"];
13 | }
14 | catch (e) {
15 | return e.message;
16 | }
17 | }
18 |
19 | test("");
20 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test64.js:
--------------------------------------------------------------------------------
1 | // evalExp/INDEX: n[1] throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | function Foo() {this.foo = 123;}
6 |
7 | try {
8 | (new Foo())[t()];
9 | }
10 | catch (e) {
11 | return e.message;
12 | }
13 | }
14 |
15 | test("");
16 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test65.js:
--------------------------------------------------------------------------------
1 | // evalExp/DOT: n[0] throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | function Foo() {this.foo = 123;}
6 |
7 | try {
8 | (function(){
9 | if (123)
10 | return new Foo();
11 | else
12 | t();}()).foo;
13 | }
14 | catch (e) {
15 | return e.message;
16 | }
17 | }
18 |
19 | test("");
20 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test66.js:
--------------------------------------------------------------------------------
1 | // evalExp/COMMA: first throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | try {
6 | t(), 123;
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test67.js:
--------------------------------------------------------------------------------
1 | // evalExp/COMMA: last throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | try {
6 | 321, t();
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test68.js:
--------------------------------------------------------------------------------
1 | // evalExp/COMMA: join exceptions
2 | function test(expected) {
3 | function E1(){this.msg = 1;}
4 | E1.prototype = new Error();
5 |
6 | function E2(){this.msg = "1";}
7 | E2.prototype = new Error();
8 |
9 | function t(e){throw e;}
10 |
11 | try {
12 | t(new E1()), t(new E2());
13 | }
14 | catch (e) {
15 | return e.msg;
16 | }
17 | }
18 |
19 | var numOrStr;
20 | numOrStr = 0;
21 | numOrStr = "";
22 | test(numOrStr);
23 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test69.js:
--------------------------------------------------------------------------------
1 | // evalExp/DOT_PROTO: n[0] throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | function Foo() {}
6 |
7 | try {
8 | (function(){
9 | if (123) t(); else return new Foo();
10 | }()).prototype;
11 | }
12 | catch (e) {
13 | return e.message;
14 | }
15 | }
16 |
17 | test("");
18 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test7.js:
--------------------------------------------------------------------------------
1 | // test plus
2 | function test(expected) {
3 | var x;
4 | x = 0;
5 | x = "0";
6 | return x + 0;
7 | }
8 |
9 | var numOrStr;
10 | numOrStr = 0;
11 | numOrStr = "0";
12 | test(numOrStr);
13 |
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test70.js:
--------------------------------------------------------------------------------
1 | // evalExp/CALL: args throw
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | function id(x) {return x;}
6 |
7 | try {
8 | id(t());
9 | }
10 | catch (e) {
11 | return e.message;
12 | }
13 | }
14 |
15 | test("");
16 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test71.js:
--------------------------------------------------------------------------------
1 | // evalExp/CALL: rator throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | function id(x) {return x;}
6 |
7 | try {
8 | (id(t()))();
9 | }
10 | catch (e) {
11 | return e.message;
12 | }
13 | }
14 |
15 | test("");
16 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test72.js:
--------------------------------------------------------------------------------
1 | // evalLval/INDEX: n[0] throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | function Foo() {this.foo = 123;}
6 |
7 | try {
8 | (function(){
9 | if (123)
10 | return new Foo();
11 | else
12 | t();}())["foo"] = 123;
13 | }
14 | catch (e) {
15 | return e.message;
16 | }
17 | }
18 |
19 | test("");
20 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test73.js:
--------------------------------------------------------------------------------
1 | // evalLval/INDEX: n[1] throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | function Foo() {this.foo = 123;}
6 |
7 | try {
8 | (new Foo())[t()] = 123;
9 | }
10 | catch (e) {
11 | return e.message;
12 | }
13 | }
14 |
15 | test("");
16 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test74.js:
--------------------------------------------------------------------------------
1 | // evalLval/DOT: n[0] throws
2 | function test(expected) {
3 | function t() {throw new Error("asdfaafs");}
4 |
5 | function Foo() {this.foo = 123;}
6 |
7 | try {
8 | (function(){
9 | if (123)
10 | return new Foo();
11 | else
12 | t();}()).foo = 123;
13 | }
14 | catch (e) {
15 | return e.message;
16 | }
17 | }
18 |
19 | test("");
20 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test75.js:
--------------------------------------------------------------------------------
1 | // evalFun: call fun w/ more args
2 | function test(expected) {
3 | function f() {}
4 |
5 | f(1, 2, 3);
6 | return 0;
7 | }
8 |
9 | test(0);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test76.js:
--------------------------------------------------------------------------------
1 | // evalFun: call fun w/ fewer args
2 | function test(expected) {
3 | function f(x) {}
4 |
5 | f();
6 | return 0;
7 | }
8 |
9 | test(0);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test77.js:
--------------------------------------------------------------------------------
1 | // evalExp/ARGUMENTS: no extra args but use arguments
2 | function test(expected) {
3 | function f(x) {
4 | var n = 0;
5 | return arguments[0] + arguments[n];
6 | }
7 |
8 | return f(123);
9 | }
10 |
11 | test(0);
12 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test78.js:
--------------------------------------------------------------------------------
1 | // evalExp/ARGUMENTS: negative index
2 | function test(expected) {
3 | function f(x) {
4 | return arguments[-1];
5 | }
6 |
7 | return f(123);
8 | }
9 |
10 | test((new Object()).propdoesntexist);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test79.js:
--------------------------------------------------------------------------------
1 | // evalExp/ARGUMENTS: too large index (unsound)
2 | function test(expected) {
3 | function f() {
4 | return arguments[1];
5 | }
6 |
7 | return f(123);
8 | }
9 |
10 | test(0);
11 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test8.js:
--------------------------------------------------------------------------------
1 | // test comma
2 | function test(expected) {
3 | var x, y;
4 |
5 | x = 4, (y = 5);
6 | return x + y;
7 | }
8 |
9 | test(0);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test80.js:
--------------------------------------------------------------------------------
1 | // evalExp/ARGUMENTS: join all args
2 | function test(expected) {
3 | function f(x) {
4 | return arguments[0 + 1];
5 | }
6 |
7 | return f(123, "asdfasdf");
8 | }
9 |
10 | var numOrStr;
11 | numOrStr = 0;
12 | numOrStr = "";
13 | test(numOrStr);
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test81.js:
--------------------------------------------------------------------------------
1 | // evalExp/ARGUMENTS throws
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | function f(x) { return arguments[t()]; }
6 |
7 | try {
8 | f(432);
9 | }
10 | catch (e) {
11 | return e.message;
12 | }
13 | }
14 |
15 | test("");
16 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test82.js:
--------------------------------------------------------------------------------
1 | // THROW's exp throws
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try {
6 | throw t();
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test83.js:
--------------------------------------------------------------------------------
1 | // * / %
2 | function test(expected) {
3 | return 123 * 543 / 432 % 321;
4 | }
5 |
6 | test(0);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test84.js:
--------------------------------------------------------------------------------
1 | // unary_plus, unary_minus, ++, --
2 | function test(expected) {
3 | return + 1234 - 543 + (8++) - (-1234--);
4 | }
5 |
6 | test(0);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test85.js:
--------------------------------------------------------------------------------
1 | // unary_plus, unary_minus, ++, -- throw
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try {
6 | return + 1234 - 543 + (t()++) - (-t()--);
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | var numOrStr;
14 | numOrStr = 0;
15 | numOrStr = "";
16 | test(numOrStr);
17 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test86.js:
--------------------------------------------------------------------------------
1 | // ==, !=, ===, !==, <, <=, >=, >, instanceof
2 | function test(expected) {
3 | return 123 == 321 != "afd" !== true < false <=
4 | true >= 0 > -321 === (0 instanceof Object) > ("asdf" in 0);
5 | }
6 |
7 | test(true);
8 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test87.js:
--------------------------------------------------------------------------------
1 | // ==, !=, ===, !==, <, <=, >=, >, instanceof throw
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try {
6 | t() == 321 != "afd" !== t() < false <=
7 | true >= t() > -321 === (0 instanceof t()) <= (t() in 0);
8 | }
9 | catch (e) {
10 | return e.message;
11 | }
12 | }
13 |
14 | test("");
15 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test88.js:
--------------------------------------------------------------------------------
1 | // !
2 | function test(expected) {
3 | return !432;
4 | }
5 |
6 | test(true);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test89.js:
--------------------------------------------------------------------------------
1 | // ! throws
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try { !t(); }
6 | catch (e) { return e.message; }
7 | }
8 |
9 | test("");
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test9.js:
--------------------------------------------------------------------------------
1 | function test(expected) {
2 |
3 | function Foo(x) {
4 | this.x = x;
5 | }
6 |
7 | var o = new Foo(0);
8 | o = new Foo("asdf");
9 | return o.x;
10 | }
11 |
12 | var numOrStr;
13 | numOrStr = 0;
14 | numOrStr = "0";
15 | test(numOrStr);
16 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test90.js:
--------------------------------------------------------------------------------
1 | // &&
2 | function test(expected) {
3 | function Foo(){}
4 |
5 | return (new Foo()).foo && 123;
6 | }
7 |
8 | function Bar() {}
9 | test((new Bar()).propertydoesntexist);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test91.js:
--------------------------------------------------------------------------------
1 | // &&
2 | function test(expected) {
3 | return 123 && "";
4 | }
5 |
6 | var numOrStr;
7 | numOrStr = 0;
8 | numOrStr = "";
9 | test(numOrStr);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test92.js:
--------------------------------------------------------------------------------
1 | // && throws, join the two errors
2 | function test(expected) {
3 | function E1(){this.foo = 0;}
4 | E1.prototype = new Error();
5 |
6 | function E2(){this.foo = "";}
7 | E2.prototype = new Error();
8 |
9 | function t(e) { throw e; }
10 |
11 | try {
12 | (t(new E1()) + 123) && t(new E2());
13 | }
14 | catch (e) {
15 | return e.foo;
16 | }
17 | }
18 |
19 | var numOrStr;
20 | numOrStr = 0;
21 | numOrStr = "";
22 | test(numOrStr);
23 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test93.js:
--------------------------------------------------------------------------------
1 | // ||
2 | function test(expected) {
3 | function Foo(){}
4 |
5 | return (new Foo()).foo || 123;
6 | }
7 |
8 | test(0);
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test94.js:
--------------------------------------------------------------------------------
1 | // ||
2 | function test(expected) {
3 | return 123 || "";
4 | }
5 |
6 | var numOrStr;
7 | numOrStr = 0;
8 | numOrStr = "";
9 | test(numOrStr);
10 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test95.js:
--------------------------------------------------------------------------------
1 | // || throws, join the two errors
2 | function test(expected) {
3 | function E1(){this.foo = 0;}
4 | E1.prototype = new Error();
5 |
6 | function E2(){this.foo = "";}
7 | E2.prototype = new Error();
8 |
9 | function t(e) { throw e; }
10 |
11 | try {
12 | (t(new E1()) + 123) || t(new E2());
13 | }
14 | catch (e) {
15 | return e.foo;
16 | }
17 | }
18 |
19 | var numOrStr;
20 | numOrStr = 0;
21 | numOrStr = "";
22 | test(numOrStr);
23 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test96.js:
--------------------------------------------------------------------------------
1 | // |, ^, &, <<, >>, >>>
2 | function test(expected) {
3 | return 123 | 321 ^ "afd" << true >> false >>> true;
4 | }
5 |
6 | test(0);
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test97.js:
--------------------------------------------------------------------------------
1 | // |, ^, &, <<, >>, >>> throw
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try {
6 | 123 | t() ^ "afd" << true >> t() >>> t();
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test98.js:
--------------------------------------------------------------------------------
1 | //evalExp/TYPEOF
2 | function test(expected) {
3 | return typeof "asdf";
4 | }
5 |
6 | test("");
7 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/tests/test99.js:
--------------------------------------------------------------------------------
1 | //evalExp/TYPEOF throws
2 | function test(expected) {
3 | function t() { throw new Error(); }
4 |
5 | try {
6 | typeof t();
7 | }
8 | catch (e) {
9 | return e.message;
10 | }
11 | }
12 |
13 | test("");
14 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/getctags:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | for file in `ls *js`
4 | do
5 | /home/dimvar/moz/jsctags-wcopy/bin/jsctags.js "$file"
6 | mv tags `basename "$file" .js`.tags
7 | done
8 |
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/google/getctags:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | for file in `ls *js`
4 | do
5 | /home/dimvar/moz/jsctags-wcopy/bin/jsctags.js "$file"
6 | mv tags `basename "$file" .js`.tags
7 | done
8 |
9 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/google/regexp.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | runBlock0 regexp.js /^ function runBlock0() {$/;" f lineno:62 type:void function()
8 | runBlock1 regexp.js /^ function runBlock1() {$/;" f lineno:148 type:void function()
9 | runBlock10 regexp.js /^ function runBlock10() {$/;" f lineno:998 type:void function()
10 | runBlock11 regexp.js /^ function runBlock11() {$/;" f lineno:1179 type:void function()
11 | runBlock2 regexp.js /^ function runBlock2() {$/;" f lineno:213 type:void function()
12 | runBlock3 regexp.js /^ function runBlock3() {$/;" f lineno:293 type:void function()
13 | runBlock4 regexp.js /^ function runBlock4() {$/;" f lineno:417 type:void function()
14 | runBlock5 regexp.js /^ function runBlock5() {$/;" f lineno:483 type:void function()
15 | runBlock6 regexp.js /^ function runBlock6() {$/;" f lineno:552 type:void function()
16 | runBlock7 regexp.js /^ function runBlock7() {$/;" f lineno:643 type:void function()
17 | runBlock8 regexp.js /^ function runBlock8() {$/;" f lineno:708 type:void function()
18 | runBlock9 regexp.js /^ function runBlock9() {$/;" f lineno:829 type:void function()
19 | runRegExpBenchmark regexp.js /^function runRegExpBenchmark() {$/;" f lineno:42 type:void function()
20 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/google/run.js:
--------------------------------------------------------------------------------
1 | // Copyright 2008 the V8 project authors. All rights reserved.
2 | // Redistribution and use in source and binary forms, with or without
3 | // modification, are permitted provided that the following conditions are
4 | // met:
5 | //
6 | // * Redistributions of source code must retain the above copyright
7 | // notice, this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above
9 | // copyright notice, this list of conditions and the following
10 | // disclaimer in the documentation and/or other materials provided
11 | // with the distribution.
12 | // * Neither the name of Google Inc. nor the names of its
13 | // contributors may be used to endorse or promote products derived
14 | // from this software without specific prior written permission.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 |
29 | load('base.js');
30 | load('richards.js');
31 | load('deltablue.js');
32 | load('crypto.js');
33 | load('raytrace.js');
34 | load('earley-boyer.js');
35 | load('regexp.js');
36 | load('splay.js');
37 |
38 | var success = true;
39 |
40 | function PrintResult(name, result) {
41 | print(name + ': ' + result);
42 | }
43 |
44 |
45 | function PrintError(name, error) {
46 | PrintResult(name, error);
47 | success = false;
48 | }
49 |
50 |
51 | function PrintScore(score) {
52 | if (success) {
53 | print('----');
54 | print('Score (version ' + BenchmarkSuite.version + '): ' + score);
55 | }
56 | }
57 |
58 |
59 | BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
60 | NotifyError: PrintError,
61 | NotifyScore: PrintScore });
62 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/google/splay.tags:
--------------------------------------------------------------------------------
1 | !_TAG_FILE_FORMAT 2 /extended format/
2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3 | !_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton@mozilla.com/
4 | !_TAG_PROGRAM_NAME jsctags //
5 | !_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
6 | !_TAG_PROGRAM_VERSION 0.1 //
7 | %anonymous_function splay.js /^ this.root_.traverse_(function(node) { result.push(node.key); });$/;" f lineno:261 type:void function()
8 | GenerateKey splay.js /^function GenerateKey() {$/;" f lineno:64 type:number function()
9 | GeneratePayloadTree splay.js /^function GeneratePayloadTree(depth, key) {$/;" f lineno:49 type:Object function(number, number)
10 | InsertNewNode splay.js /^function InsertNewNode() {$/;" f lineno:71 type:number function()
11 | Node splay.js /^SplayTree.Node = function(key, value) {$/;" f lineno:345 type:Node function(, )
12 | SplayRun splay.js /^function SplayRun() {$/;" f lineno:111 type:void function()
13 | SplaySetup splay.js /^function SplaySetup() {$/;" f lineno:83 type:void function()
14 | SplayTearDown splay.js /^function SplayTearDown() {$/;" f lineno:89 type:void function()
15 | SplayTree splay.js /^function SplayTree() {$/;" f lineno:130 type:SplayTree function()
16 | exportKeys splay.js /^SplayTree.prototype.exportKeys = function() {$/;" f lineno:258 type:Array[number] function()
17 | find splay.js /^SplayTree.prototype.find = function(key) {$/;" f lineno:223 type:null function(number)
18 | findGreatestLessThan splay.js /^SplayTree.prototype.findGreatestLessThan = function(key) {$/;" f lineno:236 type:null function(any)
19 | insert splay.js /^SplayTree.prototype.insert = function(key, value) {$/;" f lineno:159 type:void function(number, Object)
20 | isEmpty splay.js /^SplayTree.prototype.isEmpty = function() {$/;" f lineno:146 type:boolean function()
21 | kSplayTreeModifications splay.js /^var kSplayTreeModifications = 80;$/;" v lineno:43 type:number
22 | kSplayTreePayloadDepth splay.js /^var kSplayTreePayloadDepth = 5;$/;" v lineno:44 type:number
23 | kSplayTreeSize splay.js /^var kSplayTreeSize = 8000;$/;" v lineno:42 type:number
24 | remove splay.js /^SplayTree.prototype.remove = function(key) {$/;" f lineno:192 type:void function(any)
25 | splayTree splay.js /^var splayTree = null;$/;" v lineno:46 type:
26 | splay_ splay.js /^SplayTree.prototype.splay_ = function(key) {$/;" f lineno:277 type:void function(number)
27 | traverse_ splay.js /^SplayTree.Node.prototype.traverse_ = function(f) {$/;" f lineno:370 type:void function(void function())
28 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/run-crypto.js:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Google Inc. All Rights Reserved.
2 | // Redistribution and use in source and binary forms, with or without
3 | // modification, are permitted provided that the following conditions are
4 | // met:
5 | //
6 | // * Redistributions of source code must retain the above copyright
7 | // notice, this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above
9 | // copyright notice, this list of conditions and the following
10 | // disclaimer in the documentation and/or other materials provided
11 | // with the distribution.
12 | // * Neither the name of Google Inc. nor the names of its
13 | // contributors may be used to endorse or promote products derived
14 | // from this software without specific prior written permission.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 |
29 | load('base.js');
30 | load('crypto.js');
31 |
32 | function PrintResult(name, result) {
33 | print(name + ': ' + result);
34 | }
35 |
36 |
37 | function PrintScore(score) {
38 | print('----');
39 | print('Score: ' + score);
40 | }
41 |
42 |
43 | BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
44 | NotifyScore: PrintScore });
45 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/run-deltablue.js:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Google Inc. All Rights Reserved.
2 | // Redistribution and use in source and binary forms, with or without
3 | // modification, are permitted provided that the following conditions are
4 | // met:
5 | //
6 | // * Redistributions of source code must retain the above copyright
7 | // notice, this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above
9 | // copyright notice, this list of conditions and the following
10 | // disclaimer in the documentation and/or other materials provided
11 | // with the distribution.
12 | // * Neither the name of Google Inc. nor the names of its
13 | // contributors may be used to endorse or promote products derived
14 | // from this software without specific prior written permission.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 |
29 | load('base.js');
30 | load('deltablue.js');
31 |
32 | function PrintResult(name, result) {
33 | print(name + ': ' + result);
34 | }
35 |
36 |
37 | function PrintScore(score) {
38 | print('----');
39 | print('Score: ' + score);
40 | }
41 |
42 |
43 | BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
44 | NotifyScore: PrintScore });
45 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/run-earley-boyer.js:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Google Inc. All Rights Reserved.
2 | // Redistribution and use in source and binary forms, with or without
3 | // modification, are permitted provided that the following conditions are
4 | // met:
5 | //
6 | // * Redistributions of source code must retain the above copyright
7 | // notice, this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above
9 | // copyright notice, this list of conditions and the following
10 | // disclaimer in the documentation and/or other materials provided
11 | // with the distribution.
12 | // * Neither the name of Google Inc. nor the names of its
13 | // contributors may be used to endorse or promote products derived
14 | // from this software without specific prior written permission.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 |
29 | load('base.js');
30 | load('earley-boyer.js');
31 |
32 | function PrintResult(name, result) {
33 | print(name + ': ' + result);
34 | }
35 |
36 |
37 | function PrintScore(score) {
38 | print('----');
39 | print('Score: ' + score);
40 | }
41 |
42 |
43 | BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
44 | NotifyScore: PrintScore });
45 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/run-raytrace.js:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Google Inc. All Rights Reserved.
2 | // Redistribution and use in source and binary forms, with or without
3 | // modification, are permitted provided that the following conditions are
4 | // met:
5 | //
6 | // * Redistributions of source code must retain the above copyright
7 | // notice, this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above
9 | // copyright notice, this list of conditions and the following
10 | // disclaimer in the documentation and/or other materials provided
11 | // with the distribution.
12 | // * Neither the name of Google Inc. nor the names of its
13 | // contributors may be used to endorse or promote products derived
14 | // from this software without specific prior written permission.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 |
29 | load('base.js');
30 | load('raytrace.js');
31 |
32 | function PrintResult(name, result) {
33 | print(name + ': ' + result);
34 | }
35 |
36 |
37 | function PrintScore(score) {
38 | print('----');
39 | print('Score: ' + score);
40 | }
41 |
42 |
43 | BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
44 | NotifyScore: PrintScore });
45 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/run-richards.js:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Google Inc. All Rights Reserved.
2 | // Redistribution and use in source and binary forms, with or without
3 | // modification, are permitted provided that the following conditions are
4 | // met:
5 | //
6 | // * Redistributions of source code must retain the above copyright
7 | // notice, this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above
9 | // copyright notice, this list of conditions and the following
10 | // disclaimer in the documentation and/or other materials provided
11 | // with the distribution.
12 | // * Neither the name of Google Inc. nor the names of its
13 | // contributors may be used to endorse or promote products derived
14 | // from this software without specific prior written permission.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 |
29 | load('base.js');
30 | load('richards.js');
31 |
32 | function PrintResult(name, result) {
33 | print(name + ': ' + result);
34 | }
35 |
36 |
37 | function PrintScore(score) {
38 | print('----');
39 | print('Score: ' + score);
40 | }
41 |
42 |
43 | BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
44 | NotifyScore: PrintScore });
45 |
--------------------------------------------------------------------------------
/lib/jsctags/narcissus/v8/run.js:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Google Inc. All Rights Reserved.
2 | // Redistribution and use in source and binary forms, with or without
3 | // modification, are permitted provided that the following conditions are
4 | // met:
5 | //
6 | // * Redistributions of source code must retain the above copyright
7 | // notice, this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above
9 | // copyright notice, this list of conditions and the following
10 | // disclaimer in the documentation and/or other materials provided
11 | // with the distribution.
12 | // * Neither the name of Google Inc. nor the names of its
13 | // contributors may be used to endorse or promote products derived
14 | // from this software without specific prior written permission.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 |
29 | load('base.js');
30 | load('richards.js');
31 | load('deltablue.js');
32 | load('crypto.js');
33 | load('raytrace.js');
34 | load('earley-boyer.js');
35 |
36 |
37 | function PrintResult(name, result) {
38 | print(name + ': ' + result);
39 | }
40 |
41 |
42 | function PrintScore(score) {
43 | print('----');
44 | print('Score: ' + score);
45 | }
46 |
47 |
48 | BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
49 | NotifyScore: PrintScore });
50 |
--------------------------------------------------------------------------------
/lib/jsctags/servetypes.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var parse = require('./narcissus/jsparse').parse;
3 | var getTags = require('./narcissus/jscfa').getTags;
4 | var formidable = require('../formidable');
5 |
6 | function analyze(cwd, req, resp) {
7 | // FIXME: extra field for header message (instead of "Not Found")
8 | function error(code, msg) {
9 | resp.writeHead(code, "Not Found", { 'Content-type': 'text/plain' });
10 | resp.end(code + " " + msg);
11 | }
12 |
13 | if (req.method !== 'POST') {
14 | resp.writeHead(405, "Invalid Method", { 'Content-type': 'text/plain' });
15 | resp.end("405 Only POST method allowed");
16 | return;
17 | }
18 |
19 | // FIXME: prevent formidable from saving files
20 | var form = new formidable.IncomingForm();
21 | var src;
22 |
23 | form
24 | .addListener('error', function(err) {
25 | error(400, err);
26 | })
27 | .addListener('field', function(field, value) {
28 | if (field === 'src')
29 | src = value;
30 | })
31 | .addListener('end', function() {
32 | if (!src) {
33 | error(400, 'No "src" field in POST');
34 | return;
35 | }
36 |
37 | // farm the work out to rn.js
38 | var spawn = require('child_process').spawn;
39 | var rn = spawn(path.join(cwd, 'rn.js'));
40 |
41 | // on timeout, kill the process and send an error
42 | var timeout = setTimeout(function() {
43 | if (rn) {
44 | rn.kill(); // ooh, brutal ;)
45 | error(500, "Service timed out");
46 | }
47 | }, 10000);
48 |
49 | // send the input program to rn.js
50 | rn.stdin.end(src);
51 |
52 | // forward the output ctags to the response
53 | var buf = [];
54 | rn.stdout.on("data", _(buf.push).bind(buf));
55 | rn.stdout.on("end", function() {
56 | clearTimeout(timeout);
57 | rn = null;
58 | resp.writeHead(200, "OK", { "Content-type": "application/json" });
59 | resp.end(buf.join(""));
60 | });
61 | });
62 |
63 | form.parse(req);
64 | }
65 |
66 | exports.analyze = analyze;
67 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ctags",
3 | "description": "Intelligent code indexing for JavaScript",
4 | "version": "0.1.0",
5 | "keywords": [ "ctags", "tags" ],
6 | "maintainers": [
7 | {
8 | "name": "Patrick Walton",
9 | "email": "pwalton@mozilla.com",
10 | "web": "http://pcwalton.blogspot.com/"
11 | }
12 | ],
13 | "contributors": [
14 | {
15 | "name": "Patrick Walton",
16 | "email": "pwalton@mozilla.com",
17 | "web": "http://pcwalton.blogspot.com/"
18 | }
19 | ],
20 | "bugs": "http://github.com/pcwalton/jsctags/issues",
21 | "licenses": [
22 | {
23 | "type": "MPL",
24 | "url": "http://www.mozilla.org/MPL/MPL-1.1.html"
25 | },
26 | {
27 | "type": "GPLv2",
28 | "url": "http://www.gnu.org/licenses/gpl-2.0.html"
29 | },
30 | {
31 | "type": "LGPLv2.1",
32 | "url": "http://www.gnu.org/licenses/lgpl-2.1.html"
33 | }
34 | ],
35 | "repositories": [
36 | {
37 | "type": "git",
38 | "url": "git://github.com/pcwalton/jsctags.git"
39 | }
40 | ],
41 | "dependencies": {},
42 | "homepage": "http://github.com/pcwalton/jsctags/",
43 | "engine": [ "node" ],
44 | "directories": [ "bin", "lib", "test" ],
45 | "implements": [ "CommonJS/Modules/1.0" ],
46 | "scripts": {
47 | "install": "install.js",
48 | "serve": "serve.js",
49 | "uninstall": "uninstall.js"
50 | }
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/serve.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /* ***** BEGIN LICENSE BLOCK *****
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | * http://www.mozilla.org/MPL/
9 | *
10 | * Software distributed under the License is distributed on an "AS IS" basis,
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 | * for the specific language governing rights and limitations under the
13 | * License.
14 | *
15 | * The Original Code is Bespin.
16 | *
17 | * The Initial Developer of the Original Code is
18 | * Mozilla.
19 | * Portions created by the Initial Developer are Copyright (C) 2009
20 | * the Initial Developer. All Rights Reserved.
21 | *
22 | * Contributor(s):
23 | * Bespin Team (bespin@mozilla.com)
24 | *
25 | * Alternatively, the contents of this file may be used under the terms of
26 | * either the GNU General Public License Version 2 or later (the "GPL"), or
27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 | * in which case the provisions of the GPL or the LGPL are applicable instead
29 | * of those above. If you wish to allow use of your version of this file only
30 | * under the terms of either the GPL or the LGPL, and not to allow others to
31 | * use your version of this file under the terms of the MPL, indicate your
32 | * decision by deleting the provisions above and replace them with the notice
33 | * and other provisions required by the GPL or the LGPL. If you do not delete
34 | * the provisions above, a recipient may use your version of this file under
35 | * the terms of any one of the MPL, the GPL or the LGPL.
36 | *
37 | * ***** END LICENSE BLOCK ***** */
38 |
39 | require.paths.unshift('./lib/jsctags');
40 | var http = require('http'), paperboy = require('paperboy');
41 | var sys = require('sys');
42 |
43 | http.createServer(function(req, resp) {
44 | paperboy.deliver(__dirname, req, resp).
45 | error(function(code, msg) {
46 | resp.writeHead(code, { "Content-type": "text/plain" });
47 | resp.close();
48 | }).
49 | otherwise(function(err) {
50 | resp.writeHead(404, { "Content-type": "text/plain" });
51 | resp.close();
52 | });
53 | }).listen(8080);
54 |
55 |
--------------------------------------------------------------------------------
/test/readtags.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var argv = process.argv;
4 | var path = require('path');
5 | require.paths.unshift(path.join(path.dirname(argv[1]), "..", "lib",
6 | "jsctags"));
7 |
8 | var ctags = require('ctags'), fs = require('fs'), sys = require('sys');
9 |
10 | var tags = new ctags.Tags();
11 | var str = fs.readFileSync(argv[2]);
12 | tags.readString(str);
13 |
14 | var result = (argv.length >= 4) ? tags.stem(argv[3]) : tags.tags;
15 | sys.puts(sys.inspect(result));
16 |
17 |
--------------------------------------------------------------------------------
/test/testcases/boot.js:
--------------------------------------------------------------------------------
1 | /* ***** BEGIN LICENSE BLOCK *****
2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 | *
4 | * The contents of this file are subject to the Mozilla Public License Version
5 | * 1.1 (the "License"); you may not use this file except in compliance with
6 | * the License. You may obtain a copy of the License at
7 | * http://www.mozilla.org/MPL/
8 | *
9 | * Software distributed under the License is distributed on an "AS IS" basis,
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 | * for the specific language governing rights and limitations under the
12 | * License.
13 | *
14 | * The Original Code is Bespin.
15 | *
16 | * The Initial Developer of the Original Code is
17 | * Mozilla.
18 | * Portions created by the Initial Developer are Copyright (C) 2009
19 | * the Initial Developer. All Rights Reserved.
20 | *
21 | * Contributor(s):
22 | * Bespin Team (bespin@mozilla.com)
23 | *
24 | * Alternatively, the contents of this file may be used under the terms of
25 | * either the GNU General Public License Version 2 or later (the "GPL"), or
26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
28 | * of those above. If you wish to allow use of your version of this file only
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
30 | * use your version of this file under the terms of the MPL, indicate your
31 | * decision by deleting the provisions above and replace them with the notice
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
33 | * the provisions above, a recipient may use your version of this file under
34 | * the terms of any one of the MPL, the GPL or the LGPL.
35 | *
36 | * ***** END LICENSE BLOCK ***** */
37 |
38 | // This module is set up to be dependency-less so that Narwhal
39 | // will be able to run it right away.
40 |
41 | bespin.useBespin = function(element, options) {
42 | var baseConfig = %s;
43 | options = options || {};
44 | for (var key in options) {
45 | baseConfig[key] = options[key];
46 | }
47 | var appconfig = bespin.tiki.require("appconfig");
48 | baseConfig.element = element;
49 | return appconfig.launch(baseConfig);
50 | };
51 |
52 | document.addEventListener("DOMContentLoaded", function() {
53 | var nodes = document.querySelectorAll(".bespin");
54 | for (var i = 0; i < nodes.length; i++) {
55 | var node = nodes[i];
56 | var options = node.getAttribute('data-bespinoptions');
57 | node.bespin = bespin.useBespin(node, JSON.parse(options));
58 | }
59 |
60 | // If users want a custom startup
61 | if (window.onBespinLoad) {
62 | window.onBespinLoad();
63 | }
64 | }, false);
65 |
--------------------------------------------------------------------------------
/test/testcases/jquery-pattern.js:
--------------------------------------------------------------------------------
1 | (function(wnd) {
2 | var myQuery = {
3 | foo: function() {
4 | window.alert("foo");
5 | },
6 |
7 | bar: function() {
8 | return 1;
9 | },
10 |
11 | baz: 3
12 | };
13 |
14 | myQuery.boo = function() {
15 | return 42;
16 | };
17 |
18 | myQuery.boo.foo = 12;
19 |
20 | wnd.$ = wnd.myQuery = myQuery;
21 | })(window);
22 |
23 |
--------------------------------------------------------------------------------
/test/testcases/simple.js:
--------------------------------------------------------------------------------
1 | function foo() {
2 | return x;
3 | }
4 |
5 | var bar = function() {
6 | return y;
7 | };
8 |
9 | function baz() { // foo
10 | return z;
11 | }
12 |
13 | function baz() {
14 | return 1;
15 | }
16 |
17 |
--------------------------------------------------------------------------------