Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

Apparent code generation error in AIR 16 AOT

New Here ,
Nov 20, 2014 Nov 20, 2014

I have a fairly large project that seems to run well under AIR 16 except for a library that is throwing an error.  The library is D.eval-1.1.swc. D.eval is a library for simulating the eval function of AS2 in AS3.   Our program uses it for runtime scripting much like LUA.   I have reduced the problem to a very simple program that shows the error.

The program is:

import flash.display.MovieClip;
import r1.deval.D;

   

public class testEval extends MovieClip {
  
    public function testEval() {
        var value:String = "10==10";
        try {
            var result:Boolean = D.evalToBoolean(value);            // evaluate conditional
        } catch (e:Error) {
            trace("testEval:  caught error from D.evalToBoolean");
            trace("testEval:  error = " + e);
            trace("testEval:  stack = " + e.getStackTrace());
        }
        trace("testEval:  result = " + result);

    }
}

   

 

When compiled under AIR 14 for IOS (or AIR16 for the desktop debugger) the output is the expected:

testEval:  result = true

When compiled under AIR 16 for IOS, this is the result:

testEval:  caught error from D.evalToBoolean

testEval:  error = TypeError: Error #1009: Cannot access a property or method of a null object reference.

testEval:  stack = TypeError: Error #1009: Cannot access a property or method of a null object reference.

    at r1.deval.rt::Env$/idToMessage()

    at r1.deval.rt::Env$/getMessage()

    at r1.deval.rt::Env$/getMessage()

    at Function/http://adobe.com/AS3/2006/builtin::apply()

    at r1.deval.rt::Env$/reportError()

    at TokenStream$/reportError()

    at TokenStream/getToken()

    at r1.deval.parser::ExprParser/peekToken()

    at r1.deval.parser::BaseParser/parseProgram()

    at r1.deval::D$/parseProgram()

    at r1.deval::D$/eval()

    at r1.deval::D$/evalToBoolean()

    at com.toolwire.Test_Files::testEval()

    at com.toolwire.Test_Files::testEval()

testEval:  result = false

I looked into this a little bit. I decompiled the library with JPEXS.   The function that throws the error is:

private static function idToMessage(id:String) : String
  {
     var msg:String = __errors[id] as String;
     return msg == null?id:msg;
  }

__errors is a static Object that starts off:

 
  private static const __errors:Object = {
     "msg.no.paren.parms":"missing ( before function parameters.",
     "msg.misplaced.case":"misplaced case",

The thrown error indicates that it couldn't find the static Object.    There is probably another error in the generated code as well.  From the stacktrace, you can see that there is an error in getToken that  precipitates the error.   That error in getToken doesn't occur normally because the expression doesn't have an error.  My guess is that is caused by more incorrectly generated code (If the gods are smiling it might have the same underlying cause as the thrown error).

My guess as to what is wrong is the library SWC is at SWF level 9.   Maybe the AOT compiler has trouble with something (static const Objects) in that format.  The library is no longer supported and I believe that  we are using  the final version, so getting an updated version doesn't seem possible.  (The decompiled SWC has too many errors to be useful as source code). 

For now, I am now stuck at AIR 14 which is not useful in an IOS 8 world, and to me this seems important.  

Dennis

TOPICS
Air beta
854
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 20, 2014 Nov 20, 2014

Dennis, if you start looking for alternatives, you could check out Haxe's HScript. It compiles to SWC, and can be passed and operate on any AS3 objects / classes directly with no translation/serialization. It's syntax is Haxe, which is very ecma-like (just like AS3 or JavaScript - aka, familiar). You can pass it your stage and objects (or pass it getDefinitionByName and then basically have dynamic access to everything). The only downside I've found to HScript is that it's fairly slow, so dynamic loops / algorithms are a bad idea.

I'll try to write a blog post / github quick example app sometime.  (wishful promises.  😃

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 24, 2014 Nov 24, 2014

It is known that some libraries compiled with some old compiler versions give problems with latest ones, so if you have access to the source code you could recompile the SWC or link directly to the source itself, surely that will solve the problem.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 24, 2014 Nov 24, 2014

That's the problem.  The code is only available as an old SWC.   RiaOne, the developer of the package, seems to have disappeared and with it the source code.  I have tried to use JPEXS to get a working source, but the decompiled code has way to many errors to be useful.  I haven't figured out enough about RABCDAsm to give that a try.  

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 25, 2014 Nov 25, 2014

Thanks for reporting the issue ernie,

Its reproducible at our end, we are looking into it. As a workaround you can use our legacy compiler by using  "-useLegacyAOT yes " option while packaging.

Regards,

Jitender

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 25, 2014 Nov 25, 2014
LATEST

Thanks for the good news Jitender.   Bugs are bad, but reproducible ones are the best kind. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines