AVM2 – 用戶端指令碼引擎axscript

來源:互聯網
上載者:User

讓我們再回顧一下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,請自行研究;如日後有時間,可能會深入。

讓我們再回顧一下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,請自行研究;如日後有時間,可能會深入。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.