20 Semantica delle espressioni 2 | Ifthenelse(a,b,c) -> let (g, s1, h1) = sem(a, r, s, h) in if typecheck( bool ,g) then (if g = Bool(true) then sem(b, r, s, h1) else sem(c, r, s, h1)) else failwith ( nonboolean guard ) | Val(e) -> let (v, s1, h1) = semden(e, r, s, h) in (match v with | Dloc n -> mvaltoeval(applystore(s1, n)), s1, h1 | _ -> failwith( not a variable ) | Let(i,e1,e2) -> let (v, s1, h1) = semden(e1, r, s, h) in sem(e2, bind (r,i, v), s1, h1) | Fun(i,e1) -> dvaltoeval(makefun(e,r)), s, h | Rec(i,e1) -> makefunrec(i, e1, r), s, h | Appl(a,b) -> let (v1, s1, h1) = semlist(b, r, s, h) in let (v2, s2, h2) = sem(a, r, s, h1) in applyfun(evaltodval v2, v1, s2, h2) | New(i,ge) -> let (v, s1, h1) = semlist(ge, r, s, h) in applyclass(applyenv(r,i), v, s1, h1) | This -> (dvaltoeval(applyenv(r, this )), s, h) | _ -> failwith ( nonlegal expression for sem ) val sem : exp * dval env * mval store * heap -> eval * mval store * heap =
{}