Skip to content

Commit

Permalink
include lvalue type in operations' __str__ methods
Browse files Browse the repository at this point in the history
  • Loading branch information
0xalpharush committed May 13, 2023
1 parent eda3e54 commit ac2142f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion slither/slithir/operations/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ def __str__(self) -> str:
points = lvalue.points_to
while isinstance(points, ReferenceVariable):
points = points.points_to
return f"{lvalue} (->{points}) := {self.rvalue}({self.rvalue.type})"
return f"{lvalue}({lvalue.type}) (->{points}) := {self.rvalue}({self.rvalue.type})"
return f"{lvalue}({lvalue.type}) := {self.rvalue}({self.rvalue.type})"
5 changes: 4 additions & 1 deletion slither/slithir/operations/new_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ def depth(self) -> int:

def __str__(self):
args = [str(a) for a in self.arguments]
return f"{self.lvalue} = new {self.array_type}{'[]' * self.depth}({','.join(args)})"
lvalue = self.lvalue
return (
f"{lvalue}({lvalue.type}) = new {self.array_type}{'[]' * self.depth}({','.join(args)})"
)
3 changes: 2 additions & 1 deletion slither/slithir/operations/new_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ def __str__(self) -> str:
if self.call_salt:
options += f"salt:{self.call_salt} "
args = [str(a) for a in self.arguments]
return f"{self.lvalue} = new {self.contract_name}({','.join(args)}) {options}"
lvalue = self.lvalue
return f"{lvalue}({lvalue.type}) = new {self.contract_name}({','.join(args)}) {options}"
3 changes: 2 additions & 1 deletion slither/slithir/operations/new_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ def structure_name(self):

def __str__(self):
args = [str(a) for a in self.arguments]
return f"{self.lvalue} = new {self.structure_name}({','.join(args)})"
lvalue = self.lvalue
return f"{lvalue}({lvalue.type}) = new {self.structure_name}({','.join(args)})"

0 comments on commit ac2142f

Please sign in to comment.