@@ -2104,6 +2104,33 @@ def float_mod(self, lhs: Value, rhs: Value, line: int) -> Value:
21042104 def compare_floats (self , lhs : Value , rhs : Value , op : int , line : int ) -> Value :
21052105 return self .add (FloatComparisonOp (lhs , rhs , op , line ))
21062106
2107+ def int_add (self , lhs : Value , rhs : Value | int ) -> Value :
2108+ """Helper to add two native integers.
2109+
2110+ The result has the type of lhs.
2111+ """
2112+ if isinstance (rhs , int ):
2113+ rhs = Integer (rhs , lhs .type )
2114+ return self .int_op (lhs .type , lhs , rhs , IntOp .ADD , line = - 1 )
2115+
2116+ def int_sub (self , lhs : Value , rhs : Value | int ) -> Value :
2117+ """Helper to subtract a native integer from another one.
2118+
2119+ The result has the type of lhs.
2120+ """
2121+ if isinstance (rhs , int ):
2122+ rhs = Integer (rhs , lhs .type )
2123+ return self .int_op (lhs .type , lhs , rhs , IntOp .SUB , line = - 1 )
2124+
2125+ def int_mul (self , lhs : Value , rhs : Value | int ) -> Value :
2126+ """Helper to multiply two native integers.
2127+
2128+ The result has the type of lhs.
2129+ """
2130+ if isinstance (rhs , int ):
2131+ rhs = Integer (rhs , lhs .type )
2132+ return self .int_op (lhs .type , lhs , rhs , IntOp .MUL , line = - 1 )
2133+
21072134 def fixed_width_int_op (
21082135 self , type : RPrimitive , lhs : Value , rhs : Value , op : int , line : int
21092136 ) -> Value :
0 commit comments