Skip to content

Commit

Permalink
Changed Type from Pointer(FunctionPointer) to FunctionPointer()
Browse files Browse the repository at this point in the history
  • Loading branch information
fnhartmann committed Feb 27, 2024
1 parent adb451d commit 008fef1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 3 additions & 2 deletions decompiler/backend/cexpressiongenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from itertools import chain, repeat

from decompiler.structures import pseudo as expressions
from decompiler.structures.pseudo import Float, FunctionTypeDef, Integer, OperationType, Pointer, StringSymbol, Type
from decompiler.structures.pseudo import Float, FunctionTypeDef, FunctionPointer, Integer, OperationType, Pointer, StringSymbol, Type
from decompiler.structures.pseudo import instructions as instructions
from decompiler.structures.pseudo import operations as operations
from decompiler.structures.pseudo.operations import MemberAccess
Expand Down Expand Up @@ -349,7 +349,8 @@ def _format_string_literal(constant: expressions.Constant) -> str:
def format_variables_declaration(var_type: Type, var_names: list[str]) -> str:
"""Return a string representation of variable declarations."""
match var_type:
case Pointer(type=FunctionTypeDef() as fun_type):
case Pointer(type=FunctionTypeDef()) | FunctionPointer():
fun_type = var_type.type if isinstance(var_type, Pointer) else var_type
parameter_names = ", ".join(str(parameter) for parameter in fun_type.parameters)
declarations_without_return_type = [f"(* {var_name})({parameter_names})" for var_name in var_names]
return f"{fun_type.return_type} {', '.join(declarations_without_return_type)}"
Expand Down
10 changes: 4 additions & 6 deletions decompiler/pipeline/preprocessing/get_function_pointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ def run(self, task: DecompilerTask):
and isinstance(expression.value, Call)
and isinstance(expression.value.function, Variable)
):
expression.value.function._type = Pointer(
basetype=FunctionPointer(
size=expression.value.function.type.size,
return_type=expression.value.function.type,
parameters=tuple(expression.value.parameters),
),
expression.value.function._type = FunctionPointer(
return_type=expression.value.function.type,
parameters=tuple(expression.value.parameters),
size=expression.value.function.type.size,
)
2 changes: 1 addition & 1 deletion decompiler/structures/pseudo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
Return,
)
from .operations import BinaryOperation, Call, Condition, ListOperation, Operation, OperationType, TernaryExpression, UnaryOperation
from .typing import CustomType, Float, FunctionTypeDef, Integer, Pointer, Type, TypeParser, UnknownType
from .typing import CustomType, Float, FunctionTypeDef, FunctionPointer, Integer, Pointer, Type, TypeParser, UnknownType
from .z3_logic import Z3Converter

0 comments on commit 008fef1

Please sign in to comment.