1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_SValue_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_SValue_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/BasicTypes.h>
7 #include <Rose/BinaryAnalysis/SmtSolver.h>
9 #include <boost/serialization/access.hpp>
10 #include <boost/serialization/export.hpp>
11 #include <boost/serialization/nvp.hpp>
12 #include <Sawyer/SharedPointer.h>
15 namespace BinaryAnalysis {
16 namespace InstructionSemantics {
27 template<
class To,
class From>
29 return from.template dynamicCast<To>();
56 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
58 friend class boost::serialization::access;
61 void serialize(S &s,
const unsigned ) {
62 s & BOOST_SERIALIZATION_NVP(width);
70 explicit SValue(
size_t nbits): width(nbits) {}
183 size_t nBits() const ;
258 virtual
void hash(Combinatorics::Hasher&) const = 0;
264 virtual
void print(
std::ostream&, Formatter&) const = 0;
279 void print(std::ostream &stream)
const { obj->print(stream, fmt); }
291 WithFormatter
operator+(
const std::string &linePrefix);
328 std::ostream& operator<<(std::ostream&,
const SValue&);
329 std::ostream& operator<<(std::ostream&,
const SValue::WithFormatter&);
Base classes for instruction semantics.
virtual void set_width(size_t nbits)
Virtual API.
virtual SValuePtr boolean_(bool value) const
Create a new, Boolean value.
SharedObject()
Default constructor.
virtual bool may_equal(const SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const =0
Virtual API.
virtual std::string get_comment() const
Some subclasses support the ability to add comments to values.
WithFormatter with_format(Formatter &fmt)
Used for printing values with formatting.
WithFormatter operator+(Formatter &fmt)
Used for printing values with formatting.
virtual SValuePtr copy(size_t new_width=0) const =0
Create a new value from an existing value, changing the width if new_width is non-zero.
virtual void set_comment(const std::string &) const
Some subclasses support the ability to add comments to values.
Holds a value or nothing.
SValuePtr createMerged(const SValuePtr &other, const MergerPtr &merger, const SmtSolverPtr &solver) const
Create a new value by merging two existing values.
Main namespace for the ROSE library.
virtual void hash(Combinatorics::Hasher &) const =0
Hash this semantic value.
Sawyer::Optional< int64_t > toSigned() const
Converts a concrete value to a native signed integer.
virtual SValuePtr undefined_(size_t nbits) const =0
Create a new undefined semantic value.
std::string comment() const
Property: Comment.
Reference-counting intrusive smart pointer.
Name space for the entire library.
bool isFalse() const
Returns true if concrete zero.
bool isConcrete() const
Determines if the value is a concrete number.
virtual bool must_equal(const SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const =0
Virtual API.
Creates SharedPointer from this.
virtual size_t get_width() const
Virtual API.
virtual SValuePtr bottom_(size_t nBits) const =0
Data-flow bottom value.
bool isTrue() const
Returns true if concrete non-zero.
void print(std::ostream &) const
Print a value to a stream using default format.
virtual uint64_t get_number() const =0
Virtual API.
Base class for semantic values.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
virtual bool isBottom() const =0
Determines whether a value is a data-flow bottom.
Base class for reference counted objects.
virtual SValuePtr unspecified_(size_t nbits) const =0
Create a new unspecified semantic value.
std::shared_ptr< SmtSolver > SmtSolverPtr
Reference counting pointer.
virtual Sawyer::Optional< SValuePtr > createOptionalMerge(const SValuePtr &other, const MergerPtr &merger, const SmtSolverPtr &solver) const =0
Possibly create a new value by merging two existing values.
virtual bool is_number() const =0
Virtual API.
bool mayEqual(const SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
Tests two values for possible equality.
bool mustEqual(const SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
Tests two values for equality.
std::string toString() const
Render this symbolic expression as a string.
virtual SValuePtr number_(size_t nbits, uint64_t number) const =0
Create a new concrete semantic value.
Sawyer::Optional< uint64_t > toUnsigned() const
Converts a concrete value to a native unsigned integer.
size_t nBits() const
Property: value width.