如何从AS3 code调用Tamarin的ESC编译器? [英] How do I call the Tamarin ESC Compiler from AS3 Code?

查看:321
本文介绍了如何从AS3 code调用Tamarin的ESC编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从AS3 code致电绢毛猴的ESC编译。我已经得到了在Flash Player加载的ESC编译字节code,但是当我打电话吧,ESC编译器总是返回相同的无可奈何字节code,不管是什么来源$ C ​​$ C我喂它。人类可读的ESC code是这样的:

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;
}

我用下面的AS3 code调用它:

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" );

但无论怎样源$ C ​​$ C我喂养它,它总是返回两个功能,一是调用其他字节code,既没有功能做任何事情。

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.

这是字节code返回(元数据剥离出来,转化为人类可读):

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      
}

在此先感谢!我知道这是骨灰级的问题,但我希望一些铁杆codeR可以揭示一些关于它的光芒!

Thanks in advance! I know this is hardcore question but I hope some hardcore coder can shed some light on it!

推荐答案

找到了答案,以我自己的问题。

Found an answer to my own question.

下面的网站使用了最新的狨ESC编译ABC位动态通过Flash运行code(在左边的面板中显示了运行编译器的源$ C ​​$ C):

The following site uses the newest Tamarin ESC Compiler ABC bits to dynamically run code through Flash (the panel on the left shows the source code which runs the compiler):

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

它实际上是抓住使用水银HTTP接口下载的狨终极版位:的 http://hg.mozilla.org/tamarin-redux/raw-file/db3ebe261f68/esc/bin/

It actually grabs the Tamarin Redux bits using the Mercurial http interface downloader: http://hg.mozilla.org/tamarin-redux/raw-file/db3ebe261f68/esc/bin/

在wonderfl code轮流使用克劳斯Wahlers'codeazur as3swf包裹ABC位加载到Flash(包括编译器本身和编译代码):

The wonderfl code in turns uses Claus Wahlers' codeazur as3swf to wrap the ABC bits to load into Flash (both the compiler itself and the compiled bits):

https://github.com/claus/as3swf

感谢您克劳斯和wonderfl!开源$ C ​​$ C岩石。

Thank you Claus and wonderfl! Open sourced code rocks.

这篇关于如何从AS3 code调用Tamarin的ESC编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