Skip to content

Commit

Permalink
Lint code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfish committed Dec 12, 2024
1 parent 7459e1d commit 8717de4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 34 deletions.
5 changes: 3 additions & 2 deletions ailment/converter_vex.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def Binop(expr, manager):
manager.next_atom(),
op2_size,
op1_size,
False if op._from_signed == "U" else True,
op._from_signed != "U",
operands[1],
ins_addr=manager.ins_addr,
vex_block_addr=manager.block_addr,
Expand Down Expand Up @@ -389,7 +389,8 @@ def Triop(expr, manager):
)

raise TypeError(
"Please figure out what kind of operation this is (smart money says fused multiply) and convert it into multiple binops"
"Please figure out what kind of operation this is (smart money says fused multiply) and convert it into "
"multiple binops"
)

@staticmethod
Expand Down
36 changes: 9 additions & 27 deletions ailment/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from __future__ import annotations
from typing import TYPE_CHECKING, cast
from collections.abc import Sequence
from typing_extensions import Self
from enum import Enum, IntEnum
from abc import abstractmethod
from typing_extensions import Self


try:
Expand All @@ -26,7 +26,10 @@ class Expression(TaggedObject):

bits: int

__slots__ = ("depth",)
__slots__ = (
"bits",
"depth",
)

def __init__(self, idx, depth, **kwargs):
super().__init__(idx, **kwargs)
Expand Down Expand Up @@ -92,10 +95,7 @@ def copy(self) -> Self: # pylint:disable=no-self-use


class Const(Atom):
__slots__ = (
"value",
"bits",
)
__slots__ = ("value",)

def __init__(self, idx: int | None, variable, value: int | float, bits: int, **kwargs):
super().__init__(idx, variable, **kwargs)
Expand Down Expand Up @@ -141,10 +141,7 @@ def copy(self) -> Const:


class Tmp(Atom):
__slots__ = (
"tmp_idx",
"bits",
)
__slots__ = ("tmp_idx",)

def __init__(self, idx: int | None, variable, tmp_idx: int, bits, **kwargs):
super().__init__(idx, variable, **kwargs)
Expand Down Expand Up @@ -176,10 +173,7 @@ def copy(self) -> Tmp:


class Register(Atom):
__slots__ = (
"reg_offset",
"bits",
)
__slots__ = ("reg_offset",)

def __init__(self, idx: int | None, variable, reg_offset: int, bits: int, **kwargs):
super().__init__(idx, variable, **kwargs)
Expand Down Expand Up @@ -227,7 +221,6 @@ class VirtualVariableCategory(IntEnum):
class VirtualVariable(Atom):

__slots__ = (
"bits",
"varid",
"category",
"oident",
Expand Down Expand Up @@ -331,10 +324,7 @@ def copy(self) -> VirtualVariable:

class Phi(Atom):

__slots__ = (
"bits",
"src_and_vvars",
)
__slots__ = ("src_and_vvars",)

def __init__(
self,
Expand Down Expand Up @@ -456,7 +446,6 @@ def verbose_op(self):
class UnaryOp(Op):
__slots__ = (
"operand",
"bits",
"variable",
"variable_offset",
)
Expand Down Expand Up @@ -759,7 +748,6 @@ def copy(self) -> Reinterpret:
class BinaryOp(Op):
__slots__ = (
"operands",
"bits",
"variable",
"variable_offset",
"floating_point",
Expand Down Expand Up @@ -1012,7 +1000,6 @@ class Load(Expression):
"variable_offset",
"guard",
"alt",
"bits",
)

def __init__(
Expand Down Expand Up @@ -1120,7 +1107,6 @@ class ITE(Expression):
"cond",
"iffalse",
"iftrue",
"bits",
"variable",
"variable_offset",
)
Expand Down Expand Up @@ -1233,7 +1219,6 @@ class DirtyExpression(Expression):
"mfx",
"maddr",
"msize",
"bits",
)

def __init__(
Expand Down Expand Up @@ -1371,7 +1356,6 @@ class VEXCCallExpression(Expression):
__slots__ = (
"callee",
"operands",
"bits",
)

def __init__(self, idx: int | None, callee: str, operands: tuple[Expression, ...], bits: int, **kwargs):
Expand Down Expand Up @@ -1456,7 +1440,6 @@ class MultiStatementExpression(Expression):
__slots__ = (
"stmts",
"expr",
"bits",
)

def __init__(self, idx: int | None, stmts: list[Statement], expr: Expression, **kwargs):
Expand Down Expand Up @@ -1532,7 +1515,6 @@ def copy(self) -> MultiStatementExpression:

class BasePointerOffset(Expression):
__slots__ = (
"bits",
"base",
"offset",
"variable",
Expand Down
7 changes: 2 additions & 5 deletions ailment/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint:disable=ungrouped-imports
from __future__ import annotations
from typing import TypeAlias
import struct
Expand Down Expand Up @@ -86,8 +87,6 @@ def is_none_or_likeable(arg1, arg2, is_list=False):
"""
Returns whether two things are both None or can like each other
"""
from .expression import Expression # pylint:disable=import-outside-toplevel

if arg1 is None or arg2 is None:
if arg1 == arg2:
return True
Expand All @@ -105,8 +104,6 @@ def is_none_or_matchable(arg1, arg2, is_list=False):
"""
Returns whether two things are both None or can match each other
"""
from .expression import Expression # pylint:disable=import-outside-toplevel

if arg1 is None or arg2 is None:
if arg1 == arg2:
return True
Expand All @@ -120,4 +117,4 @@ def is_none_or_matchable(arg1, arg2, is_list=False):
return arg1 == arg2


from .expression import Expression
from .expression import Expression # pylint:disable=wrong-import-position

0 comments on commit 8717de4

Please sign in to comment.