Continuum - ES6 Virtual Machine

87 views
Skip to first unread message

Brandon Benvie

unread,
Nov 26, 2012, 10:26:44 AM11/26/12
to esp...@googlegroups.com


Continuum is ECMAScript 6 virtual machine (though ES6 is a moving target). It uses esprima's harmony branch (with some modifications) to parse source into AST which it then generates bytecode from and also uses the source locations that esprima adds in order to provide Spidermonkey-style syntax error reporting. When esprima throws a syntax error, Continuum catches it and creates a corresponding VM SyntaxError object and emits that as an Abrupt Completion.

I've been able to implement nearly all the features of ES6, though much testing and bug fixing and refinement remains to be done. The ES runtime builtins are actually self-hosted and written as ES6 modules, which are executed during the initialization of a new context, thus allowing them to be written using new ES6 features. Everything else is written in ES3 and works in at least IE8 and I'm pretty sure it'd run in IE6 if I spent a half hour on it. A goal for the near future is bootstrapping the whole thing by having it compile itself to bytecode and then running that on an minimal instruction set, so then the whole thing can be rewritten using ES6 and distributed in precompiled form.


The modifications I've made to esprima are somewhat unstable changes in order to support some new features, which I'm hoping to be able to submit pull requests in due course.

The first is support for AtSymbol (referred to on the ES wiki as AtNames currently) which is basically an Identifier beginning with '@' that is restricted to not being an assignable LHS. To allow for bringing an AtSymbol into scope, there's SymbolDeclaration and SymbolDeclarator which works similarly to a VariableDeclaration, but the public form is probably going to use a non-restricted word (I currently am using 'symbol' but it's not decided as far as I know what it will actually be) so this is a context keyword match instead of a normal keyword. A SymbolDeclaration is legal in a ClassBody (I'm not sure whether initializers are legal in this context though, I currently don't allow them). 

Second is parameter defaults, which are really easy to implement. All that's needed here is checking for '=' before checking for the comma or closing parenthesis and then parsing an assignment expression. I haven't implemented the actual functionality for this in Continuum yet but I'm going to soon, and I'd like to get a pull request in for it soon as well since it's such a simple change.

Ariya Hidayat

unread,
Nov 27, 2012, 10:20:08 AM11/27/12
to esp...@googlegroups.com
Continuum is quite impressive! If someone told me a year ago that this
can be made, I wouldn't believe him. Apparently, it is now possible.
Many kudos!

One thing that you can easily add to help others understand it is a
bunch of bite-size, step-by-step tutorial. Even for JavaScript
experts, it's not really obvious what to do with the demo page.

It's an excellent work and keep improving it! Looking forward to
getting the AtSymbol and default parameter patches.


Thank you!

Regards,

--
Ariya Hidayat, http://ariya.ofilabs.com
http://twitter.com/ariyahidayat

Brandon Benvie

unread,
Nov 27, 2012, 3:10:52 PM11/27/12
to esp...@googlegroups.com

One thing that you can easily add to help others understand it is a
bunch of bite-size, step-by-step tutorial. Even for JavaScript
experts, it's not really obvious what to do with the demo page.

Agree, what's there is kind of the bare essentials. Right now the debugger you've seen is similar to firebug or the webkit debugger...you can drill down into an object and see its properties, or a function's scope. The next iteration I'm working on extends that concept to an interface where you drill down to the AST level overlaid on top of the code, with the ability to introspect the static semantics as well as the runtime behavior. Instead of having the separate input pane area at the bottom, the inspector and the editor are the same thing. The original motivation behind making Continuum to begin with was to create an editor/dev environment that completely removes the barrier between writing and executing code.
Reply all
Reply to author
Forward
0 new messages