open AstT

let predef_fun = 
  let rec aux = function
    | 0 ->
      [ "print_int", Tval ([Tint],Tunit) ;
        "print_newline", Tval ([Tunit], Tunit) ;
        "read_int", Tval ([Tunit], Tint) ;
        "not", Tval ([Tbool], Tbool) ;
        "sleep", Tval ([Tunit], Tunit) ]
    | n -> 
        ("output"^(string_of_int (n-1)), Tval ([Tint],Tunit))::
        ("input"^(string_of_int (n-1)), Tval ([Tunit],Tint))::
        aux (n-1)
  in aux 16

module Smap = Map.Make(String)

let base_env = 
  List.fold_left 
    (fun env (p,t) -> 
      let p' = p^"_0" in
        Smap.add p ([p'],t) env
    )
    Smap.empty
    predef_fun

module Sset = Set.Make(String)

let set_fun =
  Smap.fold
    (fun p ([p'],t) (set:Sset.t) ->
       Sset.add p' set
    )
    base_env
    Sset.empty
