37 const nlohmann::json &node,
40 std::size_t param_idx,
41 const nlohmann::json &
module);
45 const nlohmann::json &call,
77 bool eval_const_int(
const exprt &e,
BigInt &out)
const;
80 bool eval_const_str(
const exprt &e, std::string &out)
const;
86 exprt build_temporary_receiver(
const nlohmann::json &ctor_call)
const;
92 bool is_math_comb_call()
const;
100 exprt handle_math_comb()
const;
109 exprt unbound_method_error(
const symbolt &func_symbol)
const;
112 exprt call_argument_error(
const symbolt &func_symbol)
const;
114 exprt check_argument_types(
116 const nlohmann::json &args,
117 const nlohmann::json &keywords)
const;
121 bool argument_matches_parameter(
123 const typet &actual)
const;
126 std::vector<std::string>
127 find_possible_class_types(
const symbolt *obj_symbol)
const;
129 bool method_exists_in_class_hierarchy(
130 const std::string &class_name,
131 const std::string &method_name)
const;
133 exprt generate_attribute_error(
134 const std::string &method_name,
135 const std::vector<std::string> &possible_classes,
141 bool is_nondet_call()
const;
143 bool is_introspection_call()
const;
147 bool is_generic_hash_call()
const;
151 exprt handle_generic_hash();
157 unimplemented_abstract_method(
const nlohmann::json &ctor_call)
const;
159 bool is_abstract_instantiation()
const;
162 exprt abstract_instantiation_error(
const nlohmann::json &ctor_call)
const;
164 bool is_unmodelled_base_instantiation()
const;
169 refuse_unmodelled_base_instance(
const std::string &class_name)
const;
171 static void collect_method_abstractness(
173 const std::string &class_name,
174 std::map<std::string, bool> &methods,
175 std::set<std::string> &visited,
178 bool is_input_call()
const;
180 bool is_print_call()
const;
185 exprt handle_print()
const;
188 exprt handle_input()
const;
191 int decode_utf8_codepoint(
const std::string &utf8_str)
const;
196 exprt build_nondet_call()
const;
201 exprt build_constant_from_arg()
const;
211 exprt build_fresh_object()
const;
213 std::optional<BigInt>
214 try_fold_constant_arith_json(
const nlohmann::json &node)
const;
219 exprt handle_bytes_fromhex()
const;
224 void get_function_type();
230 nlohmann::json find_class_node(
const std::string &name)
const;
231 bool resolves_to_staticmethod(
232 const nlohmann::json &class_node,
233 const std::string &method)
const;
235 find_inherited_classmethod(
const std::string &func_symbol_id)
const;
237 build_post_init_forward_call(
const std::string &func_symbol_id);
239 exprt forward_constant_return(
const nlohmann::json &func_node)
const;
244 std::string get_object_name()
const;
254 const symbolt *get_object_list_symbol(std::string &display_name)
const;
268 const symbolt *resolve_list_receiver_symbol(std::string &display_name)
const;
278 std::optional<exprt> fold_constant_list_query()
const;
279 void materialize_list_symbol(
const symbolt *sym)
const;
285 exprt handle_int_to_str(nlohmann::json &arg)
const;
287 exprt handle_int_to_bytes()
const;
295 exprt handle_int_literal_method()
const;
303 exprt handle_float_is_integer_literal()
const;
309 exprt handle_float_hex_literal()
const;
315 exprt handle_float_fromhex()
const;
322 std::optional<std::string>
323 extract_string_from_symbol(
const symbolt *sym)
const;
329 const symbolt *lookup_python_symbol(
const std::string &var_name)
const;
331 void refuse_isinstance_on_path_dependent_number(
332 const nlohmann::json &obj_arg,
333 const std::vector<nlohmann::json> &types)
const;
334 exprt handle_isinstance()
const;
340 exprt bind_isinstance_call(
exprt &obj_expr)
const;
342 list_isinstance(
const exprt &obj,
const std::string &type_name)
const;
347 exprt isinstance_operand(
348 const nlohmann::json &node,
349 const std::function<
exprt(
const std::string &)> &build,
350 const std::function<std::string(
const nlohmann::json &)> &type_name)
const;
354 exprt isinstance_without_type_name(
355 const nlohmann::json &obj_arg,
356 const exprt &obj_expr,
357 const std::vector<nlohmann::json> &types)
const;
362 is_class_object_operand(
const nlohmann::json &arg,
const exprt &obj)
const;
366 exprt isinstance_str_as_type(
const exprt &obj_expr)
const;
368 exprt handle_hasattr()
const;
373 bool is_getattr_call()
const;
374 exprt handle_getattr();
382 std::optional<exprt> module_hasattr(
383 const nlohmann::json &obj_arg,
384 const std::string &attr_name)
const;
390 exprt handle_issubclass()
const;
397 exprt handle_callable()
const;
399 exprt handle_type_call()
const;
400 exprt tagged_scalar_class(
const exprt &tagged)
const;
401 bool is_str_of_type_call()
const;
402 exprt handle_str_of_type_call()
const;
404 exact_instance_class(
const nlohmann::json &arg,
const exprt &expr)
const;
411 bool is_single_assignment_str_symbol(
413 const std::string &name)
const;
420 std::optional<exprt> handle_str_symbol_to_int(
const symbolt *sym)
const;
426 std::optional<exprt> handle_str_symbol_to_float(
const symbolt *sym)
const;
433 exprt handle_float_to_str(nlohmann::json &arg)
const;
439 exprt handle_complex_to_str()
const;
445 size_t handle_str(nlohmann::json &arg)
const;
451 void handle_float_to_int(nlohmann::json &arg)
const;
462 exprt guard_none_to_float(
exprt operand)
const;
473 void handle_int_to_float(nlohmann::json &arg)
const;
479 exprt handle_chr(nlohmann::json &arg)
const;
485 exprt handle_hex(nlohmann::json &arg)
const;
493 exprt handle_oct(nlohmann::json &arg)
const;
499 exprt handle_bin(nlohmann::json &arg)
const;
505 exprt handle_ascii()
const;
513 exprt handle_format()
const;
519 exprt handle_ord(nlohmann::json &arg)
const;
528 std::optional<int> folded_char_array_codepoint(
const exprt &e)
const;
530 exprt build_ord_constant(nlohmann::json &arg,
int code_point)
const;
538 exprt handle_abs(nlohmann::json &arg)
const;
545 exprt handle_round(nlohmann::json &arg)
const;
554 exprt handle_complex()
const;
560 bool is_min_max_call()
const;
570 handle_min_max(
const std::string &func_name,
irep_idt comparison_op)
const;
573 bool is_tuple_method_call()
const;
574 exprt handle_tuple_method()
const;
577 bool is_dict_method_call()
const;
578 exprt handle_dict_method()
const;
584 bool receiver_is_non_dict_object()
const;
587 bool is_dict_class_method_call()
const;
590 bool is_set_method_call()
const;
591 exprt handle_set_method()
const;
594 bool receiver_is_tracked_numpy_view(
const std::string &recv_type)
const;
595 bool receiver_is_binop_or_list_symbol()
const;
596 bool receiver_class_defines_method(
const std::string &method_name)
const;
597 void reject_unresolved_user_method(
const std::string &method_name)
const;
598 bool is_list_method_call()
const;
599 exprt handle_list_method()
const;
600 exprt handle_list_append()
const;
601 exprt handle_list_insert()
const;
602 exprt handle_list_extend()
const;
603 exprt handle_list_clear()
const;
604 exprt handle_list_pop()
const;
608 exprt handle_list_popleft()
const;
609 exprt handle_list_appendleft()
const;
610 exprt handle_list_copy()
const;
611 exprt handle_list_remove()
const;
612 exprt handle_list_sort()
const;
613 exprt handle_list_reverse()
const;
614 exprt handle_list_count()
const;
615 exprt handle_list_index()
const;
618 bool is_numpy_astype_call()
const;
619 exprt handle_numpy_astype()
const;
626 bool is_re_module_call()
const;
634 exprt validate_re_module_args()
const;
635 void route_re_flags_call();
637 bool is_any_call()
const;
638 bool is_all_call()
const;
642 exprt compute_element_truthiness(
const exprt &element)
const;
654 exprt reduce_iterable_literal_truthiness(
655 const nlohmann::json &iterable_arg,
665 reduce_tuple_expr_truthiness(
const exprt &tuple_expr, ReduceOp op)
const;
672 exprt handle_any_all(ReduceOp op,
const char *name);
678 exprt handle_base_conversion(
680 const std::string &func_name,
681 const std::string &prefix,
682 std::ios_base &(*base_formatter)(std::ios_base &))
const;
688 bool is_string_arg(
const nlohmann::json &arg)
const;
693 exprt handle_divmod()
const;
700 exprt handle_pow()
const;
703 using HandlerFunction = std::function<
exprt()>;
704 using PredicateFunction = std::function<
bool()>;
706 struct FunctionHandler
708 PredicateFunction predicate;
709 HandlerFunction handler;
710 const char *description;
714 std::vector<FunctionHandler> get_dispatch_table();
728 bool is_int_to_bytes_call()
const;
731 bool is_int_literal_method_call()
const;
733 bool is_float_is_integer_literal_call()
const;
735 bool is_float_hex_literal_call()
const;
737 bool is_builtin_name_call(
const std::string &name)
const;
738 bool is_iter_on_builtin_call()
const;
740 bool is_str_on_builtin_scalar_call()
const;
742 exprt handle_str_on_builtin_scalar();
744 exprt handle_isnan_isinf();
746 bool is_cmath_log_call()
const;
747 exprt handle_cmath_log_dispatch();
749 bool is_cmath_inverse_call()
const;
750 exprt handle_cmath_inverse_fast_path();
752 bool is_math_function_dispatch_call()
const;
753 exprt dispatch_math_call();
754 exprt handle_math_function_dispatch();
755 std::optional<std::string> bounded_math_import()
const;
756 bool takes_bounded_math(
const std::string &
function)
const;
757 std::optional<exprt> try_bounded_math_call(
const std::string &func_name);
760 exprt handle_general_function_call();
763 symbolt *find_receiver_symbol(symbol_id &obj_symbol_id)
const;
766 exprt build_value_receiver(
const symbolt &method)
const;
780 std::optional<exprt> try_fold_sorted();
781 std::optional<exprt> try_materialize_numpy_tolist();
782 std::optional<exprt> try_reduce_numpy_descriptor_method();
791 std::optional<exprt> try_numpy_inplace_sort();
796 long long extract_numpy_inplace_sort_axis()
const;
803 void reject_numpy_sort_write_through_view(
804 const nlohmann::json &receiver_node)
const;
810 std::optional<exprt> try_numpy_tolist_or_inplace_sort();
817 std::optional<exprt> try_reduce_any_all_along_axis(
818 const std::string &func_name,
819 const std::string &qualifier,
820 const std::pair<std::vector<std::size_t>, std::vector<exprt>> &materialized,
821 std::size_t positional_offset);
826 exprt reduce_any_all_axis_slice(
827 const std::vector<exprt> &elems,
828 const std::vector<std::size_t> &shape,
829 long long normalized_axis,
839 reduce_any_all_rank1(
const std::vector<exprt> &elems, ReduceOp op)
const;
845 static void validate_any_all_axis_shape(
846 const std::vector<std::size_t> &shape,
847 const std::string &func_name,
848 const std::string &qualifier);
856 struct any_all_receiver
858 std::pair<std::vector<std::size_t>, std::vector<exprt>> materialized;
859 std::string qualifier;
860 std::size_t positional_offset;
869 std::optional<any_all_receiver>
870 resolve_any_all_receiver(
const std::string &func_name);
873 std::string dict_keys_list_id_for_call(
const nlohmann::json &arg)
const;
875 std::optional<exprt> fold_sorted_int_list(
876 const std::string &list_id,
878 bool fast_path_reverse)
const;
879 std::optional<exprt> fold_sorted_constant_tuples(
880 const std::string &list_id,
882 bool fast_path_reverse)
const;
883 std::optional<exprt> fold_sorted_symbolic_tuples(
884 const std::string &list_id,
886 bool fast_path_reverse);
892 std::optional<exprt> try_handle_round(
bool is_user_imported);
901 std::optional<exprt> try_fold_identity_array_return();
919 random_sequence_suffix(
const exprt &seq,
const std::string &func_name);
934 std::optional<exprt> fold_random_choice_over_tuple(
const exprt &seq);
936 exprt handle_bool_call(
const nlohmann::json &arg,
size_t arg_size)
const;
950 fold_sum_over_tuple(
bool is_user_imported,
bool is_numpy_model_call);
957 std::optional<exprt> apply_builtin_dispatch(
958 std::string &actual_func_name,
959 bool is_user_imported,
960 bool is_numpy_model_call);
967 std::optional<exprt> try_indirect_variable_call();
970 std::optional<exprt> try_indirect_member_call();
975 void refuse_unheld_attribute(
976 const std::string &class_name,
977 const std::string &attr)
const;
981 void refuse_untyped_attribute(
982 const std::string &class_name,
983 const std::string &attr,
984 const typet &field_type)
const;
988 mro_may_bind(
const std::string &class_name,
const std::string &attr)
const;
991 const python_converter::attribute_functions *held_functions(
992 const std::string &class_name,
993 const std::string &attr,
994 const typet &field_type)
const;
997 held_signature(
const python_converter::attribute_functions &held)
const;
1001 const python_converter::attribute_functions *held,
1003 const exprt &member)
const;
1013 std::optional<exprt> resolve_missing_function_symbol(
1014 const symbolt *&func_symbol,
1015 const std::string &func_symbol_id,
1016 symbolt *obj_symbol,
1017 const symbol_id &obj_symbol_id);
1030 size_t bind_call_receiver(
1031 code_function_callt &call,
1032 symbolt *obj_symbol,
1033 const symbolt *func_symbol,
1034 const locationt &location);
1042 exprt retype_or_typecast(exprt expr,
const typet &target)
const;
1044 exprt coerce_tagged_argument(
1046 const typet ¶m_type,
1047 const locationt &location)
const;
1049 void refuse_float_to_int_argument(
1051 const typet ¶m_type,
1052 const symbolt &callee)
const;
1054 typet dict_param_value_type(
const symbolt *func,
size_t idx)
const;
1055 bool is_size_builtin()
const;
1056 bool is_list_typed(
const typet &type)
const;
1057 exprt build_dict_size_call(
const exprt &dict);
1058 std::optional<exprt> build_positional_arguments(
1059 code_function_callt &call,
1060 size_t param_offset,
1061 const locationt &location,
1062 const symbolt *func_symbol);
1063 std::optional<exprt>
1064 raise_positional_oversupply(
const symbolt &func_symbol)
const;
1065 void reject_numpy_layout_mismatch(
1066 const typet &arg_type,
1067 const symbolt &callee,
1069 bool is_bytes_literal)
const;
1070 void reject_list_for_numpy_parameter(
1071 const typet &arg_type,
1073 size_t param_idx)
const;
1074 exprt finalize_call(
1075 code_function_callt &call,
1076 size_t param_offset,
1077 const locationt &location,
1078 const symbolt *func_symbol,
1079 symbolt *obj_symbol);
1081 const symbolt *cached_find_symbol(
const std::string &
id)
const;
1098 mutable std::unordered_map<std::string, const symbolt *>
sym_cache_;