ROSE 0.11.145.192
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#include <boost/serialization/access.hpp>
10#include <boost/serialization/export.hpp>
11#include <boost/serialization/shared_ptr.hpp>
12
13namespace Rose {
14namespace BinaryAnalysis {
15namespace InstructionSemantics {
16namespace BaseSemantics {
17
19// Memory State
21
26public:
29
30private:
31 SValuePtr addrProtoval_;
32 SValuePtr valProtoval_;
33 ByteOrder::Endianness byteOrder_;
34 MergerPtr merger_;
35 bool byteRestricted_; // are cell values all exactly one byte wide?
36
38 // Serialization
39#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
40private:
41 friend class boost::serialization::access;
42
43 template<class S>
44 void serialize(S &s, const unsigned /*version*/) {
45 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AddressSpace);
46 s & BOOST_SERIALIZATION_NVP(addrProtoval_);
47 s & BOOST_SERIALIZATION_NVP(valProtoval_);
48 s & BOOST_SERIALIZATION_NVP(byteOrder_);
49 //s & merger_ -- not saved
50 s & BOOST_SERIALIZATION_NVP(byteRestricted_);
51 }
52#endif
53
54
56 // Real constructors
57protected:
58 MemoryState(); // for serialization
59 MemoryState(const SValuePtr &addrProtoval, const SValuePtr &valProtoval);
60 MemoryState(const MemoryStatePtr &other);
61
62public:
63 virtual ~MemoryState();
64
66 // Static allocating constructors. None needed since this class is abstract
67
69 // Virtual constructors
70public:
77 virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const = 0;
78
80 // Dynamic pointer casts. No-op since this is the base class.
81public:
82 static MemoryStatePtr promote(const AddressSpacePtr&);
83
85 // Methods first declared at this level of the class hierarchy
86public:
96 void merger(const MergerPtr&);
102
106
108 virtual void clear() = 0;
109
117 bool byteRestricted() const;
118 void byteRestricted(bool);
146 virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt,
147 RiscOperators *addrOps, RiscOperators *valOps) = 0;
148
153 virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt,
154 RiscOperators *addrOps, RiscOperators *valOps) = 0;
155
165 virtual void writeMemory(const SValuePtr &addr, const SValuePtr &value,
166 RiscOperators *addrOps, RiscOperators *valOps) = 0;
167
168
169};
170
171} // namespace
172} // namespace
173} // namespace
174} // namespace
175
177
178#endif
179#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.