Module IR.Typ

The Smallfoot Intermediate Language: Types

module F = Stdlib.Format
type ikind =
  1. | IChar
    (*

    char

    *)
  2. | ISChar
    (*

    signed char

    *)
  3. | IUChar
    (*

    unsigned char

    *)
  4. | IBool
    (*

    bool

    *)
  5. | IInt
    (*

    int

    *)
  6. | IUInt
    (*

    unsigned int

    *)
  7. | IShort
    (*

    short

    *)
  8. | IUShort
    (*

    unsigned short

    *)
  9. | ILong
    (*

    long

    *)
  10. | IULong
    (*

    unsigned long

    *)
  11. | ILongLong
    (*

    long long (or _int64 on Microsoft Visual C)

    *)
  12. | IULongLong
    (*

    unsigned long long (or unsigned _int64 on Microsoft Visual C)

    *)
  13. | I128
    (*

    __int128_t

    *)
  14. | IU128
    (*

    __uint128_t

    *)

Kinds of integers

val compare_ikind : ikind -> ikind -> int
val equal_ikind : ikind -> ikind -> bool
val hash_fold_ikind : Ppx_hash_lib.Std.Hash.state -> ikind -> Ppx_hash_lib.Std.Hash.state
val hash_ikind : ikind -> Ppx_hash_lib.Std.Hash.hash_value
val hash_normalize_ikind : ikind -> ikind
val hash_normalize_ikind_opt : ikind option -> ikind option
val hash_normalize_ikind_list : ikind list -> ikind list
val ikind_is_char : ikind -> bool

Check whether the integer kind is a char

val ikind_is_unsigned : ikind -> bool

Check whether the integer kind is unsigned

type fkind =
  1. | FFloat
    (*

    float

    *)
  2. | FDouble
    (*

    double

    *)
  3. | FLongDouble
    (*

    long double

    *)

Kinds of floating-point numbers

val compare_fkind : fkind -> fkind -> int
type ptr_kind =
  1. | Pk_pointer
    (*

    C/C++, Java, Objc standard/__strong pointer

    *)
  2. | Pk_lvalue_reference
    (*

    C++ lvalue reference

    *)
  3. | Pk_rvalue_reference
    (*

    C++ rvalue reference

    *)
  4. | Pk_objc_weak
    (*

    Obj-C __weak pointer

    *)
  5. | Pk_objc_unsafe_unretained
    (*

    Obj-C __unsafe_unretained pointer

    *)
  6. | Pk_objc_autoreleasing
    (*

    Obj-C __autoreleasing pointer

    *)

kind of pointer

val compare_ptr_kind : ptr_kind -> ptr_kind -> int
val equal_ptr_kind : ptr_kind -> ptr_kind -> bool
type type_quals
val compare_type_quals : type_quals -> type_quals -> int
val equal_type_quals : type_quals -> type_quals -> bool
val mk_type_quals : ?default:type_quals -> ?is_const:bool -> ?is_reference:bool -> ?is_restrict:bool -> ?is_volatile:bool -> unit -> type_quals
val is_const : type_quals -> bool
val is_restrict : type_quals -> bool
val is_volatile : type_quals -> bool
type t = {
  1. desc : desc;
  2. quals : type_quals;
}

types for sil (structured) expressions

and desc =
  1. | Tint of ikind
    (*

    integer type

    *)
  2. | Tfloat of fkind
    (*

    float type

    *)
  3. | Tvoid
    (*

    void type

    *)
  4. | Tfun
    (*

    function type

    *)
  5. | Tptr of t * ptr_kind
    (*

    pointer type

    *)
  6. | Tstruct of name
    (*

    structured value type name

    *)
  7. | TVar of string
    (*

    type variable (ie. C++ template variables)

    *)
  8. | Tarray of {
    1. elt : t;
    2. length : IntLit.t option;
    3. stride : IntLit.t option;
    }
    (*

    array type with statically fixed length and stride

    *)
and objc_block_sig = {
  1. class_name : name option;
  2. name : string;
  3. mangled : string;
}
and c_function_sig = {
  1. c_name : QualifiedCppName.t;
  2. c_mangled : string option;
  3. c_template_args : template_spec_info;
}
and name =
  1. | CStruct of QualifiedCppName.t
  2. | CUnion of QualifiedCppName.t
  3. | CppClass of {
    1. name : QualifiedCppName.t;
    2. template_spec_info : template_spec_info;
    3. is_union : bool;
    }
  4. | CSharpClass of CSharpClassName.t
  5. | ErlangType of ErlangTypeName.t
  6. | HackClass of HackClassName.t
  7. | JavaClass of JavaClassName.t
  8. | ObjcClass of QualifiedCppName.t
  9. | ObjcProtocol of QualifiedCppName.t
  10. | PythonClass of PythonClassName.t
  11. | ObjcBlock of objc_block_sig
  12. | CFunction of c_function_sig
