From 6de4900db74a341fddfda46f7cb4342fdc31f8e0 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Wed, 23 Jun 2021 09:31:22 -0400 Subject: Refactor Variable class The Variable class is now broken into 3 separate classes with helper methods to convert between them. CoreVariable is implemented as a frozen dataclass and is analogous to BNVariable VariableNameAndType is analogous to BNVariableNameAndType Bothe the above are passive objects and can not be changed directly The new and improved Variable object is now an active object which can be operated on directly and changes will take effect immediately --- python/types.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'python/types.py') diff --git a/python/types.py b/python/types.py index bead9a64..3cd44bd8 100644 --- a/python/types.py +++ b/python/types.py @@ -19,7 +19,8 @@ # IN THE SOFTWARE. import ctypes -from typing import Generator, List, Union +from typing import Generator, List, Union, Mapping, Tuple, Optional +from dataclasses import dataclass # Binary Ninja components from . import _binaryninjacore as core @@ -28,6 +29,7 @@ from . import callingconvention from . import function from . import variable from . import architecture +from . import types from . import log QualifiedNameType = Union[List[str], str, 'QualifiedName', List[bytes]] @@ -588,7 +590,7 @@ class Type(object): name = self._platform.arch.get_reg_name(params[i].location.storage) elif params[i].location.type == VariableSourceType.StackVariableSourceType: name = "arg_%x" % params[i].location.storage - param_location = variable.Variable(None, params[i].location.type, params[i].location.index, + param_location = variable.VariableNameAndType(params[i].location.type, params[i].location.index, params[i].location.storage, name, param_type) result.append(FunctionParameter(param_type, params[i].name, param_location)) core.BNFreeTypeParameterList(params, count.value) -- cgit v1.3.1