From 9290bd614d83b389ba0c1159379d3d357c658b1e Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Tue, 26 Oct 2021 12:11:24 -0400 Subject: Make all ILInstructions inherit from the same abstract base class --- python/commonil.py | 5 +++++ python/highlevelil.py | 4 ++-- python/lowlevelil.py | 4 ++-- python/mediumlevelil.py | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) (limited to 'python') diff --git a/python/commonil.py b/python/commonil.py index 4a079f02..fdb6540e 100644 --- a/python/commonil.py +++ b/python/commonil.py @@ -23,6 +23,11 @@ from dataclasses import dataclass # This file contains a list of top level abstract classes for implementing BNIL instructions +@dataclass(frozen=True, repr=False) +class ILInstruction: + pass + + @dataclass(frozen=True, repr=False) class Constant: pass diff --git a/python/highlevelil.py b/python/highlevelil.py index a71dc69c..0ae927e4 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -37,7 +37,7 @@ from . import types from . import highlight from . import flowgraph from . import variable -from .commonil import (Call, Tailcall, Syscall, Comparison, Signed, UnaryOperation, BinaryOperation, +from .commonil import (ILInstruction, Call, Tailcall, Syscall, Comparison, Signed, UnaryOperation, BinaryOperation, SSA, Phi, Loop, ControlFlow, Memory, Constant, Arithmetic, DoublePrecision, Terminal, FloatingPoint) @@ -128,7 +128,7 @@ class CoreHighLevelILInstruction: @dataclass(frozen=True) -class HighLevelILInstruction: +class HighLevelILInstruction(ILInstruction): """ ``class HighLevelILInstruction`` High Level Intermediate Language Instructions form an abstract syntax tree of the code. Control flow structures are present as high level constructs in the HLIL tree. diff --git a/python/lowlevelil.py b/python/lowlevelil.py index f1756692..80349987 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -35,7 +35,7 @@ from . import variable from . import binaryview from . import architecture from . import types -from .commonil import (Constant, BinaryOperation, UnaryOperation, Comparison, SSA, +from .commonil import (ILInstruction, Constant, BinaryOperation, UnaryOperation, Comparison, SSA, Phi, FloatingPoint, ControlFlow, Terminal, Call, StackOperation, Return, Signed, Arithmetic, Carry, DoublePrecision, Memory, Load, Store, RegisterStack, SetReg) @@ -299,7 +299,7 @@ class CoreLowLevelILInstruction: @dataclass(frozen=True) -class LowLevelILInstruction: +class LowLevelILInstruction(ILInstruction): """ ``class LowLevelILInstruction`` Low Level Intermediate Language Instructions are infinite length tree-based instructions. Tree-based instructions use infix notation with the left hand operand being the destination operand. diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index 202bc036..3a37bb6a 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -35,7 +35,7 @@ from . import flowgraph from . import variable from . import architecture from . import binaryview -from .commonil import (Constant, BinaryOperation, UnaryOperation, Comparison, SSA, +from .commonil import (ILInstruction, Constant, BinaryOperation, UnaryOperation, Comparison, SSA, Phi, FloatingPoint, ControlFlow, Terminal, Call, Syscall, Tailcall, Return, Signed, Arithmetic, Carry, DoublePrecision, Memory, Load, Store, RegisterStack, SetVar) @@ -105,7 +105,7 @@ class CoreMediumLevelILInstruction: @dataclass(frozen=True) -class MediumLevelILInstruction: +class MediumLevelILInstruction(ILInstruction): """ ``class MediumLevelILInstruction`` Medium Level Intermediate Language Instructions are infinite length tree-based instructions. Tree-based instructions use infix notation with the left hand operand being the destination operand. -- cgit v1.3.1