Add ReturnValueInfo class for storing function return information.

This commit is contained in:
Rene Gollent 2013-03-27 23:27:03 -04:00
parent 5a6b854033
commit 3fa429781c
2 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,47 @@
/*
* Copyright 2013, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#include "ReturnValueInfo.h"
#include "CpuState.h"
ReturnValueInfo::ReturnValueInfo()
:
BReferenceable(),
fAddress(0),
fState(NULL)
{
}
ReturnValueInfo::ReturnValueInfo(target_addr_t address, CpuState* state)
:
BReferenceable(),
fAddress(address),
fState(state)
{
state->AcquireReference();
}
ReturnValueInfo::~ReturnValueInfo()
{
if (fState != NULL)
fState->ReleaseReference();
}
void
ReturnValueInfo::SetTo(target_addr_t address, CpuState* state)
{
fAddress = address;
if (fState != NULL)
fState->ReleaseReference();
fState = state;
fState->AcquireReference();
}

View File

@ -0,0 +1,38 @@
/*
* Copyright 2013, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#ifndef RETURN_VALUE_INFO_H
#define RETURN_VALUE_INFO_H
#include "ObjectList.h"
#include "Referenceable.h"
#include "Types.h"
class CpuState;
class ReturnValueInfo : public BReferenceable {
public:
ReturnValueInfo();
ReturnValueInfo(target_addr_t address,
CpuState* state);
~ReturnValueInfo();
void SetTo(target_addr_t address, CpuState* state);
target_addr_t SubroutineAddress() const
{ return fAddress; }
CpuState* State() const { return fState; }
private:
target_addr_t fAddress;
CpuState* fState;
};
typedef BObjectList<ReturnValueInfo> ReturnValueInfoList;
#endif // RETURN_VALUE_INFO_H