text stringlengths 12 786k |
|---|
let type_list = { ocaml_type = Some Predef . path_list ; java_type = JavaAST . Reference ( " OCamlList " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlList " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " ... |
let type_option = { ocaml_type = Some Predef . path_option ; java_type = JavaAST . Reference ( " OCamlOption " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlOption " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e... |
let type_lazy = { ocaml_type = Some Predef . path_lazy_t ; java_type = JavaAST . Reference ( " OCamlLazy " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlLazy " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , "... |
let type_ref = let path_pervasives = Path . Pident ( Ident . create_persistent " Pervasives ) " in let path = Path . Pdot ( path_pervasives , " ref " , 0 ) 0 in { ocaml_type = Some path ; java_type = JavaAST . Reference ( " OCamlRef " , [ ] ) ; java_of_ocaml = ( fun e ... |
let type_in_channel = let path_pervasives = Path . Pident ( Ident . create_persistent " Pervasives ) " in let path = Path . Pdot ( path_pervasives , " in_channel " , 0 ) 0 in { ocaml_type = Some path ; java_type = JavaAST . Reference ( " OCamlInChannel " , [ ] ) ; java_of... |
let type_out_channel = let path_pervasives = Path . Pident ( Ident . create_persistent " Pervasives ) " in let path = Path . Pdot ( path_pervasives , " out_channel " , 0 ) 0 in { ocaml_type = Some path ; java_type = JavaAST . Reference ( " OCamlOutChannel " , [ ] ) ; java... |
let type_exn = { ocaml_type = Some Predef . path_exn ; java_type = JavaAST . Reference ( " OCamlExn " , [ ] ) ; java_of_ocaml = ( fun e -> JavaAST . Static_call ( " OCamlExn " , " wrap " , [ e ] e ) e ) e ; ocaml_of_java = ( fun e -> JavaAST . Call ( e , " val... |
let always_predefined_types = [ type_array ; type_list ; type_option ; type_lazy ; type_ref ; type_in_channel ; type_out_channel ; type_exn ; ] |
let boxed_only_predefined_types = [ type_int_boxed ; type_char_boxed ; type_float_boxed ; type_bool_boxed ; type_unit_boxed ; type_nativeint_boxed ; type_int32_boxed ; type_int64_boxed ; ] |
let unboxed_only_predefined_types = [ type_int ; type_char ; type_float ; type_bool ; type_nativeint ; type_int32 ; type_int64 ; ] |
let boxed_predefined_types = type_string_boxed :: ( boxed_only_predefined_types @ always_predefined_types ) always_predefined_types |
let unboxed_predefined_types = ref None |
let predefined_types boxed = if boxed then boxed_predefined_types else begin match ! unboxed_predefined_types with | Some cache -> cache | None -> let res = ( match ! Args . string_mapping with | Args . Java_string -> type_string | Args . OCamlString -> type_string_boxed | Args . Byte_array -> type... |
module HashedPath = struct type t = Path . t let equal x y = Path . same x y let rec hash = function | Path . Pident id -> Hashtbl . hash ( Ident . name id ) id | Path . Pdot ( p , s , _ ) _ -> ( hash p ) p + ( Hashtbl . hash s ) s | Path . Papply ( p1 , p2 ) p2 -> ( h... |
module Definitions = Hashtbl . Make ( HashedPath ) HashedPath |
type definitions = ( TypeInfo . t * bool ) bool Definitions . t |
let defined : definitions = Definitions . create 17 |
let locally_defined : definitions = Definitions . create 17 |
let is_defined_and_doesnt_expand path = try snd ( Definitions . find defined path ) path with Not_found -> try snd ( Definitions . find locally_defined path ) path with _ -> false |
let add_local ident dont_expand = let path , info = TypeInfo . make_simple ident in Definitions . add locally_defined path ( info , dont_expand ) dont_expand |
let promote modname = let modpath = Path . Pident ( Ident . create_persistent modname ) modname in Definitions . iter ( fun path ( info , dont_expand ) dont_expand -> let otyp = Path . Pdot ( modpath , Path . name path , 0 ) 0 in let jtyp , name = match info . TypeInfo . java_type wi... |
let find_predefined boxed path = List . find ( fun x -> match x . TypeInfo . ocaml_type with | Some p -> Path . same p path | None -> false ) false ( TypeInfo . predefined_types boxed ) boxed |
let find_defined path = try try fst ( Definitions . find defined path ) path with Not_found -> fst ( Definitions . find locally_defined path ) path with Not_found -> ( match path with | Path . Pident id -> snd ( TypeInfo . make_simple id ) id | _ -> raise Not_found ) Not_found |
let find_from_constructor boxed path = try find_predefined boxed path with Not_found -> find_defined path |
let rec make_wrapper generics i = match i with | JavaAST . Reference ( cn , l ) l -> if TypeParametersTable . mem cn generics then begin match TypeParametersTable . find cn generics with | TypeParametersTable . Parameter path -> let path = List . rev path in begin match path with | param :: accesses ... |
let augment_with_type_parameters generics res l = let l ' ' = List . map ( fun x -> x . TypeInfo . java_type ) java_type l in let jt = match res . TypeInfo . java_type with | JavaAST . Reference ( cn , [ ] ) -> JavaAST . Reference ( cn , l ' ' ) l ' ' | _ -> assert false in le... |
let rec string_of_type_expr te = string_of_type_desc te . Types . desc let open Types in match td with | Tvar None -> " ' " ? | Tvar ( Some s ) s -> " ' " ^ s | Tarrow ( _ , te1 , te2 , _ ) _ -> ( string_of_type_expr te1 ) te1 ^ " -> " ^ ( string_of_type_expr te2 ) te... |
let rec find ( ? generics = TypeParametersTable . empty ) empty boxed t = let open Types in match t . desc with | Tlink t ' -> find ~ generics boxed t ' | Tobject ( _ , { contents = Some ( path , l ) l } ) | Tconstr ( path , l , _ ) _ when is_defined_and_doesnt_expand path... |
let find ( ? generics = TypeParametersTable . empty ) empty boxed t = try find ~ generics boxed t with Not_found -> Wrap_common ( . fail ( Cannot_find_type ( string_of_type_expr t ) t ) t ) t |
module Sig_component_kind = struct type t = | Value | Type | Module | Module_type | Extension_constructor | Class | Class_type let to_string = function | Value -> " value " | Type -> " type " | Module -> " module " | Module_type -> " module type " | Extension_constructor -> " exten... |
type hiding_error = | Illegal_shadowing of { shadowed_item_id : Ident . t ; shadowed_item_kind : Sig_component_kind . t ; shadowed_item_loc : Location . t ; shadower_id : Ident . t ; user_id : Ident . t ; user_kind : Sig_component_kind . t ; user_loc : Location . t ; } | Appear... |
type error = Cannot_apply of module_type | Not_included of Includemod . error list | Cannot_eliminate_dependency of module_type | Signature_expected | Structure_expected of module_type | With_no_component of Longident . t | With_mismatch of Longident . t * Includemod . error list | With_makes_applicati... |
let rec path_concat head p = match p with Pident tail -> Pdot ( Pident head , Ident . name tail ) | Pdot ( pre , s ) -> Pdot ( path_concat head pre , s ) | Papply _ -> assert false |
let extract_sig env loc mty = match Env . scrape_alias env mty with Mty_signature sg -> sg | Mty_alias path -> raise ( Error ( loc , env , Cannot_scrape_alias path ) ) | _ -> raise ( Error ( loc , env , Signature_expected ) ) |
let extract_sig_open env loc mty = match Env . scrape_alias env mty with Mty_signature sg -> sg | Mty_alias path -> raise ( Error ( loc , env , Cannot_scrape_alias path ) ) | mty -> raise ( Error ( loc , env , Structure_expected mty ) ) |
let type_open_ ? used_slot ? toplevel ovf env loc lid = let path = Env . lookup_module_path ~ load : true ~ loc : lid . loc lid . txt env in match Env . open_signature ~ loc ? used_slot ? toplevel ovf path env with | Some env -> path , env | None -> let md = Env . find_module path env in ign... |
let initial_env ~ loc ~ safe_string ~ initially_opened_module ~ open_implicit_modules = let env = if safe_string then Env . initial_safe_string else Env . initial_unsafe_string in let open_module env m = let open Asttypes in let lid = { loc ; txt = Longident . parse m } in snd ( type_open_ Overri... |
let type_open_descr ? used_slot ? toplevel env sod = let ( path , newenv ) = Builtin_attributes . warning_scope sod . popen_attributes ( fun ( ) -> type_open_ ? used_slot ? toplevel sod . popen_override env sod . popen_loc sod . popen_expr ) in let od = { open_expr = ( path , sod ... |
let rm node = Stypes . record ( Stypes . Ti_mod node ) ; node |
let type_module_type_of_fwd : ( Env . t -> Parsetree . module_expr -> Typedtree . module_expr * Types . module_type ) ref = ref ( fun _env _m -> assert false ) |
let check_recmod_typedecls env decls = let recmod_ids = List . map fst decls in List . iter ( fun ( id , md ) -> List . iter ( fun path -> Typedecl . check_recmod_typedecl env md . Types . md_loc recmod_ids path ( Env . find_type path env ) ) ( Mtype . type_paths env ( Pident id ... |
let rec add_rec_types env = function Sig_type ( id , decl , Trec_next , _ ) :: rem -> add_rec_types ( Env . add_type ~ check : true id decl env ) rem | _ -> env |
let check_type_decl env loc id row_id newdecl decl rs rem = let env = Env . add_type ~ check : true id newdecl env in let env = match row_id with | None -> env | Some id -> Env . add_type ~ check : false id newdecl env in let env = if rs = Trec_not then env else add_rec_types env rem in Includemod . ... |
let update_rec_next rs rem = match rs with Trec_next -> rem | Trec_first | Trec_not -> match rem with Sig_type ( id , decl , Trec_next , priv ) :: rem -> Sig_type ( id , decl , rs , priv ) :: rem | Sig_module ( id , pres , mty , Trec_next , priv ) :: rem -> Sig_module ( id ,... |
let make_variance p n i = let open Variance in set May_pos p ( set May_neg n ( set May_weak n ( set Inj i null ) ) ) |
let rec iter_path_apply p ~ f = match p with | Pident _ -> ( ) | Pdot ( p , _ ) -> iter_path_apply p ~ f | Papply ( p1 , p2 ) -> iter_path_apply p1 ~ f ; iter_path_apply p2 ~ f ; f p1 p2 |
let path_is_strict_prefix = let rec list_is_strict_prefix l ~ prefix = match l , prefix with | [ ] , [ ] -> false | _ :: _ , [ ] -> true | [ ] , _ :: _ -> false | s1 :: t1 , s2 :: t2 -> String . equal s1 s2 && list_is_strict_prefix t1 ~ prefix : t2 in fun path ~ prefix... |
let iterator_with_env env = let env = ref ( lazy env ) in let super = Btype . type_iterators in env , { super with Btype . it_signature = ( fun self sg -> let env_before = ! env in env := lazy ( Env . add_signature sg ( Lazy . force env_before ) ) ; super . Btype . it_signature s... |
let retype_applicative_functor_type ~ loc env funct arg = let mty_functor = ( Env . find_module funct env ) . md_type in let mty_arg = ( Env . find_module arg env ) . md_type in let mty_param = match Env . scrape_alias env mty_functor with | Mty_functor ( Named ( _ , mty_param ) , _ ... |
let check_usage_of_path_of_substituted_item paths env signature ~ loc ~ lid = let iterator = let env , super = iterator_with_env env in { super with Btype . it_signature_item = ( fun self -> function | Sig_module ( id , _ , { md_type = Mty_alias aliased_path ; _ } , _ , _ ) when L... |
let rec extract_next_modules = function | Sig_module ( id , _ , mty , Trec_next , _ ) :: rem -> let ( id_mty_l , rem ) = extract_next_modules rem in ( ( id , mty ) :: id_mty_l , rem ) | sg -> ( [ ] , sg ) |
let check_well_formed_module env loc context mty = let open Btype in let iterator = let rec check_signature env = function | [ ] -> ( ) | Sig_module ( id , _ , mty , Trec_first , _ ) :: rem -> let ( id_mty_l , rem ) = extract_next_modules rem in begin try check_recmod_typedecls ( ... |
let ( ) = Env . check_well_formed_module := check_well_formed_module |
let type_decl_is_alias sdecl = match sdecl . ptype_manifest with | Some { ptyp_desc = Ptyp_constr ( lid , stl ) } when List . length stl = List . length sdecl . ptype_params -> begin match List . iter2 ( fun x ( y , _ ) -> match x , y with { ptyp_desc = Ptyp_var sx } , { pt... |
let params_are_constrained = let rec loop = function | [ ] -> false | hd :: tl -> match ( Btype . repr hd ) . desc with | Tvar _ -> List . memq hd tl || loop tl | _ -> true in loop ; ; |
let merge_constraint initial_env remove_aliases loc sg constr = let lid = match constr with | Pwith_type ( lid , _ ) | Pwith_module ( lid , _ ) | Pwith_typesubst ( lid , _ ) | Pwith_modsubst ( lid , _ ) -> lid in let destructive_substitution = match constr with | Pwith_type _ | Pw... |
let map_rec fn decls rem = match decls with | [ ] -> rem | d1 :: dl -> fn Trec_first d1 :: map_end ( fn Trec_next ) dl rem |
let map_rec_type ~ rec_flag fn decls rem = match decls with | [ ] -> rem | d1 :: dl -> let first = match rec_flag with | Recursive -> Trec_first | Nonrecursive -> Trec_not in fn first d1 :: map_end ( fn Trec_next ) dl rem |
let rec map_rec_type_with_row_types ~ rec_flag fn decls rem = match decls with | [ ] -> rem | d1 :: dl -> if Btype . is_row_name ( Ident . name d1 . typ_id ) then fn Trec_not d1 :: map_rec_type_with_row_types ~ rec_flag fn dl rem else map_rec_type ~ rec_flag fn decls rem |
let map_ext fn exts rem = match exts with | [ ] -> rem | d1 :: dl -> fn Text_first d1 :: map_end ( fn Text_next ) dl rem |
let rec approx_modtype env smty = match smty . pmty_desc with Pmty_ident lid -> let ( path , _info ) = Env . lookup_modtype ~ use : false ~ loc : smty . pmty_loc lid . txt env in Mty_ident path | Pmty_alias lid -> let path = Env . lookup_module_path ~ use : false ~ load : false ~ loc : ... |
let approx_modtype env smty = Warnings . without_warnings ( fun ( ) -> approx_modtype env smty ) |
module Signature_names : sig type t type info = [ | ` Exported | ` From_open | ` Shadowable of Ident . t * Location . t | ` Substituted_away of Subst . t ] val create : unit -> t val check_value : ? info : info -> t -> Location . t -> Ident . t -> unit val check_type : ? info : ... |
let has_remove_aliases_attribute attr = let remove_aliases = Attr_helper . get_no_payload_attribute [ " remove_aliases " ; " ocaml . remove_aliases " ] attr in match remove_aliases with | None -> false | Some _ -> true |
let transl_modtype_longident loc env lid = let ( path , _info ) = Env . lookup_modtype ~ loc lid env in path |
let transl_module_alias loc env lid = Env . lookup_module_path ~ load : false ~ loc lid env |
let mkmty desc typ env loc attrs = let mty = { mty_desc = desc ; mty_type = typ ; mty_loc = loc ; mty_env = env ; mty_attributes = attrs ; } in Cmt_format . add_saved_type ( Cmt_format . Partial_module_type mty ) ; mty |
let mksig desc env loc = let sg = { sig_desc = desc ; sig_loc = loc ; sig_env = env } in Cmt_format . add_saved_type ( Cmt_format . Partial_signature_item sg ) ; sg |
let rec transl_modtype env smty = Builtin_attributes . warning_scope smty . pmty_attributes ( fun ( ) -> transl_modtype_aux env smty ) let mty = transl_modtype env sarg in { mty with mty_type = Mtype . scrape_for_functor_arg env mty . mty_type } let loc = smty . pmty_loc in match smty . pmt... |
let rec path_of_module mexp = match mexp . mod_desc with | Tmod_ident ( p , _ ) -> p | Tmod_apply ( funct , arg , _coercion ) when ! Clflags . applicative_functors -> Papply ( path_of_module funct , path_of_module arg ) | Tmod_constraint ( mexp , _ , _ , _ ) -> path_of_mod... |
let path_of_module mexp = try Some ( path_of_module mexp ) with Not_a_path -> None |
let rec closed_modtype env = function Mty_ident _ -> true | Mty_alias _ -> true | Mty_signature sg -> let env = Env . add_signature sg env in List . for_all ( closed_signature_item env ) sg | Mty_functor ( arg_opt , body ) -> let env = match arg_opt with | Unit | Named ( None , _ ) -... |
let check_nongen_scheme env sig_item = match sig_item with Sig_value ( _id , vd , _ ) -> if not ( Ctype . closed_schema env vd . val_type ) then raise ( Error ( vd . val_loc , env , Non_generalizable vd . val_type ) ) | Sig_module ( _id , _ , md , _ , _ ) -> if not ... |
let check_nongen_schemes env sg = List . iter ( check_nongen_scheme env ) sg |
let anchor_submodule name anchor = match anchor , name with | None , _ | _ , None -> None | Some p , Some name -> Some ( Pdot ( p , name ) ) |
let anchor_recmodule = Option . map ( fun id -> Pident id ) |
let enrich_type_decls anchor decls oldenv newenv = match anchor with None -> newenv | Some p -> List . fold_left ( fun e info -> let id = info . typ_id in let info ' = Mtype . enrich_typedecl oldenv ( Pdot ( p , Ident . name id ) ) id info . typ_type in Env . add_type ~ check : true i... |
let enrich_module_type anchor name mty env = match anchor , name with | None , _ | _ , None -> mty | Some p , Some name -> Mtype . enrich_modtype env ( Pdot ( p , name ) ) mty |
let check_recmodule_inclusion env bindings = let subst_and_strengthen env scope s id mty = let mty = Subst . modtype ( Rescope scope ) s mty in match id with | None -> mty | Some id -> Mtype . strengthen ~ aliasable : false env mty ( Subst . module_path s ( Pident id ) ) in let rec check_incl... |
let rec package_constraints env loc mty constrs = if constrs = [ ] then mty else let sg = extract_sig env loc mty in let sg ' = List . map ( function | Sig_type ( id , ( { type_params [ ] } = as td ) , rs , priv ) when List . mem_assoc [ Ident . name id ] constrs -> let ty... |
let modtype_of_package env loc p nl tl = match ( Env . find_modtype p env ) . mtd_type with | Some mty when nl <> [ ] -> package_constraints env loc mty ( List . combine ( List . map Longident . flatten nl ) tl ) | _ -> if nl = [ ] then Mty_ident p else raise ( Error ( loc , ... |
let package_subtype env p1 nl1 tl1 p2 nl2 tl2 = let mkmty p nl tl = let ntl = List . filter ( fun ( _n , t ) -> Ctype . free_variables t = [ ] ) ( List . combine nl tl ) in let ( nl , tl ) = List . split ntl in modtype_of_package env Location . none p nl tl in let mty1 = mkmty ... |
let ( ) = Ctype . package_subtype := package_subtype |
let wrap_constraint env mark arg mty explicit = let mark = if mark then Includemod . Mark_both else Includemod . Mark_neither in let coercion = try Includemod . modtypes ~ loc : arg . mod_loc env ~ mark arg . mod_type mty with Includemod . Error msg -> raise ( Error ( arg . mod_loc , env , ... |
let rec type_module ( ? alias = false ) sttn funct_body anchor env smod = Builtin_attributes . warning_scope smod . pmod_attributes ( fun ( ) -> type_module_aux ~ alias sttn funct_body anchor env smod ) match smod . pmod_desc with Pmod_ident lid -> let path = Env . lookup_module_path ~ load ... |
let type_toplevel_phrase env s = Env . reset_required_globals ( ) ; let ( str , sg , to_remove_from_sg , env ) = type_structure ~ toplevel : true false None env s Location . none in ( str , sg , to_remove_from_sg , env ) |
let type_module_alias = type_module ~ alias : true true false None |
let type_module = type_module true false None |
let type_structure = type_structure false None |
let rec normalize_modtype env = function Mty_ident _ | Mty_alias _ -> ( ) | Mty_signature sg -> normalize_signature env sg | Mty_functor ( _param , body ) -> normalize_modtype env body Sig_value ( _id , desc , _ ) -> Ctype . normalize_type env desc . val_type | Sig_module ( _id , ... |
let type_module_type_of env smod = let remove_aliases = has_remove_aliases_attribute smod . pmod_attributes in let tmty = match smod . pmod_desc with | Pmod_ident lid -> let path , md = Env . lookup_module ~ loc : smod . pmod_loc lid . txt env in rm { mod_desc = Tmod_ident ( path , lid ) ; ... |
let rec extend_path path = fun lid -> match lid with | Lident name -> Pdot ( path , name ) | Ldot ( m , name ) -> Pdot ( extend_path path m , name ) | Lapply _ -> assert false |
let lookup_type_in_sig sg = let types , modules = List . fold_left ( fun acc item -> match item with | Sig_type ( id , _ , _ , _ ) -> let types , modules = acc in let types = String . Map . add ( Ident . name id ) id types in types , modules | Sig_module ( id , _ , _ , ... |
let type_package env m p nl = Ctype . begin_def ( ) ; let context = Typetexp . narrow ( ) in let modl = type_module env m in let scope = Ctype . create_scope ( ) in Typetexp . widen context ; let nl ' , tl ' , env = match nl with | [ ] -> [ ] , [ ] , env | nl -> ... |
let type_open_decl ? used_slot env od = type_open_decl ? used_slot ? toplevel : None false ( Signature_names . create ( ) ) env od |
let type_open_descr ? used_slot env od = type_open_descr ? used_slot ? toplevel : None env od |
let ( ) = Typecore . type_module := type_module_alias ; Typetexp . transl_modtype_longident := transl_modtype_longident ; Typetexp . transl_modtype := transl_modtype ; Typecore . type_open := type_open_ ? toplevel : None ; Typecore . type_open_decl := type_open_decl ; Typecore . type_p... |
let type_implementation sourcefile outputprefix modulename initial_env ast = Cmt_format . clear ( ) ; Misc . try_finally ( fun ( ) -> Typecore . reset_delayed_checks ( ) ; Env . reset_required_globals ( ) ; if ! Clflags . print_types then Warnings . parse_options false " - 32 ... |
let save_signature modname tsg outputprefix source_file initial_env cmi = Cmt_format . save_cmt ( outputprefix ^ " . cmti " ) modname ( Cmt_format . Interface tsg ) ( Some source_file ) initial_env ( Some cmi ) |
let type_interface env ast = transl_signature env ast |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.