From 4c375e18a4f464a049a1ac1457cb6359c0b27596 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 3 Jun 2022 09:12:45 -0400 Subject: Implement .tokens property in HLIL. LLIL and MLIL instructions both have this property. HLIL has .lines which functions similarly, but returns a a generator of DisassemblyTextLines. The .tokens property flattens those lines to return a list of InstructionTestTokens in line with LLIL and MLIL instructions. This enables plugins to work consistently regardless of instruction type and makes the API more consistent. --- python/highlevelil.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'python') diff --git a/python/highlevelil.py b/python/highlevelil.py index cd073df6..c80354b7 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -44,6 +44,7 @@ from .commonil import ( Loop, ControlFlow, Memory, Constant, Arithmetic, DoublePrecision, Terminal, FloatingPoint, Intrinsic, Return ) +TokenList = List['function.InstructionTextToken'] LinesType = Generator['function.DisassemblyTextLine', None, None] ExpressionIndex = NewType('ExpressionIndex', int) InstructionIndex = NewType('InstructionIndex', int) @@ -365,6 +366,11 @@ class HighLevelILInstruction(BaseILInstruction): def __hash__(self): return hash((self.function, self.expr_index)) + @property + def tokens(self) -> TokenList: + """HLIL tokens taken from the HLIL text lines(read-only)""" + return [token for line in self.lines for token in line.tokens] + @property def lines(self) -> LinesType: """HLIL text lines (read-only)""" -- cgit v1.3.1