From c3b91a6d7776ba25c738b3d2b8bc49a9b23a118d Mon Sep 17 00:00:00 2001 From: Manuel Blatt Date: Wed, 3 Jul 2024 10:37:07 +0200 Subject: [PATCH] rename StructTesting to StructConstant --- decompiler/backend/variabledeclarations.py | 4 ++-- decompiler/frontend/binaryninja/handlers/globals.py | 6 +++--- decompiler/structures/pseudo/__init__.py | 2 +- decompiler/structures/pseudo/expressions.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/decompiler/backend/variabledeclarations.py b/decompiler/backend/variabledeclarations.py index efd08a37d..d7f52885e 100644 --- a/decompiler/backend/variabledeclarations.py +++ b/decompiler/backend/variabledeclarations.py @@ -12,7 +12,7 @@ from decompiler.structures.ast.syntaxtree import AbstractSyntaxTree from decompiler.structures.pseudo import GlobalVariable, Integer, Variable from decompiler.structures.pseudo.complextypes import Struct -from decompiler.structures.pseudo.expressions import StructTesting +from decompiler.structures.pseudo.expressions import StructConstant from decompiler.structures.pseudo.typing import ArrayType, CustomType, Pointer from decompiler.structures.visitors.ast_dataflowobjectvisitor import BaseAstDataflowObjectVisitor from decompiler.task import DecompilerTask @@ -105,6 +105,6 @@ def visit_global_variable(self, expr: GlobalVariable): self._global_vars.add(expr.copy(ssa_label=0, ssa_name=None)) if not expr.is_constant or expr.type == Pointer(CustomType.void()): self._global_vars.add(expr.copy(ssa_label=0, ssa_name=None)) - if isinstance(expr.initial_value, StructTesting): + if isinstance(expr.initial_value, StructConstant): for member_value in expr.initial_value.value.values(): self.visit(member_value) diff --git a/decompiler/frontend/binaryninja/handlers/globals.py b/decompiler/frontend/binaryninja/handlers/globals.py index dc6f2339b..621cb76a9 100644 --- a/decompiler/frontend/binaryninja/handlers/globals.py +++ b/decompiler/frontend/binaryninja/handlers/globals.py @@ -32,7 +32,7 @@ OperationType, Pointer, Struct, - StructTesting, + StructConstant, Symbol, UnaryOperation, ) @@ -267,7 +267,7 @@ def _lift_named_type_ref(self, variable: DataVariable, parent: Optional[MediumLe values[member_type.offset] = lift.initial_value types[member_type.offset] = s_type.get_member_by_offset(member_type.offset) return self._build_global_variable( - variable.name, s_type, variable.address, StructTesting(values, s_type), parent.ssa_memory_version if parent else 0 + variable.name, s_type, variable.address, StructConstant(values, s_type), parent.ssa_memory_version if parent else 0 ) case NamedTypeReferenceClass.EnumNamedTypeClass: @@ -296,7 +296,7 @@ def _lift_structure_type(self, variable: DataVariable, parent: Optional[MediumLe values[member_type.offset] = lift.initial_value types[member_type.offset] = s_type.get_member_by_offset(member_type.offset) return self._build_global_variable( - variable.name, s_type, variable.address, StructTesting(values, s_type), parent.ssa_memory_version if parent else 0 + variable.name, s_type, variable.address, StructConstant(values, s_type), parent.ssa_memory_version if parent else 0 ) def _get_unknown_value(self, variable: DataVariable): diff --git a/decompiler/structures/pseudo/__init__.py b/decompiler/structures/pseudo/__init__.py index a1143405c..54e3148b9 100644 --- a/decompiler/structures/pseudo/__init__.py +++ b/decompiler/structures/pseudo/__init__.py @@ -11,7 +11,7 @@ IntrinsicSymbol, NotUseableConstant, RegisterPair, - StructTesting, + StructConstant, Symbol, Tag, UnknownExpression, diff --git a/decompiler/structures/pseudo/expressions.py b/decompiler/structures/pseudo/expressions.py index c7e434789..6e3e24aca 100644 --- a/decompiler/structures/pseudo/expressions.py +++ b/decompiler/structures/pseudo/expressions.py @@ -520,7 +520,7 @@ def accept(self, visitor: DataflowObjectVisitorInterface[T]) -> T: return visitor.visit_constant_composition(self) -class StructTesting(Constant): +class StructConstant(Constant): def __init__(self, value: dict[int, Expression], vartype: Struct, tags: Optional[Tuple[Tag, ...]] = None): super().__init__( value, @@ -536,6 +536,6 @@ def __str__(self) -> str: def __iter__(self) -> Iterator[Expression]: yield from self.value.values() - def copy(self) -> StructTesting: + def copy(self) -> StructConstant: """Generate a copy of the UnknownExpression with the same message.""" - return StructTesting(self.value.copy(), self._type.copy()) # Deep copy needed for all Expr inside. + return StructConstant(self.value.copy(), self._type.copy()) # Deep copy needed for all Expr inside.