56
56
from mypyc .ir .rtypes import (
57
57
RInstance ,
58
58
bool_rprimitive ,
59
- dict_rprimitive ,
60
59
int_rprimitive ,
61
60
object_rprimitive ,
61
+ true_dict_rprimitive ,
62
62
)
63
63
from mypyc .irbuild .builder import IRBuilder , calculate_arg_defaults , gen_arg_defaults
64
64
from mypyc .irbuild .callable_class import (
76
76
)
77
77
from mypyc .irbuild .generator import gen_generator_func , gen_generator_func_body
78
78
from mypyc .irbuild .targets import AssignmentTarget
79
- from mypyc .primitives .dict_ops import dict_get_method_with_none , dict_new_op , dict_set_item_op
79
+ from mypyc .primitives .dict_ops import dict_new_op , true_dict_get_method_with_none , true_dict_set_item_op
80
80
from mypyc .primitives .generic_ops import py_setattr_op
81
81
from mypyc .primitives .misc_ops import register_function
82
82
from mypyc .primitives .registry import builtin_names
@@ -124,7 +124,7 @@ def transform_decorator(builder: IRBuilder, dec: Decorator) -> None:
124
124
if decorated_func is not None :
125
125
# Set the callable object representing the decorated function as a global.
126
126
builder .primitive_op (
127
- dict_set_item_op ,
127
+ true_dict_set_item_op ,
128
128
[builder .load_globals_dict (), builder .load_str (dec .func .name ), decorated_func ],
129
129
decorated_func .line ,
130
130
)
@@ -797,10 +797,10 @@ def generate_singledispatch_dispatch_function(
797
797
798
798
arg_type = builder .builder .get_type_of_obj (arg_info .args [0 ], line )
799
799
dispatch_cache = builder .builder .get_attr (
800
- dispatch_func_obj , "dispatch_cache" , dict_rprimitive , line
800
+ dispatch_func_obj , "dispatch_cache" , true_dict_rprimitive , line
801
801
)
802
802
call_find_impl , use_cache , call_func = BasicBlock (), BasicBlock (), BasicBlock ()
803
- get_result = builder .primitive_op (dict_get_method_with_none , [dispatch_cache , arg_type ], line )
803
+ get_result = builder .primitive_op (true_dict_get_method_with_none , [dispatch_cache , arg_type ], line )
804
804
is_not_none = builder .translate_is_op (get_result , builder .none_object (), "is not" , line )
805
805
impl_to_use = Register (object_rprimitive )
806
806
builder .add_bool_branch (is_not_none , use_cache , call_find_impl )
@@ -813,7 +813,7 @@ def generate_singledispatch_dispatch_function(
813
813
find_impl = builder .load_module_attr_by_fullname ("functools._find_impl" , line )
814
814
registry = load_singledispatch_registry (builder , dispatch_func_obj , line )
815
815
uncached_impl = builder .py_call (find_impl , [arg_type , registry ], line )
816
- builder .primitive_op (dict_set_item_op , [dispatch_cache , arg_type , uncached_impl ], line )
816
+ builder .primitive_op (true_dict_set_item_op , [dispatch_cache , arg_type , uncached_impl ], line )
817
817
builder .assign (impl_to_use , uncached_impl , line )
818
818
builder .goto (call_func )
819
819
@@ -877,8 +877,8 @@ def gen_dispatch_func_ir(
877
877
"""
878
878
builder .enter (FuncInfo (fitem , dispatch_name ))
879
879
setup_callable_class (builder )
880
- builder .fn_info .callable_class .ir .attributes ["registry" ] = dict_rprimitive
881
- builder .fn_info .callable_class .ir .attributes ["dispatch_cache" ] = dict_rprimitive
880
+ builder .fn_info .callable_class .ir .attributes ["registry" ] = true_dict_rprimitive
881
+ builder .fn_info .callable_class .ir .attributes ["dispatch_cache" ] = true_dict_rprimitive
882
882
builder .fn_info .callable_class .ir .has_dict = True
883
883
builder .fn_info .callable_class .ir .needs_getseters = True
884
884
generate_singledispatch_callable_class_ctor (builder )
@@ -941,7 +941,7 @@ def add_register_method_to_callable_class(builder: IRBuilder, fn_info: FuncInfo)
941
941
942
942
943
943
def load_singledispatch_registry (builder : IRBuilder , dispatch_func_obj : Value , line : int ) -> Value :
944
- return builder .builder .get_attr (dispatch_func_obj , "registry" , dict_rprimitive , line )
944
+ return builder .builder .get_attr (dispatch_func_obj , "registry" , true_dict_rprimitive , line )
945
945
946
946
947
947
def singledispatch_main_func_name (orig_name : str ) -> str :
@@ -990,9 +990,9 @@ def maybe_insert_into_registry_dict(builder: IRBuilder, fitem: FuncDef) -> None:
990
990
registry = load_singledispatch_registry (builder , dispatch_func_obj , line )
991
991
for typ in types :
992
992
loaded_type = load_type (builder , typ , None , line )
993
- builder .primitive_op (dict_set_item_op , [registry , loaded_type , to_insert ], line )
993
+ builder .primitive_op (true_dict_set_item_op , [registry , loaded_type , to_insert ], line )
994
994
dispatch_cache = builder .builder .get_attr (
995
- dispatch_func_obj , "dispatch_cache" , dict_rprimitive , line
995
+ dispatch_func_obj , "dispatch_cache" , true_dict_rprimitive , line
996
996
)
997
997
builder .gen_method_call (dispatch_cache , "clear" , [], None , line )
998
998
0 commit comments