Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions bin/dr.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ var path = require('path');

var cwd = path.dirname(argv[1]);
var libdir = path.join(cwd, "..", "lib");

require.paths.unshift(path.join(libdir, "jsctags"));
var jscdir = path.join(libdir, "jsctags");

function requireJsc(mod) {
return require(path.join(jscdir, mod));
}

var util = require('util');
var _ = require('underscore')._;
var _ = requireJsc('underscore')._;
var http = require('http');
var url = require('url');
var servetypes = require('servetypes');
var servetypes = requireJsc('servetypes');

function usage(msg) {
util.print("usage: " + path.basename(argv[1]) + " [options]\n");
Expand Down Expand Up @@ -135,7 +138,7 @@ function makeSiteHandler(dir, service) {
txt: "text/plain"
};

return function(req, resp) {
return function (req, resp) {
var query = url.parse(req.url).pathname;

if (service && query === '/analyze') {
Expand All @@ -150,7 +153,7 @@ function makeSiteHandler(dir, service) {
var ext = path.extname(file);

var fs = require('fs');
fs.stat(file, function(err, stats) {
fs.stat(file, function (err, stats) {
if (!stats || !stats.isFile()) {
util.debug("404: " + file);
resp.writeHead(404, "Not Found", { 'Content-type': 'text/plain' });
Expand Down
45 changes: 35 additions & 10 deletions bin/rn.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,57 @@

var argv = process.argv;
var path = require('path');



var cwd = path.dirname(argv[1]);
var libdir = path.join(cwd, "..", "lib");

require.paths.unshift(path.join(libdir, "jsctags"));
var jscdir = path.join(libdir, "jsctags");

function requireJsc(mod) {
return require(path.join(jscdir, mod));
}

var util = require('util');
var _ = require('underscore')._;
var _ = requireJsc('underscore')._;
var getTags = require('../lib/cfa2/jscfa').getTags;
var parse = require('../narcissus/lib/parser').parse;

var stdin = process.openStdin();
// prints a value and exits
function returnVal(val) {
// we're only allowed to return one value
if(returnVal.returned) return false;
returnVal.returned = true;

// wait for the value to be written
process.stdout.once('drain', function () {
process.exit();
});

util.print(val);
return true;
}
// static variable
returnVal.returned = false;

// prints an object as json string and exits
function returnJson(obj) {
return returnVal(JSON.stringify(obj));
}

var stdin = process.openStdin();
stdin.setEncoding("utf8");

var buf = [];
stdin.on("data", _(buf.push).bind(buf));
stdin.on("end", function() {
stdin.on("end", function () {
var src = buf.join("");
var lines, ast;
try {
lines = src.split("\n");
ast = parse(src, "js", 1);
} catch (e) {
util.print(JSON.stringify({ error: e.message, stage: "parse" }));
process.exit();
returnJson({ error: e.message, stage: "parse" });
return;
}

var json;
Expand All @@ -73,6 +98,6 @@ stdin.on("end", function() {
json = { error: e.message, stage: "analysis" };
}

util.print(JSON.stringify(json));
process.exit();
returnJson(json);
return;
});
114 changes: 57 additions & 57 deletions lib/jsctags/ctags/interp.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Bespin.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bespin Team (bespin@mozilla.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */

// Abstract interpreter, based on Narcissus.

var getTags = require('../../cfa2/jscfa').getTags;

//dimvar: opts stands for options. If we are using commonJS it gives
//info about the module (see getModuleInfo@jsctags.js).
exports.Interpreter = function(ast, file, lines, opts) {
this.ast = ast;
this.file = file;
this.lines = lines;
this.opts = opts;
this.tags = [];
};

exports.Interpreter.prototype = {
interpret: function() {
this.tags = getTags(this.ast, this.file, this.lines, this.opts);
}
};

/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Bespin.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bespin Team (bespin@mozilla.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// Abstract interpreter, based on Narcissus.
var getTags = require('../../cfa2/jscfa').getTags;
//dimvar: opts stands for options. If we are using commonJS it gives
//info about the module (see getModuleInfo@jsctags.js).
exports.Interpreter = function (ast, file, lines, opts) {
this.ast = ast;
this.file = file;
this.lines = lines;
this.opts = opts;
this.tags = [];
};
exports.Interpreter.prototype = {
interpret: function () {
this.tags = getTags(this.ast, this.file, this.lines, this.opts);
}
};
128 changes: 64 additions & 64 deletions lib/jsctags/ctags/nativefn.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Bespin.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bespin Team (bespin@mozilla.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */

// Functions important for export detection that that we try to automatically
// detect and implement.

// jQuery's "extend".
function extend(interp, ctx, thisObject, args) {
var objects = args.data.slice(0);
if (objects.length === 0) {
return interp.getNullValue();
}

var target = objects.length === 1 ? thisObject : objects.shift();
interp.coerceToStorable(target);

objects.forEach(function(obj) {
for (var key in obj.data) {
target.data[key] = obj.data[key];
}
});

return target;
}

exports.nativeFns = {
extend: extend, // jQuery
mixin: extend // dojo, Bespin
};

/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Bespin.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bespin Team (bespin@mozilla.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// Functions important for export detection that that we try to automatically
// detect and implement.
// jQuery's "extend".
function extend(interp, ctx, thisObject, args) {
var objects = args.data.slice(0);
if (objects.length === 0) {
return interp.getNullValue();
}
var target = objects.length === 1 ? thisObject : objects.shift();
interp.coerceToStorable(target);
objects.forEach(function (obj) {
for (var key in obj.data) {
target.data[key] = obj.data[key];
}
});
return target;
}
exports.nativeFns = {
extend: extend, // jQuery
mixin: extend // dojo, Bespin
};
Loading