Welcom

18 views
Skip to first unread message

Don-Duong Quach

unread,
Oct 28, 2008, 3:58:15 PM10/28/08
to as3tohaxe
Hey guys,

Welcome and thanks for joining the as3tohaxe group!

Brent, can you give me some detail on the issues you were
experiencing? Did you build as3tohaxe from source? The binary may be
a bit out of date.

Franco, I need to get haskell set up on Windows, which could be a
little adventure. I'll post the binary to the file section and let
you know once I get it built.

-Don Q.

Franco Ponticelli

unread,
Oct 28, 2008, 4:16:19 PM10/28/08
to as3t...@googlegroups.com
Ok, no problem. I just like to test things so I am in no hurry ;-)

Franco.

Brent Pedersen

unread,
Oct 28, 2008, 4:38:57 PM10/28/08
to as3t...@googlegroups.com

hi,
i built from source, below are some quick notes i had in trying to
convert modestmaps.
there were a lot of occurences of ":Number" still in teh code. i saw
you'd made a recent commit regarding that.
also, in a lot of cases, i had to add 'static' to variables defined at
the class level.

=====================

global search-replace Number => Float
class A extends Object = > class A

interface IMapProvider extends IEventDispatcher => interface
IMapProvider implements IEventDispatcher

flash.utils.getTimer => flash.utils.Timer


class MicrosoftHybridMapProvider
implements IMapProvider
extends AbstractMicrosoftMapProvider
=>
class MicrosoftHybridMapProvider
implements IMapProvider, /* COMMA */
extends AbstractMicrosoftMapProvider


change loops to:
for(i in 0...array.length)

with(sprite.graphics){
lineTo()...
etc.
}
=>
sprite.graphics.lineTo()
etc.


delete obj[key] => Reflect.deleteField(obj, key);

Don-Duong Quach

unread,
Oct 28, 2008, 4:54:53 PM10/28/08
to as3tohaxe
I've uploaded a windows binary to the files section.

On Oct 28, 1:16 pm, "Franco Ponticelli" <franco.pontice...@gmail.com>
wrote:
> Ok, no problem. I just like to test things so I am in no hurry ;-)
> Franco.
>

Don-Duong Quach

unread,
Oct 28, 2008, 5:28:33 PM10/28/08
to as3tohaxe
Hey Brent,

My comments follow your code snippets.

> global search-replace Number => Float

Can you give me an example where Number isn't converting?

The question for me is what is Number supposed to translate to? Float
or Int? Some expressions can be complex, and I need to setup a symbol
table to look up the components of the expression to determine the
types. That's my next big task.

> class A extends Object = > class A

I'll put in a fix for "extends Object".

> interface IMapProvider extends IEventDispatcher => interface
> IMapProvider implements IEventDispatcher

Interface declarations are on the todo list.

> flash.utils.getTimer => flash.utils.Timer

Is this just an import statement conversion?

> class MicrosoftHybridMapProvider
> implements IMapProvider
> extends AbstractMicrosoftMapProvider
> =>
> class MicrosoftHybridMapProvider
> implements IMapProvider, /* COMMA */
> extends AbstractMicrosoftMapProvider

I'll get that fixed.

> change loops to:
> for(i in 0...array.length)
>
> with(sprite.graphics){
> lineTo()...
> etc.}
>
> =>
> sprite.graphics.lineTo()
> etc.

Translate "with"? I'll put that on the todo list. The code is
translating basic for loops of the type:
for(var i = 0; i < array.length; i++) to for(i ... array.length)
already

The conditions for translating for loops in iterators are:
1) look for an integer in the initial expression
2) look for a '<' in the test
3) look for a pre or post increment in the update

anything else will translate to a while loop. Currently, for each and
for in loops are ignored.

> delete obj[key] => Reflect.deleteField(obj, key);

I'll put that on the todo list.

Thanks for reporting.

On Oct 28, 1:38 pm, "Brent Pedersen" <bpede...@gmail.com> wrote:

Brent Pedersen

unread,
Oct 28, 2008, 8:33:04 PM10/28/08
to as3t...@googlegroups.com
hi, below is a script to get and attempt to convert modestmaps.
i think it will show better than i can explain.
if you run it, then cd to $MMDEST/hx_output
and grep -r Number .
you'll see there are quite a few 'Number's, i suppose it's where you
dont have the context.
though the first thing haxe fails on is "import *"

re getTimer, i'm not sure, but i think it's just a direct substitute.
let me know if i can clarify or help.

fwiw, i'm using haxe 2, linux, and built most recent as3tohaxe version
with ghc6.8+.
-brent

