My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Wiki pages
Links

BF-JS

The aim of this project is to provide a working BF interpreter in JavaScript and a working BF to JavaScript compiler. Originally, these utilities were intended to determine the efficiency of and test the limits of JavaScript Just-In-Time (JIT) compilers.

BF Interpreter in JS

The interpreter was written first, partly to test the new JIT's that were being released, and partly to ensure my brain hadn't completely shut itself off.

BF->JS Compiler

The compiler was written after I had the interpreter working. The compiler was amazingly easy to write after building the interpreter.

Update: As of revision 6, the compiler now has three modes of compilation that can be passed in. The alwayseval mode will call eval() on the code block any time the compiled program is run. The preeval mode will call eval() once during compilation and set up the actual program code as a function that will be called every time the compiled program is run. The dump mode will write the compiled code string to the browser window inside of a temp variable, and then run eval() to assign the newly created block of code to the compiled program, which will then be called every time the compiled program is run.

Test Cases

A standard "Hello World!" BF program is used in the provided test cases. In each respective test case, the program is either interpreted or compiled into JavaScript and then run a certain number of times to obtain an average run time. This probably isn't the greatest test of JIT efficiency, but it's a start. HTML files are provided for easy drag-and-drop testing of JavaScript enabled web browsers.

More

You can see more of my code at Kopfhaus.net.

Powered by Google Project Hosting