def generate_arg_extraction(schema: FunctionSchema) -> str: arg_populations = [] for i, arg in enumerate(schema.schema_order_arguments()): maybe_method = ivalue_type_conversion_method(arg.type) assert maybe_method is_reference, type_conversion_method = maybe_method reference = "&" if is_reference else "" arg_populations.append( f"const auto{reference} {arg.name} = p_node->Input({i}).{type_conversion_method}" ) return ";\n ".join(arg_populations) + ";"
def generate_test_value_definitions(schema: FunctionSchema, index: int) -> str: assert not schema.is_out_fn() schema_name = schema.name.name.base arg_map = {} for arg in schema.schema_order_arguments(): test_value_exp = test_value_expression(arg.type, index, schema_name) arg_map[arg.name] = test_value_exp config.override_test_values(arg_map, schema_name, index) arg_populations = [] for arg_name, arg_value in arg_map.items(): arg_populations.append(f"auto {arg_name}{index} = {arg_value}") return ";\n ".join(arg_populations) + ";"
def generate_test_ir_arguments( schema: FunctionSchema, ) -> List[Tuple[str, Optional[str]]]: def ir_argument(arg: Argument) -> Tuple[str, Optional[str]]: t = arg.type add_optional = False if isinstance(t, OptionalType): t = t.elem add_optional = True assert isinstance(t, BaseType) type_str = None if t.name in generate_test_ir_arguments_base_ty_to_type_str_: type_str = generate_test_ir_arguments_base_ty_to_type_str_[t.name] if type_str and add_optional: type_str = f"{type_str}?" return ("%" + arg.name, type_str) return [ir_argument(arg) for arg in schema.schema_order_arguments()]
def generate_test_value_names(schema: FunctionSchema, index: int) -> str: assert not schema.is_out_fn() return ",".join(f"{arg.name}{index}" for arg in schema.schema_order_arguments())