Move typed_impl to Typedtree.t

master
Leandro Ostera 2020-11-05 19:06:12 +01:00
parent 3be9e19c17
commit ee2f3b428c
No known key found for this signature in database
GPG Key ID: 164AFF20E1035D1F
14 changed files with 29 additions and 30 deletions

View File

@ -1010,7 +1010,6 @@ typing/printtyp.cmi : \
parsing/asttypes.cmi
typing/printtyped.cmo : \
typing/types.cmi \
typing/typemod.cmi \
typing/typedtree.cmi \
parsing/printast.cmi \
typing/path.cmi \
@ -1023,7 +1022,6 @@ typing/printtyped.cmo : \
typing/printtyped.cmi
typing/printtyped.cmx : \
typing/types.cmx \
typing/typemod.cmx \
typing/typedtree.cmx \
parsing/printast.cmx \
typing/path.cmx \

View File

@ -27,7 +27,7 @@ let interface ~source_file ~output_prefix =
(** Bytecode compilation backend for .ml files. *)
let to_bytecode i Typemod.{structure; coercion; _} =
let to_bytecode i Typedtree.{structure; coercion; _} =
(structure, coercion)
|> Profile.(record transl)
(Translmod.transl_implementation i.module_name)

View File

@ -25,7 +25,7 @@ val implementation:
val to_bytecode :
Compile_common.info ->
Typemod.typed_impl ->
Typedtree.t ->
Instruct.instruction list * Ident.Set.t
(** [to_bytecode info typed] takes a typechecked implementation
and returns its bytecode.

View File

@ -68,13 +68,13 @@ val interface : info -> unit
val parse_impl : info -> Parsetree.structure
(** [parse_impl info] parses an implementation (usually an [.ml] file). *)
val typecheck_impl : info -> Parsetree.structure -> Typemod.typed_impl
val typecheck_impl : info -> Parsetree.structure -> Typedtree.t
(** [typecheck_impl info parsetree] typechecks an implementation and returns
the typedtree of the associated module, its public interface, and a
coercion against that public interface.
*)
val implementation : info -> backend:(info -> Typemod.typed_impl -> unit) -> unit
val implementation : info -> backend:(info -> Typedtree.t -> unit) -> unit
(** The complete compilation pipeline for implementations. *)
(** {2 Build artifacts} *)

View File

@ -31,7 +31,7 @@ let (|>>) (x, y) f = (x, f y)
(** Native compilation backend for .ml files. *)
let flambda i backend Typemod.{structure; coercion; _} =
let flambda i backend Typedtree.{structure; coercion; _} =
if !Clflags.classic_inlining then begin
Clflags.default_simplify_rounds := 1;
Clflags.use_inlining_arguments_set Clflags.classic_arguments;
@ -66,7 +66,7 @@ let flambda i backend Typemod.{structure; coercion; _} =
program);
Compilenv.save_unit_info (cmx i))
let clambda i backend Typemod.{structure; coercion; _} =
let clambda i backend Typedtree.{structure; coercion; _} =
Clflags.use_inlining_arguments_set Clflags.classic_arguments;
(structure, coercion)
|> Profile.(record transl)

View File

@ -25,13 +25,13 @@ val implementation:
(** {2 Internal functions} **)
val clambda :
Compile_common.info -> (module Backend_intf.S) -> Typemod.typed_impl-> unit
Compile_common.info -> (module Backend_intf.S) -> Typedtree.t-> unit
(** [clambda info typed] applies the regular compilation pipeline to the
given typechecked implementation and outputs the resulting files.
*)
val flambda :
Compile_common.info -> (module Backend_intf.S) -> Typemod.typed_impl -> unit
Compile_common.info -> (module Backend_intf.S) -> Typedtree.t -> unit
(** [flambda info backend typed] applies the Flambda compilation pipeline to the
given typechecked implementation and outputs the resulting files.
*)

View File

