2828from . import _binaryninjacore as core
2929from .enums import (
3030 InlineDuringAnalysis , StructureVariant , SymbolType , SymbolBinding , TypeClass , NamedTypeReferenceClass ,
31- ReferenceType , VariableSourceType ,
31+ ReferenceType , VariableSourceType , ValueLocationSource ,
3232 TypeReferenceType , MemberAccess , MemberScope , TypeDefinitionLineType ,
3333 TokenEscapingType ,
3434 NameType , PointerSuffix , PointerBaseType
@@ -624,16 +624,21 @@ def _to_core_struct(self) -> core.BNReturnValue:
624624class FunctionParameter :
625625 type : SomeType
626626 name : str = ""
627+ location_source : ValueLocationSource = ValueLocationSource .DefaultLocationSource
627628 location : Optional ['ValueLocation' ] = None
628629
629- def __init__ (self , type : SomeType , name : str = "" , location : OptionalLocation = None ):
630+ def __init__ (self , type : SomeType , name : str = "" , location : OptionalLocation = None , source : Optional [ 'ValueLocationSource' ] = None ):
630631 self .type = type
631632 self .name = name
632633 location = ValueLocationWithConfidence .from_optional_location (location )
633634 if location is not None :
634635 self .location = location .location
636+ self .location_source = ValueLocationSource .CustomLocationSource
635637 else :
636638 self .location = None
639+ self .location_source = ValueLocationSource .DefaultLocationSource
640+ if source is not None :
641+ self .location_source = source
637642
638643 def __repr__ (self ):
639644 ic = self .type .immutable_copy ()
@@ -651,11 +656,12 @@ def mutable_copy(self) -> 'FunctionParameter':
651656 def _from_core_struct (struct : 'core.BNFunctionParameter' , arch : Optional ['architecture.Architecture' ] = None ) -> 'FunctionParameter' :
652657 name = struct .name
653658 ty = Type .from_core_struct (struct .type ).with_confidence (struct .typeConfidence )
654- if struct .defaultLocation :
655- location = None
656- else :
659+ source = ValueLocationSource (struct .locationSource )
660+ if source == ValueLocationSource .CustomLocationSource :
657661 location = ValueLocation ._from_core_struct (struct .location , arch )
658- return FunctionParameter (ty , name , location )
662+ else :
663+ location = None
664+ return FunctionParameter (ty , name , location , source )
659665
660666
661667@dataclass (frozen = True )
@@ -1514,10 +1520,11 @@ def parameters(self) -> List[FunctionParameter]:
15141520 param_type = Type .create (
15151521 core .BNNewTypeReference (params [i ].type ), platform = self .platform , confidence = params [i ].typeConfidence
15161522 )
1517- if params [i ].defaultLocation :
1518- param_location = None
1519- else :
1523+ source = ValueLocationSource (params [i ].locationSource )
1524+ if source == ValueLocationSource .CustomLocationSource :
15201525 param_location = ValueLocation ._from_core_struct (params [i ].location , arch )
1526+ else :
1527+ param_location = None
15211528 result .append (FunctionParameter (param_type , params [i ].name , param_location ))
15221529 core .BNFreeTypeParameterList (params , count .value )
15231530 return result
@@ -1546,7 +1553,7 @@ def _to_core_struct(params: Optional[ParamsType] = None):
15461553 core_param .name = ""
15471554 core_param .type = param .handle
15481555 core_param .typeConfidence = param .confidence
1549- core_param .defaultLocation = True
1556+ core_param .locationSource = int ( ValueLocationSource . DefaultLocationSource )
15501557 core_param .location .count = 0
15511558 elif isinstance (param , FunctionParameter ):
15521559 assert param .type is not None , "Attempting to construct function parameter without properly constructed type"
@@ -1555,11 +1562,10 @@ def _to_core_struct(params: Optional[ParamsType] = None):
15551562 core_param .name = param .name
15561563 core_param .type = param_type .handle
15571564 core_param .typeConfidence = param_type .confidence
1565+ core_param .locationSource = int (param .location_source )
15581566 if param .location is None :
1559- core_param .defaultLocation = True
15601567 core_param .location .count = 0
15611568 else :
1562- core_param .defaultLocation = False
15631569 if isinstance (param .location , ValueLocation ):
15641570 core_param .location = param .location ._to_core_struct ()
15651571 elif isinstance (param .location , variable .CoreVariable ):
@@ -1575,7 +1581,7 @@ def _to_core_struct(params: Optional[ParamsType] = None):
15751581 core_param .name = name
15761582 core_param .type = _type .handle
15771583 core_param .typeConfidence = _type .confidence
1578- core_param .defaultLocation = True
1584+ core_param .locationSource = int ( ValueLocationSource . DefaultLocationSource )
15791585 core_param .location .count = 0
15801586 else :
15811587 raise ValueError (f"Conversion from unsupported function parameter type { type (param )} " )
@@ -3472,11 +3478,12 @@ def parameters(self) -> List[FunctionParameter]:
34723478 param_type = Type .create (
34733479 core .BNNewTypeReference (params [i ].type ), platform = self ._platform , confidence = params [i ].typeConfidence
34743480 )
3475- if params [i ].defaultLocation :
3476- param_location = None
3477- else :
3481+ source = ValueLocationSource (params [i ].locationSource )
3482+ if source == ValueLocationSource .CustomLocationSource :
34783483 param_location = ValueLocation ._from_core_struct (params [i ].location , arch )
3479- result .append (FunctionParameter (param_type , params [i ].name , param_location ))
3484+ else :
3485+ param_location = None
3486+ result .append (FunctionParameter (param_type , params [i ].name , param_location , source ))
34803487 core .BNFreeTypeParameterList (params , count .value )
34813488 return result
34823489
0 commit comments