summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice Le Fessant <Fabrice.Le_fessant@inria.fr>2010-11-20 17:43:51 +0000
committerFabrice Le Fessant <Fabrice.Le_fessant@inria.fr>2010-11-20 17:43:51 +0000
commit9d3a3071e3bb6a2ff593791d0557d10062080d07 (patch)
tree45f0f99b249793cd78a02d36e14b797ccaf0c5a0
parentc2762da5c1dcd2adbe79fc1d470038784c9a1d7b (diff)
downloadocaml-9d3a3071e3bb6a2ff593791d0557d10062080d07.tar.gz
binary-compat: read and convert ast files for 3.12.0 and 3.11.2
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/binary-compat@10838 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--ChangeLog.txt4
-rw-r--r--README.txt16
-rw-r--r--binary-compat/.depend118
-rw-r--r--binary-compat/compat/3.11.2/v3112_ast.ml665
-rw-r--r--binary-compat/compat/3.11.2/v3112_ast.mli18
-rw-r--r--binary-compat/compat/3.11.2/v3112_cmi.mli31
-rw-r--r--binary-compat/compat/3.11.2/v3112_cmo.mli25
-rw-r--r--binary-compat/compat/3.11.2/v3112_cmx.mli4
-rw-r--r--binary-compat/compat/3.12.0/v3120_ast.ml579
-rw-r--r--binary-compat/compat/3.12.0/v3120_ast.mli17
-rw-r--r--binary-compat/compat/3.12.0/v3120_cmi.mli31
-rw-r--r--binary-compat/compat/3.12.0/v3120_cmo.mli25
-rw-r--r--binary-compat/compat/3.12.0/v3120_cmx.mli6
-rw-r--r--binary-compat/driver/pparse.ml4
-rw-r--r--binary-compat/otherlibs/dynlink/Makefile2
15 files changed, 1010 insertions, 535 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 254f9b7793..f8affa0b4d 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,7 @@
+2010/11/20:
+ * Implemented ast input from camlp4 for 3.12.0 and 3.11.2. Not yet tested.
+ * Added interface files
+
2010/11/19:
* Started implementing AST input (for camlp4)
diff --git a/README.txt b/README.txt
index 344d7937c5..0c0f11c76c 100644
--- a/README.txt
+++ b/README.txt
@@ -9,9 +9,23 @@ the current version of OCaml and the binary files generated by former versions
of the compiler.
Possible problems:
-
+==================
- Did the format of input_value/output_value changed ? Is there a magic ?
- It is hard to mix binary files from two versions in the same executable,
because they are not based on the same standard library. A solution ?
+Some more remarks:
+==================
+
+ * I used to purposely put an error in a signature to force the compiler to
+print the signature, and then use that signature in the interface file. It
+does not work anymore, probably because error messages are better located.
+But I lost something useful ! How to put it back ?
+
+ * I would want the editor to generate automatically a map function from a
+type definition, especially for big recursive ones. Maybe a tool could do
+that ?
+
+
+
diff --git a/binary-compat/.depend b/binary-compat/.depend
index 5fd386fb0f..3cda0ec8b3 100644
--- a/binary-compat/.depend
+++ b/binary-compat/.depend
@@ -125,7 +125,7 @@ typing/datarepr.cmo: typing/types.cmi typing/predef.cmi utils/misc.cmi \
parsing/asttypes.cmi typing/datarepr.cmi
typing/datarepr.cmx: typing/types.cmx typing/predef.cmx utils/misc.cmx \
parsing/asttypes.cmi typing/datarepr.cmi
-typing/env.cmo: compat/3.12.0/v3120_cmi.cmo typing/types.cmi utils/tbl.cmi \
+typing/env.cmo: compat/3.12.0/v3120_cmi.cmi typing/types.cmi utils/tbl.cmi \
typing/subst.cmi typing/predef.cmi typing/path.cmi utils/misc.cmi \
parsing/longident.cmi typing/ident.cmi typing/datarepr.cmi \
utils/consistbl.cmi utils/config.cmi typing/cmi_format.cmo \
@@ -334,7 +334,7 @@ bytecomp/bytelibrarian.cmo: utils/misc.cmi utils/config.cmi \
bytecomp/bytelibrarian.cmx: utils/misc.cmx utils/config.cmx \
bytecomp/cmo_format.cmi typing/cmi_format.cmx utils/clflags.cmx \
bytecomp/bytelink.cmx bytecomp/bytelibrarian.cmi
-bytecomp/bytelink.cmo: compat/3.12.0/v3120_cmo.cmo bytecomp/symtable.cmi \
+bytecomp/bytelink.cmo: compat/3.12.0/v3120_cmo.cmi bytecomp/symtable.cmi \
bytecomp/opcodes.cmo utils/misc.cmi bytecomp/instruct.cmi \
typing/ident.cmi bytecomp/dll.cmi utils/consistbl.cmi utils/config.cmi \
bytecomp/cmo_format.cmi typing/cmi_format.cmo utils/clflags.cmi \
@@ -608,7 +608,7 @@ asmcomp/comballoc.cmo: asmcomp/reg.cmi asmcomp/mach.cmi utils/config.cmi \
asmcomp/comballoc.cmi
asmcomp/comballoc.cmx: asmcomp/reg.cmx asmcomp/mach.cmx utils/config.cmx \
asmcomp/comballoc.cmi
-asmcomp/compilenv.cmo: compat/3.12.0/v3120_cmx.cmo utils/misc.cmi \
+asmcomp/compilenv.cmo: compat/3.12.0/v3120_cmx.cmi utils/misc.cmi \
typing/ident.cmi typing/env.cmi utils/config.cmi asmcomp/cmx_format.cmi \
typing/cmi_format.cmo asmcomp/clambda.cmi asmcomp/compilenv.cmi
asmcomp/compilenv.cmx: compat/3.12.0/v3120_cmx.cmx utils/misc.cmx \
@@ -717,7 +717,7 @@ driver/main_args.cmi:
driver/optcompile.cmi: typing/env.cmi
driver/opterrors.cmi:
driver/optmain.cmi:
-driver/pparse.cmi:
+driver/pparse.cmi: parsing/parsetree.cmi
driver/compile.cmo: utils/warnings.cmi typing/unused_var.cmi \
typing/typemod.cmi typing/typedtree.cmi bytecomp/translmod.cmi \
typing/stypes.cmi bytecomp/simplif.cmi typing/printtyp.cmi \
@@ -796,10 +796,12 @@ driver/optmain.cmx: utils/warnings.cmx asmcomp/printmach.cmx \
driver/main_args.cmx utils/config.cmx utils/clflags.cmx \
asmcomp/asmpackager.cmx asmcomp/asmlink.cmx asmcomp/asmlibrarian.cmx \
asmcomp/arch.cmx driver/optmain.cmi
-driver/pparse.cmo: utils/misc.cmi parsing/location.cmi utils/clflags.cmi \
- utils/ccomp.cmi driver/pparse.cmi
-driver/pparse.cmx: utils/misc.cmx parsing/location.cmx utils/clflags.cmx \
- utils/ccomp.cmx driver/pparse.cmi
+driver/pparse.cmo: parsing/parsetree.cmi utils/misc.cmi parsing/location.cmi \
+ utils/config.cmi typing/cmi_format.cmo utils/clflags.cmi utils/ccomp.cmi \
+ driver/pparse.cmi
+driver/pparse.cmx: parsing/parsetree.cmi utils/misc.cmx parsing/location.cmx \
+ utils/config.cmx typing/cmi_format.cmx utils/clflags.cmx utils/ccomp.cmx \
+ driver/pparse.cmi
toplevel/genprintval.cmi: typing/types.cmi typing/path.cmi \
typing/outcometree.cmi typing/env.cmi
toplevel/opttopdirs.cmi: parsing/longident.cmi
@@ -918,55 +920,91 @@ toplevel/trace.cmo: typing/types.cmi toplevel/toploop.cmi typing/printtyp.cmi \
toplevel/trace.cmx: typing/types.cmx toplevel/toploop.cmx typing/printtyp.cmx \
typing/predef.cmx typing/path.cmx utils/misc.cmx bytecomp/meta.cmx \
parsing/longident.cmx typing/ctype.cmx toplevel/trace.cmi
-compat/3.11.2/v3112_cmi.cmo: compat/3.11.2/v3112_types.cmo typing/types.cmi \
- typing/primitive.cmi typing/path.cmi parsing/location.cmi \
- typing/ident.cmi typing/cmi_format.cmo parsing/asttypes.cmi
-compat/3.11.2/v3112_cmi.cmx: compat/3.11.2/v3112_types.cmx typing/types.cmx \
- typing/primitive.cmx typing/path.cmx parsing/location.cmx \
- typing/ident.cmx typing/cmi_format.cmx parsing/asttypes.cmi
+compat/3.11.2/v3112_ast.cmi: compat/3.11.2/v3112_types.cmo \
+ parsing/parsetree.cmi parsing/asttypes.cmi
+compat/3.11.2/v3112_cmi.cmi: compat/3.11.2/v3112_types.cmo typing/types.cmi \
+ typing/primitive.cmi typing/path.cmi typing/ident.cmi \
+ typing/cmi_format.cmo
+compat/3.11.2/v3112_cmo.cmi: compat/3.11.2/v3112_types.cmo \
+ bytecomp/lambda.cmi bytecomp/cmo_format.cmi
+compat/3.11.2/v3112_cmx.cmi: bytecomp/cmo_format.cmi
+compat/3.11.2/v3112_ast.cmo: compat/3.11.2/v3112_types.cmo \
+ parsing/parsetree.cmi parsing/location.cmi typing/cmi_format.cmo \
+ parsing/asttypes.cmi compat/3.11.2/v3112_ast.cmi
+compat/3.11.2/v3112_ast.cmx: compat/3.11.2/v3112_types.cmx \
+ parsing/parsetree.cmi parsing/location.cmx typing/cmi_format.cmx \
+ parsing/asttypes.cmi compat/3.11.2/v3112_ast.cmi
+compat/3.11.2/v3112_cmi.cmo: compat/3.11.2/v3112_types.cmo \
+ compat/3.11.2/v3112_ast.cmi typing/types.cmi typing/primitive.cmi \
+ typing/path.cmi typing/ident.cmi typing/cmi_format.cmo \
+ parsing/asttypes.cmi compat/3.11.2/v3112_cmi.cmi
+compat/3.11.2/v3112_cmi.cmx: compat/3.11.2/v3112_types.cmx \
+ compat/3.11.2/v3112_ast.cmx typing/types.cmx typing/primitive.cmx \
+ typing/path.cmx typing/ident.cmx typing/cmi_format.cmx \
+ parsing/asttypes.cmi compat/3.11.2/v3112_cmi.cmi
compat/3.11.2/v3112_cmo.cmo: compat/3.11.2/v3112_types.cmo \
- compat/3.11.2/v3112_cmi.cmo typing/types.cmi typing/primitive.cmi \
- bytecomp/lambda.cmi typing/ident.cmi bytecomp/cmo_format.cmi \
- typing/cmi_format.cmo parsing/asttypes.cmi
+ compat/3.11.2/v3112_cmi.cmi compat/3.11.2/v3112_ast.cmi typing/types.cmi \
+ typing/primitive.cmi bytecomp/lambda.cmi typing/ident.cmi \
+ bytecomp/cmo_format.cmi typing/cmi_format.cmo parsing/asttypes.cmi \
+ compat/3.11.2/v3112_cmo.cmi
compat/3.11.2/v3112_cmo.cmx: compat/3.11.2/v3112_types.cmx \
- compat/3.11.2/v3112_cmi.cmx typing/types.cmx typing/primitive.cmx \
- bytecomp/lambda.cmx typing/ident.cmx bytecomp/cmo_format.cmi \
- typing/cmi_format.cmx parsing/asttypes.cmi
+ compat/3.11.2/v3112_cmi.cmx compat/3.11.2/v3112_ast.cmx typing/types.cmx \
+ typing/primitive.cmx bytecomp/lambda.cmx typing/ident.cmx \
+ bytecomp/cmo_format.cmi typing/cmi_format.cmx parsing/asttypes.cmi \
+ compat/3.11.2/v3112_cmo.cmi
compat/3.11.2/v3112_cmx.cmo: compat/3.11.2/v3112_types.cmo \
- compat/3.11.2/v3112_cmo.cmo compat/3.11.2/v3112_cmi.cmo \
+ compat/3.11.2/v3112_cmo.cmi compat/3.11.2/v3112_cmi.cmi \
bytecomp/lambda.cmi typing/ident.cmi asmcomp/debuginfo.cmi \
asmcomp/cmx_format.cmi typing/cmi_format.cmo asmcomp/clambda.cmi \
- parsing/asttypes.cmi
+ parsing/asttypes.cmi compat/3.11.2/v3112_cmx.cmi
compat/3.11.2/v3112_cmx.cmx: compat/3.11.2/v3112_types.cmx \
compat/3.11.2/v3112_cmo.cmx compat/3.11.2/v3112_cmi.cmx \
bytecomp/lambda.cmx typing/ident.cmx asmcomp/debuginfo.cmx \
asmcomp/cmx_format.cmi typing/cmi_format.cmx asmcomp/clambda.cmx \
- parsing/asttypes.cmi
+ parsing/asttypes.cmi compat/3.11.2/v3112_cmx.cmi
compat/3.11.2/v3112_types.cmo: typing/env.cmi
compat/3.11.2/v3112_types.cmx: typing/env.cmx
-compat/3.12.0/v3120_cmi.cmo: compat/3.12.0/v3120_types.cmo typing/types.cmi \
- typing/primitive.cmi typing/path.cmi parsing/location.cmi \
- typing/ident.cmi typing/cmi_format.cmo parsing/asttypes.cmi
-compat/3.12.0/v3120_cmi.cmx: compat/3.12.0/v3120_types.cmx typing/types.cmx \
- typing/primitive.cmx typing/path.cmx parsing/location.cmx \
- typing/ident.cmx typing/cmi_format.cmx parsing/asttypes.cmi
+compat/3.12.0/v3120_ast.cmi: compat/3.11.2/v3112_types.cmo \
+ parsing/parsetree.cmi parsing/asttypes.cmi
+compat/3.12.0/v3120_cmi.cmi: compat/3.12.0/v3120_types.cmo typing/types.cmi \
+ typing/primitive.cmi typing/path.cmi typing/ident.cmi \
+ typing/cmi_format.cmo
+compat/3.12.0/v3120_cmo.cmi: compat/3.12.0/v3120_types.cmo \
+ bytecomp/lambda.cmi bytecomp/cmo_format.cmi
+compat/3.12.0/v3120_cmx.cmi: bytecomp/cmo_format.cmi
+compat/3.12.0/v3120_ast.cmo: compat/3.12.0/v3120_types.cmo \
+ compat/3.11.2/v3112_ast.cmi parsing/parsetree.cmi parsing/longident.cmi \
+ parsing/location.cmi parsing/asttypes.cmi compat/3.12.0/v3120_ast.cmi
+compat/3.12.0/v3120_ast.cmx: compat/3.12.0/v3120_types.cmx \
+ compat/3.11.2/v3112_ast.cmx parsing/parsetree.cmi parsing/longident.cmx \
+ parsing/location.cmx parsing/asttypes.cmi compat/3.12.0/v3120_ast.cmi
+compat/3.12.0/v3120_cmi.cmo: compat/3.12.0/v3120_types.cmo \
+ compat/3.12.0/v3120_ast.cmi compat/3.11.2/v3112_cmi.cmi typing/types.cmi \
+ typing/primitive.cmi typing/path.cmi typing/ident.cmi \
+ typing/cmi_format.cmo parsing/asttypes.cmi compat/3.12.0/v3120_cmi.cmi
+compat/3.12.0/v3120_cmi.cmx: compat/3.12.0/v3120_types.cmx \
+ compat/3.12.0/v3120_ast.cmx compat/3.11.2/v3112_cmi.cmx typing/types.cmx \
+ typing/primitive.cmx typing/path.cmx typing/ident.cmx \
+ typing/cmi_format.cmx parsing/asttypes.cmi compat/3.12.0/v3120_cmi.cmi
compat/3.12.0/v3120_cmo.cmo: compat/3.12.0/v3120_types.cmo \
- compat/3.12.0/v3120_cmi.cmo typing/types.cmi typing/primitive.cmi \
+ compat/3.12.0/v3120_cmi.cmi compat/3.12.0/v3120_ast.cmi \
+ compat/3.11.2/v3112_cmo.cmi typing/types.cmi typing/primitive.cmi \
bytecomp/lambda.cmi typing/ident.cmi bytecomp/cmo_format.cmi \
- typing/cmi_format.cmo parsing/asttypes.cmi
+ parsing/asttypes.cmi compat/3.12.0/v3120_cmo.cmi
compat/3.12.0/v3120_cmo.cmx: compat/3.12.0/v3120_types.cmx \
- compat/3.12.0/v3120_cmi.cmx typing/types.cmx typing/primitive.cmx \
+ compat/3.12.0/v3120_cmi.cmx compat/3.12.0/v3120_ast.cmx \
+ compat/3.11.2/v3112_cmo.cmx typing/types.cmx typing/primitive.cmx \
bytecomp/lambda.cmx typing/ident.cmx bytecomp/cmo_format.cmi \
- typing/cmi_format.cmx parsing/asttypes.cmi
+ parsing/asttypes.cmi compat/3.12.0/v3120_cmo.cmi
compat/3.12.0/v3120_cmx.cmo: compat/3.12.0/v3120_types.cmo \
- compat/3.12.0/v3120_cmo.cmo compat/3.12.0/v3120_cmi.cmo \
- bytecomp/lambda.cmi typing/ident.cmi asmcomp/debuginfo.cmi \
- asmcomp/cmx_format.cmi typing/cmi_format.cmo asmcomp/clambda.cmi \
- parsing/asttypes.cmi
+ compat/3.12.0/v3120_cmo.cmi compat/3.12.0/v3120_cmi.cmi \
+ compat/3.11.2/v3112_cmx.cmi bytecomp/lambda.cmi typing/ident.cmi \
+ asmcomp/debuginfo.cmi asmcomp/cmx_format.cmi asmcomp/clambda.cmi \
+ parsing/asttypes.cmi compat/3.12.0/v3120_cmx.cmi
compat/3.12.0/v3120_cmx.cmx: compat/3.12.0/v3120_types.cmx \
compat/3.12.0/v3120_cmo.cmx compat/3.12.0/v3120_cmi.cmx \
- bytecomp/lambda.cmx typing/ident.cmx asmcomp/debuginfo.cmx \
- asmcomp/cmx_format.cmi typing/cmi_format.cmx asmcomp/clambda.cmx \
- parsing/asttypes.cmi
+ compat/3.11.2/v3112_cmx.cmx bytecomp/lambda.cmx typing/ident.cmx \
+ asmcomp/debuginfo.cmx asmcomp/cmx_format.cmi asmcomp/clambda.cmx \
+ parsing/asttypes.cmi compat/3.12.0/v3120_cmx.cmi
compat/3.12.0/v3120_types.cmo:
compat/3.12.0/v3120_types.cmx:
diff --git a/binary-compat/compat/3.11.2/v3112_ast.ml b/binary-compat/compat/3.11.2/v3112_ast.ml
index a448a8aee2..e7d39f4abf 100644
--- a/binary-compat/compat/3.11.2/v3112_ast.ml
+++ b/binary-compat/compat/3.11.2/v3112_ast.ml
@@ -1,5 +1,10 @@
exception TODO
+let ghost_loc loc =
+ { loc with Location.loc_ghost = true }
+
+ let string s = s
+
module AST = struct
@@ -46,6 +51,14 @@ module Asttypes = struct
T.Upto -> Upto
| T.Downto -> Downto
+ let closed_flag = Open
+
+ let override_flag = Override
+
+
+
+ let label s = s
+
end
module Lexing = struct
@@ -75,288 +88,399 @@ module Location = struct
end
+module Longident = struct
+
+ open Longident
+ module T = V3112_types.Longident
+
+ let rec t l =
+ match l with
+ T.Lident s -> Lident s
+ | T.Ldot (ll, s) -> Ldot (t ll, s)
+ | T.Lapply (l1, l2) -> Lapply (t l1, t l2)
+
+end
+
+
module Parsetree : sig
val signature :
- V3112_types.Parsetree.signature -> Parsetree.signature
+ V3112_types.Parsetree.signature -> Parsetree.signature
+
+ val structure :
+ V3112_types.Parsetree.structure -> Parsetree.structure
end = struct
- let signature x = raise TODO
-
-(*
-(* Abstract syntax tree produced by parsing *)
-
-open Asttypes
-
-(* Type expressions for the core language *)
-
-type core_type =
- { ptyp_desc: core_type_desc;
- ptyp_loc: Location.t }
-
-and core_type_desc =
- Ptyp_any
- | Ptyp_var of string
- | Ptyp_arrow of label * core_type * core_type
- | Ptyp_tuple of core_type list
- | Ptyp_constr of Longident.t * core_type list
- | Ptyp_object of core_field_type list
- | Ptyp_class of Longident.t * core_type list * label list
- | Ptyp_alias of core_type * string
- | Ptyp_variant of row_field list * bool * label list option
- | Ptyp_poly of string list * core_type
- | Ptyp_package of package_type
-
-and package_type = Longident.t * (string * core_type) list
-
-and core_field_type =
- { pfield_desc: core_field_desc;
- pfield_loc: Location.t }
-
-and core_field_desc =
- Pfield of string * core_type
- | Pfield_var
-
-and row_field =
- Rtag of label * bool * core_type list
- | Rinherit of core_type
-
-(* Type expressions for the class language *)
-
-type 'a class_infos =
- { pci_virt: virtual_flag;
- pci_params: string list * Location.t;
- pci_name: string;
- pci_expr: 'a;
- pci_variance: (bool * bool) list;
- pci_loc: Location.t }
-
-(* Value expressions for the core language *)
-
-type pattern =
- { ppat_desc: pattern_desc;
- ppat_loc: Location.t }
-
-and pattern_desc =
- Ppat_any
- | Ppat_var of string
- | Ppat_alias of pattern * string
- | Ppat_constant of constant
- | Ppat_tuple of pattern list
- | Ppat_construct of Longident.t * pattern option * bool
- | Ppat_variant of label * pattern option
- | Ppat_record of (Longident.t * pattern) list * closed_flag
- | Ppat_array of pattern list
- | Ppat_or of pattern * pattern
- | Ppat_constraint of pattern * core_type
- | Ppat_type of Longident.t
- | Ppat_lazy of pattern
-
-type expression =
- { pexp_desc: expression_desc;
- pexp_loc: Location.t }
-
-and expression_desc =
- Pexp_ident of Longident.t
- | Pexp_constant of constant
- | Pexp_let of rec_flag * (pattern * expression) list * expression
- | Pexp_function of label * expression option * (pattern * expression) list
- | Pexp_apply of expression * (label * expression) list
- | Pexp_match of expression * (pattern * expression) list
- | Pexp_try of expression * (pattern * expression) list
- | Pexp_tuple of expression list
- | Pexp_construct of Longident.t * expression option * bool
- | Pexp_variant of label * expression option
- | Pexp_record of (Longident.t * expression) list * expression option
- | Pexp_field of expression * Longident.t
- | Pexp_setfield of expression * Longident.t * expression
- | Pexp_array of expression list
- | Pexp_ifthenelse of expression * expression * expression option
- | Pexp_sequence of expression * expression
- | Pexp_while of expression * expression
- | Pexp_for of string * expression * expression * direction_flag * expression
- | Pexp_constraint of expression * core_type option * core_type option
- | Pexp_when of expression * expression
- | Pexp_send of expression * string
- | Pexp_new of Longident.t
- | Pexp_setinstvar of string * expression
- | Pexp_override of (string * expression) list
- | Pexp_letmodule of string * module_expr * expression
- | Pexp_assert of expression
- | Pexp_assertfalse
- | Pexp_lazy of expression
- | Pexp_poly of expression * core_type option
- | Pexp_object of class_structure
- | Pexp_newtype of string * expression
- | Pexp_pack of module_expr * package_type
- | Pexp_open of Longident.t * expression
-
-(* Value descriptions *)
-
-and value_description =
- { pval_type: core_type;
- pval_prim: string list }
-
-(* Type declarations *)
-
-and type_declaration =
- { ptype_params: string list;
- ptype_cstrs: (core_type * core_type * Location.t) list;
- ptype_kind: type_kind;
- ptype_private: private_flag;
- ptype_manifest: core_type option;
- ptype_variance: (bool * bool) list;
- ptype_loc: Location.t }
-
-and type_kind =
- Ptype_abstract
- | Ptype_variant of (string * core_type list * Location.t) list
- | Ptype_record of
- (string * mutable_flag * core_type * Location.t) list
-
-and exception_declaration = core_type list
-
-(* Type expressions for the class language *)
-
-and class_type =
- { pcty_desc: class_type_desc;
- pcty_loc: Location.t }
-
-and class_type_desc =
- Pcty_constr of Longident.t * core_type list
- | Pcty_signature of class_signature
- | Pcty_fun of label * core_type * class_type
-
-and class_signature = core_type * class_type_field list
-
-and class_type_field =
- Pctf_inher of class_type
- | Pctf_val of (string * mutable_flag * virtual_flag * core_type * Location.t)
- | Pctf_virt of (string * private_flag * core_type * Location.t)
- | Pctf_meth of (string * private_flag * core_type * Location.t)
- | Pctf_cstr of (core_type * core_type * Location.t)
-
-and class_description = class_type class_infos
-
-and class_type_declaration = class_type class_infos
-
-(* Value expressions for the class language *)
-
-and class_expr =
- { pcl_desc: class_expr_desc;
- pcl_loc: Location.t }
-
-and class_expr_desc =
- Pcl_constr of Longident.t * core_type list
- | Pcl_structure of class_structure
- | Pcl_fun of label * expression option * pattern * class_expr
- | Pcl_apply of class_expr * (label * expression) list
- | Pcl_let of rec_flag * (pattern * expression) list * class_expr
- | Pcl_constraint of class_expr * class_type
-
-and class_structure = pattern * class_field list
-
-and class_field =
- Pcf_inher of override_flag * class_expr * string option
- | Pcf_valvirt of (string * mutable_flag * core_type * Location.t)
- | Pcf_val of (string * mutable_flag * override_flag * expression * Location.t)
- | Pcf_virt of (string * private_flag * core_type * Location.t)
- | Pcf_meth of (string * private_flag *override_flag * expression * Location.t)
- | Pcf_cstr of (core_type * core_type * Location.t)
- | Pcf_let of rec_flag * (pattern * expression) list * Location.t
- | Pcf_init of expression
-
-and class_declaration = class_expr class_infos
-
-(* Type expressions for the module language *)
-
-and module_type =
- { pmty_desc: module_type_desc;
- pmty_loc: Location.t }
-
-and module_type_desc =
- Pmty_ident of Longident.t
- | Pmty_signature of signature
- | Pmty_functor of string * module_type * module_type
- | Pmty_with of module_type * (Longident.t * with_constraint) list
- | Pmty_typeof of module_expr
-
-and signature = signature_item list
-
-and signature_item =
- { psig_desc: signature_item_desc;
- psig_loc: Location.t }
-
-and signature_item_desc =
- Psig_value of string * value_description
- | Psig_type of (string * type_declaration) list
- | Psig_exception of string * exception_declaration
- | Psig_module of string * module_type
- | Psig_recmodule of (string * module_type) list
- | Psig_modtype of string * modtype_declaration
- | Psig_open of Longident.t
- | Psig_include of module_type
- | Psig_class of class_description list
- | Psig_class_type of class_type_declaration list
-
-and modtype_declaration =
- Pmodtype_abstract
- | Pmodtype_manifest of module_type
-
-and with_constraint =
- Pwith_type of type_declaration
- | Pwith_module of Longident.t
- | Pwith_typesubst of type_declaration
- | Pwith_modsubst of Longident.t
+ open Asttypes
+
+ open Parsetree
+ module T = V3112_types.Parsetree
+
+ let signature s = raise TODO
+
+ let rec core_type c =
+ { ptyp_desc = core_type_desc c.T.ptyp_desc;
+ ptyp_loc = Location.t c.T.ptyp_loc }
+
+ and core_type_desc c =
+ match c with
+ T.Ptyp_any -> Ptyp_any
+ | T.Ptyp_var string -> Ptyp_var string
+ | T.Ptyp_arrow (l, c1, c2) ->
+ Ptyp_arrow (label l, core_type c1, core_type c2)
+ | T.Ptyp_tuple list -> Ptyp_tuple (List.map core_type list)
+ | T.Ptyp_constr (l, list) ->
+ Ptyp_constr (Longident.t l, List.map core_type list)
+ | T.Ptyp_object list -> Ptyp_object (List.map core_field_type list)
+ | T.Ptyp_class (l, clist, llist) ->
+ Ptyp_class (Longident.t l, List.map core_type clist, List.map label llist)
+ | T.Ptyp_alias (c1, string) -> Ptyp_alias (core_type c1, string)
+ | T.Ptyp_variant (list, bool, option) ->
+ Ptyp_variant (List.map row_field list, bool,
+ match option with
+ None -> None
+ | Some list -> Some (List.map label list))
+ | T.Ptyp_poly (list, c1) -> Ptyp_poly (list, core_type c1)
+
+and package_type (l, list) =
+ (Longident.t l,List.map (fun (s,c) -> (s, core_type c)) list)
+
+and core_field_type c =
+ { pfield_desc = core_field_desc c.T.pfield_desc;
+ pfield_loc = Location.t c.T.pfield_loc;
+ }
+
+and core_field_desc c =
+ match c with
+ T.Pfield (s, c1) -> Pfield (s, core_type c1)
+ | T.Pfield_var -> Pfield_var
+
+and row_field r =
+ match r with
+ T.Rtag (l, bool, list) ->
+ Rtag (label l, bool, List.map core_type list)
+ | T.Rinherit c -> Rinherit (core_type c)
+
+let class_infos a c =
+ { pci_virt = virtual_flag c.T.pci_virt;
+ pci_params = (let (list, l) = c.T.pci_params in
+ (list, Location.t l));
+ pci_name = c.T.pci_name;
+ pci_expr = a c.T.pci_expr;
+ pci_variance = c.T.pci_variance;
+ pci_loc = Location.t c.T.pci_loc;
+ }
+
+
+let option f x =
+ match x with
+ None -> None
+ | Some s -> Some (f s)
+
+let rec pattern p =
+ { ppat_desc = pattern_desc p.T.ppat_desc;
+ ppat_loc = Location.t p.T.ppat_loc }
+
+and pattern_desc p =
+ match p with
+ T.Ppat_any -> Ppat_any
+ | T.Ppat_var s -> Ppat_var s
+ | T.Ppat_alias (p1, s) -> Ppat_alias (pattern p1, s)
+ | T.Ppat_constant c -> Ppat_constant (constant c)
+ | T.Ppat_tuple list -> Ppat_tuple (List.map pattern list)
+ | T.Ppat_construct (l, o, bool) ->
+ Ppat_construct (Longident.t l, option pattern o, bool)
+ | T.Ppat_variant (l, o) ->
+ Ppat_variant (label l, option pattern o)
+ | T.Ppat_record list ->
+ Ppat_record (List.map (fun (l, p) ->
+ (Longident.t l, pattern p)) list, closed_flag)
+ | T.Ppat_array list -> Ppat_array (List.map pattern list)
+ | T.Ppat_or (p1, p2) -> Ppat_or (pattern p1, pattern p2)
+ | T.Ppat_constraint (p1, c) -> Ppat_constraint (pattern p1, core_type c)
+ | T.Ppat_type l -> Ppat_type (Longident.t l)
+ | T.Ppat_lazy p1 -> Ppat_lazy (pattern p1)
+
+let ghexp d loc = { pexp_desc = d; pexp_loc = ghost_loc loc; }
+let ghtyp d loc = { ptyp_desc = d; ptyp_loc = ghost_loc loc; }
+let mkexp exp loc = { pexp_desc = exp; pexp_loc = loc }
+
+let rec expression e =
+ let pexp_loc = Location.t e.T.pexp_loc in
+ let pexp_desc = expression_desc e.T.pexp_desc
+ in
+ { pexp_desc; pexp_loc }
+
+and expression_desc e =
+ match e with
+ T.Pexp_ident l -> Pexp_ident (Longident.t l)
+ | T.Pexp_constant c -> Pexp_constant (constant c)
+ | T.Pexp_let (r, list, e) ->
+ Pexp_let (rec_flag r,
+ List.map (fun (p,e) ->
+ (pattern p, expression e)) list, expression e)
+ | T.Pexp_function (l, o, list) ->
+ Pexp_function (label l, option expression o,
+ List.map (fun (p,e) -> (pattern p, expression e)) list)
+ | T.Pexp_apply (e, list) ->
+ Pexp_apply (expression e, List.map (fun (l, e) ->
+ (label l, expression e)) list)
+ | T.Pexp_match (e, list) ->
+ Pexp_match (expression e,
+ List.map (fun (p,e) -> (pattern p, expression e)) list)
+ | T.Pexp_try (e, list) ->
+ Pexp_try (expression e,
+ List.map (fun (p,e) -> (pattern p, expression e)) list)
+ | T.Pexp_tuple list ->
+ Pexp_tuple (List.map expression list)
+ | T.Pexp_construct (l, o, bool) ->
+ Pexp_construct (Longident.t l, option expression o, bool)
+ | T.Pexp_variant (l, o) ->
+ Pexp_variant (label l, option expression o)
+ | T.Pexp_record (list, o) ->
+ Pexp_record (List.map (fun (l, e) ->
+ (Longident.t l, expression e)) list, option expression o)
+ | T.Pexp_field (e, l) ->
+ Pexp_field (expression e, Longident.t l)
+ | T.Pexp_setfield (e1, l, e2) ->
+ Pexp_setfield (expression e1, Longident.t l, expression e2)
+ | T.Pexp_array list -> Pexp_array (List.map expression list)
+ | T.Pexp_ifthenelse (e1, e2, o) ->
+ Pexp_ifthenelse (expression e1, expression e2, option expression o)
+ | T.Pexp_sequence (e1, e2) ->
+ Pexp_sequence (expression e1, expression e2)
+ | T.Pexp_while (e1, e2) ->
+ Pexp_while (expression e1, expression e2)
+ | T.Pexp_for (s, e1, e2, d, e3) ->
+ Pexp_for (s, expression e1, expression e2,
+ direction_flag d, expression e3)
+ | T.Pexp_constraint (e1, o1, o2) ->
+ Pexp_constraint (expression e1, option core_type o1, option core_type o2)
+ | T.Pexp_when (e1, e2) -> Pexp_when (expression e1, expression e2)
+ | T.Pexp_send (e1, s) -> Pexp_send (expression e1, s)
+ | T.Pexp_new l -> Pexp_new (Longident.t l)
+ | T.Pexp_setinstvar (s, e) -> Pexp_setinstvar (s, expression e)
+ | T.Pexp_override list ->
+ Pexp_override (List.map (fun (s, e) -> (s, expression e)) list)
+ | T.Pexp_letmodule (s, m, e) ->
+ Pexp_letmodule (s, module_expr m, expression e)
+ | T.Pexp_assert e -> Pexp_assert (expression e)
+ | T.Pexp_assertfalse -> Pexp_assertfalse
+ | T.Pexp_lazy e -> Pexp_lazy (expression e)
+ | T.Pexp_poly (e, o) -> Pexp_poly (expression e, option core_type o)
+ | T.Pexp_object cl -> Pexp_object (class_structure cl)
+
+and value_description v =
+ {
+ pval_type = core_type v.T.pval_type;
+ pval_prim = v.T.pval_prim;
+ }
+
+
+and type_declaration t =
+ { ptype_params = t.T.ptype_params;
+ ptype_cstrs = List.map (fun (c1, c2, l) ->
+ (core_type c1, core_type c2, Location.t l)) t.T.ptype_cstrs;
+ ptype_kind = type_kind t.T.ptype_kind;
+ ptype_private = private_flag t.T.ptype_private;
+ ptype_manifest = option core_type t.T.ptype_manifest;
+ ptype_variance = t.T.ptype_variance;
+ ptype_loc = Location.t t.T.ptype_loc;
+ }
+
+and type_kind t =
+ match t with
+ T.Ptype_abstract -> Ptype_abstract
+ | T.Ptype_variant list ->
+ Ptype_variant (List.map (fun (s, list, l) ->
+ (s, List.map core_type list, Location.t l)) list)
+ | T.Ptype_record list ->
+ Ptype_record (List.map (fun (s,m,c,l) ->
+ (s, mutable_flag m, core_type c, Location.t l)) list)
+
+and exception_declaration list = List.map core_type list
+
+and class_type c =
+ { pcty_desc = class_type_desc c.T.pcty_desc;
+ pcty_loc = Location.t c.T.pcty_loc; }
+
+and class_type_desc c =
+ match c with
+ T.Pcty_constr (l, list) ->
+ Pcty_constr (Longident.t l, List.map core_type list)
+ | T.Pcty_signature c -> Pcty_signature (class_signature c)
+ | T.Pcty_fun (l, ct, cl) ->
+ Pcty_fun (label l, core_type ct, class_type cl)
+
+and class_signature (c, list) =
+ (core_type c, List.map class_type_field list)
+
+and class_type_field c =
+ match c with
+ T.Pctf_inher c -> Pctf_inher (class_type c)
+ | T.Pctf_val (s, m, v, c, l) ->
+ Pctf_val (s, mutable_flag m, virtual_flag v, core_type c, Location.t l)
+ | T.Pctf_virt (s, p, c, l) ->
+ Pctf_virt (s, private_flag p, core_type c, Location.t l)
+ | T.Pctf_meth (s, p, c, l) ->
+ Pctf_meth (s, private_flag p, core_type c, Location.t l)
+ | T.Pctf_cstr (c1, c2, l) ->
+ Pctf_cstr (core_type c1, core_type c2, Location.t l)
+
+and class_description c = class_infos class_type c
+
+and class_type_declaration c = class_infos class_type c
+
+and class_expr c =
+ { pcl_desc = class_expr_desc c.T.pcl_desc;
+ pcl_loc = Location.t c.T.pcl_loc; }
+
+and class_expr_desc c =
+ match c with
+ T.Pcl_constr (l, list) ->
+ Pcl_constr (Longident.t l, List.map core_type list)
+ | T.Pcl_structure c ->
+ Pcl_structure (class_structure c)
+ | T.Pcl_fun (l, o, p, c) ->
+ Pcl_fun (label l, option expression o, pattern p, class_expr c)
+ | T.Pcl_apply (c, list) ->
+ Pcl_apply (class_expr c, List.map (fun (l, e) ->
+ (label l, expression e)) list)
+ | T.Pcl_let (r, list, c) ->
+ Pcl_let (rec_flag r,
+ List.map (fun (p,e) -> (pattern p, expression e)) list, class_expr c)
+ | T.Pcl_constraint (c1, c2) ->
+ Pcl_constraint (class_expr c1, class_type c2)
+
+and class_structure (p, list) =
+ (pattern p, List.map class_field list)
+
+and class_field c =
+ match c with
+ T.Pcf_inher (e, op) ->
+ Pcf_inher (override_flag, class_expr e, option string op)
+ | T.Pcf_valvirt (s, mf, c, l) ->
+ Pcf_valvirt (s, mutable_flag mf, core_type c, Location.t l)
+ | T.Pcf_val (s, mf, e, loc) ->
+ Pcf_val (s, mutable_flag mf, override_flag, expression e, Location.t loc)
+ | T.Pcf_virt (s, pf, c, loc) ->
+ Pcf_virt (s, private_flag pf, core_type c, Location.t loc)
+ | T.Pcf_meth (s, pf, e, loc) ->
+ Pcf_meth (s , private_flag pf, override_flag, expression e, Location.t loc)
+ | T.Pcf_cstr (c1, c2, loc) ->
+ Pcf_cstr (core_type c1, core_type c2, Location.t loc)
+ | T.Pcf_let (r, list, loc) ->
+ Pcf_let ( rec_flag r, List.map (fun (pat, e) ->
+ (pattern pat, expression e)) list, Location.t loc)
+ | T.Pcf_init e -> Pcf_init (expression e)
+
+and class_declaration list = class_infos class_expr list
+
+and module_type m =
+ { pmty_desc = module_type_desc m.T.pmty_desc;
+ pmty_loc = Location.t m.T.pmty_loc }
+
+and module_type_desc m =
+ match m with
+ T.Pmty_ident l -> Pmty_ident (Longident.t l)
+ | T.Pmty_signature sg -> Pmty_signature (signature sg)
+ | T.Pmty_functor (s, mt1, mt2) ->
+ Pmty_functor (s, module_type mt1, module_type mt2)
+ | T.Pmty_with (mt, list) ->
+ Pmty_with (module_type mt, List.map (fun (l, w) ->
+ (Longident.t l, with_constraint w)) list)
+
+and signature list = List.map signature_item list
+
+and signature_item sg =
+ { psig_desc = signature_item_desc sg.T.psig_desc;
+ psig_loc = Location.t sg.T.psig_loc }
+
+and signature_item_desc si =
+ match si with
+ T.Psig_value (s, v) ->
+ Psig_value (s, value_description v)
+ | T.Psig_type list ->
+ Psig_type (List.map (fun (s, t) -> (string s, type_declaration t)) list)
+ | T.Psig_exception (s, e) ->
+ Psig_exception (s, exception_declaration e)
+ | T.Psig_module (s, mt) ->
+ Psig_module (s, module_type mt)
+ | T.Psig_recmodule list ->
+ Psig_recmodule (List.map (fun (s, mt) -> (s, module_type mt)) list)
+ | T.Psig_modtype (s, md) ->
+ Psig_modtype (s, modtype_declaration md)
+ | T.Psig_open l -> Psig_open (Longident.t l)
+ | T.Psig_include mt -> Psig_include (module_type mt)
+ | T.Psig_class list ->
+ Psig_class (List.map class_description list)
+ | T.Psig_class_type list -> Psig_class_type (List.map class_type_declaration list)
+
+and modtype_declaration m =
+ match m with
+ T.Pmodtype_abstract -> Pmodtype_abstract
+ | T.Pmodtype_manifest mt -> Pmodtype_manifest (module_type mt)
+
+and with_constraint w =
+ match w with
+ T.Pwith_type t -> Pwith_type (type_declaration t)
+ | T.Pwith_module l -> Pwith_module (Longident.t l)
(* value expressions for the module language *)
-and module_expr =
- { pmod_desc: module_expr_desc;
- pmod_loc: Location.t }
-
-and module_expr_desc =
- Pmod_ident of Longident.t
- | Pmod_structure of structure
- | Pmod_functor of string * module_type * module_expr
- | Pmod_apply of module_expr * module_expr
- | Pmod_constraint of module_expr * module_type
- | Pmod_unpack of expression * package_type
-
-and structure = structure_item list
-
-and structure_item =
- { pstr_desc: structure_item_desc;
- pstr_loc: Location.t }
-
-and structure_item_desc =
- Pstr_eval of expression
- | Pstr_value of rec_flag * (pattern * expression) list
- | Pstr_primitive of string * value_description
- | Pstr_type of (string * type_declaration) list
- | Pstr_exception of string * exception_declaration
- | Pstr_exn_rebind of string * Longident.t
- | Pstr_module of string * module_expr
- | Pstr_recmodule of (string * module_type * module_expr) list
- | Pstr_modtype of string * module_type
- | Pstr_open of Longident.t
- | Pstr_class of class_declaration list
- | Pstr_class_type of class_type_declaration list
- | Pstr_include of module_expr
-
+and module_expr me =
+ let pmod_loc = Location.t me.T.pmod_loc in
+ let pmod_desc = module_expr_desc me.T.pmod_desc in
+ { pmod_desc; pmod_loc }
+
+and module_expr_desc me =
+ match me with
+ T.Pmod_ident l -> Pmod_ident (Longident.t l)
+ | T.Pmod_structure (s) -> Pmod_structure (structure s)
+ | T.Pmod_functor (s, mt, me) ->
+ Pmod_functor (s, module_type mt, module_expr me)
+ | T.Pmod_apply (me1, me2) -> Pmod_apply (module_expr me1, module_expr me2)
+ | T.Pmod_constraint (me, mt) -> Pmod_constraint (module_expr me, module_type mt)
+
+and structure list = List.map structure_item list
+
+and structure_item si =
+ { pstr_desc = structure_item_desc si.T.pstr_desc;
+ pstr_loc = Location.t si.T.pstr_loc }
+
+and structure_item_desc si =
+ match si with
+ T.Pstr_eval e -> Pstr_eval (expression e)
+ | T.Pstr_value (r, list) -> Pstr_value (rec_flag r,
+ List.map (fun (pat, e) -> (pattern pat, expression e)) list)
+ | T.Pstr_primitive (s, v) -> Pstr_primitive (s, value_description v)
+ | T.Pstr_type (list) -> Pstr_type (List.map
+ (fun (s, t) -> (s, type_declaration t)) list)
+ | T.Pstr_exception (s, e) -> Pstr_exception (s, exception_declaration e)
+ | T.Pstr_exn_rebind (s, l) -> Pstr_exn_rebind (s, Longident.t l)
+ | T.Pstr_module (s, me) -> Pstr_module (s, module_expr me)
+ | T.Pstr_recmodule list -> Pstr_recmodule (List.map (
+ fun (s, mt, me) -> (s, module_type mt, module_expr me)) list)
+ | T.Pstr_modtype (s, mt) -> Pstr_modtype (s, module_type mt)
+ | T.Pstr_open (l) -> Pstr_open (Longident.t l)
+ | T.Pstr_class (list) -> Pstr_class (List.map class_declaration list)
+ | T.Pstr_class_type (list) -> Pstr_class_type (List.map class_type_declaration list)
+ | T.Pstr_include (me) -> Pstr_include (module_expr me)
+
+ (*
(* Toplevel phrases *)
type toplevel_phrase =
Ptop_def of structure
- | Ptop_dir of string * directive_argument
+ | T.Ptop_dir (a) -> Ptop_dir (string, directive_argument
and directive_argument =
Pdir_none
- | Pdir_string of string
- | Pdir_int of int
- | Pdir_ident of Longident.t
- | Pdir_bool of bool
+ | T.Pdir_string (a) -> Pdir_string (string
+ | T.Pdir_int (a) -> Pdir_int (int
+ | T.Pdir_ident (a) -> Pdir_ident (Longident.t
+ | T.Pdir_bool (a) -> Pdir_bool (bool
*)
end
@@ -370,3 +494,12 @@ let input_intf_file ic magic =
let v = (input_value ic : V3112_types.Parsetree.signature) in
AST.Parsetree.signature v
end
+
+
+let input_impl_file ic magic =
+ if magic <> V3112_types.ast_impl_magic_number then
+ raise Cmi_format.No_such_magic
+ else begin
+ let v = (input_value ic : V3112_types.Parsetree.structure) in
+ AST.Parsetree.structure v
+ end
diff --git a/binary-compat/compat/3.11.2/v3112_ast.mli b/binary-compat/compat/3.11.2/v3112_ast.mli
new file mode 100644
index 0000000000..5ddff68a19
--- /dev/null
+++ b/binary-compat/compat/3.11.2/v3112_ast.mli
@@ -0,0 +1,18 @@
+
+module AST : sig
+
+ module Asttypes : sig
+ val constant : V3112_types.Asttypes.constant -> Asttypes.constant
+ val virtual_flag : V3112_types.Asttypes.virtual_flag -> Asttypes.virtual_flag
+ val private_flag : V3112_types.Asttypes.private_flag -> Asttypes.private_flag
+ val rec_flag : V3112_types.Asttypes.rec_flag -> Asttypes.rec_flag
+ val mutable_flag : V3112_types.Asttypes.mutable_flag -> Asttypes.mutable_flag
+ val direction_flag : V3112_types.Asttypes.direction_flag -> Asttypes.direction_flag
+ end
+
+(* functor(S: sig end) -> sig end *)
+ end
+
+val input_intf_file : in_channel -> string -> Parsetree.signature
+val input_impl_file : in_channel -> string -> Parsetree.structure
+ \ No newline at end of file
diff --git a/binary-compat/compat/3.11.2/v3112_cmi.mli b/binary-compat/compat/3.11.2/v3112_cmi.mli
new file mode 100644
index 0000000000..d74c1f9ac3
--- /dev/null
+++ b/binary-compat/compat/3.11.2/v3112_cmi.mli
@@ -0,0 +1,31 @@
+
+module CMI : sig
+ module Ident :
+ sig
+ val reset : unit -> unit
+ val t : V3112_types.Ident.t -> Ident.t
+ end
+ module Path : sig val t : V3112_types.Path.t -> Path.t end
+ module Primitive :
+ sig
+ val description :
+ V3112_types.Primitive.description -> Primitive.description
+ end
+ module Types :
+ sig
+ val reset : unit -> unit
+ val signature_item :
+ V3112_types.Types.signature_item -> Types.signature_item
+ val record_representation :
+ V3112_types.Types.record_representation ->
+ Types.record_representation
+ end
+ module Cmi_format :
+ sig
+ val pers_flags :
+ V3112_types.Cmi_format.pers_flags -> Cmi_format.pers_flags
+ end
+ end
+
+
+val input_cmi_file : in_channel -> string -> Cmi_format.cmi_file
diff --git a/binary-compat/compat/3.11.2/v3112_cmo.mli b/binary-compat/compat/3.11.2/v3112_cmo.mli
new file mode 100644
index 0000000000..82c9667687
--- /dev/null
+++ b/binary-compat/compat/3.11.2/v3112_cmo.mli
@@ -0,0 +1,25 @@
+
+module CMO : sig
+ module Lambda :
+ sig
+ val structured_constant :
+ V3112_types.Lambda.structured_constant ->
+ Lambda.structured_constant
+ val primitive :
+ V3112_types.Lambda.primitive -> Lambda.primitive
+ val meth_kind :
+ V3112_types.Lambda.meth_kind -> Lambda.meth_kind
+ end
+ module Cmo_format :
+ sig
+ val compilation_unit :
+ V3112_types.Cmo_format.compilation_unit ->
+ Cmo_format.compilation_unit
+ val library :
+ V3112_types.Cmo_format.library -> Cmo_format.library
+ end
+ end
+
+ (* functor(M : sig end) -> sig end *)
+
+val input_cmo_file : in_channel -> string -> Cmo_format.cmo_unit
diff --git a/binary-compat/compat/3.11.2/v3112_cmx.mli b/binary-compat/compat/3.11.2/v3112_cmx.mli
new file mode 100644
index 0000000000..9a8e0cb112
--- /dev/null
+++ b/binary-compat/compat/3.11.2/v3112_cmx.mli
@@ -0,0 +1,4 @@
+
+module CMX : functor(M : sig end) -> sig end
+
+val input_cmx_file : in_channel -> string -> Cmo_format.cmo_unit
diff --git a/binary-compat/compat/3.12.0/v3120_ast.ml b/binary-compat/compat/3.12.0/v3120_ast.ml
index c860a607de..9ff237c026 100644
--- a/binary-compat/compat/3.12.0/v3120_ast.ml
+++ b/binary-compat/compat/3.12.0/v3120_ast.ml
@@ -1,5 +1,10 @@
exception TODO
+let ghost_loc loc =
+ { loc with Location.loc_ghost = true }
+
+ let string s = s
+
module AST = struct
@@ -46,6 +51,14 @@ module Asttypes = struct
T.Upto -> Upto
| T.Downto -> Downto
+ let closed_flag cf = match cf with
+ T.Closed -> Closed | T.Open -> Open
+
+ let override_flag ovf =
+ match ovf with
+ T.Override -> Override
+ | T.Fresh -> Fresh
+
let label s = s
end
@@ -94,6 +107,8 @@ end
module Parsetree : sig
val signature :
V3120_types.Parsetree.signature -> Parsetree.signature
+ val structure :
+ V3120_types.Parsetree.structure -> Parsetree.structure
end = struct
@@ -147,243 +162,347 @@ and row_field r =
T.Rtag (l, bool, list) ->
Rtag (label l, bool, List.map core_type list)
| T.Rinherit c -> Rinherit (core_type c)
+
+let class_infos a c =
+ { pci_virt = virtual_flag c.T.pci_virt;
+ pci_params = (let (list, l) = c.T.pci_params in
+ (list, Location.t l));
+ pci_name = c.T.pci_name;
+ pci_expr = a c.T.pci_expr;
+ pci_variance = c.T.pci_variance;
+ pci_loc = Location.t c.T.pci_loc;
+ }
-(*
-(* Type expressions for the class language *)
-
-type 'a class_infos =
- { pci_virt: virtual_flag;
- pci_params: string list * Location.t;
- pci_name: string;
- pci_expr: 'a;
- pci_variance: (bool * bool) list;
- pci_loc: Location.t }
-
-(* Value expressions for the core language *)
-
-type pattern =
- { ppat_desc: pattern_desc;
- ppat_loc: Location.t }
-
-and pattern_desc =
- Ppat_any
- | T.Ppat_var of string
- | T.Ppat_alias of pattern * string
- | T.Ppat_constant of constant
- | T.Ppat_tuple of pattern list
- | T.Ppat_construct of Longident.t * pattern option * bool
- | T.Ppat_variant of label * pattern option
- | T.Ppat_record of (Longident.t * pattern) list * closed_flag
- | T.Ppat_array of pattern list
- | T.Ppat_or of pattern * pattern
- | T.Ppat_constraint of pattern * core_type
- | T.Ppat_type of Longident.t
- | T.Ppat_lazy of pattern
-
-type expression =
- { pexp_desc: expression_desc;
- pexp_loc: Location.t }
-
-and expression_desc =
- Pexp_ident of Longident.t
- | T.Pexp_constant of constant
- | T.Pexp_let of rec_flag * (pattern * expression) list * expression
- | T.Pexp_function of label * expression option * (pattern * expression) list
- | T.Pexp_apply of expression * (label * expression) list
- | T.Pexp_match of expression * (pattern * expression) list
- | T.Pexp_try of expression * (pattern * expression) list
- | T.Pexp_tuple of expression list
- | T.Pexp_construct of Longident.t * expression option * bool
- | T.Pexp_variant of label * expression option
- | T.Pexp_record of (Longident.t * expression) list * expression option
- | T.Pexp_field of expression * Longident.t
- | T.Pexp_setfield of expression * Longident.t * expression
- | T.Pexp_array of expression list
- | T.Pexp_ifthenelse of expression * expression * expression option
- | T.Pexp_sequence of expression * expression
- | T.Pexp_while of expression * expression
- | T.Pexp_for of string * expression * expression * direction_flag * expression
- | T.Pexp_constraint of expression * core_type option * core_type option
- | T.Pexp_when of expression * expression
- | T.Pexp_send of expression * string
- | T.Pexp_new of Longident.t
- | T.Pexp_setinstvar of string * expression
- | T.Pexp_override of (string * expression) list
- | T.Pexp_letmodule of string * module_expr * expression
- | T.Pexp_assert of expression
- | T.Pexp_assertfalse
- | T.Pexp_lazy of expression
- | T.Pexp_poly of expression * core_type option
- | T.Pexp_object of class_structure
- | T.Pexp_newtype of string * expression
- | T.Pexp_pack of module_expr * package_type
- | T.Pexp_open of Longident.t * expression
-
-(* Value descriptions *)
-
-and value_description =
- { pval_type: core_type;
- pval_prim: string list }
-
-(* Type declarations *)
-
-and type_declaration =
- { ptype_params: string list;
- ptype_cstrs: (core_type * core_type * Location.t) list;
- ptype_kind: type_kind;
- ptype_private: private_flag;
- ptype_manifest: core_type option;
- ptype_variance: (bool * bool) list;
- ptype_loc: Location.t }
-
-and type_kind =
- Ptype_abstract
- | T.Ptype_variant of (string * core_type list * Location.t) list
- | T.Ptype_record of
- (string * mutable_flag * core_type * Location.t) list
-
-and exception_declaration = core_type list
-
-(* Type expressions for the class language *)
-
-and class_type =
- { pcty_desc: class_type_desc;
- pcty_loc: Location.t }
-
-and class_type_desc =
- Pcty_constr of Longident.t * core_type list
- | T.Pcty_signature of class_signature
- | T.Pcty_fun of label * core_type * class_type
-
-and class_signature = core_type * class_type_field list
-
-and class_type_field =
- Pctf_inher of class_type
- | T.Pctf_val of (string * mutable_flag * virtual_flag * core_type * Location.t)
- | T.Pctf_virt of (string * private_flag * core_type * Location.t)
- | T.Pctf_meth of (string * private_flag * core_type * Location.t)
- | T.Pctf_cstr of (core_type * core_type * Location.t)
-
-and class_description = class_type class_infos
-
-and class_type_declaration = class_type class_infos
-
-(* Value expressions for the class language *)
-
-and class_expr =
- { pcl_desc: class_expr_desc;
- pcl_loc: Location.t }
-
-and class_expr_desc =
- Pcl_constr of Longident.t * core_type list
- | T.Pcl_structure of class_structure
- | T.Pcl_fun of label * expression option * pattern * class_expr
- | T.Pcl_apply of class_expr * (label * expression) list
- | T.Pcl_let of rec_flag * (pattern * expression) list * class_expr
- | T.Pcl_constraint of class_expr * class_type
-
-and class_structure = pattern * class_field list
-
-and class_field =
- Pcf_inher of override_flag * class_expr * string option
- | T.Pcf_valvirt of (string * mutable_flag * core_type * Location.t)
- | T.Pcf_val of (string * mutable_flag * override_flag * expression * Location.t)
- | T.Pcf_virt of (string * private_flag * core_type * Location.t)
- | T.Pcf_meth of (string * private_flag *override_flag * expression * Location.t)
- | T.Pcf_cstr of (core_type * core_type * Location.t)
- | T.Pcf_let of rec_flag * (pattern * expression) list * Location.t
- | T.Pcf_init of expression
-
-and class_declaration = class_expr class_infos
-
-(* Type expressions for the module language *)
-
-and module_type =
- { pmty_desc: module_type_desc;
- pmty_loc: Location.t }
-
-and module_type_desc =
- Pmty_ident of Longident.t
- | T.Pmty_signature of signature
- | T.Pmty_functor of string * module_type * module_type
- | T.Pmty_with of module_type * (Longident.t * with_constraint) list
- | T.Pmty_typeof of module_expr
-
-and signature = signature_item list
-
-and signature_item =
- { psig_desc: signature_item_desc;
- psig_loc: Location.t }
-
-and signature_item_desc =
- Psig_value of string * value_description
- | T.Psig_type of (string * type_declaration) list
- | T.Psig_exception of string * exception_declaration
- | T.Psig_module of string * module_type
- | T.Psig_recmodule of (string * module_type) list
- | T.Psig_modtype of string * modtype_declaration
- | T.Psig_open of Longident.t
- | T.Psig_include of module_type
- | T.Psig_class of class_description list
- | T.Psig_class_type of class_type_declaration list
-
-and modtype_declaration =
- Pmodtype_abstract
- | T.Pmodtype_manifest of module_type
-
-and with_constraint =
- Pwith_type of type_declaration
- | T.Pwith_module of Longident.t
- | T.Pwith_typesubst of type_declaration
- | T.Pwith_modsubst of Longident.t
-(* value expressions for the module language *)
+let option f x =
+ match x with
+ None -> None
+ | Some s -> Some (f s)
+
+let rec pattern p =
+ { ppat_desc = pattern_desc p.T.ppat_desc;
+ ppat_loc = Location.t p.T.ppat_loc }
+
+and pattern_desc p =
+ match p with
+ T.Ppat_any -> Ppat_any
+ | T.Ppat_var s -> Ppat_var s
+ | T.Ppat_alias (p1, s) -> Ppat_alias (pattern p1, s)
+ | T.Ppat_constant c -> Ppat_constant (constant c)
+ | T.Ppat_tuple list -> Ppat_tuple (List.map pattern list)
+ | T.Ppat_construct (l, o, bool) ->
+ Ppat_construct (Longident.t l, option pattern o, bool)
+ | T.Ppat_variant (l, o) ->
+ Ppat_variant (label l, option pattern o)
+ | T.Ppat_record (list, cl) ->
+ Ppat_record (List.map (fun (l, p) ->
+ (Longident.t l, pattern p)) list, closed_flag cl)
+ | T.Ppat_array list -> Ppat_array (List.map pattern list)
+ | T.Ppat_or (p1, p2) -> Ppat_or (pattern p1, pattern p2)
+ | T.Ppat_constraint (p1, c) -> Ppat_constraint (pattern p1, core_type c)
+ | T.Ppat_type l -> Ppat_type (Longident.t l)
+ | T.Ppat_lazy p1 -> Ppat_lazy (pattern p1)
+
+let ghexp d loc = { pexp_desc = d; pexp_loc = ghost_loc loc; }
+let ghtyp d loc = { ptyp_desc = d; ptyp_loc = ghost_loc loc; }
+let mkexp exp loc = { pexp_desc = exp; pexp_loc = loc }
+
+let rec expression e =
+ let pexp_loc = Location.t e.T.pexp_loc in
+ let pexp_desc =
+ match e.T.pexp_desc with
+ T.Pexp_pack (m, p) ->
+ Pexp_constraint (
+ ghexp (Pexp_pack (module_expr m)) pexp_loc,
+ Some (ghtyp (Ptyp_package (package_type p)) pexp_loc), None)
+ | _ -> expression_desc e.T.pexp_desc
+ in
+ { pexp_desc; pexp_loc }
+
+and expression_desc e =
+ match e with
+ T.Pexp_ident l -> Pexp_ident (Longident.t l)
+ | T.Pexp_constant c -> Pexp_constant (constant c)
+ | T.Pexp_let (r, list, e) ->
+ Pexp_let (rec_flag r,
+ List.map (fun (p,e) ->
+ (pattern p, expression e)) list, expression e)
+ | T.Pexp_function (l, o, list) ->
+ Pexp_function (label l, option expression o,
+ List.map (fun (p,e) -> (pattern p, expression e)) list)
+ | T.Pexp_apply (e, list) ->
+ Pexp_apply (expression e, List.map (fun (l, e) ->
+ (label l, expression e)) list)
+ | T.Pexp_match (e, list) ->
+ Pexp_match (expression e,
+ List.map (fun (p,e) -> (pattern p, expression e)) list)
+ | T.Pexp_try (e, list) ->
+ Pexp_try (expression e,
+ List.map (fun (p,e) -> (pattern p, expression e)) list)
+ | T.Pexp_tuple list ->
+ Pexp_tuple (List.map expression list)
+ | T.Pexp_construct (l, o, bool) ->
+ Pexp_construct (Longident.t l, option expression o, bool)
+ | T.Pexp_variant (l, o) ->
+ Pexp_variant (label l, option expression o)
+ | T.Pexp_record (list, o) ->
+ Pexp_record (List.map (fun (l, e) ->
+ (Longident.t l, expression e)) list, option expression o)
+ | T.Pexp_field (e, l) ->
+ Pexp_field (expression e, Longident.t l)
+ | T.Pexp_setfield (e1, l, e2) ->
+ Pexp_setfield (expression e1, Longident.t l, expression e2)
+ | T.Pexp_array list -> Pexp_array (List.map expression list)
+ | T.Pexp_ifthenelse (e1, e2, o) ->
+ Pexp_ifthenelse (expression e1, expression e2, option expression o)
+ | T.Pexp_sequence (e1, e2) ->
+ Pexp_sequence (expression e1, expression e2)
+ | T.Pexp_while (e1, e2) ->
+ Pexp_while (expression e1, expression e2)
+ | T.Pexp_for (s, e1, e2, d, e3) ->
+ Pexp_for (s, expression e1, expression e2,
+ direction_flag d, expression e3)
+ | T.Pexp_constraint (e1, o1, o2) ->
+ Pexp_constraint (expression e1, option core_type o1, option core_type o2)
+ | T.Pexp_when (e1, e2) -> Pexp_when (expression e1, expression e2)
+ | T.Pexp_send (e1, s) -> Pexp_send (expression e1, s)
+ | T.Pexp_new l -> Pexp_new (Longident.t l)
+ | T.Pexp_setinstvar (s, e) -> Pexp_setinstvar (s, expression e)
+ | T.Pexp_override list ->
+ Pexp_override (List.map (fun (s, e) -> (s, expression e)) list)
+ | T.Pexp_letmodule (s, m, e) ->
+ Pexp_letmodule (s, module_expr m, expression e)
+ | T.Pexp_assert e -> Pexp_assert (expression e)
+ | T.Pexp_assertfalse -> Pexp_assertfalse
+ | T.Pexp_lazy e -> Pexp_lazy (expression e)
+ | T.Pexp_poly (e, o) -> Pexp_poly (expression e, option core_type o)
+ | T.Pexp_object cl -> Pexp_object (class_structure cl)
+ | T.Pexp_newtype (s, e) -> Pexp_newtype (s, expression e)
+ | T.Pexp_pack (m, p) -> assert false
+ | T.Pexp_open (l, e) -> Pexp_open (Longident.t l, expression e)
+
+and value_description v =
+ {
+ pval_type = core_type v.T.pval_type;
+ pval_prim = v.T.pval_prim;
+ }
+
-and module_expr =
- { pmod_desc: module_expr_desc;
- pmod_loc: Location.t }
-
-and module_expr_desc =
- Pmod_ident of Longident.t
- | T.Pmod_structure of structure
- | T.Pmod_functor of string * module_type * module_expr
- | T.Pmod_apply of module_expr * module_expr
- | T.Pmod_constraint of module_expr * module_type
- | T.Pmod_unpack of expression * package_type
-
-and structure = structure_item list
-
-and structure_item =
- { pstr_desc: structure_item_desc;
- pstr_loc: Location.t }
-
-and structure_item_desc =
- Pstr_eval of expression
- | T.Pstr_value of rec_flag * (pattern * expression) list
- | T.Pstr_primitive of string * value_description
- | T.Pstr_type of (string * type_declaration) list
- | T.Pstr_exception of string * exception_declaration
- | T.Pstr_exn_rebind of string * Longident.t
- | T.Pstr_module of string * module_expr
- | T.Pstr_recmodule of (string * module_type * module_expr) list
- | T.Pstr_modtype of string * module_type
- | T.Pstr_open of Longident.t
- | T.Pstr_class of class_declaration list
- | T.Pstr_class_type of class_type_declaration list
- | T.Pstr_include of module_expr
+and type_declaration t =
+ { ptype_params = t.T.ptype_params;
+ ptype_cstrs = List.map (fun (c1, c2, l) ->
+ (core_type c1, core_type c2, Location.t l)) t.T.ptype_cstrs;
+ ptype_kind = type_kind t.T.ptype_kind;
+ ptype_private = private_flag t.T.ptype_private;
+ ptype_manifest = option core_type t.T.ptype_manifest;
+ ptype_variance = t.T.ptype_variance;
+ ptype_loc = Location.t t.T.ptype_loc;
+ }
+
+and type_kind t =
+ match t with
+ T.Ptype_abstract -> Ptype_abstract
+ | T.Ptype_variant list ->
+ Ptype_variant (List.map (fun (s, list, l) ->
+ (s, List.map core_type list, Location.t l)) list)
+ | T.Ptype_record list ->
+ Ptype_record (List.map (fun (s,m,c,l) ->
+ (s, mutable_flag m, core_type c, Location.t l)) list)
+
+and exception_declaration list = List.map core_type list
+
+and class_type c =
+ { pcty_desc = class_type_desc c.T.pcty_desc;
+ pcty_loc = Location.t c.T.pcty_loc; }
+
+and class_type_desc c =
+ match c with
+ T.Pcty_constr (l, list) ->
+ Pcty_constr (Longident.t l, List.map core_type list)
+ | T.Pcty_signature c -> Pcty_signature (class_signature c)
+ | T.Pcty_fun (l, ct, cl) ->
+ Pcty_fun (label l, core_type ct, class_type cl)
+
+and class_signature (c, list) =
+ (core_type c, List.map class_type_field list)
+
+and class_type_field c =
+ match c with
+ T.Pctf_inher c -> Pctf_inher (class_type c)
+ | T.Pctf_val (s, m, v, c, l) ->
+ Pctf_val (s, mutable_flag m, virtual_flag v, core_type c, Location.t l)
+ | T.Pctf_virt (s, p, c, l) ->
+ Pctf_virt (s, private_flag p, core_type c, Location.t l)
+ | T.Pctf_meth (s, p, c, l) ->
+ Pctf_meth (s, private_flag p, core_type c, Location.t l)
+ | T.Pctf_cstr (c1, c2, l) ->
+ Pctf_cstr (core_type c1, core_type c2, Location.t l)
+
+and class_description c = class_infos class_type c
+
+and class_type_declaration c = class_infos class_type c
+
+and class_expr c =
+ { pcl_desc = class_expr_desc c.T.pcl_desc;
+ pcl_loc = Location.t c.T.pcl_loc; }
+
+and class_expr_desc c =
+ match c with
+ T.Pcl_constr (l, list) ->
+ Pcl_constr (Longident.t l, List.map core_type list)
+ | T.Pcl_structure c ->
+ Pcl_structure (class_structure c)
+ | T.Pcl_fun (l, o, p, c) ->
+ Pcl_fun (label l, option expression o, pattern p, class_expr c)
+ | T.Pcl_apply (c, list) ->
+ Pcl_apply (class_expr c, List.map (fun (l, e) ->
+ (label l, expression e)) list)
+ | T.Pcl_let (r, list, c) ->
+ Pcl_let (rec_flag r,
+ List.map (fun (p,e) -> (pattern p, expression e)) list, class_expr c)
+ | T.Pcl_constraint (c1, c2) ->
+ Pcl_constraint (class_expr c1, class_type c2)
+
+and class_structure (p, list) =
+ (pattern p, List.map class_field list)
+
+and class_field c =
+ match c with
+ T.Pcf_inher (ovf, e, op) ->
+ Pcf_inher (override_flag ovf, class_expr e, option string op)
+ | T.Pcf_valvirt (s, mf, c, l) ->
+ Pcf_valvirt (s, mutable_flag mf, core_type c, Location.t l)
+ | T.Pcf_val (s, mf, ovf, e, loc) ->
+ Pcf_val (s, mutable_flag mf, override_flag ovf, expression e, Location.t loc)
+ | T.Pcf_virt (s, pf, c, loc) ->
+ Pcf_virt (s, private_flag pf, core_type c, Location.t loc)
+ | T.Pcf_meth (s, pf, ovf, e, loc) ->
+ Pcf_meth (s , private_flag pf, override_flag ovf, expression e, Location.t loc)
+ | T.Pcf_cstr (c1, c2, loc) ->
+ Pcf_cstr (core_type c1, core_type c2, Location.t loc)
+ | T.Pcf_let (r, list, loc) ->
+ Pcf_let ( rec_flag r, List.map (fun (pat, e) ->
+ (pattern pat, expression e)) list, Location.t loc)
+ | T.Pcf_init e -> Pcf_init (expression e)
+
+and class_declaration list = class_infos class_expr list
+
+and module_type m =
+ { pmty_desc = module_type_desc m.T.pmty_desc;
+ pmty_loc = Location.t m.T.pmty_loc }
+
+and module_type_desc m =
+ match m with
+ T.Pmty_ident l -> Pmty_ident (Longident.t l)
+ | T.Pmty_signature sg -> Pmty_signature (signature sg)
+ | T.Pmty_functor (s, mt1, mt2) ->
+ Pmty_functor (s, module_type mt1, module_type mt2)
+ | T.Pmty_with (mt, list) ->
+ Pmty_with (module_type mt, List.map (fun (l, w) ->
+ (Longident.t l, with_constraint w)) list)
+ | T.Pmty_typeof me -> Pmty_typeof (module_expr me)
+
+and signature list = List.map signature_item list
+
+and signature_item sg =
+ { psig_desc = signature_item_desc sg.T.psig_desc;
+ psig_loc = Location.t sg.T.psig_loc }
+
+and signature_item_desc si =
+ match si with
+ T.Psig_value (s, v) ->
+ Psig_value (s, value_description v)
+ | T.Psig_type list ->
+ Psig_type (List.map (fun (s, t) -> (string s, type_declaration t)) list)
+ | T.Psig_exception (s, e) ->
+ Psig_exception (s, exception_declaration e)
+ | T.Psig_module (s, mt) ->
+ Psig_module (s, module_type mt)
+ | T.Psig_recmodule list ->
+ Psig_recmodule (List.map (fun (s, mt) -> (s, module_type mt)) list)
+ | T.Psig_modtype (s, md) ->
+ Psig_modtype (s, modtype_declaration md)
+ | T.Psig_open l -> Psig_open (Longident.t l)
+ | T.Psig_include mt -> Psig_include (module_type mt)
+ | T.Psig_class list ->
+ Psig_class (List.map class_description list)
+ | T.Psig_class_type list -> Psig_class_type (List.map class_type_declaration list)
+
+and modtype_declaration m =
+ match m with
+ T.Pmodtype_abstract -> Pmodtype_abstract
+ | T.Pmodtype_manifest mt -> Pmodtype_manifest (module_type mt)
+
+and with_constraint w =
+ match w with
+ T.Pwith_type t -> Pwith_type (type_declaration t)
+ | T.Pwith_module l -> Pwith_module (Longident.t l)
+ | T.Pwith_typesubst t -> Pwith_typesubst (type_declaration t)
+ | T.Pwith_modsubst l -> Pwith_modsubst (Longident.t l)
+
+(* value expressions for the module language *)
+and module_expr me =
+ let pmod_loc = Location.t me.T.pmod_loc in
+ let pmod_desc = match me.T.pmod_desc with
+ | T.Pmod_unpack (e, p) ->
+ Pmod_unpack (ghexp
+ (Pexp_constraint (expression e,
+ Some (ghtyp (Ptyp_package (package_type p)) pmod_loc),
+ None
+ ))
+ pmod_loc)
+ | me -> module_expr_desc me in
+ { pmod_desc; pmod_loc }
+
+and module_expr_desc me =
+ match me with
+ T.Pmod_ident l -> Pmod_ident (Longident.t l)
+ | T.Pmod_structure (s) -> Pmod_structure (structure s)
+ | T.Pmod_functor (s, mt, me) ->
+ Pmod_functor (s, module_type mt, module_expr me)
+ | T.Pmod_apply (me1, me2) -> Pmod_apply (module_expr me1, module_expr me2)
+ | T.Pmod_constraint (me, mt) -> Pmod_constraint (module_expr me, module_type mt)
+ | T.Pmod_unpack (e, p) -> assert false
+
+and structure list = List.map structure_item list
+
+and structure_item si =
+ { pstr_desc = structure_item_desc si.T.pstr_desc;
+ pstr_loc = Location.t si.T.pstr_loc }
+
+and structure_item_desc si =
+ match si with
+ T.Pstr_eval e -> Pstr_eval (expression e)
+ | T.Pstr_value (r, list) -> Pstr_value (rec_flag r,
+ List.map (fun (pat, e) -> (pattern pat, expression e)) list)
+ | T.Pstr_primitive (s, v) -> Pstr_primitive (s, value_description v)
+ | T.Pstr_type (list) -> Pstr_type (List.map
+ (fun (s, t) -> (s, type_declaration t)) list)
+ | T.Pstr_exception (s, e) -> Pstr_exception (s, exception_declaration e)
+ | T.Pstr_exn_rebind (s, l) -> Pstr_exn_rebind (s, Longident.t l)
+ | T.Pstr_module (s, me) -> Pstr_module (s, module_expr me)
+ | T.Pstr_recmodule list -> Pstr_recmodule (List.map (
+ fun (s, mt, me) -> (s, module_type mt, module_expr me)) list)
+ | T.Pstr_modtype (s, mt) -> Pstr_modtype (s, module_type mt)
+ | T.Pstr_open (l) -> Pstr_open (Longident.t l)
+ | T.Pstr_class (list) -> Pstr_class (List.map class_declaration list)
+ | T.Pstr_class_type (list) -> Pstr_class_type (List.map class_type_declaration list)
+ | T.Pstr_include (me) -> Pstr_include (module_expr me)
+
+ (*
(* Toplevel phrases *)
type toplevel_phrase =
Ptop_def of structure
- | T.Ptop_dir of string * directive_argument
+ | T.Ptop_dir (a) -> Ptop_dir (string, directive_argument
and directive_argument =
Pdir_none
- | T.Pdir_string of string
- | T.Pdir_int of int
- | T.Pdir_ident of Longident.t
- | T.Pdir_bool of bool
+ | T.Pdir_string (a) -> Pdir_string (string
+ | T.Pdir_int (a) -> Pdir_int (int
+ | T.Pdir_ident (a) -> Pdir_ident (Longident.t
+ | T.Pdir_bool (a) -> Pdir_bool (bool
*)
end
@@ -397,3 +516,11 @@ let input_intf_file ic magic =
let v = (input_value ic : V3120_types.Parsetree.signature) in
AST.Parsetree.signature v
end
+
+let input_impl_file ic magic =
+ if magic <> V3120_types.ast_impl_magic_number then
+ V3112_ast.input_impl_file ic magic
+ else begin
+ let v = (input_value ic : V3120_types.Parsetree.structure) in
+ AST.Parsetree.structure v
+ end
diff --git a/binary-compat/compat/3.12.0/v3120_ast.mli b/binary-compat/compat/3.12.0/v3120_ast.mli
new file mode 100644
index 0000000000..7c805fea15
--- /dev/null
+++ b/binary-compat/compat/3.12.0/v3120_ast.mli
@@ -0,0 +1,17 @@
+
+module AST : sig
+
+ module Asttypes : sig
+ val constant : V3120_types.Asttypes.constant -> Asttypes.constant
+ val virtual_flag : V3120_types.Asttypes.virtual_flag -> Asttypes.virtual_flag
+ val private_flag : V3120_types.Asttypes.private_flag -> Asttypes.private_flag
+ val rec_flag : V3120_types.Asttypes.rec_flag -> Asttypes.rec_flag
+ val mutable_flag : V3120_types.Asttypes.mutable_flag -> Asttypes.mutable_flag
+ val direction_flag : V3120_types.Asttypes.direction_flag -> Asttypes.direction_flag
+ end
+
+(* functor(S: sig end) -> sig end *)
+ end
+
+val input_intf_file : in_channel -> string -> Parsetree.signature
+val input_impl_file : in_channel -> string -> Parsetree.structure \ No newline at end of file
diff --git a/binary-compat/compat/3.12.0/v3120_cmi.mli b/binary-compat/compat/3.12.0/v3120_cmi.mli
new file mode 100644
index 0000000000..e6c55695d6
--- /dev/null
+++ b/binary-compat/compat/3.12.0/v3120_cmi.mli
@@ -0,0 +1,31 @@
+
+module CMI : sig
+ module Ident :
+ sig
+ val reset : unit -> unit
+ val t : V3120_types.Ident.t -> Ident.t
+ end
+ module Path : sig val t : V3120_types.Path.t -> Path.t end
+ module Primitive :
+ sig
+ val description :
+ V3120_types.Primitive.description -> Primitive.description
+ end
+ module Types :
+ sig
+ val reset : unit -> unit
+ val signature_item :
+ V3120_types.Types.signature_item -> Types.signature_item
+ val record_representation :
+ V3120_types.Types.record_representation ->
+ Types.record_representation
+ end
+ module Cmi_format :
+ sig
+ val pers_flags :
+ V3120_types.Cmi_format.pers_flags -> Cmi_format.pers_flags
+ end
+ end
+
+
+val input_cmi_file : in_channel -> string -> Cmi_format.cmi_file
diff --git a/binary-compat/compat/3.12.0/v3120_cmo.mli b/binary-compat/compat/3.12.0/v3120_cmo.mli
new file mode 100644
index 0000000000..21f5f58a15
--- /dev/null
+++ b/binary-compat/compat/3.12.0/v3120_cmo.mli
@@ -0,0 +1,25 @@
+
+module CMO : sig
+ module Lambda :
+ sig
+ val structured_constant :
+ V3120_types.Lambda.structured_constant ->
+ Lambda.structured_constant
+ val primitive :
+ V3120_types.Lambda.primitive -> Lambda.primitive
+ val meth_kind :
+ V3120_types.Lambda.meth_kind -> Lambda.meth_kind
+ end
+ module Cmo_format :
+ sig
+ val compilation_unit :
+ V3120_types.Cmo_format.compilation_unit ->
+ Cmo_format.compilation_unit
+ val library :
+ V3120_types.Cmo_format.library -> Cmo_format.library
+ end
+ end
+
+ (* functor(M : sig end) -> sig end *)
+
+val input_cmo_file : in_channel -> string -> Cmo_format.cmo_unit
diff --git a/binary-compat/compat/3.12.0/v3120_cmx.mli b/binary-compat/compat/3.12.0/v3120_cmx.mli
new file mode 100644
index 0000000000..8d47f9e904
--- /dev/null
+++ b/binary-compat/compat/3.12.0/v3120_cmx.mli
@@ -0,0 +1,6 @@
+
+module CMX : functor(M : sig end) -> sig end
+
+val input_cmx_file : in_channel -> string -> Cmo_format.cmo_unit
+
+ \ No newline at end of file
diff --git a/binary-compat/driver/pparse.ml b/binary-compat/driver/pparse.ml
index 1d2b3a5441..1d80cd4b91 100644
--- a/binary-compat/driver/pparse.ml
+++ b/binary-compat/driver/pparse.ml
@@ -51,13 +51,13 @@ let input_intf_file ic magic =
if magic = Config.ast_intf_magic_number then
(input_value ic : Parsetree.signature)
else
- raise Cmi_format.No_such_magic
+ V3120_ast.input_intf_file ic magic
let input_impl_file ic magic =
if magic = Config.ast_impl_magic_number then
(input_value ic : Parsetree.structure)
else
- raise Cmi_format.No_such_magic
+ V3120_ast.input_impl_file ic magic
let file ppf inputfile parse_fun input_fun ast_magic =
let ic = open_in_bin inputfile in
diff --git a/binary-compat/otherlibs/dynlink/Makefile b/binary-compat/otherlibs/dynlink/Makefile
index 15e7c46d88..baddaa9478 100644
--- a/binary-compat/otherlibs/dynlink/Makefile
+++ b/binary-compat/otherlibs/dynlink/Makefile
@@ -37,6 +37,8 @@ COMPILEROBJS=\
../../compat/3.11.2/v3112_types.cmo \
../../compat/3.12.0/v3120_types.cmo \
../../typing/cmi_format.cmo \
+ ../../compat/3.11.2/v3112_ast.cmo \
+ ../../compat/3.12.0/v3120_ast.cmo \
../../compat/3.11.2/v3112_cmi.cmo \
../../compat/3.12.0/v3120_cmi.cmo \
../../typing/env.cmo \