1 module List = ListLabels
4 module Symbol = Tiger_symbol
5 module Temp = Tiger_temp
6 module Translate = Tiger_translate
7 module Type = Tiger_env_type
11 { access : Tiger_translate.access
12 ; ty : Tiger_env_type.t
15 { formals : Tiger_env_type.t list
16 ; result : Tiger_env_type.t
17 ; level : Tiger_translate.Level.t
18 ; label : Tiger_temp.Label.t
25 [ ("print" , [Type.String] , Type.Unit )
26 ; ("flush" , [] , Type.Unit )
27 ; ("getchar" , [] , Type.String )
28 ; ("ord" , [Type.String] , Type.Int )
29 ; ("chr" , [Type.Int] , Type.String )
30 ; ("size" , [Type.String] , Type.Int )
31 ; ("substring" , [Type.String; Type.Int; Type.Int] , Type.String )
32 ; ("concat" , [Type.String; Type.String] , Type.String )
33 ; ("not" , [Type.Int] , Type.Int )
34 ; ("exit" , [Type.Int] , Type.Unit )
36 |> List.map ~f:(fun (name, formals, result) ->
37 let key = Symbol.of_string name in
38 let level = Translate.Level.init in
39 let label = Temp.Label.gen () in
40 let value = Fun {formals; result; level; label} in