I'm trying to call Tamarin's ESC Compiler from AS3 code. I've got the ESC Compiler byte code loaded in Flash Player, but when I call it, the ESC Compiler always returns the same do nothing byte code, no matter what source code I feed it. The human readable ESC code looks like this:
function compileStringToBytes(input, context="(string)", start_line=1) {
let [_,_,res] = compile( (function () input),
(function (abc) abc.getBytes()),
context,
start_line );
return res;
}
I'm calling it using the following AS3 code:
var compile:Function = getDefinitionByName("ESC::compileStringToBytes") as Function;
var array:ByteArray = compile( function():String { return "trace(\"hi\");" },
"test" );
But no matter what source code I feed it, it always returns byte code of two functions, one that calls the other, with neither function doing anything.
This is the byte code it returns (metadata stripped out, converted to human readable):
script0
const <#internal test>::internal:Namespace = <#internal test> /* slot_id 0 */
const <#internal test>::public:Namespace = /* slot_id 0 */
var Function:* /* slot_id 0 */
function script0$init():* /* disp_id 0*/
{
// local_count=2 max_scope=1 max_stack=2 code_len=11
0 getlocal0
1 pushscope
2 findpropstrict Function
4 newfunction function ():* /* disp_id 0*/
6 setproperty Function
8 getlocal1
9 returnvalue
10 returnvoid
}
function ():* /* disp_id 0*/
{
// local_count=1 max_scope=0 max_stack=0 code_len=1
0 returnvoid
}
Thanks in advance! I know this is hardcore question but I hope some hardcore coder can shed some light on it!