and template_arg =
  1. | TType of t
  2. | TInt of IStdlib.IStd.Int64.t
  3. | TNull
  4. | TNullPtr
  5. | TOpaque
and template_spec_info =
  1. | NoTemplate
  2. | Template of {
    1. mangled : string option;
      (*

      WARNING: because of type substitutions performed by sub_type and sub_tname, mangling is not guaranteed to be unique to a single type. All the information in the template arguments is also needed for uniqueness.

      *)
    2. args : template_arg list;
    }
val compare : t -> t -> int
val compare_desc : desc -> desc -> int
val compare_objc_block_sig : objc_block_sig -> objc_block_sig -> int
val compare_c_function_sig : c_function_sig -> c_function_sig -> int
val compare_name : name -> name -> int
val compare_template_arg : template_arg -> template_arg -> int
val compare_template_spec_info : template_spec_info -> template_spec_info -> int
val equal_objc_block_sig : objc_block_sig -> objc_block_sig -> bool
val equal_c_function_sig : c_function_sig -> c_function_sig -> bool
val equal_template_arg : template_arg -> template_arg -> bool
val equal_template_spec_info : template_spec_info -> template_spec_info -> bool
val yojson_of_t : t -> Ppx_yojson_conv_lib.Yojson.Safe.t
val yojson_of_desc : desc -> Ppx_yojson_conv_lib.Yojson.Safe.t
val yojson_of_objc_block_sig : objc_block_sig -> Ppx_yojson_conv_lib.Yojson.Safe.t
val yojson_of_c_function_sig : c_function_sig -> Ppx_yojson_conv_lib.Yojson.Safe.t
val yojson_of_name : name -> Ppx_yojson_conv_lib.Yojson.Safe.t
val yojson_of_template_arg : template_arg -> Ppx_yojson_conv_lib.Yojson.Safe.t
val yojson_of_template_spec_info : template_spec_info -> Ppx_yojson_conv_lib.Yojson.Safe.t
val hash_normalize : t -> t
val hash_normalize_opt : t option -> t option
val hash_normalize_list : t list -> t list
val hash_normalize_desc : desc -> desc
val hash_normalize_desc_opt : desc option -> desc option
val hash_normalize_desc_list : desc list -> desc list
val hash_normalize_objc_block_sig : objc_block_sig -> objc_block_sig
val hash_normalize_objc_block_sig_opt : objc_block_sig option -> objc_block_sig option
val hash_normalize_objc_block_sig_list : objc_block_sig list -> objc_block_sig list
val hash_normalize_c_function_sig : c_function_sig -> c_function_sig
val hash_normalize_c_function_sig_opt : c_function_sig option -> c_function_sig option
val hash_normalize_c_function_sig_list : c_function_sig list -> c_function_sig list
val hash_normalize_name : name -> name
val hash_normalize_name_opt : name option -> name option
val hash_normalize_name_list : name list -> name list
val hash_normalize_template_arg : template_arg -> template_arg
val hash_normalize_template_arg_opt : template_arg option -> template_arg option
val hash_normalize_template_arg_list : template_arg list -> template_arg list
val hash_normalize_template_spec_info : template_spec_info -> template_spec_info
val hash_normalize_template_spec_info_opt : template_spec_info option -> template_spec_info option
val hash_normalize_template_spec_info_list : template_spec_info list -> template_spec_info list
val hash_fold_t : Ppx_hash_lib.Std.Hash.state -> t -> Ppx_hash_lib.Std.Hash.state
val hash : t -> Ppx_hash_lib.Std.Hash.hash_value
val hash_fold_desc : Ppx_hash_lib.Std.Hash.state -> desc -> Ppx_hash_lib.Std.Hash.state
val hash_desc : desc -> Ppx_hash_lib.Std.Hash.hash_value
val hash_fold_objc_block_sig : Ppx_hash_lib.Std.Hash.state -> objc_block_sig -> Ppx_hash_lib.Std.Hash.state
val hash_objc_block_sig : objc_block_sig -> Ppx_hash_lib.Std.Hash.hash_value
val hash_fold_c_function_sig : Ppx_hash_lib.Std.Hash.state -> c_function_sig -> Ppx_hash_lib.Std.Hash.state
val hash_c_function_sig : c_function_sig -> Ppx_hash_lib.Std.Hash.hash_value
val hash_fold_name : Ppx_hash_lib.Std.Hash.state -> name -> Ppx_hash_lib.Std.Hash.state
val hash_name : name -> Ppx_hash_lib.Std.Hash.hash_value
val hash_fold_template_arg : Ppx_hash_lib.Std.Hash.state -> template_arg -> Ppx_hash_lib.Std.Hash.state
val hash_template_arg : template_arg -> Ppx_hash_lib.Std.Hash.hash_value
val hash_fold_template_spec_info : Ppx_hash_lib.Std.Hash.state -> template_spec_info -> Ppx_hash_lib.Std.Hash.state
val hash_template_spec_info : template_spec_info -> Ppx_hash_lib.Std.Hash.hash_value
val sexp_of_t : t -> Sexplib0.Sexp.t
val sexp_of_desc : desc -> Sexplib0.Sexp.t
val sexp_of_objc_block_sig : objc_block_sig -> Sexplib0.Sexp.t
val sexp_of_c_function_sig : c_function_sig -> Sexplib0.Sexp.t
val sexp_of_name : name -> Sexplib0.Sexp.t
val sexp_of_template_arg : template_arg -> Sexplib0.Sexp.t
val sexp_of_template_spec_info : template_spec_info -> Sexplib0.Sexp.t
val t_of_sexp : Sexplib0.Sexp.t -> t
val desc_of_sexp : Sexplib0.Sexp.t -> desc
val objc_block_sig_of_sexp : Sexplib0.Sexp.t -> objc_block_sig
val c_function_sig_of_sexp : Sexplib0.Sexp.t -> c_function_sig
val name_of_sexp : Sexplib0.Sexp.t -> name
val template_arg_of_sexp : Sexplib0.Sexp.t -> template_arg
val template_spec_info_of_sexp : Sexplib0.Sexp.t -> template_spec_info
val pp_template_spec_info : IStdlib.Pp.env -> F.formatter -> template_spec_info -> unit
val is_template_spec_info_empty : template_spec_info -> bool
val mk : ?default:t -> ?quals:type_quals -> desc -> t

