Add optional cpu state to Variable.
- Used to preserve the CPU state for variables representing return values, since they may potentially be retrieved from registers, and these might be overwritten later in the same statement.
This commit is contained in:
@@ -6,22 +6,26 @@
|
||||
|
||||
#include "Variable.h"
|
||||
|
||||
#include "CpuState.h"
|
||||
#include "ObjectID.h"
|
||||
#include "Type.h"
|
||||
#include "ValueLocation.h"
|
||||
|
||||
|
||||
Variable::Variable(ObjectID* id, const BString& name, Type* type,
|
||||
ValueLocation* location)
|
||||
ValueLocation* location, CpuState* state)
|
||||
:
|
||||
fID(id),
|
||||
fName(name),
|
||||
fType(type),
|
||||
fLocation(location)
|
||||
fLocation(location),
|
||||
fCpuState(state)
|
||||
{
|
||||
fID->AcquireReference();
|
||||
fType->AcquireReference();
|
||||
fLocation->AcquireReference();
|
||||
if (fCpuState != NULL)
|
||||
fCpuState->AcquireReference();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,4 +34,6 @@ Variable::~Variable()
|
||||
fID->ReleaseReference();
|
||||
fType->ReleaseReference();
|
||||
fLocation->ReleaseReference();
|
||||
if (fCpuState != NULL)
|
||||
fCpuState->ReleaseReference();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <Referenceable.h>
|
||||
|
||||
|
||||
class CpuState;
|
||||
class ObjectID;
|
||||
class Type;
|
||||
class ValueLocation;
|
||||
@@ -19,19 +20,22 @@ class ValueLocation;
|
||||
class Variable : public BReferenceable {
|
||||
public:
|
||||
Variable(ObjectID* id, const BString& name,
|
||||
Type* type, ValueLocation* location);
|
||||
Type* type, ValueLocation* location,
|
||||
CpuState* state = NULL);
|
||||
~Variable();
|
||||
|
||||
ObjectID* ID() const { return fID; }
|
||||
const BString& Name() const { return fName; }
|
||||
Type* GetType() const { return fType; }
|
||||
ValueLocation* Location() const { return fLocation; }
|
||||
CpuState* GetCpuState() const { return fCpuState; }
|
||||
|
||||
private:
|
||||
ObjectID* fID;
|
||||
BString fName;
|
||||
Type* fType;
|
||||
ValueLocation* fLocation;
|
||||
CpuState* fCpuState;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user