Apparent code generation error in AIR 16 AOT
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