Create Typ.t from given desc. if default is passed then use its value to set other fields such as quals

val mk_array : ?default:t -> ?quals:type_quals -> ?length:IntLit.t -> ?stride:IntLit.t -> t -> t

Create an array type from a given element type. If length or stride value is given, use them as static length and size.

val mk_struct : name -> t
val mk_ptr : ?ptr_kind:ptr_kind -> t -> t

make a pointer to t, default kind is Pk_pointer

val set_ptr_to_const : t -> t
val set_to_const : t -> t
val get_ikind_opt : t -> ikind option

Get ikind if the type is integer.

val size_t : ikind

ikind of size_t

val is_weak_pointer : t -> bool
val is_strong_pointer : t -> bool
module Name : sig ... end
val equal : t -> t -> bool

Equality for types.

val equal_desc : desc -> desc -> bool
val equal_name : name -> name -> bool
val equal_ignore_quals : t -> t -> bool

Equality for types, but ignoring quals in it.

val overloading_resolution : (t -> t -> bool) list

overloading_resolution is a list of predicates that compare whether a type T1 binds a type T2.

val pp_full : IStdlib.Pp.env -> F.formatter -> t -> unit

Pretty print a type with all the details.

val pp : IStdlib.Pp.env -> F.formatter -> t -> unit

Pretty print a type.

val pp_desc : IStdlib.Pp.env -> F.formatter -> desc -> unit

Pretty print a type desc.

val pp_java : verbose:bool -> F.formatter -> t -> unit

Pretty print a Java type. Raises if type isn't produced by the Java frontend

val pp_cs : verbose:bool -> F.formatter -> t -> unit

Pretty print a Java type. Raises if type isn't produced by the CSharp frontend

val to_string : t -> string
val desc_to_string : desc -> string
val d_full : t -> unit

Dump a type with all the details.

val d_list : t list -> unit

Dump a list of types.

val name : t -> Name.t option

The name of a type

val strip_ptr : t -> t

turn a *T into a T. fails if t is not a pointer type

val is_ptr_to_ignore_quals : t -> ptr:t -> bool

check if ptr is a pointer type to t, ignoring quals

val is_ptr_to_const : t -> bool

check if typ is a pointer type to const

val array_elem : t option -> t -> t

If an array type, return the type of the element. If not, return the default type if given, otherwise raise an exception

val is_objc_class : t -> bool
val is_cpp_class : t -> bool
val is_pointer_to_cpp_class : t -> bool
val is_pointer_to_smart_pointer : t -> bool
val is_pointer_to_unique_pointer : t -> bool
val shared_pointer_matcher : QualifiedCppName.Match.quals_matcher
val is_shared_pointer : t -> bool
val is_folly_coro : t -> bool
val is_pointer_to_void : t -> bool
val is_void : t -> bool
val is_pointer_to_int : t -> bool
val is_pointer_to_const : t -> bool
val is_pointer_to_function : t -> bool
val is_pointer : t -> bool
val is_reference : t -> bool
val is_rvalue_reference : t -> bool
val is_const_reference_on_source : t -> bool
val is_struct : t -> bool
val is_int : t -> bool
val is_unsigned_int : t -> bool
val is_char : t -> bool
val is_csharp_type : t -> bool

is t a type produced by the Java frontend?

val is_java_type : t -> bool

is t a type produced by the Java frontend?

val unsome : string -> t option -> t