package saltoIL

  1. Overview
  2. Docs

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

  • author Pierre Lermusiaux <pierre.lermusiaux@inria.fr>
type ('a, 'b) typing =
  1. | Transposed of 'a
  2. | Typed of {
    1. typ : Types.type_expr;
    2. extras : ('b * Location.t * Typedtree.attributes) list;
    3. attrs : Typedtree.attributes;
    4. env : Env.t;
    }
    (*

    Generic type used to store original OCaml typed tree data from the cmt file or encapsulate typing data

    *)
type ('a, 'b) transposed = {
  1. pp : Program_point.t;
  2. term : 'a;
  3. data : 'b;
}

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

Record type for the Salto AST patterns and their original OCaml typed tree data

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

Record type for the Salto AST exceptions and their original OCaml typed tree data

and expression =
  1. | Exp_ident of Salto_id.Path.typed_path
  2. | Exp_constant of Asttypes.constant
    (*

    1, 'a', "this is a string", 1.0, 1l, 1L, 1n

    *)
  3. | Exp_let of Asttypes.rec_flag * value_binding list * expression_data
  4. | Exp_fun of {
    1. arg_label : Asttypes.arg_label;
    2. param : Salto_id.Id.t;
    3. body : expression_data;
    }
  5. | Exp_apply of operand * (Asttypes.arg_label * Salto_id.Path.typed_path) list
  6. | Exp_match of expression_data * case list
  7. | Exp_dispatch of expression_data * value_binding * value_binding
  8. | Exp_tuple of Salto_id.Path.typed_path list
    (*

    (E1, ..., EN)

    *)
  9. | Exp_construct of Salto_id.Longident.t Asttypes.loc * Types.constructor_description * Salto_id.Path.typed_path list
  10. | Exp_variant of Asttypes.label * Salto_id.Path.typed_path option
  11. | Exp_record of {
    1. mutable_flag : Asttypes.mutable_flag;
    2. fields : (Types.label_description * record_label_definition) array;
    3. representation : Types.record_representation;
    4. extended_expression : Salto_id.Path.typed_path option;
    }
  12. | Exp_field of Salto_id.Path.typed_path * Salto_id.Longident.t Asttypes.loc * Asttypes.mutable_flag * Types.label_description
  13. | Exp_setfield of Salto_id.Path.typed_path * Salto_id.Longident.t Asttypes.loc * Types.label_description * Salto_id.Path.typed_path
  14. | Exp_array of Salto_id.Path.typed_path list
  15. | Exp_ifthenelse of expression_data * expression_data * expression_data
  16. | Exp_while of expression_data * expression_data
  17. | Exp_for of Salto_id.Id.t * Parsetree.pattern * Salto_id.Path.typed_path * Salto_id.Path.typed_path * Asttypes.direction_flag * expression_data
  18. | Exp_send of Salto_id.Path.typed_path * meth
  19. | Exp_new of Types.class_declaration Salto_id.Path.t
  20. | Exp_instvar of unit Salto_id.Path.t * unit Salto_id.Path.t
  21. | Exp_setinstvar of unit Salto_id.Path.t * unit Salto_id.Path.t * Salto_id.Path.typed_path
  22. | Exp_override of unit Salto_id.Path.t * (Salto_id.Id.t * Salto_id.Path.typed_path) list
  23. | Exp_letmodule of Salto_id.Id.t option * Types.module_presence * module_expr_data * expression_data
  24. | Exp_letexception of Typedtree.extension_constructor * expression_data
  25. | Exp_assert of expression_data
  26. | Exp_lazy of expression_data
  27. | Exp_object of class_structure * string list
  28. | Exp_pack of module_expr_data
  29. | Exp_unreachable
  30. | Exp_extension_constructor of unit Salto_id.Path.t
  31. | 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 =
  1. | Meth_name of string
  2. | Meth_val of unit Salto_id.Path.t
  3. | Meth_ancestor of unit Salto_id.Path.t
and case = {
  1. c_lhs : pattern_data;
  2. c_guard : expression_data option;
  3. c_rhs : expression_data;
}

Record type for the Salto AST pattern matching cases

and value_binding = {
  1. vb_id : Salto_id.Id.t option;
  2. vb_expr : expression_data;
  3. vb_attributes : Typedtree.attributes;
  4. vb_loc : Location.t;
}

Record type for the Salto AST value_bindings

and record_label_definition =
  1. | Kept of Types.type_expr
  2. | Overridden of Salto_id.Longident.t Asttypes.loc * Salto_id.Path.typed_path

Type for the Salto AST record label expressions

and operand =
  1. | Path_op of Salto_id.Path.typed_path
  2. | 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

Type for the Salto AST class expressions

and class_structure = {
  1. cstr_self : pattern_data;
  2. cstr_fields : class_field_data list;
  3. cstr_type : Types.class_signature;
  4. 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 =
  1. | Cfk_virtual of Typedtree.core_type
  2. | Cfk_concrete of Asttypes.override_flag * expression_data

Type for the Salto AST class field kinds

and class_field =
  1. | Cf_inherit of Asttypes.override_flag * class_expr_data * string option * (string * Ident.t) list * (string * Ident.t) list
  2. | Cf_val of Asttypes.mutable_flag * Salto_id.Id.t * class_field_kind * bool
  3. | Cf_method of string Asttypes.loc * Asttypes.private_flag * class_field_kind
  4. | Cf_constraint of Typedtree.core_type * Typedtree.core_type
  5. | Cf_initializer of expression_data
  6. | 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

Type for the Salto AST module expressions

and functor_parameter =
  1. | Unit
  2. | Named of Salto_id.Id.t option * module_type_data

Type for the Salto AST functor module parameter

and module_type_constraint =
  1. | Modtype_implicit
    (*

    The module type constraint has been synthesized during typechecking.

    *)
  2. | 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 = {
  1. str_items : structure_item_data list;
  2. str_type : Types.signature;
  3. str_final_env : Env.t;
}

Record type for the Salto AST module structures

Record type for the Salto AST module structure items and their original OCaml typed tree data

and structure_item =
  1. | Str_value of Asttypes.rec_flag * value_binding list
  2. | Str_primitive of Typedtree.value_description * expression_data
  3. | Str_type of Asttypes.rec_flag * Typedtree.type_declaration list
  4. | Str_typext of Typedtree.type_extension
  5. | Str_exception of Typedtree.type_exception
  6. | Str_module of module_binding
  7. | Str_recmodule of module_binding list
  8. | Str_modtype of module_type_declaration
  9. | Str_open of open_declaration
  10. | Str_class of (class_declaration * string list) list
  11. | Str_class_type of (Ident.t * Typedtree.class_type_declaration) list
  12. | Str_include of include_declaration
  13. | Str_attribute of Typedtree.attribute

Type for the Salto AST module structure items

and module_binding = {
  1. mb_id : Salto_id.Id.t option;
  2. mb_presence : Types.module_presence;
  3. mb_expr : module_expr_data;
  4. mb_attributes : Typedtree.attributes;
  5. 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 =
  1. | Mty_ident of Types.module_type Salto_id.Path.t
  2. | Mty_signature of signature
  3. | Mty_functor of functor_parameter * module_type_data
  4. | Mty_with of module_type_data * (unit Salto_id.Path.t * with_constraint) list
  5. | Mty_typeof of module_expr_data
  6. | Mty_alias of Types.module_type Salto_id.Path.t

Type for the Salto AST module types

and signature = {
  1. sig_items : signature_item_data list;
  2. sig_type : Types.signature;
  3. sig_final_env : Env.t;
}

Record type for the Salto AST module signatures

Record type for the Salto AST module signature items and their original OCaml typed tree data

and signature_item =
  1. | Sig_value of Typedtree.value_description
  2. | Sig_type of Asttypes.rec_flag * Typedtree.type_declaration list
  3. | Sig_typesubst of Typedtree.type_declaration list
  4. | Sig_typext of Typedtree.type_extension
  5. | Sig_exception of Typedtree.type_exception
  6. | Sig_module of module_declaration
  7. | Sig_modsubst of Typedtree.module_substitution
  8. | Sig_recmodule of module_declaration list
  9. | Sig_modtype of module_type_declaration
  10. | Sig_modtypesubst of module_type_declaration
  11. | Sig_open of Typedtree.open_description
  12. | Sig_include of include_description
  13. | Sig_class of Typedtree.class_description list
  14. | Sig_class_type of Typedtree.class_type_declaration list
  15. | Sig_attribute of Typedtree.attribute

Type for the Salto AST module signatures items

and module_declaration = {
  1. md_id : Salto_id.Id.t option;
  2. md_presence : Types.module_presence;
  3. md_type : module_type_data;
  4. md_attributes : Typedtree.attributes;
  5. md_loc : Location.t;
}

Record type for the Salto AST module declarations

and module_type_declaration = {
  1. mtd_id : Salto_id.Id.t;
  2. mtd_type : module_type_data option;
  3. mtd_attributes : Typedtree.attributes;
  4. 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 =
  1. | With_type of Typedtree.type_declaration
  2. | With_module of unit Salto_id.Path.t
  3. | With_modtype of module_type_data
  4. | With_typesubst of Typedtree.type_declaration
  5. | With_modsubst of unit Salto_id.Path.t
  6. | 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

OCaml

Innovation. Community. Security.