[tamarin系列之7]客户端脚本引擎axscript

让我们再回顾一下tamarin

|-- tamarin-tracing    // tamarin源码工程    

|-- axscript // 客户端脚本引擎    

 |-- build    

|-- configure    

|-- configure.py       

|-- core                

 |-- esc                

 |-- extensions    

 |-- localization    

 |-- manifest.mk    

 |-- nanojit    

|-- pcre    

|-- platform            

|-- shell                

|-- space            

|-- test    

|-- utils                

`-- zlib

我们看到axscript是tamarin的一部分,它主要用于在浏览器中能够解释ES4脚本以代替Javascript。

项目最好是tamarin-central  (下载地址在 http://hg.mozilla.org/tamarin-central/

如果是tamarin-tracing可能会缺少很多包而不能编译通过

然后我们先编译整个tamarin项目,项目文件在platform里,我们选择用win32去编译

然后进入axscript ,用VC编译,成功。

axscript是一个ATL项目,通过axtam.rgs注册到系统中,这样我们通过名称application/javascript;version=2或

application/javascript;version=4 就拥有解释es4的能力了

例子1:simple.html

<html>     <head>         <title>Tamarin</title>     </head>

    <script language="application/javascript;version=2">

         // alert dialog

         window.alert('Hello from Tamarin')

         // XXX - we don't have correct global semantics yet

         // so the 'window.' prefix must always be used.

        var document = window.document

         // add content to the document

         document.write("Hello from tamarin<br>")

         document.write("This document is at <code>" + document.location + "<code>")     </script>

</html>

使用IE即可执行这段代码

例子2:wsh_simple.es4

WScript.Echo("Hello from es4/wsh") WScript.Echo("WSH version is " + WScript.Version)

我们使用cscript wsh_simple.es4 即可运行这个es4脚本代码

=========================================================

这个axscript是要单独拉出个项目的,它并不能屈就于只是tamarin的一个子项目。后期可能整合到ScreamingMonkey之内。

因为mozilla的“猴子计划”中对ScreamingMonkey的介绍为: 

ScreamingMonkey is the project to add script-engine integration glue to Tamarin, so that it can handle

 <script type="application/ecmascript;version=4">

and

 <script type="application/javascript;version=2">

tags in other browsers, starting with IE (using ActiveScript interfaces).

跟这个是同一个口径,所以日后肯定会移植出去到ScreamingMonkey等“猴子”项目中。

具体的内部结构本节不再赘述,毕竟只是tamarin的另类shell,关于用作脚本解释的ATL,请自行研究;如日后有时间,可能会深入。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值