Nicolas Cannasse MTASC MotionTwin Action Script Compiler No

  • Slides: 20
Download presentation
Nicolas Cannasse MTASC Motion-Twin Action. Script Compiler No more Coffee Break while compiling

Nicolas Cannasse MTASC Motion-Twin Action. Script Compiler No more Coffee Break while compiling

Rich Internet Applications – RIA n AJAX Dynamic HTML, RAD, Browser Integration n Flash

Rich Internet Applications – RIA n AJAX Dynamic HTML, RAD, Browser Integration n Flash Vector Engine, Low. Level, better control, more powerful

MTASC Is an Action. Script version 2 compiler n Works from Command. Line n

MTASC Is an Action. Script version 2 compiler n Works from Command. Line n ¨ Can be integrated in « your n favorite IDE » Is not an IDE : ¨ Can’t edit Flash Graphics or Code n Is Open. Source ¨ GPL License, Motion. Twin offering support

The History of MTASC n n n Prehistory : Action. Script 1 Middle. Age

The History of MTASC n n n Prehistory : Action. Script 1 Middle. Age : 09/2003 Flash. MX 2004 Action. Script 2 Need More Checks : 12/2003 ASML Need More Types : 04/2004 Motion. Types Back to AS 2 : 10/2004 MTASC Beta 1 01/2005 MTASC 1. 0 05/2005 FAME Platform / OSFlash. org 07/2005 MTASC 1. 09

ASML : Action. Script. Meta. Language December 2003 n Run before Macromedia Compiler n

ASML : Action. Script. Meta. Language December 2003 n Run before Macromedia Compiler n Add « Type Inference » to AS 2 n Check number of parameters (no optional parameters) n Faster compilation process n

Type Inference n To « Guess » the types at compilation time function length(o)

Type Inference n To « Guess » the types at compilation time function length(o) { return Math. sqrt(o. x*o. x + o. y*o. y); }

Type Inference n To « Guess » the types at compilation time function length(o

Type Inference n To « Guess » the types at compilation time function length(o : Tmp) : Number { return Math. sqrt(o. x*o. x + o. y*o. y); } Tmp { var x : Number; var y : Number; }

Type Inference n Pros : ¨ Do not write Types ¨ Your program is

Type Inference n Pros : ¨ Do not write Types ¨ Your program is still checked ¨ Changes propagate everywhere n Cons : ¨ You need to understand how it works ¨ Error reporting is difficult ¨ Typing order matters

Motion. Types n n April 2004 More Types need more Syntax Different Language (.

Motion. Types n n April 2004 More Types need more Syntax Different Language (. mt files ) Anonymous Types : var o : { x : Number, y : Number }; n Lambda Types : var on. Connect : Boolean -> Void; n First AS 1 generation, then SWF generation

MTASC n n Back to AS 2 : compatibility Improves Macromedia Compiler : ¨

MTASC n n Back to AS 2 : compatibility Improves Macromedia Compiler : ¨ Faster ¨ More strict n n Use SWF generation developed for Motion. Types Ready for RIA : ¨ V 2 Components ¨ Action. Step

MTASC Internals Bunch of AS text files n Lexing : produce tokens n Parsing

MTASC Internals Bunch of AS text files n Lexing : produce tokens n Parsing : build AST n Typing : type-check the AST n SWF Code-Generation n MTASC is Written in OCAML (www. ocaml. org) n

Flash Bytecode function add(x, y) { return x + y; } function add x

Flash Bytecode function add(x, y) { return x + y; } function add x : reg 0 y : reg 1 push reg 0 push reg 1 add ret Stack-based Virtual Machine. Registers for local variables (since Flash 7).

Flash Bytecode function max(x, y) { if( x < y ) return y; else

Flash Bytecode function max(x, y) { if( x < y ) return y; else return x; } Conditional Jumps function max x : reg 0 y : reg 1 push reg 0 push reg 1 lt condjump +2 push reg 1 ret push reg 0 ret

From AS 2 to AS 1 class Ref { var v : Number; function

From AS 2 to AS 1 class Ref { var v : Number; function Ref(v) { this. v = v; } if( !Ref ) { _global. Ref = function(r) { this. r = r; } Ref. prototype. add = function(p) { this. r = this. r + p. r; } } function add(r : Ref) { r += p. r; } } AS 2 is Class-based AS 1 is Prototype-based

From AS 1 to SWF if( !Ref ) { _global. Ref = function(r) {

From AS 1 to SWF if( !Ref ) { _global. Ref = function(r) { this. r = r; } Ref. prototype. add = function(p) { this. r = this. r + p. r; } } push ‘Ref’ eval not compjump +XXX push ‘_global’ eval push ‘Ref’ function (r: r 1) this: r 0 push ‘r’ push r 1 objset. .

MTASC in Numbers n MTASC sources (without libs) are : ¨ 8 files ¨

MTASC in Numbers n MTASC sources (without libs) are : ¨ 8 files ¨ 113 Ko ¨ 20’ 000 words ¨ 4’ 000 lines n It takes 3 -4 seconds for compiling more than 300 Classes (20 -30 seconds with Macromedia Compiler)

The FAMES Platform A complete Open. Source platform : Flashout : SWF Preview, Log

The FAMES Platform A complete Open. Source platform : Flashout : SWF Preview, Log n ASDT : AS 2 Dev. Eclipse plugin n MTASC : AS 2 Compiler n Eclipse : IDE n Swf. Mill : Resources (Fonts, JPEG, …) n

The FAMES Platform A complete Open. Source platform : Open Source IDE and Tools

The FAMES Platform A complete Open. Source platform : Open Source IDE and Tools n Edit / Compile / Test n Ready for RIA dev n Using Macromedia V 2 Components (need license) ¨ Using OS Components ¨ n More complete everyday ¨ See http: //osflash. org

Flash Open. Source Tools n n A lot of tools Available on OSFlash. org

Flash Open. Source Tools n n A lot of tools Available on OSFlash. org General Purpose ¨ n UI Frameworks ¨ n Admin. Tool Protocols ¨ n Action. Step, En. Flash, ARP, As. Wing… Debug/Log ¨ n AS 2 Lib, ASUnit… AMFPHP, Open. AMF… Tutorials, tips, …

Questions ?

Questions ?