Well this is what I have up to this point.

Some missing semi colons, maybe some other stuff. But the recursion on expressions, binary and unary operators are working great.

Got anonymous functions, getters, setters, try etc. working. Will have to be schooled on the use of 'this' and other things but the design is so mutable we could even implement more than one type of cross compile as easy as I just made this new one for the closure compiler.

How do we want default arguments dealt with on functions?

Honestly I don't know exactly how ActionScript is supposed to translate to JavaScript on somethings. I have namespaces and stuff like that working but obviously it doesn't have a js counterpart.

Erik! I need your table erm.. javascript bible for a reference of what we need to test against.

Ah, the beauty of this new design is we can unit test each part of the expression, statement conversion from as -> js! This part is so exciting, we will know down to the binary, unary expression if the js code is getting output correct.

Erik, you will have to get me a comprehensive list for comment and type hint locations as well.

Well that's it for me for now.

Mike


//-------------------------------------------------------
// ActionScript class

package com.example.components {

import flash.display.Sprite;
import flash.events.Event;

public class MyTextButton extends Sprite {
    public var foo:Number = 100;

    protected var baz:String = "what are you doing";

    private var _goo:String = 'goog';

    private var _bar:int = 1 + 3;

    public function get aprop():unit {
        return 0;
    }

    public function set aprop(value:unit):void {
    }

    public function MyTextButton() {
        super();
        testFunc(4, "20");
        for (var b:int = 1; b <= 10; b++) {
            bar();
        }
        for (; ;) {
            break foo;
        }
        for (var g:int in blah) {
            r();
        }
        for each (var g:Object in baz[goo]) {
            r();
        }
        if (a) b();
        while (false) v();
        do {
            continue;
        } while (m);
        if (true) {
            if (a) {
            } else {
                if (b == c) {
                    foo.bar['baz']['goo'].baz(42);
                } else if (c != d) {
                } else {
                    trace('mike');
                }
            }
        } else if (false) {
        } else if (a < 3) {
        } else {
        }
        try {
            print("me" + 42);
        } catch (e:Error) {
            that.could['be'].bad(o.o['p'], e);
        } finally {
            dont();
        }
        var b:Function = function (a:int) {
            return 2;
        }
        return a.call(i.j * k, l[m]);
    }

    public function testFunc(a:int = 4, b:String = null):Event {
        print();
        return null;
    }
}
}


// end ActionScript
/////////////////////////////////////////////////////////

//-------------------------------------------------------
// Javascript class


/**
 * CROSS-COMPILED BY MXMLJxC (329449.1) ON 2012-12-09 18:14:31
 */
goog.provide('com.example.components.MyTextButton');

goog.require('flash.display.Sprite');
goog.require('flash.events.Event');

/**
 * @constructor
 * @extends {flash.display.Sprite}
 */
com.example.components.MyTextButton = function()
{
        goog.base(this);
        this._bar = 1 + 3;
        this._goo = 'goog';
        testFunc(4, "20");
        for(var b = 1;b <= 10;++b){
                bar();
        }
        for(;;){
                break foo;
        }
        for(var g in blah){
                r();
        }
        for each(var g in baz[goo]){
                r();
        }
        if(a){
                b();
        }
        while(false){
                v();
        }
        do{
                continue;
        }while(m);
        if(true){
                if(a){
                }else{
                        if(b == c){
                                foo.bar['baz']['goo'].baz(42);
                        }else if(c != d){
                        }else{
                                trace('mike');
                        }
                }
        }else if(false){
        }else if(a < 3){
        }else{
        }
        try{
                print("me" + 42);
        }catch(e){
                that.could['be'].bad(o.o['p'], e);
        }finally{
                dont();
        }
        var b = function(a)
        {
                return 2
        }

        return a.call(i.j * k, l[m]);
}


goog.inherits(com.example.components.MyTextButton, flash.display.Sprite);

/** @type {Number} */
com.example.components.MyTextButton.prototype.foo = 100;

/** @type {String} */
com.example.components.MyTextButton.prototype.baz = "what are you doing";


/**
 * @this {com.example.components.MyTextButton}
 * @return {unit}
 */
com.example.components.MyTextButton.get_aprop = function()
{
        return 0
}

/**
 * @this {com.example.components.MyTextButton}
 * @param {unit} value
 * @return {void}
 */
com.example.components.MyTextButton.set_aprop = function(value)
{
}

/**
 * @this {com.example.components.MyTextButton}
 * @param {int} a
 * @param {String} b
 * @return {Event}
 */
com.example.components.MyTextButton.testFunc = function(a, b)
{
        print();
        return null
}



// end Javascript
/////////////////////////////////////////////////////////










Quoting Michael Schmalle <apa...@teotigraphix.com>:


Hi,

Seeing as winter is here in NewHampshire and ice covers the ground, I used the opportunity to put my money where my mouth is;

NOTE: All the javascript is generated by code I wrote using the AST/Visitor/Walker pattern of the node hierarchy and their corresponding definitions. I have it running from the command line like MXMLC does.

I about 10 hours of programing I have the following constructs cross compiling to JS using Flacon.

I will say, Falcon is one of the best designed APIs I have used in a long time. Whoever architected this compiler gets a huge pat on the back from me.

Right now this is hoisted ontop of MXMLC as a quasi target compiler. Oh how I love prototypes. I cannot believe I actually have this working in less than two days.

As far as code, it will be in my whiteboard when it's in my whiteboard. :) Whenever that is, no specific time.

The amount of ridiculousness I felt trying to wade through the FlaconJS code prompted me to do this.

The thing I really grabbed on to is we are using the closure compiler so worrying about highly optimized cross compiler becomes a non issue. Quote Erik on this.




Peace,
Mike

--
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com



--
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com

Reply via email to