Saturday, September 6, 2008

Modified V8 Shell w/ translateCode

This week Dan Ingalls came down to visit us at VPRI, and we got to chat about V8 for a little bit. We're both really excited about it. "It's like they just gave you a new horse", he said. :)

So tonight I was looking at the source code of the V8 shell, and it turned out to be pretty easy to modify it to support my translateCode idea. In case you don't know what I'm talking about, there really isn't much to it: translateCode is just a user-defined function that's called (implicitly) by the shell/workspace. It takes as an argument the code that the user typed in, and returns the code that should run in its place. It's extremely useful for playing with source-to-source translators. Here's a link to my modified, if you're interested.

The following transcript shows this modified shell in action. ometa-rhino.js is just a file that loads the OMeta/JS implementation and defines translateCode just like I do in the browser, i.e., so that both OMeta and JavaScript are accepted.
  ./v8 ometa-rhino.js --shell
V8 version 0.3.0
> ometa M { ones = (1 -> 2)* }
[object Object]
> M.matchAll([1, 1, 1, 1], "ones")
[2, 2, 2, 2]
Now if only these guys at Google would hurry up and get Chrome to work on my Mac...

1 comment:

Torsten said...

See also

SquirrelFish Extreme is available for Mac