Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Instrumenting Javascript using Rhino

111 views
Skip to first unread message

Frank

unread,
Oct 16, 2009, 8:14:47 AM10/16/09
to
Hi,

I would like to use Rhino (if possible) to instrument some Javascript
code. This means I would need to use the Rhino parser to create an
AST, then modify this AST and somehow print out Javascript source code
again. Is this possible? Where can I find the documentation I would
need?

Regards,
Frank Groeneveld

Frank Groeneveld

unread,
Nov 3, 2009, 11:03:44 AM11/3/09
to

I've started this project by using the newest cvs code that includes
the better AST stuff. I think the only problem I will hit is the fact
that I can't decompile the modified AST. Did anybody ever try to
create a decompile function for a modified AST?

Regards,
Frank Groeneveld

Attila Szegedi

unread,
Nov 3, 2009, 12:15:19 PM11/3/09
to Frank, dev-tech-js-...@lists.mozilla.org
What kind of instrumentation do you need? You can achieve some things
by implementing the org.mozilla.javascript.debug.Debugger interface
and hook an instance of it into the Context using setDebugger(). I.e.
function enter/exit, code coverage by line etc. are all possible to be
tracked by implementing a Debugger.

Attila.

Frank Groeneveld

unread,
Nov 3, 2009, 12:26:34 PM11/3/09
to
On 3 nov, 18:15, Attila Szegedi <szege...@gmail.com> wrote:
> What kind of instrumentation do you need? You can achieve some things  
> by implementing the org.mozilla.javascript.debug.Debugger interface  
> and hook an instance of it into the Context using setDebugger(). I.e.  
> function enter/exit, code coverage by line etc. are all possible to be  
> tracked by implementing a Debugger.
>
> Attila.

Sorry, I wasn't clear on that. I need to add instrumentation code to
javascript files and then produce new javascript files (with the
instrumentation code), so that they can be run in a web browser.

Frank

Frank Groeneveld

unread,
Nov 5, 2009, 3:20:30 AM11/5/09
to
It seems the toSource() method of AstNodes works the way I want :)
The only problem I found sofar is that I need the patch from bug
#491621 to get correct output for variable declarations.

Frank

0 new messages