package saltoIL
Library
Module
Module type
Parameter
Class
Class type
Modified OCaml typed AST from the one defined in the compiler-libs
(**************************************************************************) (* *) (* OCaml *) (* *) (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) (* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) (* the GNU Lesser General Public License version 2.1, with the *) (* special exception on linking described in the file LICENSE. *) (* *) (**************************************************************************)
Copyright © Inria 2021
type ('a, 'b) typing =
| Transposed of 'a
| Typed of {
typ : Types.type_expr;
extras : ('b * Location.t * Typedtree.attributes) list;
attrs : Typedtree.attributes;
env : Env.t;
}
(*Generic type used to store original OCaml typed tree data from the cmt file or encapsulate typing data
*)
Generic record type used to store transposed term and their original OCaml typed tree data from the cmt file
type ('a, 'b, 'c) typed = ('a, ('b, 'c) typing) transposed
Generic record type used to store transposed typed term and their original OCaml typed tree data from the cmt file
type pattern_data = (Pattern.t, Typedtree.pattern, Typedtree.pat_extra) typed
Record type for the Salto AST patterns and their original OCaml typed tree data
type general_pattern =
(pattern_data list * pattern_data list,
Typedtree.computation Typedtree.general_pattern)
transposed
Record type for computation patterns transposed as a pair of pattern lists, the first one concerning value patterns and the second one concerning exception patterns
type expression_data =
(expression, Typedtree.expression, Typedtree.exp_extra) typed
Record type for the Salto AST exceptions and their original OCaml typed tree data
and expression =
| Exp_ident of Salto_id.Path.typed_path
| Exp_constant of Asttypes.constant
(*1, 'a', "this is a string", 1.0, 1l, 1L, 1n
*)| Exp_let of Asttypes.rec_flag * value_binding list * expression_data
| Exp_fun of {
arg_label : Asttypes.arg_label;
param : Salto_id.Id.t;
body : expression_data;
}
| Exp_apply of operand * (Asttypes.arg_label * Salto_id.Path.typed_path) list
| Exp_match of expression_data * case list
| Exp_dispatch of expression_data * value_binding * value_binding
| Exp_tuple of Salto_id.Path.typed_path list
(*(E1, ..., EN)
*)| Exp_construct of Salto_id.Longident.t Asttypes.loc * Types.constructor_description * Salto_id.Path.typed_path list
| Exp_variant of Asttypes.label * Salto_id.Path.typed_path option
| Exp_record of {
mutable_flag : Asttypes.mutable_flag;
fields : (Types.label_description * record_label_definition) array;
representation : Types.record_representation;
extended_expression : Salto_id.Path.typed_path option;
}
| Exp_field of Salto_id.Path.typed_path * Salto_id.Longident.t Asttypes.loc * Asttypes.mutable_flag * Types.label_description
| Exp_setfield of Salto_id.Path.typed_path * Salto_id.Longident.t Asttypes.loc * Types.label_description * Salto_id.Path.typed_path
| Exp_array of Salto_id.Path.typed_path list
| Exp_ifthenelse of expression_data * expression_data * expression_data
| Exp_while of expression_data * expression_data
| Exp_for of Salto_id.Id.t * Parsetree.pattern * Salto_id.Path.typed_path * Salto_id.Path.typed_path * Asttypes.direction_flag * expression_data
| Exp_send of Salto_id.Path.typed_path * meth
| Exp_new of Types.class_declaration Salto_id.Path.t
| Exp_instvar of unit Salto_id.Path.t * unit Salto_id.Path.t
| Exp_setinstvar of unit Salto_id.Path.t * unit Salto_id.Path.t * Salto_id.Path.typed_path
| Exp_override of unit Salto_id.Path.t * (Salto_id.Id.t * Salto_id.Path.typed_path) list
| Exp_letmodule of Salto_id.Id.t option * Types.module_presence * module_expr_data * expression_data
| Exp_letexception of Typedtree.extension_constructor * expression_data
| Exp_assert of expression_data
| Exp_lazy of expression_data
| Exp_object of class_structure * string list
| Exp_pack of module_expr_data
| Exp_unreachable
| Exp_extension_constructor of unit Salto_id.Path.t
| Exp_open of open_declaration * expression_data
Type for the Salto AST expressions, where try_with expressions and match_with expressions containing exceptions cases are now encoded through a dispatch construction
and meth =
| Meth_name of string
| Meth_val of unit Salto_id.Path.t
| Meth_ancestor of unit Salto_id.Path.t
Record type for the Salto AST pattern matching cases
and value_binding = {
vb_id : Salto_id.Id.t option;
vb_expr : expression_data;
vb_attributes : Typedtree.attributes;
vb_loc : Location.t;
}
Record type for the Salto AST value_bindings
and record_label_definition =
| Kept of Types.type_expr
| Overridden of Salto_id.Longident.t Asttypes.loc * Salto_id.Path.typed_path
Type for the Salto AST record label expressions
and operand =
| Path_op of Salto_id.Path.typed_path
| Primitive of Primitive.description Salto_id.Path.t
Type of operands for the n-ary application node of expressions. If the operand is a primitive, the application is exactly complete
and class_expr_data = (class_expr, Typedtree.class_expr) transposed
Record type for the Salto AST class expressions and their original OCaml typed tree data
and class_expr =
| Cl_ident of Types.class_type Salto_id.Path.t * Typedtree.core_type list
| Cl_structure of class_structure
| Cl_fun of Asttypes.arg_label * pattern_data * (Ident.t * expression_data) list * class_expr_data * Typedtree.partial
| Cl_apply of class_expr_data * (Asttypes.arg_label * expression_data option) list
| Cl_let of Asttypes.rec_flag * value_binding list * (Salto_id.Id.t * expression_data) list * class_expr_data
| Cl_constraint of class_expr_data * Typedtree.class_type option * string list * string list * Types.MethSet.t
| Cl_open of Typedtree.open_description * class_expr_data
Type for the Salto AST class expressions
and class_structure = {
cstr_self : pattern_data;
cstr_fields : class_field_data list;
cstr_type : Types.class_signature;
cstr_meths : Ident.t Types.Meths.t;
}
Record type for the Salto AST class structures
and class_field_data = (class_field, Typedtree.class_field) transposed
Record type for the Salto AST class fields and their original OCaml typed tree data
and class_field_kind =
| Cfk_virtual of Typedtree.core_type
| Cfk_concrete of Asttypes.override_flag * expression_data
Type for the Salto AST class field kinds
and class_field =
| Cf_inherit of Asttypes.override_flag * class_expr_data * string option * (string * Ident.t) list * (string * Ident.t) list
| Cf_val of Asttypes.mutable_flag * Salto_id.Id.t * class_field_kind * bool
| Cf_method of string Asttypes.loc * Asttypes.private_flag * class_field_kind
| Cf_constraint of Typedtree.core_type * Typedtree.core_type
| Cf_initializer of expression_data
| Cf_attribute of Typedtree.attribute
Type for the Salto AST class fields
and module_expr_data = (module_expr, Typedtree.module_expr) transposed
Record type for the Salto AST module expressions and their original OCaml typed tree data
and module_expr =
| Mod_ident of Types.module_type Salto_id.Path.t
| Mod_structure of structure
| Mod_functor of functor_parameter * module_expr_data
| Mod_apply of module_expr_data * module_expr_data * Typedtree.module_coercion * Coercion.t
| Mod_constraint of module_expr_data * Types.module_type * module_type_constraint * Typedtree.module_coercion * Coercion.t
| Mod_unpack of expression_data * Types.module_type
Type for the Salto AST module expressions
Type for the Salto AST functor module parameter
and module_type_constraint =
| Modtype_implicit
(*The module type constraint has been synthesized during typechecking.
*)| Modtype_explicit of module_type_data
(*The module type was in the source file.
*)
Type for the Salto Ast constraints on module types
and structure = {
str_items : structure_item_data list;
str_type : Types.signature;
str_final_env : Env.t;
}
Record type for the Salto AST module structures
and structure_item_data = (structure_item, Typedtree.structure_item) transposed
Record type for the Salto AST module structure items and their original OCaml typed tree data
and structure_item =
| Str_value of Asttypes.rec_flag * value_binding list
| Str_primitive of Typedtree.value_description * expression_data
| Str_type of Asttypes.rec_flag * Typedtree.type_declaration list
| Str_typext of Typedtree.type_extension
| Str_exception of Typedtree.type_exception
| Str_module of module_binding
| Str_recmodule of module_binding list
| Str_modtype of module_type_declaration
| Str_open of open_declaration
| Str_class of (class_declaration * string list) list
| Str_class_type of (Ident.t * Typedtree.class_type_declaration) list
| Str_include of include_declaration
| Str_attribute of Typedtree.attribute
Type for the Salto AST module structure items
and module_binding = {
mb_id : Salto_id.Id.t option;
mb_presence : Types.module_presence;
mb_expr : module_expr_data;
mb_attributes : Typedtree.attributes;
mb_loc : Location.t;
}
Record type for the Salto AST module bindings
and module_type_data = (module_type, Typedtree.module_type) transposed
Record type for the Salto AST module types and their original OCaml typed tree data
and module_type =
| Mty_ident of Types.module_type Salto_id.Path.t
| Mty_signature of signature
| Mty_functor of functor_parameter * module_type_data
| Mty_with of module_type_data * (unit Salto_id.Path.t * with_constraint) list
| Mty_typeof of module_expr_data
| Mty_alias of Types.module_type Salto_id.Path.t
Type for the Salto AST module types
and signature = {
sig_items : signature_item_data list;
sig_type : Types.signature;
sig_final_env : Env.t;
}
Record type for the Salto AST module signatures
and signature_item_data = (signature_item, Typedtree.signature_item) transposed
Record type for the Salto AST module signature items and their original OCaml typed tree data
and signature_item =
| Sig_value of Typedtree.value_description
| Sig_type of Asttypes.rec_flag * Typedtree.type_declaration list
| Sig_typesubst of Typedtree.type_declaration list
| Sig_typext of Typedtree.type_extension
| Sig_exception of Typedtree.type_exception
| Sig_module of module_declaration
| Sig_modsubst of Typedtree.module_substitution
| Sig_recmodule of module_declaration list
| Sig_modtype of module_type_declaration
| Sig_modtypesubst of module_type_declaration
| Sig_open of Typedtree.open_description
| Sig_include of include_description
| Sig_class of Typedtree.class_description list
| Sig_class_type of Typedtree.class_type_declaration list
| Sig_attribute of Typedtree.attribute
Type for the Salto AST module signatures items
and module_declaration = {
md_id : Salto_id.Id.t option;
md_presence : Types.module_presence;
md_type : module_type_data;
md_attributes : Typedtree.attributes;
md_loc : Location.t;
}
Record type for the Salto AST module declarations
and module_type_declaration = {
mtd_id : Salto_id.Id.t;
mtd_type : module_type_data option;
mtd_attributes : Typedtree.attributes;
mtd_loc : Location.t;
}
Record type for the Salto AST module type declarations
and open_declaration = module_expr_data Typedtree.open_infos
Record type for the Salto AST open declarations
and include_description = module_type_data Typedtree.include_infos
Record type for the Salto AST include descriptions
and include_declaration = module_expr_data Typedtree.include_infos
Record type for the Salto AST include declarations
and with_constraint =
| With_type of Typedtree.type_declaration
| With_module of unit Salto_id.Path.t
| With_modtype of module_type_data
| With_typesubst of Typedtree.type_declaration
| With_modsubst of unit Salto_id.Path.t
| With_modtypesubst of module_type_data
Type for the Salto AST with constraints
and class_declaration = class_expr_data Typedtree.class_infos
Record type for the Salto AST class declarations