How To Compile ABC Files With asc

40 views
Skip to first unread message

maxim.porges

unread,
Apr 27, 2009, 7:57:59 AM4/27/09
to loom-as3
Hey guys,

Thanks for the wedding wishes - we had a fabulous time this weekend
and are getting ready to leave for the honeymoon this afternoon.
Unfortunately, I didn't get a chance to finish the SWFLoader last
week, so here's the next best thing: how to compile your own .abc
files for working with Loom.

1) asc is the command-line ActionScript Compiler that produces raw ABC
files. It's basically a really stripped-down version of the command-
line Flex tools. To get the asc source, run svn checkout
http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/modules/asc/

2) cd in to the directory SVN created, and go in to build/java. Run
ant clean main to build, producing the asc JAR in the path /path/to/
asc/lib.

3) Set up an alias for ease of use. I have mine set up as follows.
Note the imports for toplevel.abc and playerglobal.abc - you need
those to have references to classes like String and Object and the
other builtins. The -md option tells asc to keep class metadata.
alias asc='java -jar /path/to/asc/lib/asc.jar -md -import /path/to/asc/
abc/builtin.abc -import /path/to/asc/abc/toplevel.abc'

4) Write a .as class file in a text editor and compile it using: asc /
path/to/file/FileName.as. This produces a .abc file with the same name
as the original file. The contents are the binary ABC in the AVM2
format. I recommend that you keep this file simple for reasons covered
further down.

5) If you like, you can dump the file using abcdump. It looks like the
Tamarin team has changed abcdump, since when I ran the JAR in the
latest asc trunk with the -b option to print the opcodes for a simple
class it failed with a NPE, but the pure ActionScript version I
compiled from Tamarin last October worked fine with the same class. I
don't have time to try the latest Tamarin build, but I will upload the
old abcdump.exe file that I typically use for you guys to mess with.
Ignore the .exe extension - it runs fine on a Mac. You can alias this
with alias abcdump='/path/to/executable/abcdump.exe' and run it with
'abcdump FileCompiledByAscToDump.abc', and it will produce a text file
with a .abc.il extension which shows the basic class structure and
opcodes. Another way to get the opcodes is to trace an AbcFile
produced by Loom's AbcDeserializer, which gives you a much more
detailed output including the opcodes, but the downside is that I
don't have all the opcodes implemented in Loom yet so it only works
for the test classes at present. I've been using the trace of AbcFiles
in Loom to determine the opcodes, namespaces, and multinames required
to weave the functionality presently supported, so the tool chain
works pretty well.

6) Instead of embedding the BaseClass.abc file in to the test app in
the Loom alpha, change the path to point to your compiled .abc file
and you will be good to go.

Currently, the opcodes implemented in Loom support tracing and
returning of simple values from method calls, so if you stick to
simple method bodies things will work fine. However, I don't think
this will be a serious limitation for you; even if you could run more
complicated classes through Loom, you probably wouldn't be able to
compile them since asc is really dumb, and requires you to import all
the classes needed by the compile chain in the right order as .abc
files, which must already be precompiled by a previous run. I tried
compiling some Flex-dependent classes one night and burned three hours
without success, so the SWFLoader really needs to be done before you
can get too fancy.

So, using the instructions above, you can compile .abc files with
whatever structure you like for getting your Loom-supported libraries
and frameworks going. I figured most of you will want to use metadata
or method/class names to determine how to hook in to Loom, so you'll
be able to get this far with these instructions.

Good luck, happy tinkering, and please post back with requests and
complaints on the Loom API as you go so that I can start tracking
features and bugs for implementation. I'll see you guys back on the
list in two weeks!

Thanks,

- max

Dirk Eismann

unread,
May 5, 2009, 8:25:25 AM5/5/09
to loom-as3
Hey Max,

hope you're enjoying your honeymoon :)

I played around with the latest Loom snapshot but end up getting RTE
like "Unknown NamespaceKind: 108" - I guess this is due to missing
opcodes, right?

Dirk.

Maxim Porges

unread,
May 10, 2009, 6:30:28 PM5/10/09
to loom...@googlegroups.com
Thanks Dirk! It was great, just got back and am digging myself out of
my personal email accounts... :)

That's a parsing error of some kind. What's happening is that Loom
read a value expecting it to be a NamespaceKind (of which there is a
limited enumeration) and the value turned out not to be a valid entry
in the lookup table. It might be opcode related, but it's hard to tell
without looking at it. If you can send me the ABC file directly I'll
take a look.

Cheers,

- max
Reply all
Reply to author
Forward
0 new messages