File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1616 Box ,
1717 Call ,
1818 CallC ,
19+ Cast ,
1920 CString ,
2021 DecRef ,
2122 GetAttr ,
@@ -57,7 +58,7 @@ def get_load_global_name(op: CallC) -> str | None:
5758
5859
5960# These primitives perform an implicit IncRef for the return value. Only some of the most common ones
60- # are included.
61+ # are included, and mostly ops that could be switched to use borrowing in some contexts .
6162primitives_that_inc_ref : Final = {
6263 "list_get_item_unsafe" ,
6364 "CPyList_GetItemShort" ,
@@ -121,6 +122,12 @@ def visit_box(self, op: Box) -> Value:
121122 def visit_unbox (self , op : Unbox ) -> Value :
122123 return self .log (op , "unbox" , str (op .type ))
123124
125+ def visit_cast (self , op : Cast ) -> Value | None :
126+ value = self .log (op , "cast" , str (op .type ))
127+ if not op .is_borrowed :
128+ self .log_inc_ref (value )
129+ return value
130+
124131 def visit_inc_ref (self , op : IncRef ) -> Value :
125132 return self .log (op , "inc_ref" , str (op .src .type ))
126133
You can’t perform that action at this time.
0 commit comments