views:

465

answers:

3

Hey there

I'm interested in making a language to run on the AVM2 and I'm looking for advice on where to start. I do realize that this is by no means a trivial task, but I would like to give it a try and at the very least learn more about implementing a language along the way.

I have messed around with ANTLR and have been reading up on syntax issues for language development. What I'm looking for is advice on a path to take or useful references/books.

For instance I would like to generate (script/manually) some very simple AVM2 bytecode and get that to run on the VM as a start.

Thanks

+1  A: 

Take a look at haXe: it is an open source language that can target different platforms, including the AVM. You can dig into the SWF compiler source code to get some inspiration.

fbonnet
+2  A: 

If you are not interested in haXe, you will basically need to write your own compiler that compiles objects down to ABC (Actionscript Byte Code). The AVM2 Overview document available from Adobe on ABC and the AVM2 which should help you get started. It's a fairly thorough document but stay alert for a few typo's in the bytecode instructions.

You will also need to wrap the bytecode in a doABC tag as part of a SWF container. You can get more information from the SWF File Format documentation.

If you'd like a headstart on writing the data structures (optimised int formats, etc), feel free to checkout the code at asmock, a dynamic mocking project I've been working on. The SWF/ByteCode generation stuff is a bit messy but there are IDataOutput wrappers (SWF, ByteCode) that might come in handy.

Richard Szalay
Thanks Richard, I've just picked those docs up a while back, now to sit down with them. I'll try use the ASMock code to output a simple SWF file that performs some simple arithmetic operations for a start.
Brian Heylin
The portion of asmock that generates bytecode (flemit) is not actually documented/supported yet, but if you have any questions feel free to shoot them over.
Richard Szalay
A: 

Project Alchemy by Adobe can be a good reference http://labs.adobe.com/technologies/alchemy/

How did it go? I'm also interested in doing a Java to AVM2 compiler... Do you have any published code?

Ehrann Mehdan
I looked into it and found it too much work, although I am still interested in it. Im not interested in translating languages but more making a modified as3.
Brian Heylin