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