Titanium是怎樣工作的?

來源:互聯網
上載者:User

 
  In a Titanium Mobile application, your source code is packaged into a binary file and then interpreted at runtime by a JavaScript engine bundled in by the Titanium build process. 

In this guide, you will learn more about the JavaScript runtime environment that your code runs in.

 Titanium runs your application’s JavaScript using one of two JavaScript interpreters – JavaScriptCore on
iOS (the interpreter used by Webkit) and Mozilla Rhino on Android and BlackBerry.


    Titanium takes your Javascript code, analyzes and preprocesses itand then pre-compiles it into a set of symbols that are resolved
based on your applications uses of Titanium APIs.       From this symbol hierarchy we can build asymbol dependency matrix that maps to the underlying Titanium library symbols to understand
which APIs (and related dependencies, frameworks, etc)specifically your app needs.      I'm using the word symbol in a semi-generic waysince it's a little different based on the language.      In iPhone, the symbol mapsto a true C symbol that ultimately maps to a compiled .o file that has beencompiled for ARM/i386 architectures.      For Java, well, it's more or less a .classfile, etc.       Once the front end can understand your dependency matrix, we then invoke the SDK compiler (i.e. GCC for iPhone, Java for Android)
to then compileyour application into the final native binary. So, a simple way to think aboutit is that your JS code is compiled almost one to one into the representative symbols in nativeland.     There's still an interpreter running in interpreted modeotherwise things like dynamic code wouldn't work. However, its much faster,much
more compact and it's about as close to pure native mapping as you canget.

    We're  obviously still got plenty of room to improve this and working on that. So farin our latest 1.0 testing, it's almost indistinguishable from the sameobjective-c direct
code (since in most cases it's exactly mapped to that).

    Froma CompSci standpoint, we can now however start to optimize things that a humanreally couldn't easily do that - much like the GCC compiler already does today.


   參考:http://stackoverflow.com/questions/2444001/how-does-appcelerator-titanium-mobile-work

                     http://www.itwriting.com/blog/4198-is-appcelerator-titanium-native-and-what-does-native-mean-anyway.html/comment-page-1#comment-535303

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.