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 (
80
+ dict_new_op ,
81
+ true_dict_get_method_with_none ,
82
+ true_dict_set_item_op ,
83
+ )
80
84
from mypyc .primitives .generic_ops import py_setattr_op
81
85
from mypyc .primitives .misc_ops import register_function
82
86
from mypyc .primitives .registry import builtin_names
@@ -124,7 +128,7 @@ def transform_decorator(builder: IRBuilder, dec: Decorator) -> None:
124
128
if decorated_func is not None :
125
129
# Set the callable object representing the decorated function as a global.
126
130
builder .primitive_op (
127
- dict_set_item_op ,
131
+ true_dict_set_item_op ,
128
132
[builder .load_globals_dict (), builder .load_str (dec .func .name ), decorated_func ],
129
133
decorated_func .line ,
130
134
)
@@ -797,10 +801,12 @@ def generate_singledispatch_dispatch_function(
797
801
798
802
arg_type = builder .builder .get_type_of_obj (arg_info .args [0 ], line )
799
803
dispatch_cache = builder .builder .get_attr (
800
- dispatch_func_obj , "dispatch_cache" , dict_rprimitive , line
804
+ dispatch_func_obj , "dispatch_cache" , true_dict_rprimitive , line
801
805
)
802
806
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 )
807
+ get_result = builder .primitive_op (
808
+ true_dict_get_method_with_none , [dispatch_cache , arg_type ], line
809
+ )
804
810
is_not_none = builder .translate_is_op (get_result , builder .none_object (), "is not" , line )
805
811
impl_to_use = Register (object_rprimitive )
806
812
builder .add_bool_branch (is_not_none , use_cache , call_find_impl )
@@ -813,7 +819,7 @@ def generate_singledispatch_dispatch_function(
813
819
find_impl = builder .load_module_attr_by_fullname ("functools._find_impl" , line )
814
820
registry = load_singledispatch_registry (builder , dispatch_func_obj , line )
815
821
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 )
822
+ builder .primitive_op (true_dict_set_item_op , [dispatch_cache , arg_type , uncached_impl ], line )
817
823
builder .assign (impl_to_use , uncached_impl , line )
818
824
builder .goto (call_func )
819
825
@@ -877,8 +883,8 @@ def gen_dispatch_func_ir(
877
883
"""
878
884
builder .enter (FuncInfo (fitem , dispatch_name ))
879
885
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
886
+ builder .fn_info .callable_class .ir .attributes ["registry" ] = true_dict_rprimitive
887
+ builder .fn_info .callable_class .ir .attributes ["dispatch_cache" ] = true_dict_rprimitive
882
888
builder .fn_info .callable_class .ir .has_dict = True
883
889
builder .fn_info .callable_class .ir .needs_getseters = True
884
890
generate_singledispatch_callable_class_ctor (builder )
@@ -941,7 +947,7 @@ def add_register_method_to_callable_class(builder: IRBuilder, fn_info: FuncInfo)
941
947
942
948
943
949
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 )
950
+ return builder .builder .get_attr (dispatch_func_obj , "registry" , true_dict_rprimitive , line )
945
951
946
952
947
953
def singledispatch_main_func_name (orig_name : str ) -> str :
@@ -990,9 +996,9 @@ def maybe_insert_into_registry_dict(builder: IRBuilder, fitem: FuncDef) -> None:
990
996
registry = load_singledispatch_registry (builder , dispatch_func_obj , line )
991
997
for typ in types :
992
998
loaded_type = load_type (builder , typ , None , line )
993
- builder .primitive_op (dict_set_item_op , [registry , loaded_type , to_insert ], line )
999
+ builder .primitive_op (true_dict_set_item_op , [registry , loaded_type , to_insert ], line )
994
1000
dispatch_cache = builder .builder .get_attr (
995
- dispatch_func_obj , "dispatch_cache" , dict_rprimitive , line
1001
+ dispatch_func_obj , "dispatch_cache" , true_dict_rprimitive , line
996
1002
)
997
1003
builder .gen_method_call (dispatch_cache , "clear" , [], None , line )
998
1004
0 commit comments