How can I name the Tamarin ESC compiler from AS3 code?

I am trying to call Tamarin ESC Compiler from AS3 code. I have an ESC compiler byte code loaded in Flash Player, but when I call it, the ESC compiler always returns the same byte code, no matter what source code I feed it. Custom 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 call 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 a bytecode of two functions, one of which calls the other, and none of them does anything.

This is the bytecode that it returns (metadata deleted, 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 a hardcore question, but I hope some kind of hardcore encoder can shed some light on it!

+3
1

.

ABC Tamarin ESC Flash ( , ):

http://wonderfl.net/c/2pBs/read

Tamarin Redux, HTTP- Mercurial: http://hg.mozilla.org/tamarin-redux/raw-file/db3ebe261f68/esc/bin/

wonderfl as3swf, ABC Flash ( , ):

https://github.com/claus/as3swf

! .

+4

Source: https://habr.com/ru/post/1545166/


All Articles