Targeting Tamarin

Using the Tamarin Target


First you need to download and compile tamarin for your system. More information can be found in the Tamarin Build Documentation
You can also download a ready built binary (avmshell) from here: ftp://ftp.mozilla.org/pub/js/tamarin/builds/tamarin-redux/
Some changes are needed to the following classes:
  • Boot.hx
    Modify the standard std\flash\Boot.hx file by replacing it with the code from Boot.hx
  • System.hx
    Add a new System class by creating a folder avmplus in the std folder and in there add a new file System.hx.
    You should end up with: std\avmplus\System.hx

Now, let's do a simple test:
Create a file Main.hx and add the code below.

import avmplus.System;
@:ns("")@:native("IPL") class Main
{
    public function new()
    { 
        trace("hello cruel world from Haxe targeting avmshell! tamarin v" + System.getAvmplusVersion()); 
    }
    
    public static function main() 
    { 
        var tt = new Main(); trace("goodbye cruel world! freeMem:" + System.freeMemory); 
    }
}

Create a file build.hxml and add the following commands
-main Main 
-D avmshell
-swf main.swf 

Before we can test our compiled code in avmshell we need to create a little script that calls the main class in our swf:
Create a file boot.as with the following code:

IPL.main()

and compile it to boot.abc with:
java -jar asc.jar -import builtin.abc boot.as
(asc.jar and builtin.abc are part of the Flex sdk and can be downloaded from here )

Now we can finally run our test from terminal /command line:

avmshell main.swf boot.abc

You should see printed:
Main.hx:5: hello cruel world from Haxe targeting avmshell! tamarin v2.1 1049616:
Main.hx:11: goodbye cruel world! freeMem:794624

Notes
Although you can extract the abc file from the compiled main.swf with this tool: abcdump.as (instructions), you can also use the main.swf without conversion as shown in the test above.
[ Please note this is work in progress based on an IRC conversation ]
The details of the IRC conversation

version #15438, modified 2012-09-05 03:42:03 by jan_flanders