(* Run time support: senza tagstack e retention *) type tipo = Vvar of string | Intero | Booleano | Mkprod of tipo * tipo | Mkarrow of tipo * tipo type env = int type proc = eval -> eval and eval = Funval of proc | Mkpair of eval * eval | Int of int | Bool of bool | Unbound type 'x stack = ('x array) * int ref let emptystack(nm,x) = (Array.create nm x, ref(-1)) let push(x,(s,n)) = if !n = (Array.length(s) - 1) then failwith("full stack") else (Array.set s (!n +1) x; n := !n +1) let top(s,n) = if !n = -1 then failwith("top is undefined") else Array.get s !n let pop(s,n) = if !n = -1 then failwith("pop is undefined") else n:= !n -1 let empty(s,n) = if !n = -1 then true else false let lungh(s,n) = !n let access ((s,n), k) = if not(k > !n) & not(k < 0) then Array.get s k else failwith("error in access") let svuota (s,n) = n := -1 let stacksize = 100 let tempvalstack = emptystack(stacksize,emptystack(1,Unbound)) let dvalstack = emptystack(stacksize,Unbound) let slinkstack = emptystack(stacksize, -1) let currentenv = ref(0)