@ -151,7 +151,7 @@ let process_file sourcefile =
match parsetree_typedtree_opt with
None ->
None
| Some (parsetree, Typemod.{structure; coercion; _}) ->
| Some (parsetree, Typedtree.{structure; coercion; _}) ->
let typedtree = (structure, coercion) in
let file_module = Ast_analyser.analyse_typed_tree file
input_file parsetree typedtree

View File

@ -942,4 +942,4 @@ let interface ppf x = list 0 signature_item ppf x.sig_items;;
let implementation ppf x = list 0 structure_item ppf x.str_items;;
let implementation_with_coercion ppf Typemod.{structure; _} = implementation ppf structure
let implementation_with_coercion ppf Typedtree.{structure; _} = implementation ppf structure

View File

@ -19,4 +19,4 @@ open Format;;
val interface : formatter -> signature -> unit;;
val implementation : formatter -> structure -> unit;;
val implementation_with_coercion : formatter -> Typemod.typed_impl -> unit;;
val implementation_with_coercion : formatter -> Typedtree.t -> unit;;

View File

@ -613,6 +613,13 @@ and 'a class_infos =
ci_attributes: attribute list;
}
type t = {
structure: structure;
coercion: module_coercion;
signature: Types.signature
}
(* Auxiliary functions over the a.s.t. *)
let as_computation_pattern (p : pattern) : computation general_pattern =

View File

@ -752,6 +752,12 @@ and 'a class_infos =
ci_attributes: attributes;
}
type t = {
structure: structure;
coercion: module_coercion;
signature: Types.signature
}
(* Auxiliary functions over the a.s.t. *)
(** [as_computation_pattern p] is a computation pattern with description

View File

@ -106,12 +106,6 @@ type error =
exception Error of Location.t * Env.t * error
exception Error_forward of Location.error
type typed_impl = {
structure: Typedtree.structure;
coercion: Typedtree.module_coercion;
signature: Types.signature
}
open Typedtree
let rec path_concat head p =

View File

@ -29,12 +29,6 @@ module Signature_names : sig
val simplify: Env.t -> t -> signature -> signature
end
type typed_impl = {
structure: Typedtree.structure;
coercion: Typedtree.module_coercion;
signature: Types.signature
}
val type_module:
Env.t -> Parsetree.module_expr -> Typedtree.module_expr
val type_structure:
@ -44,7 +38,7 @@ val type_toplevel_phrase:
Env.t -> Parsetree.structure ->
Typedtree.structure * Types.signature * Signature_names.t * Env.t
val type_implementation:
string -> string -> string -> Env.t -> Parsetree.structure -> typed_impl
string -> string -> string -> Env.t -> Parsetree.structure -> Typedtree.t
val type_interface:
Env.t -> Parsetree.signature -> Typedtree.signature
val transl_signature:

View File

@ -605,7 +605,7 @@ let functor_parameter sub : functor_parameter -> Parsetree.functor_parameter =
| Unit -> Unit
| Named (_, name, mtype) -> Named (name, sub.module_type sub mtype)
let module_type sub mty =
let module_type (sub : mapper) mty =
let loc = sub.location sub mty.mty_loc in
let attrs = sub.attributes sub mty.mty_attributes in
let desc = match mty.mty_desc with
@ -633,7 +633,7 @@ let with_constraint sub (_path, lid, cstr) =
| Twith_modsubst (_path, lid2) ->
Pwith_modsubst (map_loc sub lid, map_loc sub lid2)
let module_expr sub mexpr =
let module_expr (sub : mapper) mexpr =
let loc = sub.location sub mexpr.mod_loc in
let attrs = sub.attributes sub mexpr.mod_attributes in
match mexpr.mod_desc with
@ -882,10 +882,10 @@ let default_mapper =
object_field = object_field ;
}
let untype_structure ?(mapper=default_mapper) structure =
let untype_structure ?(mapper : mapper = default_mapper) structure =
mapper.structure mapper structure
let untype_signature ?(mapper=default_mapper) signature =
let untype_signature ?(mapper : mapper = default_mapper) signature =
mapper.signature mapper signature
let untype_expression ?(mapper=default_mapper) expression =