Skip to content
Snippets Groups Projects
Commit f7594310 authored by vincent's avatar vincent
Browse files

[BTCMachine] Remove unused parameter in _min_bytes_needed

parent 7ac79378
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ class BTCVector:
BTC_FALSE = IntVal(0)
@classmethod
def _min_bytes_needed(cls, val: ExprRef, n=0):
def _min_bytes_needed(cls, val: ExprRef):
return If(
val == 0,
IntVal(0),
......@@ -89,13 +89,13 @@ class BTCVector:
def __add__(self, other):
"""Return the sum of 2 btc vectors."""
return BTCVector(
self.val + other.val, self._min_bytes_needed(self.val + other.val, 1)
self.val + other.val, self._min_bytes_needed(self.val + other.val)
)
def __sub__(self, other):
"""Return the difference of 2 btc vectors."""
return BTCVector(
self.val - other.val, self._min_bytes_needed(self.val - other.val, 1)
self.val - other.val, self._min_bytes_needed(self.val - other.val)
)
def __neg__(self):
......@@ -109,7 +109,7 @@ class BTCVector:
def __eq__(self, other):
"""Return the BTC vector `True` if `self.val == other.val`."""
if isinstance(other, int):
other = BTCVector(IntVal(other), self._min_bytes_needed(other, 1))
other = BTCVector(IntVal(other), self._min_bytes_needed(other))
return BTCVector(
If(
And(self.val == other.val, self.size == other.size),
......@@ -206,10 +206,10 @@ class BTCVector:
def __size__(self):
"""Return the number of bytes the vector is composed of."""
return BTCVector(self.size, self._min_bytes_needed(self.size, 1))
return BTCVector(self.size, self._min_bytes_needed(self.size))
BTC_VECTOR_1 = BTCVector(IntVal(1), BTCVector._min_bytes_needed(1, 1))
BTC_VECTOR_1 = BTCVector(IntVal(1), BTCVector._min_bytes_needed(1))
class SymbolicConditionError(Exception):
......@@ -286,7 +286,7 @@ class BTCMachine(IStackBasedMachine, IRAMBasedMachine, ISymbolicMachine):
if val < -(2 ** 31 - 1) or val > (2 ** 31 - 1):
raise ValueError(f"This integer is too large to be encoded: {val}.")
val = IntVal(val)
size = BTCVector._min_bytes_needed(val, 1)
size = BTCVector._min_bytes_needed(val)
elif isinstance(val, str):
bytes_needed = len(val) // 2 # The string must be in hex format
if bytes_needed > self._word_size // 8:
......@@ -381,7 +381,7 @@ class BTCMachine(IStackBasedMachine, IRAMBasedMachine, ISymbolicMachine):
def count_stack_elements(self, n: int = 0) -> BTCVector:
"""Return the number of elements on the stack {n}."""
return BTCVector(
self._stack_sizes[n], BTCVector._min_bytes_needed(self._stack_sizes[n], 1)
self._stack_sizes[n], BTCVector._min_bytes_needed(self._stack_sizes[n])
)
# ######################## #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment