4

For a project I'm tangentially working on, I need a way to compile JavaScript into some intermediate language or bytecode so that I can single-step through it. I know that many of the JavaScript engines in modern browsers do something like this, but they don't make the resulting bytecode accessible. Is there a good off-the-shelf tool for this sort of JavaScript compilation?

2
  • Why don't you then just use a debugger of a browser? I mean, you want to step through the code and therefore you're going to translate it into some intermediate code so you can step through it...? Also interesting maybe: .NET supports JScript - maybe that helps you? Commented Mar 18, 2011 at 19:47
  • The idea is to have students write JavaScript code in a web browser and then to be able to run it in the browser with a debugger available. Many browsers do have good debuggers in them, but sometimes they're really hard to use or have weird side-effects, like locking up the browser except for the debugging console. For that reason, .NET won't be very useful, since this should run in a browser on any OS. Still, thanks for the suggestion! Commented Mar 18, 2011 at 19:50

1 Answer 1

5

Not exactly sure of your needs, however maybe Rhino could work for you.

The JavaScript compiler translates JavaScript source into Java class files. The resulting Java class files can then be loaded and executed at another time, providing a convenient method for transfering JavaScript, and for avoiding translation cost.

More about the compile function is located here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.