Fixes #615: "make coverage" is broken. The current "make coverage" failure occurs as the coverage-checking tool attempts to access "src/batInnerPervasives.mlv" and does not find the file. It looks for this file because it is present in the lexer-directive comments of the preprocessed file (src/batInnerPervasives.ml), and it makes sense for a coverage checking to display covered lines in terms of the source file instead of post-filtering file (which is not what developers see). But because the prefilter step currently happens purely in Make-land, before ocamlbuild is invoked, ocamlbuild does not know about this .mlv file and does not copy it in the _build directory, from where the coverage preprocessing is started. The solution to this problem is to teach ocamlbuild about the .mlv preprocessing step, instead of doing it ahead-of-time in the Makefile. Now ocamlbuild decides which .mlv to prefilter, and copies them to _build along the process, which makes "make coverage work again". This has one downside and some upsides. Downside: - The prefiltering logic was previously in the Makefile: (simple, easy to read, most programmers are familiar with it. It is now in myocamlbuild.ml: less simple, most programmers avoid touching it, and it has a bit of cruft due to support for really old ocamlbuild versions. Upsides: - No more need to explicitly list all files to preprocess in the Makefile. This had had been a source of minor inconvenience when adding to the set of such files; but admittedly this could be automated at the Makefile level as well). - No more need to use "make clean-prefilter" when unsure whether the changes to a .mlv file have been taken into acount; now ocamlbuild tracks dependencies for .mlv (and prefilter.byte, which was previously mostly untracked by the build system) as any other file, and will only rebuild them when needed. This is a major improvement in convenience when manipulating these files.
The implementations are inspired by the original proposal of Daniel Bünzli in http://caml.inria.fr/mantis/view.php?id=6009
… optims BatSplay uses a bit of type-checking magic to respect the Map interface (which requires map types to be covariant) while internally keeping a mutable reference for (inobservable) rebalancing mutations. The previous implementation is safe for the current versions of the OCaml compiler, but has the fundamental issue of mutating (through Obj magic) constructed values of a known-immutable type. The new implementation creates values at an immutable type, and then magically coerce them into the covariant immutable type. This ensures that the compiler knows (at value-creation time) that the allocated memory is *not* immutable -- this is the same technique we use for destination-passing-style lists. This trick of "covariant mutable references" can be isolated as a small submodule, which is then used (internally) throughout the BatSplay implementation. Thanks to Pierre Chambart for the discussion that led to this change.
…ew elements + minor indentation changes
…the previous key. This is the same semantics as Hashtbl.replace
…nly does one lookup if the key is already in the table. If the key is not found modify_opt calls add to add the key in order to ensure that the hashtbl is grown if needed.