Sunday, January 25, 2009

JSHydra

Over the past week or so, in between my myriads of projects, I managed to find time to revive a partially-completed tool called jshydra (properly capitalized as "JSHydra"). JSHydra, in both name and code, is derived from Dehydra and Treehydra: it is a static analyzer for JavaScript. I first decided that such a tool was needed when I was in the middle of a large refactoring of address book code.

The source code for jshydra can be found at my Mozilla user hg repo. Presently, it requires some hackery and file modifications to merely build the system. I use SpiderMonkey internal APIs (the parsing APIs, to be exact), so that's where most of the hackery comes into play.

For the time being, I'm probably going to put aside doing more work on jshydra, as I have more pressing work on my plate at this time. If you have any questions, feel free to contact me via IRC (handle: jcranmer (I should be in #mmgc)) or via my email address as listed in bugzilla.

5 comments:

Andrew Sutherland said...

Nice! When I was thinking about javascript documentation issues the other day, I was pondering hooking some javascript up to the spidermonkey parser... then this shows up! (the best solutions right now use Rhino, which I don't think quite keeps up sufficiently....)

Any chance of augmenting the jsscan module to (optionally) emit comments as AST blocks? That would enable actual inference logic to parse out type annotations from the comments and check them/propagate from there. But more importantly, it makes it much easier to do fancy documentation processing (than when you don't have the documentation blocks...)

(And lest there be any confusion, by "any chance", I'm not wondering if it's possible; it's a plea for you to distract yourself from your other projects some more. ;)

Joshua Cranmer said...

I chose to use the actual SpiderMonkey APIs, as unfriendly as they are, because that would guarantee me 100% accuracy (at least as far as Mozilla JS is concerned).

Re the comment stuff, this is something that has been considered, as jshydra would need something à la GCC's user attributes or Java's annotations to be useful in doing static analyses.

Unknown said...

This is really cool, Joshua, nice work. I'd love to hear more about it when you have a chance some time. I'm especially interested to see if I can use this at all to supplement my dxr stuff to now get proper JS info when I build the type database.

Anonymous said...

I hope you have more success than me with JStify -- you should, if you have enough time to spend on the project.

I'll be sure to send you any person who's looking for JavaScript static analysis.

arshad'sblog said...

Sir,
I would like to know which version of spidermonkey is required by latest jshydra