Update changelog
[pkg-ocaml-js-of-ocaml.git] / compiler / primitive.ml
blobfeed3617e7d50b3b2d77b1268f957515ad10e62b
1 (* Js_of_ocaml compiler
2 * http://www.ocsigen.org/js_of_ocaml/
3 * Copyright (C) 2010 Jérôme Vouillon
4 * Laboratoire PPS - CNRS Université Paris Diderot
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, with linking exception;
9 * either version 2.1 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 let aliases = Hashtbl.create 17
23 let alias nm nm' = Hashtbl.add aliases nm nm'
24 let rec resolve nm = try resolve (Hashtbl.find aliases nm) with Not_found -> nm
26 (****)
28 type kind = [ `Pure | `Mutable | `Mutator ]
30 let kinds = Hashtbl.create 37
32 let register p k = Hashtbl.add kinds p k
34 let kind nm = try Hashtbl.find kinds (resolve nm) with Not_found -> `Mutator
36 let is_pure nm = kind nm <> `Mutator
38 (****)
40 let primitives = ref Util.StringSet.empty
42 let mark_used nm =
43 primitives := Util.StringSet.add nm !primitives
45 let list_used () =
46 Format.eprintf "Primitives:@.";
47 Util.StringSet.iter (fun nm -> Format.eprintf " %s@." nm) !primitives
49 let get_used () = Util.StringSet.elements !primitives