@@ -59,7 +59,9 @@ def unknown(self, text: str, width: int | None) -> Interval:
5959 del text
6060 return Interval .full (width or 64 )
6161
62- def binary (self , op : Opcode , lhs : Interval , rhs : Interval , width : int | None ) -> Interval :
62+ def binary (
63+ self , op : Opcode , lhs : Interval , rhs : Interval , width : int | None
64+ ) -> Interval :
6365 w = width or max (lhs .width , rhs .width , 64 )
6466 if lhs .is_exact and rhs .is_exact :
6567 return Interval .exact (eval_binary (op , lhs .lo , rhs .lo , w ), w )
@@ -73,10 +75,14 @@ def binary(self, op: Opcode, lhs: Interval, rhs: Interval, width: int | None) ->
7375 return Interval (0 , min ((1 << w ) - 1 , lhs .lo ), w )
7476 return Interval .full (w )
7577
76- def icmp (self , predicate : IntPredicate , lhs : Interval , rhs : Interval , width : int | None ) -> Interval :
78+ def icmp (
79+ self , predicate : IntPredicate , lhs : Interval , rhs : Interval , width : int | None
80+ ) -> Interval :
7781 del width
7882 if lhs .is_exact and rhs .is_exact :
79- return Interval .exact (int (eval_icmp (predicate , lhs .lo , rhs .lo , lhs .width )), 1 )
83+ return Interval .exact (
84+ int (eval_icmp (predicate , lhs .lo , rhs .lo , lhs .width )), 1
85+ )
8086 name = predicate .name
8187 if name == "EQ" and (lhs .hi < rhs .lo or rhs .hi < lhs .lo ):
8288 return Interval .exact (0 , 1 )
@@ -88,13 +94,19 @@ def icmp(self, predicate: IntPredicate, lhs: Interval, rhs: Interval, width: int
8894 return Interval .exact (0 , 1 )
8995 return Interval .full (1 )
9096
91- def select (self , cond : Interval , true_val : Interval , false_val : Interval , width : int | None ) -> Interval :
97+ def select (
98+ self , cond : Interval , true_val : Interval , false_val : Interval , width : int | None
99+ ) -> Interval :
92100 if cond .is_exact :
93101 return true_val if cond .lo else false_val
94102 w = width or max (true_val .width , false_val .width , 64 )
95- return self ._bounded (min (true_val .lo , false_val .lo ), max (true_val .hi , false_val .hi ), w )
103+ return self ._bounded (
104+ min (true_val .lo , false_val .lo ), max (true_val .hi , false_val .hi ), w
105+ )
96106
97- def cast (self , op : Opcode , val : Interval , from_width : int | None , to_width : int | None ) -> Interval :
107+ def cast (
108+ self , op : Opcode , val : Interval , from_width : int | None , to_width : int | None
109+ ) -> Interval :
98110 w = to_width or val .width
99111 if val .is_exact :
100112 if op == Opcode .SExt :
@@ -115,7 +127,9 @@ def funnel_shift(
115127 ) -> Interval :
116128 w = width or max (high .width , low .width , amount .width , 64 )
117129 if high .is_exact and low .is_exact and amount .is_exact :
118- return Interval .exact (eval_funnel_shift_value (high .lo , low .lo , amount .lo , w , left = left ), w )
130+ return Interval .exact (
131+ eval_funnel_shift_value (high .lo , low .lo , amount .lo , w , left = left ), w
132+ )
119133 return Interval .full (w )
120134
121135 def concrete_bool (self , val : Interval ) -> bool | None :
@@ -127,7 +141,9 @@ def concrete_bool(self, val: Interval) -> bool | None:
127141 return True
128142 return None
129143
130- def with_width (self , val : Interval , width : int | None , * , signed : bool = False ) -> Interval :
144+ def with_width (
145+ self , val : Interval , width : int | None , * , signed : bool = False
146+ ) -> Interval :
131147 w = width or val .width
132148 if val .is_exact :
133149 if signed :
@@ -162,26 +178,36 @@ def read(self, offset: Interval, width: int, *, insn_addr: int = 0) -> Interval:
162178 return stored
163179 if self .backing is not None :
164180 byte_width = width // 8
165- if self .backing .in_range (offset .lo ) and self .backing .in_range (offset .lo + byte_width - 1 ):
181+ if self .backing .in_range (offset .lo ) and self .backing .in_range (
182+ offset .lo + byte_width - 1
183+ ):
166184 data = self .backing .get_data (offset .lo , byte_width )
167185 return Interval .exact (int .from_bytes (data , "little" ), width )
168186 return Interval .full (width )
169187
170- def write (self , offset : Interval , value : Interval , width : int , * , insn_addr : int = 0 ) -> None :
188+ def write (
189+ self , offset : Interval , value : Interval , width : int , * , insn_addr : int = 0
190+ ) -> None :
171191 del insn_addr
172192 bytes_for_width (width )
173193 if offset .is_exact :
174194 self .store [(offset .lo , width )] = value
175195
176196
177197class IntervalRegisters (RegisterState [Interval ]):
178- def __init__ (self , reg_sizes : dict [str , int ], initial : dict [str , int | Interval ] | None = None ):
198+ def __init__ (
199+ self ,
200+ reg_sizes : dict [str , int ],
201+ initial : dict [str , int | Interval ] | None = None ,
202+ ):
179203 self ._sizes = reg_sizes
180204 initial = initial or {}
181205 self ._regs : dict [str , Interval ] = {}
182206 for name , size in reg_sizes .items ():
183207 value = initial .get (name , 0 )
184- self ._regs [name ] = value if isinstance (value , Interval ) else Interval .exact (value , size )
208+ self ._regs [name ] = (
209+ value if isinstance (value , Interval ) else Interval .exact (value , size )
210+ )
185211
186212 def read (self , name : str ) -> Interval :
187213 return self ._regs [name ]
0 commit comments