dart javascript编译器(dart2js)如何工作? [英] How does the dart javascript compiler (dart2js) work?

查看:443
本文介绍了dart javascript编译器(dart2js)如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dart在自己的Dart VM中运行,但您可以将其编译为现代优化的JavaScript。但是如何工作?有在线的任何文章或论文解释这个过程吗?



我想知道这是否是一个简单直接匹配元素的元素,只需要耗费开发,过程或是否有某些元素/方面的Dart无法编译为JavaScript。



http://www.dartlang.org



编辑:thx您的2个答案。关键是,我告诉一个同事关于dart和dart可以编译为JavaScript。他接受了它可以编译为JavaScript,但它会导致mumbojumba代码,并将只适用于简单的东西。最后他说:好吧,解释一下。这个编译是如何工作在非平凡的代码?'''



这就是为什么我问。我希望有一些材料在线我可以链接他。

解决方案

Dart编辑器现在将编译你的Dart代码JavaScript与dart2js。



对于问题的第二部分,dart:io库仅用于服务器/命令行,因此无法编译dart2js。



现在我意识到你在问工程师如何设计和实现dart2js编译器,而不是你怎么运行dart2js。



这是一个关于dart2js公告的博文: http://news.dartlang.org/2012/05/new-dart-to-javascript-compiler-ready.html



工程师之一Kasper Lund补充说:对于技术上有兴趣的人,我可以告诉你,新编译器
使用SSA形式的内部表示(静态单赋值)
,编译器完全在Dart中实现。



源代码位于 http://code.google.com/p/dart/source/browse/#svn%2Fbranches%2Fbleeding_edge%2Fdart %2Flib%2Fcompiler%2Fimplementation


Dart runs in its own Dart VM, but you can compile it to modern optimized JavaScript. But how does that work? Are there any articles or papers online which explain that process?

I am wondering if that is an easy straight forward matching element to element, only time consuming to develop, process or are there some elements/aspects of Dart which could not be compiled to JavaScript.

http://www.dartlang.org

EDIT:thx for your 2 answers. The point is, that i told a collegue of mine about dart and that dart can be compiled to JavaScript. He accepted that it could be compiled to JavaScript but it would result in mumbojumba code and will only work for simple stuff. In the end he said: '''ok, explain me. how is this compiling going to work on nontrivial code?'''

That's why i am asking. I was hoping that there is some material online i could link him.

解决方案

The Dart Editor will now compile your Dart code to JavaScript with dart2js.

As for the second part of your question, the dart:io libraries are only for the server/command-line, so they can't be compiled with dart2js.

I realize now I think you are asking "how did the engineers design and implement the dart2js compiler", not "how do you run dart2js"

Here's a blog post on the announcement of dart2js: http://news.dartlang.org/2012/05/new-dart-to-javascript-compiler-ready.html

Kasper Lund, one of the engineers, adds "For the technically interested, I can tell you that the new compiler uses an internal representation in SSA form (static single assignment) and that the compiler is implemented entirely in Dart."

The source code is at http://code.google.com/p/dart/source/browse/#svn%2Fbranches%2Fbleeding_edge%2Fdart%2Flib%2Fcompiler%2Fimplementation

这篇关于dart javascript编译器(dart2js)如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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