3 module List = ListLabels
6 module Symbol = Tiger_symbol
18 ; fields : (Symbol.t * t) list
24 | Name of Symbol.t * t option ref
32 let new_record fields =
35 ; unique = new_unique ()
41 ; unique = new_unique ()
46 | Record {unique=u1; _}, Record {unique=u2; _} -> u1 == u2
47 | Array {unique=u1; _}, Array {unique=u2; _} -> u1 == u2
49 (* The above pattern matching is "fragile" and I'm OK with it.
50 * TODO: Can we ignore the warning locally?
53 let is_record = function
59 | Nil (* nil belongs to ANY record *)
71 let is_name = function
80 let to_string = function
84 | Record {unique; _} -> sprintf "record(%d)" (Obj.magic unique)
85 | Array {unique; _} -> sprintf "array(%d)" (Obj.magic unique)
87 | Name (name, _) -> Symbol.to_string name
95 |> List.map ~f:(fun (k, v) -> (Symbol.of_string k, v))