[Haskell] ANNOUNCE: Haskell SWF generation library

Jeremy Shaw jeremy.shaw at linspireinc.com
Sun Apr 8 00:21:01 EDT 2007


Hello,

I would like to take this opportunity to announce the availability of
an Adobe Shockwave Flash (SWF) library for Haskell:

darcs get http://www.n-heptane.com/nhlab/repos/haskell-swf/

The library is a bit old and crufty, and it is not really release
quality code. The cabal files are out of date, etc. But, I thought I
would get it out there in case people wanted to play with it. (I have
heard some noise on #haskell about it).

It is primarily useful for compiling ActionScript assembly into a .swf
file.

If anyone is interested in improving the library, the most sensible
starting places would be:

 1) Update the code to use the new Binary library

 2) Create a better API for creating assemble macros

 3) Add support for the new Flash 9 action script virtual machine
    (AVM2).

I currently implement 'macros' by defining a function like,

> popArray :: [SwfAssembly]
> popArray =
>    [ ActionPushFloat 0.0 	-- Array.pop takes no arguments
>    , ActionStackSwap
>    , ActionPushString "pop"	-- Call the pop() method
>    , ActionCallMethod
>    ]

And then using it like:

>      bindArg (STG.AtomVar var) = 
>          (ActionPushDuplicate :
>           popArray ++
>           [ ActionPushString (escape var)
>           , ActionGetVariable
>           , ActionSetVariable
>           ])

This is clearly, pretty lame. :)

j.

ps. I also have the beginnings of a YHC.Core -> SWF compiler. It can
currently compile this simple program:

> main =
>    case id (Just 'a') of
>      (Just c) -> displayPrimitive c
>      Nothing -> displayPrimitive 'f'

Unfortunately, it does not yet implement garbage collecting, updates,
proper environment saving, and other essential features. It also
generates some pretty inefficient code. I am going to try to get the
current version 'working', and then do a better implementation based
on everything I learned from my first attempt at a Haskell compiler.

I should note that this is different than the Haskell -> Javascript
compiler that is already in YHC. I am targeting the flash virtual
machine byte-code directly, not the higher level actionscript (aka,
ecmascript) code.

I pushed what I currently have at:

http://www.n-heptane.com/nhlab/repos/yhc/

the code is in the directory:

http://www.n-heptane.com/nhlab/repos/yhc/src/translator/avm2/

First build yhc normally, then cd into that directory and run
make. Hopefully that will work for you.



More information about the Haskell mailing list