Skip to content

Virtualized Scala Reference

adriaanm edited this page Oct 3, 2011 · 27 revisions
if (c) then a else b ~~> __ifThenElse(c, a, b)

def __ifThenElse[T](cond: => Boolean, thenp: => T, elsep: => T): T

while(c) b ~~> __whileDo(c, b) do b while(c) ~~> __doWhile(b, c)

def __whileDo(cond: Boolean, body: Unit): Unit def __doWhile(body: Unit, cond: Boolean): Unit

var x = i ~~> val x = __newVar(i) x = a ~~> __assign(x, a)

def __newVar[T](init: T): T def __assign[T](lhs: T, rhs: T): Unit

return a ~~> __return(a)

def __return(expr: Any): Nothing

a.==(b_1,..., b_n) ~~> __equal(a, b_1, ..., b_n)

def __equal(expr1: Any, expr2: Any): Boolean

trait Row[+Rep[x]] def __new[T](args: (String, T => _)*): Any

new C { (val x_i: T_i = v_i)* } ~~> __new(("x_i", (self_i: Rep[C{ (val x_i: T_i')* }]) => v_i')) : Rep[C{ (val x_i: T_i') }]

if there's a type constructor Rep[x] so that C <:< Row[Rep] and for all i, there's some T_i' so that T_i = Rep[T_i'] -- or, if that previous equality is not unifiable, T_i = T_i' v_i' results from retyping v_i with expected type Rep[T_i'], after replacing this by a fresh variable self_i (with type Rep[C{ (val x_i: T_i')* }])

the resulting call to __new is typed with expected type Rep[C{ (val x_i: T_i')* }]

type TransparentProxy[+T]

def __forward[A,B,C](self: TransparentProxy[A], method: String, x: TransparentProxy[B]*): TransparentProxy[C]