HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.18k stars 656 forks source link

Issue 244 - Decompiled Haxe to AS3 code for Float variable declarations return untyped :*, a cause for concern? - haxe #244

Closed issuesbot closed 11 years ago

issuesbot commented 11 years ago

[Google Issue #244 : https://code.google.com/p/haxe/issues/detail?id=244] by glidiast...@gmail.com, at 03/12/2010, 04:25:50 I often like to see the decompiled code output to see how Haxe processes inlined stuff.

The compiled input: static function main()

   {
    var b:Vec3 = new Vec3(3, 1, 1);
    var c:Vec3 = new Vec3(16, 14, 14);
    var testNumDeclaration:Float = 1 + 1;
    var tryNum:Float = b.dotProduct(c); // inline method
    }

The decompiled output:

    public static function main() : void
        {
    var _loc_1:* = new Vec3(3, 1, 1);
    var _loc_2:* = new Vec3(16, 14, 14);
    var _loc_3:Number = 2;
    var _loc_4:* = _loc_1.x * _loc_2.x + _loc_1.y * _loc_2.y + _loc_1.z * _loc_2.z;
    return;
}

// end function

Does this really mean that Float variables returned by inline methods are actually untyped? Or is it an illusion/code obsfucation done on Haxe part against decompilers? Does inlining actually makes things slower as a result? I know it may create more variables if you're not careful, but in this case, it's not more variables, just an untyped variable i'm concerned about.

issuesbot commented 11 years ago

[comment from ncanna...@gmail.com, published at 03/12/2010, 11:04:00] Float variables are usually well-typed. Could you send the smallest reproducible example possible that still show the issue ?

issuesbot commented 11 years ago

[comment from glidiast...@gmail.com, published at 15/12/2010, 15:45:55] Well, my SWC export goes like this:

Haxe: public static function createFromBuffer(polyCount:Int, polyBuffer:Vector, pointBuffer:Vector, pointCounts:Vector):ConvexPoly

to

Flash SWC: public static function createFromBuffer(polyCount:int, polyBuffer:Vector.<_>, pointBuffer:Vector.<_>, pointCounts:Vector.):ConvexPoly

issuesbot commented 11 years ago

[comment from glidiast...@gmail.com, published at 15/12/2010, 16:36:52] Hmm.. managed to compile. But i removed some Flash.memory reference which might have been causing some issues with it. (not sure if that triggered the problem).

Well i think it works okay now, and Vector. could compile against the Flash SWC [model]'s Vector.<*> output in FlashDevelop. Apparently, i think FlashDevelop SWC [model] is dodgy here. Seems to work without any errors at runtime though. A3DSectorUtils.createPolyhedronFromMesh( new Box() ); // return ConvexPolyhedron.create(0, 0, 0, ConvexPoly.createFromBuffer(polycount, POLY_BUFFER, VERTEX_BUFFER, VERTEX_COUNTS) );

despite the [model] public static function createFromBuffer(polyCount:int, polyBuffer:Vector.<_>, pointBuffer:Vector.<_>, pointCounts:Vector.):ConvexPoly Again, might be the Haxe/Flash code obscuator when it comes to decompiled code.

issuesbot commented 11 years ago

[comment from ncanna...@gmail.com, published at 17/12/2010, 14:45:48] I confirm this is a FlashDevelop issue : all Vector type parameters seems to be displayed as * instead of Number.