MMDEST=/tmp/mm/

HAXE=/usr/bin/haxe
A2H=/var/www/tinker/as3tohaxe/as3tohaxe

cd $MMDEST
rm -r hx_output

svn co http://modestmaps.mapstraction.com/svn/trunk/as3 $MMDEST/modestmaps

$A2H $MMDEST/modestmaps/lib/


cd $MMDEST/modestmaps/samples/as3/ModestMapsSample/
$A2H ModestMapsSample.as

cd hx_output
haxe -swf9 mapsample.swf -swf-version 9 -main ModestMapsSample -cp
$MMDEST/hx_output/$MMDEST/lib/

echo "file in ..."
echo $MMDEST/modestmaps/samples/as3/ModestMapsSample/hx_output/

Don-Duong Quach

unread,
Oct 28, 2008, 9:10:42 PM10/28/08
to as3tohaxe
k I see what you mean by "import x.*" failing. It's too bad haXe
can't handle that because I don't have anything in the code to convert
that yet. That's actually a pretty big task that will be made
possible with the symbol table. I'll need to lookup all the
identifiers in a file and determine if they're classes and if so
update the import declarations based on their location. The user will
have to specify the class paths for the converter to look into the
same way you specify the -cp parameter for haxe. Unfortunately, we'll
still have to do that conversion by hand for now.

As for Number, I can default to Float and allow you to also specify an
optional "NumberToType" parameter. Then I can add smarter conversions
as long as we can determine the proper type with code analysis. How's
that sound?

This is my first foray into code analysis and haskell, so please bear
with me.

Thanks.
-Don Q.

Franco Ponticelli

unread,
Oct 29, 2008, 5:08:59 AM10/29/08
to as3t...@googlegroups.com
I've uploaded a windows binary to the files section.

Thank you.

Franco

alijaya

unread,
Nov 23, 2008, 8:18:24 AM11/23/08
to as3tohaxe
hello i want to give some suggestion :D

for(i=v; condition; nextStep)
{
action
}

convert to:

i = v;
while(condition)
{
action
nextStep
}

can it be??

Don-Duong Quach

unread,
Nov 23, 2008, 3:00:37 PM11/23/08
to as3tohaxe
The converter currently does that. Do you have some sample code
where the conversion doesn't behave as expected?

Here's a sample conversion.

ForTest.as:
package
{
import flash.display.Sprite;
import flash.text.TextField;

public class ForTest extends Sprite
{
public function ForTest(){
var txt:TextField = new TextField();

for(var i:uint = 0; i < 10; i++)
{
txt.appendText(i+" ");
}

addChild(txt);

var j:int;
for(j = 10; j < 100; j+= 10) {
txt.appendText(j+" ");
}
}
}
}

hx_output/ForTest.hx :


import flash.display.Sprite;
import flash.text.TextField;

class ForTest extends Sprite {
public function new() { }

static function main() {
var txt:TextField = new TextField();

for(i in 0...10)
{
txt.appendText(i+" ");
}

addChild(txt);

var j:Int;
j = 10;
while (j < 100) {
txt.appendText(j+" ");
j+= 10;
}
}
}

-Don Q.

Ali Jaya Meilio

unread,
Nov 23, 2008, 5:36:33 PM11/23/08
to as3t...@googlegroups.com
Oh sorry.
I'm newbie here and i have not try the converter :p
Can i see the to do list?
And what language it use?
Sorry for asking before exploring :p

---- 
Sent using a Sony Ericsson mobile phone

Don-Duong Quach

unread,
Nov 24, 2008, 11:53:30 AM11/24/08
to as3t...@googlegroups.com
No worries. 

I have a TODO list, but it's in a private project tracker I'm using.  Unfortunately, there's always too much to do and too little time (gotta work on stuff that pays the bills). 

But I'm willing to discuss what needs to happen in case anyone else is up to coding or help with pointers on how to implement this faster.

Before improved translation will happen, there are major tasks such as implementing a better symbol table (to handle multiple classes), symbol lookups to resolve class dependencies (possibly parallelize this for a speed boost on multi-core systems), parsing the intrinsic classes like "flash.events.Event" (probably into an optimized form for fast lookups).

I'm not sure when I can get around to them, but I'll fix any bugs in the current translation ASAP.  Any help would be great.  I'm using Haskell and in particular ghc, http://www.haskell.org/ghc , to implement it.  The code is here: http://www.github.com/geekrelief/as3tohaxe .

Cheers,
-Don Q.
Reply all
Reply to author
Forward
0 new messages