Project Description
AbcExplorationLib is a library to read and write ActionScript Byte Code (ABC) files. When completed it could be used for compiled program analysis or as part the back end of an experimental compiler.

It is written in F# but it could be used from other .NET languages.
Inspiration for this library comes from many excellent libraries for bytecode manipulation such as BCEL, ASM, Cecil or System.Reflection.Emit.

Given the following ActionScript 3 program:

var i = 0;
for( i = 0;i < 10;i++) {
   print("inside loop");
}
print("Done");


When compiled using asc.jar:

java -jar c:\flexsdk\lib\asc.jar test.as


Can be inspected using AbcExplorationLib (here using fsi.exe):

> #r "abcexplorationlib.dll";;

--> Referenced 'abcexplorationlib.dll'
> let abcFile = using (new System.IO.FileStream("test.abc",System.IO.FileMode.Open)) ( 
                                  fun s -> AvmAbcFile.Create(s));;
> abcFile;;
val it : AvmAbcFile
= Langexplr.Abc.AvmAbcFile {Classes = [];
                            Scripts = [Langexplr.Abc.AvmScript];}

> abcFile.Scripts.[0].InitMethod.Body.Value.Instructions |> Array.iter pr;;
 getlocal_0
 pushscope
 pushbyte
 getglobalscope
 swap
 setslot
 pushbyte
 getglobalscope
 swap
 setslot
 jump dest39
dest18:
 label
 findpropertystrict
 pushstring
 callprop
 pop
 getglobalscope
 getslot
 increment
 setlocal_2
 getlocal_2
 getglobalscope
 swap
 setslot
 kill
dest39:
 getglobalscope
 getslot
 pushbyte
 iflt dest18
 findpropertystrict
 pushstring
 callprop
 coerce_a
 setlocal_1
 getlocal_1
 returnvalue
 kill
val it : unit = ()


For more information check:

Last edited May 17, 2009 at 1:03 PM by luisdiegofallas, version 6