20. コンパイル例
Dart JavaScript
print(“Hello, world”); print$(“Hello, world”);
for(var $$i = a.iterator();
for(var i in a) {
$$i.hasNext();){ var i = $$i.next();
Parent.prototype.de?nedInParent.
super.de?nedInParent()
call(this)
x + y (when num x, y)
x+y
$add(x, y) (when var x, y)
20
22. Isolate
Actor model (shared nothing)のthread interface
frogcでの実装は3つ(Worker, timer, while loop)
WebWorkerでは spawn-self hack で実行
ただしDartiumではすぐクラッシュするしfrogc+Chrome
でも挙動はあやしいしfrogc+node.jsでは動かないし全
然ダメ
22
23. Isolation of global state
すべてのグローバル変数?クラスは、JSレベルでは
global stateというオブジェクトのプロパティ
spawnするとこれをコピーして、functionオブジェクト
とglobal stateを一緒にqueueに突っ込むイメージ
そしてイベントループの中でqueueから取り出して実行
コンテキストスイッチは単に $globals = c.isolateStatics
23
26. Run Time Type Information
Run-Time Type InformationはほぼJSそのまま
Dart VMだと値が型情報を持つ
C<T> はTの情報を持たない
だからC<T>のメソッドでnew T()ができない
当然 if(c is C<T>)もまともに動かない
doubleとintも区別なし
26