text
stringlengths
0
601k
type cnl_kind = | K_expr of ( event_name * field_name ) option | K_actn | K_evnt | K_cond | K_actns | K_actns_closed | K_rule
type cnl_ast = | Cnl_expr of cnl_expr | Cnl_actn of cnl_action | Cnl_evnt of cnl_event | Cnl_cond of cnl_cond | Cnl_actns of cnl_actions | Cnl_rule of cnl_rule
let string_of_cnl_agg agg = begin match agg with | A_total -> " total " | A_avg -> " average " end
let string_of_cnl_unop op = begin match op with | Op_not -> " not " | Op_toString -> " toString " end
let string_of_cnl_binop op = begin match op with | Op_eq -> " is " | Op_ne -> " is not " | Op_lt -> " is less than " | Op_le -> " is under " | Op_gt -> " is more than " | Op_ge -> " is over " | Op_and -> " and " | Op_or -> " or " | Op_plus -> " " + | Op_minus -> " " - | Op_mult -> " " * | Op_div -> " " / | Op_mod -> " ...
let node_desc node = begin match node with | N_undefined _ -> None | N_filled ( _ , desc ) | N_rejected ( _ , desc ) | N_accepted desc -> Some desc end
let node_id node = begin match node with | N_undefined id | N_filled ( id , _ ) | N_rejected ( id , _ ) -> Some id | N_accepted _ -> None end
let find_node_kind ( id : id ) ( kind : cnl_kind ) ( node : ' a node ) ( acc : cnl_kind option ) : cnl_kind option = begin match node with | N_undefined id ' | N_filled ( id ' , _ ) | N_rejected ( id ' , _ ) -> if id = id ' then begin match acc with | None -> Some kind | Some _ -> acc end else acc | N_accepted _ -> acc...
let find_node_kind_fold_fun ( id : id ) = let f kind node acc = find_node_kind id kind node acc in { Cnl2cnl . id_fold_over_node_fun with Cnl2cnl . poly_fold_fun = f }
let rule_find_node_kind ( id : id ) ( rule : cnl_rule ) : cnl_kind option = Cnl2cnl . rule_dp_fold_over_nodes ( find_node_kind_fold_fun id ) rule None
let get_node_ids ( kind : cnl_kind ) ( node : ' a node ) ( acc : ( id * cnl_kind * unit node ) list ) : ( id * cnl_kind * unit node ) list = begin match node with | N_undefined id -> ( id , kind , N_undefined id ) :: acc | N_filled ( id , _ ) -> ( id , kind , N_filled ( id , ( ) ) ) :: acc | N_rejected ( id , _ ) -> ( ...
let get_node_ids_fold_fun = { Cnl2cnl . id_fold_over_node_fun with Cnl2cnl . poly_fold_fun = get_node_ids }
let rule_get_node_ids ( rule : cnl_rule ) : ( id * cnl_kind * unit node ) list = Cnl2cnl . rule_dp_fold_over_nodes get_node_ids_fold_fun rule [ ]
let get_undefined ( kind : cnl_kind ) ( node : ' a node ) ( acc : ( id * cnl_kind ) list ) : ( id * cnl_kind ) list = begin match node with | N_undefined id -> ( id , kind ) :: acc | N_filled ( _ , _ ) | N_rejected ( _ , _ ) | N_accepted _ -> acc end
let get_undefined_fold_fun = { Cnl2cnl . id_fold_over_node_fun with Cnl2cnl . poly_fold_fun = get_undefined }
let rule_get_undefined ( rule : cnl_rule ) : ( id * cnl_kind ) list = Cnl2cnl . rule_dp_fold_over_nodes get_undefined_fold_fun rule [ ]
let evnt_get_undefined ( evnt : cnl_event ) : ( id * cnl_kind ) list = Cnl2cnl . evnt_dp_fold_over_nodes get_undefined_fold_fun evnt [ ]
let cond_get_undefined ( cond : cnl_cond ) : ( id * cnl_kind ) list = Cnl2cnl . cond_dp_fold_over_nodes get_undefined_fold_fun cond [ ]
let actns_get_undefined ( actns : cnl_actions ) : ( id * cnl_kind ) list = Cnl2cnl . actns_dp_fold_over_nodes get_undefined_fold_fun actns [ ]
let actn_get_undefined ( actn : cnl_action ) : ( id * cnl_kind ) list = Cnl2cnl . actn_dp_fold_over_nodes get_undefined_fold_fun actn [ ]
let expr_get_undefined ( expr : cnl_expr ) : ( id * cnl_kind ) list = Cnl2cnl . expr_dp_fold_over_nodes get_undefined_fold_fun expr [ ]
let get_filled ( kind : cnl_kind ) ( node : ' a node ) ( acc : ( id * cnl_kind ) list ) : ( id * cnl_kind ) list = begin match node with | N_filled ( id , _ ) -> ( id , kind ) :: acc | N_undefined _ | N_rejected ( _ , _ ) | N_accepted _ -> acc end
let get_filled_fold_fun = { Cnl2cnl . id_fold_over_node_fun with Cnl2cnl . poly_fold_fun = get_filled }
let rule_get_filled ( rule : cnl_rule ) : ( id * cnl_kind ) list = Cnl2cnl . rule_dp_fold_over_nodes get_filled_fold_fun rule [ ]
let evnt_get_filled ( evnt : cnl_event ) : ( id * cnl_kind ) list = Cnl2cnl . evnt_dp_fold_over_nodes get_filled_fold_fun evnt [ ]
let cond_get_filled ( cond : cnl_cond ) : ( id * cnl_kind ) list = Cnl2cnl . cond_dp_fold_over_nodes get_filled_fold_fun cond [ ]
let actns_get_filled ( actns : cnl_actions ) : ( id * cnl_kind ) list = Cnl2cnl . actns_dp_fold_over_nodes get_filled_fold_fun actns [ ]
let actn_get_filled ( actn : cnl_action ) : ( id * cnl_kind ) list = Cnl2cnl . actn_dp_fold_over_nodes get_filled_fold_fun actn [ ]
let expr_get_filled ( expr : cnl_expr ) : ( id * cnl_kind ) list = Cnl2cnl . expr_dp_fold_over_nodes get_filled_fold_fun expr [ ]
let get_rejected ( kind : cnl_kind ) ( node : ' a node ) ( acc : ( id * cnl_kind ) list ) : ( id * cnl_kind ) list = begin match node with | N_rejected ( id , _ ) -> ( id , kind ) :: acc | N_undefined _ | N_filled ( _ , _ ) | N_accepted _ -> acc end
let get_rejected_fold_fun = { Cnl2cnl . id_fold_over_node_fun with Cnl2cnl . poly_fold_fun = get_rejected }
let rule_get_rejected ( rule : cnl_rule ) : ( id * cnl_kind ) list = Cnl2cnl . rule_dp_fold_over_nodes get_rejected_fold_fun rule [ ]
let evnt_get_rejected ( evnt : cnl_event ) : ( id * cnl_kind ) list = Cnl2cnl . evnt_dp_fold_over_nodes get_rejected_fold_fun evnt [ ]
let cond_get_rejected ( cond : cnl_cond ) : ( id * cnl_kind ) list = Cnl2cnl . cond_dp_fold_over_nodes get_rejected_fold_fun cond [ ]
let actns_get_rejected ( actns : cnl_actions ) : ( id * cnl_kind ) list = Cnl2cnl . actns_dp_fold_over_nodes get_rejected_fold_fun actns [ ]
let actn_get_rejected ( actn : cnl_action ) : ( id * cnl_kind ) list = Cnl2cnl . actn_dp_fold_over_nodes get_rejected_fold_fun actn [ ]
let expr_get_rejected ( expr : cnl_expr ) : ( id * cnl_kind ) list = Cnl2cnl . expr_dp_fold_over_nodes get_rejected_fold_fun expr [ ]
let rec expr_get_cnl ( id : id ) ( expr : cnl_expr ) : cnl_ast option = begin match node_id expr . expr_node with | Some n -> if id = n then Some ( Cnl_expr expr ) else Cnl2cnl . expr_sh_fold ( fun expr acc -> begin match acc with | Some _ -> acc | None -> expr_get_cnl id expr end ) expr None | None -> None end
let evnt_get_cnl ( id : id ) ( evnt : cnl_event ) : cnl_ast option = begin match node_id evnt . evnt_node with | Some n -> if id = n then Some ( Cnl_evnt evnt ) else Cnl2cnl . evnt_sh_fold ( fun ( ) acc -> acc ) evnt None | None -> None end
let cond_get_cnl ( id : id ) ( cond : cnl_cond ) : cnl_ast option = begin match node_id cond . cond_node with | Some n -> if id = n then Some ( Cnl_cond cond ) else Cnl2cnl . cond_sh_fold ( fun expr acc -> begin match acc with | Some _ -> acc | None -> expr_get_cnl id expr end ) cond None | None -> None end
let actn_get_cnl ( id : id ) ( actn : cnl_action ) : cnl_ast option = begin match node_id actn . actn_node with | Some n -> if id = n then Some ( Cnl_actn actn ) else Cnl2cnl . actn_sh_fold ( fun expr acc -> begin match acc with | Some _ -> acc | None -> expr_get_cnl id expr end ) actn None | None -> None end
let actns_get_cnl ( id : id ) ( actns : cnl_actions ) : cnl_ast option = begin match node_id actns . actns_node with | Some n -> if id = n then Some ( Cnl_actns actns ) else Cnl2cnl . actns_sh_fold ( fun actn acc -> begin match acc with | Some _ -> acc | None -> actn_get_cnl id actn end ) ( fun closed acc -> acc ) actn...
let rule_get_cnl ( id : id ) ( rule : cnl_rule ) : cnl_ast option = begin match node_id rule . rule_node with | Some n -> if id = n then Some ( Cnl_rule rule ) else Cnl2cnl . rule_sh_fold ( fun evnt acc -> begin match acc with | Some _ -> acc | None -> evnt_get_cnl id evnt end ) ( fun cond acc -> begin match acc with |...
let rec expr_next_focus_fold ( focus : int ) ( expr : cnl_expr ) ( ( res , id_found ) : ( int * cnl_kind ) option * bool ) : ( int * cnl_kind ) option * bool = begin match res , id_found , expr . expr_node with | Some _ , _ , _ -> ( res , id_found ) | None , true , ( N_undefined ( Some id ) | N_rejected ( Some id , _ )...
let evnt_next_focus_fold ( focus : int ) ( evnt : cnl_event ) ( ( res , id_found ) : ( int * cnl_kind ) option * bool ) : ( int * cnl_kind ) option * bool = begin match res , id_found , evnt . evnt_node with | Some _ , _ , _ -> ( res , id_found ) | None , true , ( N_undefined ( Some id ) | N_rejected ( Some id , _ ) ) ...
let cond_next_focus_fold ( focus : int ) ( cond : cnl_cond ) ( ( res , id_found ) : ( int * cnl_kind ) option * bool ) : ( int * cnl_kind ) option * bool = begin match res , id_found , cond . cond_node with | Some _ , _ , _ -> ( res , id_found ) | None , true , ( N_undefined ( Some id ) | N_rejected ( Some id , _ ) ) -...
let actn_next_focus_fold ( focus : int ) ( actn : cnl_action ) ( ( res , id_found ) : ( int * cnl_kind ) option * bool ) : ( int * cnl_kind ) option * bool = begin match res , id_found , actn . actn_node with | Some _ , _ , _ -> ( res , id_found ) | None , true , ( N_undefined ( Some id ) | N_rejected ( Some id , _ ) )...
let actns_next_focus_fold ( focus : int ) ( actns : cnl_actions ) ( ( res , id_found ) : ( int * cnl_kind ) option * bool ) : ( int * cnl_kind ) option * bool = begin match res , id_found , actns . actns_node with | Some _ , _ , _ -> ( res , id_found ) | None , true , ( N_undefined ( Some id ) | N_rejected ( Some id , ...
let rule_next_focus ( focus : int ) ( rule : cnl_rule ) : ( int * cnl_kind ) option = let res_opt , _ = let id_found = node_id rule . rule_node = Some ( Some focus ) in Cnl2cnl . rule_sh_fold ( evnt_next_focus_fold focus ) ( cond_next_focus_fold focus ) ( actns_next_focus_fold focus ) rule ( None , id_found ) in begin ...
let cond_next_focus ( focus : int ) ( rule : cnl_rule ) : ( int * cnl_kind ) option = let res_opt , _ = let id_found = node_id rule . rule_node = Some ( Some focus ) in Cnl2cnl . rule_sh_fold ( fun _ acc -> acc ) ( cond_next_focus_fold focus ) ( fun _ acc -> acc ) rule ( None , id_found ) in begin match res_opt , node_...
let max_id ( rule : cnl_rule ) : id = let fold_fun kind node m_id = let id = begin match node with | N_undefined id | N_filled ( id , _ ) | N_rejected ( id , _ ) -> id | N_accepted _ -> None end in begin match id , m_id with | Some id1 , Some id2 -> Some ( max id1 id2 ) | Some id , None | None , Some id -> Some id | No...
let next_id ( id : id ) : id = begin match id with | None -> Some 1 | Some n -> Some ( n + 1 ) end
let index_rule ( rule : cnl_rule ) : cnl_rule = let map_fold_fun kind node id = begin match node with | N_undefined None -> N_undefined id , next_id id | N_filled ( None , x ) -> N_filled ( id , x ) , next_id id | N_rejected ( None , x ) -> N_rejected ( id , x ) , next_id id | N_undefined ( Some _ ) | N_filled ( Some _...
let f_to_a p = begin match p with | N_undefined _ -> raise ( Failure " Cannot confirm undefined AST node " ) | N_filled ( _ , ed ) -> N_accepted ed | N_rejected _ -> raise ( Failure " Cannot confirm rejected AST node " ) | N_accepted ed -> N_accepted ed end
let expr_f_to_a ( expr : cnl_expr ) : cnl_expr = Cnl2cnl . expr_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_a node ) } expr
let actn_f_to_a ( actn : cnl_action ) : cnl_action = Cnl2cnl . actn_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_a node ) } actn
let evnt_f_to_a ( evnt : cnl_event ) : cnl_event = Cnl2cnl . evnt_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_a node ) } evnt
let cond_f_to_a ( cond : cnl_cond ) : cnl_cond = Cnl2cnl . cond_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_a node ) } cond
let actns_f_to_a ( actns : cnl_actions ) : cnl_actions = Cnl2cnl . actns_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_a node ) } actns
let rule_f_to_a ( rule : cnl_rule ) : cnl_rule = Cnl2cnl . rule_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_a node ) } rule
let cnl_f_to_a ( cnl : cnl_ast ) : cnl_ast = begin match cnl with | Cnl_expr expr -> Cnl_expr ( expr_f_to_a expr ) | Cnl_actn actn -> Cnl_actn ( actn_f_to_a actn ) | Cnl_evnt evnt -> Cnl_evnt ( evnt_f_to_a evnt ) | Cnl_cond cond -> Cnl_cond ( cond_f_to_a cond ) | Cnl_actns actns -> Cnl_actns ( actns_f_to_a actns ) | Cn...
let f_to_r p = begin match p with | N_undefined _ -> raise ( Failure " Cannot confirm undefined AST node " ) | N_filled ( id , ed ) -> N_rejected ( id , ed ) | N_rejected _ -> p | N_accepted ed -> N_accepted ed end
let expr_f_to_r ( expr : cnl_expr ) : cnl_expr = Cnl2cnl . expr_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_r node ) } expr
let actn_f_to_r ( actn : cnl_action ) : cnl_action = Cnl2cnl . actn_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_r node ) } actn
let evnt_f_to_r ( evnt : cnl_event ) : cnl_event = Cnl2cnl . evnt_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_r node ) } evnt
let cond_f_to_r ( cond : cnl_cond ) : cnl_cond = Cnl2cnl . cond_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_r node ) } cond
let actns_f_to_r ( actns : cnl_actions ) : cnl_actions = Cnl2cnl . actns_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_r node ) } actns
let rule_f_to_r ( rule : cnl_rule ) : cnl_rule = Cnl2cnl . rule_dp_map_over_nodes { Cnl2cnl . id_map_over_node_fun with Cnl2cnl . poly_map_fun = ( fun kind node -> f_to_r node ) } rule
let cnl_f_to_r ( cnl : cnl_ast ) : cnl_ast = begin match cnl with | Cnl_expr expr -> Cnl_expr ( expr_f_to_r expr ) | Cnl_actn actn -> Cnl_actn ( actn_f_to_r actn ) | Cnl_evnt evnt -> Cnl_evnt ( evnt_f_to_r evnt ) | Cnl_cond cond -> Cnl_cond ( cond_f_to_r cond ) | Cnl_actns actns -> Cnl_actns ( actns_f_to_r actns ) | Cn...
let add_cond rule = let id , rule_desc = begin match rule . rule_node with | N_undefined id -> assert false | N_rejected ( id , _ ) -> assert false | N_accepted _ -> assert false | N_filled ( id , rule_desc ) -> id , rule_desc end in let cond = begin match rule_desc . rule_cond . cond_node with | N_undefined id -> Cnl_...
let expr_prompt id expr = let rec expr_prompt_aux id txt expr = begin match node_id expr . expr_node , node_desc expr . expr_node with | Some id ' , _ when id = id ' -> raise ( Prompt txt ) | _ , None -> ( ) | _ , Some expr_desc -> begin match expr_desc with | E_lit _ -> ( ) | E_var _ -> ( ) | E_get ( e , field ) -> le...
let rule_prompt id rule = Cnl2cnl . rule_sh_fold ( fun _ acc -> acc ) ( fun cond acc -> Cnl2cnl . cond_sh_fold ( fun expr acc -> begin match acc with | Some _ -> acc | None -> let s = expr_prompt id expr in if s = " " then None else Some s end ) cond acc ) ( fun actns acc -> Cnl2cnl . actns_sh_fold ( fun actn acc -> Cn...
let json_of_expr expr = Yojson . Safe . to_basic ( cnl_expr_to_yojson expr )
let json_of_expr_desc desc = Yojson . Safe . to_basic ( cnl_expr_desc_to_yojson desc )
let json_of_evnt evnt = Yojson . Safe . to_basic ( cnl_event_to_yojson evnt )
let json_of_evnt_desc desc = Yojson . Safe . to_basic ( cnl_evnt_desc_to_yojson desc )
let json_of_cond cond = Yojson . Safe . to_basic ( cnl_cond_to_yojson cond )
let json_of_cond_desc desc = Yojson . Safe . to_basic ( cnl_cond_desc_to_yojson desc )
let json_of_actn actn = Yojson . Safe . to_basic ( cnl_action_to_yojson actn )
let json_of_actn_desc desc = Yojson . Safe . to_basic ( cnl_actn_desc_to_yojson desc )
let json_of_actns actns = Yojson . Safe . to_basic ( cnl_actions_to_yojson actns )
let json_of_actns_desc desc = Yojson . Safe . to_basic ( cnl_actns_desc_to_yojson desc )
let json_of_rule rule = Yojson . Safe . to_basic ( cnl_rule_to_yojson rule )
let json_of_rule_desc desc = Yojson . Safe . to_basic ( cnl_rule_desc_to_yojson desc )
let rec json_replace ( old : string ) ( new_ : string ) ( j : Yojson . Basic . json ) = begin match j with | ` Null | ` Bool _ | ` Int _ | ` Float _ -> j | ` String s -> if s = old then ` String new_ else j | ` Assoc l -> let l = List . map ( fun ( s , j ) -> let s = if s = old then new_ else s in let j = json_replace ...
type t = Flambda . Function_params_and_body . t Code0 . t
let create code_id ~ params_and_body ~ free_names_of_params_and_body ~ newer_version_of ~ params_arity ~ num_trailing_local_params ~ result_arity ~ result_types ~ contains_no_escaping_local_allocs ~ stub ~ inline ~ is_a_functor ~ recursive ~ cost_metrics ~ inlining_arguments ~ dbg ~ is_tupled ~ is_my_closure_used ~ inl...
let with_params_and_body = Code0 . with_params_and_body ~ print_function_params_and_body : Flambda . Function_params_and_body . print
let apply_renaming = Code0 . apply_renaming ~ apply_renaming_function_params_and_body : Flambda . Function_params_and_body . apply_renaming
let print = Code0 . print ~ print_function_params_and_body : Flambda . Function_params_and_body . print
let all_ids_for_export = Code0 . all_ids_for_export ~ all_ids_for_export_function_params_and_body : Flambda . Function_params_and_body . all_ids_for_export
type ' function_params_and_body t = { params_and_body : ' function_params_and_body ; free_names_of_params_and_body : Name_occurrences . t ; code_metadata : Code_metadata . t }
let code_metadata t = t . code_metadata
let code_id t = Code_metadata . code_id t . code_metadata
let params_and_body t = t . params_and_body
let newer_version_of t = Code_metadata . newer_version_of t . code_metadata
let params_arity t = Code_metadata . params_arity t . code_metadata
let num_leading_heap_params t = Code_metadata . num_leading_heap_params t . code_metadata
let num_trailing_local_params t = Code_metadata . num_trailing_local_params t . code_metadata
let result_arity t = Code_metadata . result_arity t . code_metadata