Define MIPS word size
[tiger.ml.git] / compiler / src / lib / tiger / tiger_env.ml
... / ...
CommitLineData
1module Map = Tiger_map
2module Sym = Tiger_symbol
3module Translate = Tiger_translate
4module Type = Tiger_env_type
5module Value = Tiger_env_value
6
7type t =
8 { typs : Type.env
9 ; vals : Value.env
10 ; loop : Sym.t option
11 ; level : Translate.Level.t
12 }
13
14let base =
15 { typs = Type.built_in
16 ; vals = Value.built_in
17 ; loop = None
18 ; level = Translate.Level.init
19 }
20
21let get_typ {typs; _} k =
22 Map.get typs ~k
23
24let get_val {vals; _} k =
25 Map.get vals ~k
26
27let set_typ t k v =
28 {t with typs = Map.set t.typs ~k ~v}
29
30let set_val t k v =
31 {t with vals = Map.set t.vals ~k ~v}
32
33let loop_begin t =
34 let loop = Sym.unique_of_string "loop" in
35 let t = {t with loop = Some loop} in
36 (loop, t)
37
38let loop_end t given =
39 match t.loop with
40 | None ->
41 assert false
42 | Some current when (not (Sym.is_equal current given)) ->
43 assert false
44 | Some _ ->
45 {t with loop = None}
46
47let loop_current {loop; _} =
48 loop
49
50let level_set t level =
51 {t with level}
52
53let level_get {level; _} =
54 level
This page took 0.025743 seconds and 4 git commands to generate.