Begin translation module
[tiger.ml.git] / compiler / src / lib / tiger / tiger_env_value.ml
... / ...
CommitLineData
1module List = ListLabels
2
3module Map = Tiger_map
4module Symbol = Tiger_symbol
5module Temp = Tiger_temp
6module Translate = Tiger_translate
7module Type = Tiger_env_type
8
9type t =
10 | Var of
11 { access : Tiger_translate.access
12 ; ty : Tiger_env_type.t
13 }
14 | Fun of
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
19 }
20
21type env =
22 (Symbol.t, t ) Map.t
23
24let built_in =
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 )
35 ]
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
41 (key, value)
42 )
43 |> Map.of_list
This page took 0.026187 seconds and 5 git commands to generate.