diff options
author | Jeremie Dimino <jdimino@janestreet.com> | 2017-01-12 11:56:24 +0000 |
---|---|---|
committer | Jeremie Dimino <jeremie@dimino.org> | 2018-02-12 08:29:16 +0000 |
commit | 225d1c65b9f284b2cd85b26b58698da342ce9792 (patch) | |
tree | b567ac8bee5053ab00aa48fd5f539750505b945b /otherlibs | |
parent | e2e928fafe23807d9c792d61314ad4725655aa59 (diff) | |
download | ocaml-225d1c65b9f284b2cd85b26b58698da342ce9792.tar.gz |
Prefix the compilation unit names of all modules in the stdlib
Except for the Camlinternal* modules and the new Stdlib module, all
modules in the stdlib now compile to Stdlib__<module>.
Pervasives is renamed to Stdlib and now contains a list of aliases
from the long names to the short ones, so that from inside and outside
the stdlib we can refer to the standard modules as just List or
Stdlib.List rather than Stdlib__list.
In order to avoid printing the long names in error messages and in the
toplevel, the following heuristic is added to Printtyp: given a path
Foo__bar, if Foo.Bar exists and is a direct or indirect alias to
Foo__bar, then prefer Foo.Bar.
A bootstrap step was required to replace Pervasives by Stdlib as the
module opened by default.
Diffstat (limited to 'otherlibs')
-rw-r--r-- | otherlibs/threads/Makefile | 58 | ||||
-rw-r--r-- | otherlibs/threads/stdlib.ml (renamed from otherlibs/threads/pervasives.ml) | 53 |
2 files changed, 83 insertions, 28 deletions
diff --git a/otherlibs/threads/Makefile b/otherlibs/threads/Makefile index e6ccbf4491..01a3390fa2 100644 --- a/otherlibs/threads/Makefile +++ b/otherlibs/threads/Makefile @@ -33,22 +33,25 @@ CAML_OBJS=thread.cmo mutex.cmo condition.cmo event.cmo threadUnix.cmo LIB=../../stdlib -LIB_OBJS=$(LIB)/camlinternalFormatBasics.cmo pervasives.cmo \ - $(LIB)/array.cmo $(LIB)/list.cmo $(LIB)/char.cmo $(LIB)/bytes.cmo \ - $(LIB)/string.cmo $(LIB)/sys.cmo $(LIB)/sort.cmo marshal.cmo \ - $(LIB)/obj.cmo $(LIB)/int32.cmo $(LIB)/int64.cmo \ - $(LIB)/nativeint.cmo $(LIB)/lexing.cmo $(LIB)/parsing.cmo \ - $(LIB)/set.cmo $(LIB)/map.cmo $(LIB)/stack.cmo $(LIB)/queue.cmo \ - $(LIB)/camlinternalLazy.cmo $(LIB)/lazy.cmo $(LIB)/stream.cmo \ - $(LIB)/buffer.cmo $(LIB)/camlinternalFormat.cmo $(LIB)/printf.cmo \ - $(LIB)/arg.cmo $(LIB)/printexc.cmo $(LIB)/gc.cmo $(LIB)/digest.cmo \ - $(LIB)/random.cmo $(LIB)/hashtbl.cmo $(LIB)/format.cmo \ - $(LIB)/scanf.cmo $(LIB)/callback.cmo $(LIB)/camlinternalOO.cmo \ - $(LIB)/oo.cmo $(LIB)/camlinternalMod.cmo $(LIB)/genlex.cmo \ - $(LIB)/weak.cmo $(LIB)/ephemeron.cmo $(LIB)/filename.cmo \ - $(LIB)/complex.cmo $(LIB)/arrayLabels.cmo $(LIB)/listLabels.cmo \ - $(LIB)/bytesLabels.cmo $(LIB)/stringLabels.cmo \ - $(LIB)/moreLabels.cmo $(LIB)/stdLabels.cmo +# Object file prefix +P=stdlib__ + +LIB_OBJS=$(LIB)/camlinternalFormatBasics.cmo stdlib.cmo \ + $(LIB)/$(P)array.cmo $(LIB)/$(P)list.cmo $(LIB)/$(P)char.cmo $(LIB)/$(P)bytes.cmo \ + $(LIB)/$(P)string.cmo $(LIB)/$(P)sys.cmo $(LIB)/$(P)sort.cmo marshal.cmo \ + $(LIB)/$(P)obj.cmo $(LIB)/$(P)int32.cmo $(LIB)/$(P)int64.cmo \ + $(LIB)/$(P)nativeint.cmo $(LIB)/$(P)lexing.cmo $(LIB)/$(P)parsing.cmo \ + $(LIB)/$(P)set.cmo $(LIB)/$(P)map.cmo $(LIB)/$(P)stack.cmo $(LIB)/$(P)queue.cmo \ + $(LIB)/camlinternalLazy.cmo $(LIB)/$(P)lazy.cmo $(LIB)/$(P)stream.cmo \ + $(LIB)/$(P)buffer.cmo $(LIB)/camlinternalFormat.cmo $(LIB)/$(P)printf.cmo \ + $(LIB)/$(P)arg.cmo $(LIB)/$(P)printexc.cmo $(LIB)/$(P)gc.cmo $(LIB)/$(P)digest.cmo \ + $(LIB)/$(P)random.cmo $(LIB)/$(P)hashtbl.cmo $(LIB)/$(P)format.cmo \ + $(LIB)/$(P)scanf.cmo $(LIB)/$(P)callback.cmo $(LIB)/camlinternalOO.cmo \ + $(LIB)/$(P)oo.cmo $(LIB)/camlinternalMod.cmo $(LIB)/$(P)genlex.cmo \ + $(LIB)/$(P)weak.cmo $(LIB)/$(P)ephemeron.cmo $(LIB)/$(P)filename.cmo \ + $(LIB)/$(P)complex.cmo $(LIB)/$(P)arrayLabels.cmo $(LIB)/$(P)listLabels.cmo \ + $(LIB)/$(P)bytesLabels.cmo $(LIB)/$(P)stringLabels.cmo \ + $(LIB)/$(P)moreLabels.cmo $(LIB)/$(P)stdLabels.cmo UNIXLIB=../unix @@ -70,23 +73,24 @@ stdlib.cma: $(LIB_OBJS) unix.cma: $(UNIXLIB_OBJS) $(MKLIB) -ocamlc '$(CAMLC)' -o unix -linkall $(UNIXLIB_OBJS) -pervasives.cmo: pervasives.mli pervasives.cmi pervasives.ml - $(CAMLC) ${COMPFLAGS} -nopervasives -c pervasives.ml +stdlib.cmo: stdlib.mli stdlib.cmi stdlib.ml + $(CAMLC) ${COMPFLAGS} -nopervasives \ + -pp "awk -f $(LIB)/expand_module_aliases.awk" -o $@ -c stdlib.ml -pervasives.mli: $(LIB)/pervasives.mli - ln -s $(LIB)/pervasives.mli pervasives.mli +stdlib.mli: $(LIB)/stdlib.mli + ln -s $(LIB)/stdlib.mli stdlib.mli -pervasives.cmi: $(LIB)/pervasives.cmi - ln -s $(LIB)/pervasives.cmi pervasives.cmi +stdlib.cmi: $(LIB)/stdlib.cmi + ln -s $(LIB)/stdlib.cmi stdlib.cmi -marshal.cmo: marshal.mli marshal.cmi marshal.ml - $(CAMLC) ${COMPFLAGS} -c marshal.ml +$(P)marshal.cmo: marshal.mli $(P)marshal.cmi marshal.ml + $(CAMLC) ${COMPFLAGS} -o$@ -c marshal.ml marshal.mli: $(LIB)/marshal.mli ln -s $(LIB)/marshal.mli marshal.mli -marshal.cmi: $(LIB)/marshal.cmi - ln -s $(LIB)/marshal.cmi marshal.cmi +$(P)marshal.cmi: $(LIB)/$(P)marshal.cmi + ln -s $(LIB)/$(P)marshal.cmi $(P)marshal.cmi unix.mli: $(UNIXLIB)/unix.mli ln -s -f $(UNIXLIB)/unix.mli unix.mli @@ -102,7 +106,7 @@ partialclean: clean: partialclean rm -f libvmthreads.a dllvmthreads.so *.o - rm -f pervasives.mli marshal.mli unix.mli + rm -f stdlib.mli marshal.mli unix.mli INSTALL_LIBDIR=$(DESTDIR)$(LIBDIR) INSTALL_STUBLIBDIR=$(DESTDIR)$(STUBLIBDIR) diff --git a/otherlibs/threads/pervasives.ml b/otherlibs/threads/stdlib.ml index 470a1c5c54..a1be6645a1 100644 --- a/otherlibs/threads/pervasives.ml +++ b/otherlibs/threads/stdlib.ml @@ -13,10 +13,11 @@ (* *) (**************************************************************************) -(* Same as ../../stdlib/pervasives.ml, except that I/O functions have +(* Same as ../../stdlib/stdlib.ml, except that I/O functions have been redefined to not block the whole process, but only the calling thread. *) +module Pervasives = struct (* type 'a option = None | Some of 'a *) (* Exceptions *) @@ -634,3 +635,53 @@ let exit retcode = sys_exit retcode let _ = register_named_value "Pervasives.do_at_exit" do_at_exit +end + +include Pervasives + +(*MODULE_ALIASES*) +module Arg = Arg +module Array = Array +module ArrayLabels = ArrayLabels +module Buffer = Buffer +module Bytes = Bytes +module BytesLabels = BytesLabels +module Callback = Callback +module Char = Char +module Complex = Complex +module Digest = Digest +module Ephemeron = Ephemeron +module Filename = Filename +module Format = Format +module Gc = Gc +module Genlex = Genlex +module Hashtbl = Hashtbl +module Int32 = Int32 +module Int64 = Int64 +module Lazy = Lazy +module Lexing = Lexing +module List = List +module ListLabels = ListLabels +module Map = Map +module Marshal = Marshal +module MoreLabels = MoreLabels +module Nativeint = Nativeint +module Obj = Obj +module Oo = Oo +module Parsing = Parsing +module Printexc = Printexc +module Printf = Printf +module Queue = Queue +module Random = Random +module Scanf = Scanf +module Set = Set +module Sort = Sort +module Spacetime = Spacetime +module Stack = Stack +module StdLabels = StdLabels +module Stream = Stream +module String = String +module StringLabels = StringLabels +module Sys = Sys +module Uchar = Uchar +module Weak = Weak |