型推論が動き出した

yarv2llvmを作っています。とりあえず、型推論が動き出しました。まだ、fixnumとfloatしか対応していませんが、それなりに判断しているみたいです。
ソースは http://github.com/miura1729/yarv2llvm/tree/master にあります。

こんな感じのプログラムを食わせてみると

def foo(sx, sy, sz, n)
  vx = -sx
  vy = sy + 1.0
  vz = sz
  if vx == 0.0 then
      vs = Math.sqrt(vx * vx + vy * vy + vz * vz)
      vx = vx / vs
  end
  n = n + 1
  vy = vy / vs
  vz = vz / vs
end

def bar(n)
    n + 1
end

def baz(n)
    Math.sqrt(n)
end

こんな感じで型を推論します。最初の関数がなぞですが、まだ追ってないです。

 :() -> symbol
foo :(float, float, float, fixnum, ) -> float
bar :(fixnum, ) -> fixnum
baz :(float, ) -> float

引き続き、llvmに落とすところを作っていきます。