text stringlengths 12 786k |
|---|
let expand_head_of_alias_type env kind ~ known_canonical_simple_at_in_types_mode : simple = let [ @ inline always ] name name ~ coercion = let ty = TE . find env name ( Some kind ) in match TG . get_alias_exn ty with | exception Not_found -> let coercion = if Coercion . is_id coercion then None ... |
let expand_head0 env ty ~ known_canonical_simple_at_in_types_mode = match TG . get_alias_exn ty with | exception Not_found -> ET . of_non_alias_type ty | _ -> ( match known_canonical_simple_at_in_types_mode with | Some simple -> expand_head_of_alias_type env ( TG . kind ty ) ~ known_canonical_simp... |
let expand_head env ty = match TG . get_alias_exn ty with | exception Not_found -> ET . of_non_alias_type ty | simple -> ( let kind = TG . kind ty in match TE . get_canonical_simple_exn env simple ~ min_name_mode : Name_mode . in_types with | exception Not_found -> ET . of_non_alias_type ( MTC... |
let is_bottom env t = ET . is_bottom ( expand_head env t ) |
let is_unknown env t = ET . is_unknown ( expand_head env t ) |
let missing_kind env free_names = Name_occurrences . fold_variables free_names ~ init : false ~ f ( : fun missing_kind var -> missing_kind || TE . variable_is_from_missing_cmx_file env ( Name . var var ) ) |
type to_erase = | Everything_not_in of Typing_env . t | All_variables_except of Variable . Set . t |
let free_variables_transitive ~ free_names_of_type env free_vars_acc ty = let rec free_variables_transitive0 ty ~ free_vars_acc = let free_vars = free_names_of_type ty |> Name_occurrences . with_only_variables in if missing_kind env free_vars then raise Missing_cmx_file else let to_traverse = Name_occurrences ... |
let make_suitable_for_environment env ( to_erase : to_erase ) bind_to_and_types = ( match to_erase with | Everything_not_in suitable_for -> List . iter ( fun ( bind_to , _ty ) -> if not ( TE . mem suitable_for bind_to ) then Misc . fatal_errorf " Variable to be bound % a is expected to ... |
type t = Code_or_metadata . t Code_id . Map . t |
let print ppf t = Code_id . Map . print Code_or_metadata . print ppf t |
let free_names t = Code_id . Map . fold ( fun _code_id code acc -> Name_occurrences . union acc ( Code_or_metadata . free_names code ) ) t Name_occurrences . empty |
let add_code ~ keep_code code_map t = Code_id . Map . mapi ( fun code_id code -> if not ( Code_id . equal code_id ( Code . code_id code ) ) then Misc . fatal_errorf " Code ID key in map disagrees with [ Code ] :@ % a " ( Code_id . Map . print Code . print ) code_map ; let co... |
let mark_as_imported t = Code_id . Map . map_sharing Code_or_metadata . remember_only_metadata t |
let merge t1 t2 = Code_id . Map . union Code_or_metadata . merge t1 t2 |
let mem code_id t = Code_id . Map . mem code_id t |
let find_exn t code_id = Code_id . Map . find code_id t |
let find t code_id = match Code_id . Map . find code_id t with | exception Not_found -> None | code_or_metadata -> Some code_or_metadata |
let remove_unreachable ~ reachable_names t = Code_id . Map . filter ( fun code_id _code_or_metadata -> Name_occurrences . mem_code_id reachable_names code_id ) t |
let remove_unused_value_slots_from_result_types_and_shortcut_aliases ~ used_value_slots ~ canonicalise t = Code_id . Map . map ( fun code_or_metadata -> Code_or_metadata . map_result_types code_or_metadata ~ f ( : fun result_ty -> Flambda2_types . remove_unused_value_slots_and_shortcut_aliases result... |
let all_ids_for_export t = Code_id . Map . fold ( fun code_id code_or_metadata all_ids -> Ids_for_export . union ( Ids_for_export . add_code_id all_ids code_id ) ( Code_or_metadata . all_ids_for_export code_or_metadata ) ) t Ids_for_export . empty |
let apply_renaming code_id_map renaming t = if Renaming . is_empty renaming && Code_id . Map . is_empty code_id_map then t else Code_id . Map . fold ( fun code_id code_or_metadata all_code -> let code_id = match Code_id . Map . find code_id code_id_map with | exception Not_found -> code_id | code... |
let iter_code t ~ f = Code_id . Map . iter ( fun _code_id code_or_metadata -> Code_or_metadata . iter_code code_or_metadata ~ f ) t |
type function_slot_info = | Dead_function_slot | Live_function_slot of { offset : int ; size : int } |
type value_slot_info = | Dead_value_slot | Live_value_slot of { offset : int } |
type t = { function_slot_offsets : function_slot_info Function_slot . Map . t ; value_slot_offsets : value_slot_info Value_slot . Map . t } |
let print_function_slot_info fmt = function | Dead_function_slot -> Format . fprintf fmt " [ @< h ( > dead ) ] " @ | Live_function_slot { offset ; size } -> Format . fprintf fmt " [ @< h ( > o :% d , s :% d ) ] " @ offset size |
let print_value_slot_info fmt ( info : value_slot_info ) = match info with | Dead_value_slot -> Format . fprintf fmt " [ @< h ( > removed ) ] " @ | Live_value_slot { offset } -> Format . fprintf fmt " [ @< h ( > o :% d ) ] " @ offset |
let [ @ ocamlformat " disable " ] print fmt env = Format . fprintf fmt " { [ @< v > closures : [ @< v >% a ] , @@ value_slots : [ @< v >% a ] ] } " @@ ( Function_slot . Map . print print_function_slot_info ) env . function_slot_offsets ( Value_slot . Map . pri... |
let empty = { function_slot_offsets = Function_slot . Map . empty ; value_slot_offsets = Value_slot . Map . empty } |
let equal_function_slot_info ( info1 : function_slot_info ) ( info2 : function_slot_info ) = match info1 , info2 with | Dead_function_slot , Dead_function_slot -> true | ( Live_function_slot { offset = o1 ; size = s1 } , Live_function_slot { offset = o2 ; size = s2 } ) -> o1 = ... |
let equal_value_slot_info ( info1 : value_slot_info ) ( info2 : value_slot_info ) = match info1 , info2 with | Dead_value_slot , Dead_value_slot -> true | Live_value_slot { offset = o1 } , Live_value_slot { offset = o2 } -> o1 = o2 | Dead_value_slot , Live_value_slot _ | Live_value_... |
let add_function_slot_offset env closure offset = match Function_slot . Map . find closure env . function_slot_offsets with | o -> assert ( equal_function_slot_info o offset ) ; env | exception Not_found -> let function_slot_offsets = Function_slot . Map . add closure offset env . function_slot_... |
let add_value_slot_offset env value_slot offset = match Value_slot . Map . find value_slot env . value_slot_offsets with | o -> assert ( equal_value_slot_info o offset ) ; env | exception Not_found -> let value_slot_offsets = Value_slot . Map . add value_slot offset env . value_slot_offsets in {... |
let function_slot_offset env closure = match Function_slot . Map . find closure env . function_slot_offsets with | exception Not_found -> None | res -> Some res |
let value_slot_offset env value_slot = match Value_slot . Map . find value_slot env . value_slot_offsets with | exception Not_found -> None | res -> Some res |
let map_function_slot_offsets env f = Function_slot . Map . mapi f env . function_slot_offsets |
let map_value_slot_offsets env f = Value_slot . Map . mapi f env . value_slot_offsets |
let current_offsets = ref empty |
let imported_offsets ( ) = ! current_offsets |
let merge env1 env2 = let function_slot_offsets = Function_slot . Map . disjoint_union ~ eq : equal_function_slot_info ~ print : print_function_slot_info env1 . function_slot_offsets env2 . function_slot_offsets in let value_slot_offsets = Value_slot . Map . disjoint_union ~ eq : equal_value_slot_i... |
let import_offsets env = current_offsets := merge env ! current_offsets |
type value_string_contents = | Contents of string | Unknown_or_mutable |
type value_string = { contents : value_string_contents ; size : int ; } |
type value_float_array_contents = | Contents of float option array | Unknown_or_mutable |
type value_float_array = { contents : value_float_array_contents ; size : int ; } |
type descr = | Value_block of Tag . t * approx array | Value_mutable_block of Tag . t * int | Value_int of int | Value_char of char | Value_float of float | Value_float_array of value_float_array | Value_boxed_int : ' a A . boxed_int * ' a -> descr | Value_string of value_string | Value_closure... |
let equal_approx ( a1 : approx ) ( a2 : approx ) = match a1 , a2 with | Value_unknown , Value_unknown -> true | Value_id id1 , Value_id id2 -> Export_id . equal id1 id2 | Value_symbol s1 , Value_symbol s2 -> Symbol . equal s1 s2 | ( Value_unknown | Value_symbol _ | Value_id _ ) , ... |
let equal_array eq a1 a2 = Array . length a1 = Array . length a2 && try Array . iteri ( fun i v1 -> if not ( eq a2 . ( i ) v1 ) then raise Exit ) a1 ; true with Exit -> false |
let equal_option eq o1 o2 = match o1 , o2 with | None , None -> true | Some v1 , Some v2 -> eq v1 v2 | Some _ , None | None , Some _ -> false |
let equal_set_of_closures ( s1 : value_set_of_closures ) ( s2 : value_set_of_closures ) = Set_of_closures_id . equal s1 . set_of_closures_id s2 . set_of_closures_id && Var_within_closure . Map . equal equal_approx s1 . bound_vars s2 . bound_vars && Closure_id . Map . equal equal_approx s1... |
let equal_descr ( d1 : descr ) ( d2 : descr ) : bool = match d1 , d2 with | Value_unknown_descr , Value_unknown_descr -> true | Value_block ( t1 , f1 ) , Value_block ( t2 , f2 ) -> Tag . equal t1 t2 && equal_array equal_approx f1 f2 | Value_mutable_block ( t1 , s1 ) , Value... |
type t = { sets_of_closures : A . function_declarations Set_of_closures_id . Map . t ; values : descr Export_id . Map . t Compilation_unit . Map . t ; symbol_id : Export_id . t Symbol . Map . t ; offset_fun : int Closure_id . Map . t ; offset_fv : int Var_within_closure . Map .... |
type transient = { sets_of_closures : A . function_declarations Set_of_closures_id . Map . t ; values : descr Export_id . Map . t Compilation_unit . Map . t ; symbol_id : Export_id . t Symbol . Map . t ; invariant_params : Variable . Set . t Variable . Map . t Set_of_closures_id... |
let empty : t = { sets_of_closures = Set_of_closures_id . Map . empty ; values = Compilation_unit . Map . empty ; symbol_id = Symbol . Map . empty ; offset_fun = Closure_id . Map . empty ; offset_fv = Var_within_closure . Map . empty ; constant_closures = Closure_id . Set . e... |
let opaque_transient ~ compilation_unit ~ root_symbol : transient = let export_id = Export_id . create compilation_unit in let values = let map = Export_id . Map . singleton export_id Value_unknown_descr in Compilation_unit . Map . singleton compilation_unit map in let symbol_id = Symbol . Map . s... |
let create ~ sets_of_closures ~ values ~ symbol_id ~ offset_fun ~ offset_fv ~ constant_closures ~ invariant_params ~ recursive = { sets_of_closures ; values ; symbol_id ; offset_fun ; offset_fv ; constant_closures ; invariant_params ; recursive ; } |
let create_transient ~ sets_of_closures ~ values ~ symbol_id ~ invariant_params ~ recursive ~ relevant_local_closure_ids ~ relevant_imported_closure_ids ~ relevant_local_vars_within_closure ~ relevant_imported_vars_within_closure = { sets_of_closures ; values ; symbol_id ; invariant_params ; recursi... |
let t_of_transient transient ~ program : _ ~ local_offset_fun ~ local_offset_fv ~ imported_offset_fun ~ imported_offset_fv ~ constant_closures = let offset_fun = let fold_map set = Closure_id . Map . fold ( fun key value unchanged -> if Closure_id . Set . mem key set then Closure_id . Map . ad... |
let merge ( t1 : t ) ( t2 : t ) : t = let eidmap_disjoint_union ? eq map1 map2 = Compilation_unit . Map . merge ( fun _id map1 map2 -> match map1 , map2 with | None , None -> None | None , Some map | Some map , None -> Some map | Some map1 , Some map2 -> Some ( Export_id . Map... |
let find_value eid map = let unit_map = Compilation_unit . Map . find ( Export_id . get_compilation_unit eid ) map in Export_id . Map . find eid unit_map |
let find_description ( t : t ) eid = find_value eid t . values |
let nest_eid_map map = let add_map eid v map = let unit = Export_id . get_compilation_unit eid in let m = try Compilation_unit . Map . find unit map with Not_found -> Export_id . Map . empty in Compilation_unit . Map . add unit ( Export_id . Map . add eid v m ) map in Export_id . Map . fo... |
let print_raw_approx ppf approx = let fprintf = Format . fprintf in match approx with | Value_unknown -> fprintf ppf " ( Unknown ) " | Value_id export_id -> fprintf ppf " ( Id % a ) " Export_id . print export_id | Value_symbol symbol -> fprintf ppf " ( Symbol % a ) " Symbol . pri... |
let print_value_set_of_closures ppf ( t : value_set_of_closures ) = let print_bound_vars ppf bound_vars = Format . fprintf ppf " ( % a ) " ( Var_within_closure . Map . print print_raw_approx ) bound_vars in let print_free_vars ppf free_vars = Format . fprintf ppf " ( % a ) " ( Va... |
let print_value_closure ppf ( t : value_closure ) = Format . fprintf ppf " ( ( closure_id % a ) ( set_of_closures % a ) ) " Closure_id . print t . closure_id print_value_set_of_closures t . set_of_closures |
let print_value_float_array_contents ppf ( value : value_float_array_contents ) = match value with | Unknown_or_mutable -> Format . fprintf ppf " ( Unknown_or_mutable ) " | Contents _ -> Format . fprintf ppf " ( Contents . . . ) " |
let print_value_float_array ppf ( value : value_float_array ) = Format . fprintf ppf " ( ( size % d ) ( contents % a ) ) " value . size print_value_float_array_contents value . contents |
let print_value_string_contents ppf ( value : value_string_contents ) = match value with | Unknown_or_mutable -> Format . fprintf ppf " ( Unknown_or_mutable ) " | Contents _ -> Format . fprintf ppf " ( Contents . . . ) " |
let print_value_string ppf ( value : value_string ) = Format . fprintf ppf " ( ( size % d ) ( contents % a ) ) " value . size print_value_string_contents value . contents |
let print_raw_descr ppf descr = let fprintf = Format . fprintf in let print_approx_array ppf arr = Array . iter ( fun approx -> fprintf ppf " % a " print_raw_approx approx ) arr in match descr with | Value_block ( tag , approx_array ) -> fprintf ppf " ( Value_block ( % a % a ) ) " ... |
let print_approx_components ppf ~ symbol_id ~ values ( root_symbols : Symbol . t list ) = let fprintf = Format . fprintf in let printed = ref Export_id . Set . empty in let recorded_symbol = ref Symbol . Set . empty in let symbols_to_print = Queue . create ( ) in let printed_set_of_closure... |
let print_approx ppf ( ( t : t ) , symbols ) = let symbol_id = t . symbol_id in let values = t . values in print_approx_components ppf ~ symbol_id ~ values symbols |
let print_offsets ppf ( t : t ) = Format . fprintf ppf " [ @< v 2 > offset_fun :@ " ; Closure_id . Map . iter ( fun cid off -> Format . fprintf ppf " % a -> % i @ " Closure_id . print cid off ) t . offset_fun ; Format . fprintf ppf " ] @@ [ @< v 2 > offset_fv :@... |
let print_functions ppf ( t : t ) = Set_of_closures_id . Map . print A . print_function_declarations ppf t . sets_of_closures |
let print_all ppf ( ( t , root_symbols ) : t * Symbol . t list ) = let fprintf = Format . fprintf in fprintf ppf " approxs @ % a . . " @@ print_approx ( t , root_symbols ) ; fprintf ppf " functions @ % a . . " @@ print_functions t |
let rename_id_state = Export_id . Tbl . create 100 |
let rename_set_of_closures_id_state = Set_of_closures_id . Tbl . create 10 |
let imported_function_declarations_table = ( Set_of_closures_id . Tbl . create 10 : A . function_declarations Set_of_closures_id . Tbl . t ) |
let import_eid_for_pack units pack id = try Export_id . Tbl . find rename_id_state id with Not_found -> let unit_id = Export_id . get_compilation_unit id in let id ' = if Compilation_unit . Set . mem unit_id units then Export_id . create ? name ( : Export_id . name id ) pack else id in Export_... |
let import_symbol_for_pack units pack symbol = let compilation_unit = Symbol . compilation_unit symbol in if Compilation_unit . Set . mem compilation_unit units then Symbol . import_for_pack ~ pack symbol else symbol |
let import_approx_for_pack units pack ( approx : Export_info . approx ) : Export_info . approx = match approx with | Value_symbol sym -> Value_symbol ( import_symbol_for_pack units pack sym ) | Value_id eid -> Value_id ( import_eid_for_pack units pack eid ) | Value_unknown -> Value_unknown |
let import_set_of_closures_id_for_pack units pack ( set_of_closures_id : Set_of_closures_id . t ) : Set_of_closures_id . t = let compilation_unit = Set_of_closures_id . get_compilation_unit set_of_closures_id in if Compilation_unit . Set . mem compilation_unit units then Set_of_closures_id . Tbl . ... |
let import_set_of_closures_origin_for_pack units pack ( set_of_closures_origin : Set_of_closures_origin . t ) : Set_of_closures_origin . t = Set_of_closures_origin . rename ( import_set_of_closures_id_for_pack units pack ) set_of_closures_origin |
let import_set_of_closures units pack ( set_of_closures : Export_info . value_set_of_closures ) : Export_info . value_set_of_closures = { set_of_closures_id = import_set_of_closures_id_for_pack units pack set_of_closures . set_of_closures_id ; bound_vars = Var_within_closure . Map . map ( impor... |
let import_descr_for_pack units pack ( descr : Export_info . descr ) : Export_info . descr = match descr with | Value_int _ | Value_char _ | Value_string _ | Value_float _ | Value_float_array _ | Export_info . Value_boxed_int _ | Value_mutable_block _ as desc -> desc | Value_block ( tag ,... |
let rec import_code_for_pack units pack expr = Flambda_iterators . map_named ( function | Symbol sym -> Symbol ( import_symbol_for_pack units pack sym ) | Read_symbol_field ( sym , field ) -> Read_symbol_field ( import_symbol_for_pack units pack sym , field ) | Set_of_closures set_of_closures ... |
let import_function_declarations_for_pack_aux units pack ( function_decls : A . function_declarations ) : A . function_declarations = let funs = Variable . Map . map ( fun ( function_decl : A . function_declaration ) -> A . update_function_declaration_body function_decl ( fun body -> impo... |
let import_function_declarations_approx_for_pack units pack ( function_decls : A . function_declarations ) = let original_set_of_closures_id = function_decls . set_of_closures_id in try Set_of_closures_id . Tbl . find imported_function_declarations_table original_set_of_closures_id with Not_found -> let... |
let import_eidmap_for_pack units pack f map = Export_info . nest_eid_map ( Compilation_unit . Map . fold ( fun _ map acc -> Export_id . Map . disjoint_union map acc ) ( Compilation_unit . Map . map ( fun map -> Export_id . Map . map_keys ( import_eid_for_pack units pack ) ( Export_... |
let import_for_pack ~ pack_units ~ pack ( exp : Export_info . t ) = let import_sym = import_symbol_for_pack pack_units pack in let import_descr = import_descr_for_pack pack_units pack in let import_eid = import_eid_for_pack pack_units pack in let import_eidmap f map = import_eidmap_for_pack pack_units pac... |
let clear_import_state ( ) = Set_of_closures_id . Tbl . clear imported_function_declarations_table ; Set_of_closures_id . Tbl . clear rename_set_of_closures_id_state ; Export_id . Tbl . clear rename_id_state |
module Token = struct type t = | VER of string | ID of string | LPAREN | RPAREN | AND | OR | NOT | EQ | NE | GT | LT | GE | LE let to_string = function | VER v -> v | ID s -> s | LPAREN -> " ( " | RPAREN -> " ) " | AND -> " " & | OR -> " " | | NOT -> " " ! | EQ ... |
type t = | And of t * t | Or of t * t | Not of t | Paren of t | Eq of version | Le of version | Lt of version | Ge of version | Gt of version | Ne of version |
let compare_version v1 v2 = let skip i p s e = let rec loop i = if i = e then i else if ( p s . [ i ] ) then loop ( i + 1 ) else i in loop i in let split_version v = let ( p1 , rest ) = match ( string_split ' ' : v ~ limit : 2 ) with [ _ ] -> ( " " , v ) | [ p1... |
let rec eval version constr = match constr with | And ( e1 , e2 ) -> ( eval version e1 ) && ( eval version e2 ) | Or ( e1 , e2 ) -> ( eval version e1 ) || ( eval version e2 ) | Not e -> not ( eval version e ) | Paren e -> eval version e | Eq v -> compare_version version v =... |
let rec to_string = function | And ( e1 , e2 ) -> ( to_string e1 ) ^ " && " ^ ( to_string e2 ) | Or ( e1 , e2 ) -> ( to_string e1 ) ^ " || " ^ ( to_string e2 ) | Not e -> " ! " ^ ( to_string e ) | Paren e -> " ( " ^ ( to_string e ) ^ " ) " ... |
let showList sep f l = String . concat sep ( List . map f l ) |
let parse_expr l = let rec parse_sub_expr l = match l with | [ ] -> raise MalformedExpression | Token . NOT :: r -> let ( e , r ) = parse_sub_expr r in ( ( Not e ) , r ) | Token . LPAREN :: r -> let ( e , r ) = parse_sub_expr r in let rec loop e r = ( match r with | Token .... |
let parse_constraints name cs = try match cs with | [ ] -> None | expr -> let e = parse_expr expr in Some e with e -> let err = match e with | UnknownExpression z -> " unknown constraints expression " " \ ^ z ^ " " " \ | UnbalancedParenthesis -> " unbalanced parenthesis " | Malforme... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.