Module Ocaml_typing.Compilation_unitSource
The name of a compilation unit qualified with any "-for-pack" prefix that was specified when the unit was compiled. For example if compiling foo.ml with "-for-pack Baz.Bar", the corresponding value of type t would represent "Baz.Bar.Foo", with its name representing "Foo" and its prefix representing "Baz.Bar".
Printing, comparison, sets, maps, etc.
include Ocaml_utils.Identifiable.S with type t := t
include Ocaml_utils.Identifiable.Thing with type t := T.t
include Hashtbl.HashedType with type t := T.t
A hashing function on keys. It must be such that if two keys are equal according to equal, then they have identical hash values as computed by hash. Examples: suitable (equal, hash) pairs for arbitrary key types include
- (
(=),hash) for comparing objects by structure (provided objects do not contain floats) - (
(fun x y -> compare x y = 0),hash) for comparing objects by structure and handlingStdlib.nancorrectly - (
(==),hash) for comparing objects by physical equality (e.g. for mutable or cyclic objects).
include Map.OrderedType with type t := T.t
A total ordering function over the keys. This is a two-argument function f such that f e1 e2 is zero if the keys e1 and e2 are equal, f e1 e2 is strictly negative if e1 is smaller than e2, and f e1 e2 is strictly positive if e1 is greater than e2. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare.
Print only the name of the given compilation unit.
Print the compilation unit for use in error messages. Uses Format_doc.formatter and applies inline code styling.
Create a compilation unit with the given name (which is not encoded or mangled in any way).
Convert a compilation unit to a prefix. Used to form a child of a pack.
Create a compilation unit that's an instantiation of another unit with given arguments. The arguments will be sorted alphabetically by parameter name.
Convert the compilation unit to a Global_module.Name.t, if possible (which is to say, if its prefix is empty).
Like to_global_name but throw a fatal error if there is a non-empty prefix.
Like to_global_name but succeed even when there is a pack prefix, discarding the prefix in that case.
Create the compilation unit named by the given Global_module.t. Throws a fatal error if the global is not a complete instantiation, which is to say, if it has any hidden arguments at any depth.
Create a compilation unit from the given name. No prefix is allowed; throws a fatal error if there is a "." in the name. (As a special case, a "." is allowed as the first character, to handle compilation units which take their names from hidden files.)
Create a global Ident.t representing this compilation unit. Only intended for use in bytecode; most uses of Ident.ts that are known to be global should simply use t instead.
Find whether one compilation unit has another as a child. That is, whether the other unit has this one as its path prefix.
Find whether one compilation unit can access another directly, without going through a pack. Equivalently, find whether one unit's .cmx file is visible while compiling another. Access to a packed unit is allowed only "from inside the pack," which is to say, a unit can only access its own members and those of its ancestors, though not the ancestors themselves. Thought of as a node in a tree, this means a module can access its own children, its own siblings, and its ancestors' siblings.
In terms of paths, in order for X to access Y,
(1) Y's prefix must be equal to or a prefix of X's full path, and (2) Y itself must not be (strictly) a prefix of X (though X and Y may be equal).
For example:
A.B.C_can_ accessA.QbecauseA.Qis a member ofAandAis an ancestor ofA.B.C. In other words,A.Q's prefix isAandAis a prefix ofA.B.C.A.Q_cannot_ accessA.B.CbecauseA.Bis not a prefix ofA.Q.A.Q_can_ however accessA.B, becauseA_is_ a prefix ofA.Q.A.Q_can_ also access its own member,A.Q.R, becauseA.Q.R's prefix is exactlyA.Q.A.Q_cannot_ accessA.Q.R.S, becauseA.Q.Ris not a prefix ofA.Q.A.Q_can_ accessF, sinceF's prefix is the empty path, which is trivially a prefix ofA.Q.A.Q_cannot_ accessF.G(by criterion 1) orA(by criterion 2).
A clearer name for can_access_by_name when the .cmx file is what's of interest.
Determine which .cmx file to load for a given compilation unit. This is tricky in the case of packs. It can be done by lining up the desired compilation unit's full path (i.e. pack prefix then unit name) against the accessing unit's full path and observing when/if they diverge.
This is only used for native code compilation.
The name of the compilation unit, excluding any for_pack_prefix, as as a string.
Whether the compilation unit is a name without any prefix or instance arguments.
Whether the compilation unit has the given name and neither a prefix nor any instance arguments.
The "-for-pack" prefix associated with the given compilation unit.
Replace the "-for-pack" prefix for the given compilation unit.
Returns true iff the given compilation unit has a non-empty for_pack_prefix.
Returns the full path of the compilation unit. The basename of the unit will be the last component of the returned list.
Returns the full path of the compilation unit, as a string, following usual conventions.
Returns the full path of the compilation unit including its arguments in the mangled form suitable to create its linkage name and using the given pack_separator when relevant. (See at the finishing steps in Symbol.linkage_name_for_compilation_unit).
Returns the string that should form the base of the .cmx/o file for this unit. Usually just name_as_string t uncapitalized, but if there are instance arguments, they're encoded in a Bash-friendly but otherwise unspecified manner.
Return a representation of the name as its prefix, its name, and its arguments with nesting levels attached. Good for implementing horrible name mangling and little else. So:
Foo==>[], "Foo", []Foo[X:Bar]==>[], "Foo", [(0, "X", "Bar")]Foo[X:Bar][Y:Baz]==>[], "Foo", [(0, "X", "Bar"); (0, "Y", "Baz")]Foo[X:Bar[Y:Baz]]==>[], "Foo", [(0, "X", "Bar"); (1, "Y", "Baz")]
I believe it's possible to parse this form back to the usual nested form, which one should only want to do in order to prove the encoding is unambiguous.
Returns the arguments in the compilation unit, if it is an instance, or the empty list otherwise.
Returns true iff the given compilation unit is an instance (equivalent to instance_arguments t <> []).
Returns the unit that was instantiated and the arguments it was given, if this is an instance, throwing a fatal error otherwise.
Set an override for the name mangling scheme used while compiling the current unit. Typically called by the driver when the -name-mangling-scheme command-line option is used. The override applies for the lifetime of the ocamlopt invocation.
Returns the name mangling scheme to use for the unit currently being compiled. If set_name_mangling_scheme_override has been called, that value is returned; otherwise Config.name_mangling_scheme is returned.
There is no per-t equivalent: linkage names are baked in when each unit is compiled and serialised with its .cmx, so when reading another unit we never need to know which scheme it was compiled under.