ROSE 0.11.145.237
MemoryState.h
1#ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_MemoryState_H
2#define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_MemoryState_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/AddressSpace.h>
6
7#include <Rose/BinaryAnalysis/ByteOrder.h>
8
9#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
10#include <boost/serialization/access.hpp>
11#include <boost/serialization/export.hpp>
12#include <boost/serialization/shared_ptr.hpp>
13#endif
14
15namespace Rose {
16namespace BinaryAnalysis {
17namespace InstructionSemantics {
18namespace BaseSemantics {
19
21// Memory State
23
28public:
31
32private:
33 SValuePtr addrProtoval_;
34 SValuePtr valProtoval_;
35 ByteOrder::Endianness byteOrder_;
36 MergerPtr merger_;
37 bool byteRestricted_; // are cell values all exactly one byte wide?
38
40 // Serialization
41#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
42private:
43 friend class boost::serialization::access;
44
45 template<class S>
46 void serialize(S &s, const unsigned /*version*/) {
47 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AddressSpace);
48 s & BOOST_SERIALIZATION_NVP(addrProtoval_);
49 s & BOOST_SERIALIZATION_NVP(valProtoval_);
50 s & BOOST_SERIALIZATION_NVP(byteOrder_);
51 //s & merger_ -- not saved
52 s & BOOST_SERIALIZATION_NVP(byteRestricted_);
53 }
54#endif
55
56
58 // Real constructors
59protected:
60 MemoryState(); // for serialization
61 MemoryState(const SValuePtr &addrProtoval, const SValuePtr &valProtoval);
62 MemoryState(const MemoryStatePtr &other);
63
64public:
65 virtual ~MemoryState();
66
68 // Static allocating constructors. None needed since this class is abstract
69
71 // Virtual constructors
72public:
79 virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const = 0;
80
82 // Dynamic pointer casts. No-op since this is the base class.
83public:
84 static MemoryStatePtr promote(const AddressSpacePtr&);
85
87 // Methods first declared at this level of the class hierarchy
88public:
98 void merger(const MergerPtr&);
104
108
110 virtual void clear() = 0;
111
119 bool byteRestricted() const;
120 void byteRestricted(bool);
148 virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt,
149 RiscOperators *addrOps, RiscOperators *valOps) = 0;
150
155 virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt,
156 RiscOperators *addrOps, RiscOperators *valOps) = 0;
157
167 virtual void writeMemory(const SValuePtr &addr, const SValuePtr &value,
168 RiscOperators *addrOps, RiscOperators *valOps) = 0;
169
170
171};
172
173} // namespace
174} // namespace
175} // namespace
176} // namespace
177
178#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
180#endif
181
182#endif
183#endif
void set_byteOrder(ByteOrder::Endianness)
Memory byte order.
virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const =0
Virtual allocating constructor.
virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps)=0
Read a value from memory without side effects.
SValuePtr get_val_protoval() const
Return the value protoval.
virtual void writeMemory(const SValuePtr &addr, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps)=0
Write a value to memory.
ByteOrder::Endianness get_byteOrder() const
Memory byte order.
SValuePtr get_addr_protoval() const
Return the address protoval.
bool byteRestricted() const
Indicates whether memory cell values are required to be eight bits wide.
virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps)=0
Read a value from memory.
void byteRestricted(bool)
Indicates whether memory cell values are required to be eight bits wide.
Base class for most instruction semantics RISC operators.
Base classes for instruction semantics.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
boost::shared_ptr< AddressSpace > AddressSpacePtr
Shared-ownership pointer for AddressSpace objects.
The ROSE library.