ROSE
0.9.11.10

Interior node of an expression tree for instruction semantics.
Each interior node has an operator (constant for the life of the node and obtainable with get_operator()) and zero or more children. Children are added to the interior node during the construction phase. Once construction is complete, the children should only change in ways that don't affect the value of the node as a whole (since this node might be pointed to by any number of expressions).
Definition at line 689 of file BinarySymbolicExpr.h.
#include <BinarySymbolicExpr.h>
Public Member Functions  
virtual bool  mustEqual (const Ptr &other, const SmtSolverPtr &solver=SmtSolverPtr()) ROSE_OVERRIDE 
Returns true if two expressions must be equal (cannot be unequal). More...  
virtual bool  mayEqual (const Ptr &other, const SmtSolverPtr &solver=SmtSolverPtr()) ROSE_OVERRIDE 
Returns true if two expressions might be equal, but not necessarily be equal. More...  
virtual bool  isEquivalentTo (const Ptr &other) ROSE_OVERRIDE 
Tests two expressions for structural equivalence. More...  
virtual int  compareStructure (const Ptr &other) ROSE_OVERRIDE 
Compare two expressions structurally for sorting. More...  
virtual Ptr  substitute (const Ptr &from, const Ptr &to, const SmtSolverPtr &solver=SmtSolverPtr()) ROSE_OVERRIDE 
Substitute one value for another. More...  
virtual bool  isNumber () ROSE_OVERRIDE 
Returns true if the expression is a known numeric value. More...  
virtual uint64_t  toInt () ROSE_OVERRIDE 
Property: integer value of expression node. More...  
virtual VisitAction  depthFirstTraversal (Visitor &) ROSE_OVERRIDE 
Traverse the expression. More...  
virtual uint64_t  nNodes () ROSE_OVERRIDE 
Computes the size of an expression by counting the number of nodes. More...  
size_t  nChildren () 
Returns the number of children. More...  
Ptr  child (size_t idx) 
Returns the specified child. More...  
const Nodes &  children () 
Property: Children. More...  
Operator  getOperator () 
Returns the operator. More...  
Ptr  simplifyTop (const SmtSolverPtr &solver=SmtSolverPtr()) 
Simplifies the specified interior node. More...  
Ptr  foldConstants (const Simplifier &) 
Perform constant folding. More...  
InteriorPtr  associative () 
Simplifies nonassociative operators by flattening the specified interior node with its children that are the same interior node type. More...  
InteriorPtr  commutative () 
Simplifies commutative operators by sorting arguments. More...  
Ptr  involutary () 
Simplifies involutary operators. More...  
Ptr  additiveNesting (const SmtSolverPtr &solver=SmtSolverPtr()) 
Simplifies nested shiftlike operators. More...  
Ptr  identity (uint64_t ident, const SmtSolverPtr &solver=SmtSolverPtr()) 
Removes identity arguments. More...  
Ptr  unaryNoOp () 
Replaces a binary operator with its only argument. More...  
Ptr  rewrite (const Simplifier &simplifier, const SmtSolverPtr &solver=SmtSolverPtr()) 
Simplify an interior node. More...  
virtual void  print (std::ostream &, Formatter &) ROSE_OVERRIDE 
Print the expression to a stream. More...  
Public Member Functions inherited from Rose::BinaryAnalysis::SymbolicExpr::Node  
Ptr  substituteMultiple (const ExprExprHashMap &substitutions, const SmtSolverPtr &solver=SmtSolverPtr()) 
Rewrite expression by substituting subexpressions. More...  
Ptr  renameVariables (ExprExprHashMap &index, size_t &nextVariableId, const SmtSolverPtr &solver=SmtSolverPtr()) 
Rewrite using lowest numbered variable names. More...  
size_t  nBits () 
Property: Number of significant bits. More...  
unsigned  flags () 
Property: Userdefined bit flags. More...  
Ptr  newFlags (unsigned flags) 
Sets flags. More...  
size_t  domainWidth () 
Property: Width for memory expressions. More...  
bool  isScalar () 
Check whether expression is scalar. More...  
uint64_t  nNodesUnique () 
Number of unique nodes in expression. More...  
std::set< LeafPtr >  getVariables () 
Returns the variables appearing in the expression. More...  
InteriorPtr  isInteriorNode () 
Dynamic cast of this object to an interior node. More...  
LeafPtr  isLeafNode () 
Dynamic cast of this object to a leaf node. More...  
bool  isHashed () 
Returns true if this node has a hash value computed and cached. More...  
Hash  hash () 
Returns (and caches) the hash value for this node. More...  
void  hash (Hash) 
void  assertAcyclic () 
Asserts that expressions are acyclic. More...  
std::vector< Ptr >  findCommonSubexpressions () 
Find common subexpressions. More...  
bool  matchAddVariableConstant (LeafPtr &variable, LeafPtr &constant) 
Determine whether an expression is a variable plus a constant. More...  
InteriorPtr  isOperator (Operator) 
True (nonnull) if this node is the specified operator. More...  
const std::string &  comment () 
Property: Comment. More...  
void  comment (const std::string &s) 
Property: Comment. More...  
void  userData (boost::any &data) 
Property: Userdefined data. More...  
const boost::any &  userData () 
Property: Userdefined data. More...  
WithFormatter  withFormat (Formatter &fmt) 
Combines a node with a formatter for printing. More...  
WithFormatter  operator+ (Formatter &fmt) 
Combines a node with a formatter for printing. More...  
void  print (std::ostream &o) 
Print the expression to a stream. More...  
Public Member Functions inherited from Sawyer::SharedObject  
SharedObject ()  
Default constructor. More...  
SharedObject (const SharedObject &)  
Copy constructor. More...  
virtual  ~SharedObject () 
Virtual destructor. More...  
SharedObject &  operator= (const SharedObject &) 
Assignment. More...  
Public Member Functions inherited from Sawyer::SharedFromThis< Node >  
SharedPointer< Node >  sharedFromThis () 
Create a shared pointer from this . More...  
SharedPointer< const Node >  sharedFromThis () const 
Create a shared pointer from this . More...  
Public Member Functions inherited from Sawyer::Attribute::Storage<>  
Storage ()  
Default constructor. More...  
Storage (const Storage &other)  
Copy constructor. More...  
Storage &  operator= (const Storage &other) 
Assignment operator. More...  
bool  attributeExists (Id id) const 
Check attribute existence. More...  
void  eraseAttribute (Id id) 
Erase an attribute. More...  
void  clearAttributes () 
Erase all attributes. More...  
void  setAttribute (Id id, const T &value) 
Store an attribute. More...  
bool  setAttributeMaybe (Id id, const T &value) 
Store an attribute if not already present. More...  
T  getAttribute (Id id) const 
Get an attribute that is known to exist. More...  
T  attributeOrElse (Id id, const T &dflt) const 
Return an attribute or a specified value. More...  
T  attributeOrDefault (Id id) const 
Return an attribute or a defaultconstructed value. More...  
Sawyer::Optional< T >  optionalAttribute (Id id) const 
Return the attribute as an optional value. More...  
size_t  nAttributes () const 
Number of attributes stored. More...  
std::vector< Id >  attributeIds () const 
Returns ID numbers for all IDs stored in this container. More...  
Static Public Member Functions  
static Ptr  create (size_t nbits, Operator op, const Ptr &a, const SmtSolverPtr &solver=SmtSolverPtr(), const std::string &comment="", unsigned flags=0) 
Create a new expression node. More...  
static Ptr  create (size_t nbits, Operator op, const Ptr &a, const Ptr &b, const SmtSolverPtr &solver=SmtSolverPtr(), const std::string &comment="", unsigned flags=0) 
Create a new expression node. More...  
static Ptr  create (size_t nbits, Operator op, const Ptr &a, const Ptr &b, const Ptr &c, const SmtSolverPtr &solver=SmtSolverPtr(), const std::string &comment="", unsigned flags=0) 
Create a new expression node. More...  
static Ptr  create (size_t nbits, Operator op, const Nodes &children, const SmtSolverPtr &solver=SmtSolverPtr(), const std::string &comment="", unsigned flags=0) 
Create a new expression node. More...  
Static Public Member Functions inherited from Sawyer::SmallObject  
static SynchronizedPoolAllocator &  poolAllocator () 
Return the pool allocator for this class. More...  
static void *  operator new (size_t size) 
static void  operator delete (void *ptr, size_t size) 
Protected Member Functions  
void  addChild (const Ptr &child) 
Appends child as a new child of this node. More...  
void  adjustWidth () 
Adjust width based on operands. More...  
void  adjustBitFlags (unsigned extraFlags) 
Adjust userdefined bit flags. More...  
Protected Member Functions inherited from Rose::BinaryAnalysis::SymbolicExpr::Node  
Node (const std::string &comment, unsigned flags=0)  
void  printFlags (std::ostream &o, unsigned flags, char &bracket) 
Additional Inherited Members  
Public Types inherited from Sawyer::Attribute::Storage<>  
typedef SynchronizationTraits< Sawyer::SingleThreadedTag >  Sync 
Static Public Attributes inherited from Rose::BinaryAnalysis::SymbolicExpr::Node  
static const unsigned  RESERVED_FLAGS = 0x0000ffff 
These flags are reserved for use within ROSE. More...  
static const unsigned  INDETERMINATE = 0x00000001 
Value is somehow indeterminate. More...  
static const unsigned  UNSPECIFIED = 0x00000002 
Value is somehow unspecified. More...  
static const unsigned  BOTTOM = 0x00000004 
Value represents bottom in dataflow analysis. More...  
static boost::logic::tribool(*  mayEqualCallback )(const Ptr &a, const Ptr &b, const SmtSolverPtr &) 
Usersupplied predicate to augment alias checking. More...  
Protected Attributes inherited from Rose::BinaryAnalysis::SymbolicExpr::Node  
size_t  nBits_ 
Number of significant bits. More...  
size_t  domainWidth_ 
Width of domain for unary functions. More...  
unsigned  flags_ 
Bit flags. More...  
std::string  comment_ 
Optional comment. More...  
Hash  hashval_ 
Optional hash used as a quick way to indicate that two expressions are different. More...  
boost::any  userData_ 
Additional userspecified data. More...  

inlinestatic 
Create a new expression node.
Although we're creating interior nodes, the simplification process might replace it with a leaf node. Use these class methods instead of c'tors.
The SMT solver is optional and may be the null pointer.
Flags are normally initialized as the union of the flags of the operator arguments subject to various rules in the expression simplifiers. Flags specified in the constructor are set in addition to those that would normally be set.
Definition at line 729 of file BinarySymbolicExpr.h.
References Rose::BinaryAnalysis::SymbolicExpr::Node::comment(), and Rose::BinaryAnalysis::SymbolicExpr::Node::flags().
Referenced by Rose::BinaryAnalysis::SymbolicExpr::substitute().

inlinestatic 
Create a new expression node.
Although we're creating interior nodes, the simplification process might replace it with a leaf node. Use these class methods instead of c'tors.
The SMT solver is optional and may be the null pointer.
Flags are normally initialized as the union of the flags of the operator arguments subject to various rules in the expression simplifiers. Flags specified in the constructor are set in addition to those that would normally be set.
Definition at line 734 of file BinarySymbolicExpr.h.
References Rose::BinaryAnalysis::SymbolicExpr::Node::comment(), and Rose::BinaryAnalysis::SymbolicExpr::Node::flags().

inlinestatic 
Create a new expression node.
Although we're creating interior nodes, the simplification process might replace it with a leaf node. Use these class methods instead of c'tors.
The SMT solver is optional and may be the null pointer.
Flags are normally initialized as the union of the flags of the operator arguments subject to various rules in the expression simplifiers. Flags specified in the constructor are set in addition to those that would normally be set.
Definition at line 739 of file BinarySymbolicExpr.h.
References Rose::BinaryAnalysis::SymbolicExpr::Node::comment(), and Rose::BinaryAnalysis::SymbolicExpr::Node::flags().

inlinestatic 
Create a new expression node.
Although we're creating interior nodes, the simplification process might replace it with a leaf node. Use these class methods instead of c'tors.
The SMT solver is optional and may be the null pointer.
Flags are normally initialized as the union of the flags of the operator arguments subject to various rules in the expression simplifiers. Flags specified in the constructor are set in addition to those that would normally be set.
Definition at line 744 of file BinarySymbolicExpr.h.
References Rose::BinaryAnalysis::SymbolicExpr::Node::comment(), and Rose::BinaryAnalysis::SymbolicExpr::Node::flags().

virtual 
Returns true if two expressions must be equal (cannot be unequal).
If an SMT solver is specified then that solver is used to answer this question, otherwise equality is established by looking only at the structure of the two expressions. Two expressions can be equal without being the same width (e.g., a 32bit constant zero is equal to a 16bit constant zero).
Implements Rose::BinaryAnalysis::SymbolicExpr::Node.

virtual 
Returns true if two expressions might be equal, but not necessarily be equal.
Implements Rose::BinaryAnalysis::SymbolicExpr::Node.

virtual 
Tests two expressions for structural equivalence.
Two leaf nodes are equivalent if they are the same width and have equal values or are the same variable. Two interior nodes are equivalent if they are the same width, the same operation, have the same number of children, and those children are all pairwise equivalent.
Implements Rose::BinaryAnalysis::SymbolicExpr::Node.

virtual 
Compare two expressions structurally for sorting.
Returns 1 if this
is less than other
, 0 if they are structurally equal, and 1 if this
is greater than other
. This function returns zero when an only when isEquivalentTo returns zero, but isEquivalentTo can be much faster since it uses hashing.
Implements Rose::BinaryAnalysis::SymbolicExpr::Node.

virtual 
Substitute one value for another.
Finds all occurrances of from
in this expression and replace them with to
. If a substitution occurs, then a new expression is returned. The matching of from
to subparts of this expression uses structural equivalence, the isEquivalentTo predicate. The from
and to
expressions must have the same width.
Implements Rose::BinaryAnalysis::SymbolicExpr::Node.
Referenced by Rose::BinaryAnalysis::SymbolicExpr::substitute().

inlinevirtual 
Returns true if the expression is a known numeric value.
The value itself is stored in the number property.
Implements Rose::BinaryAnalysis::SymbolicExpr::Node.
Definition at line 757 of file BinarySymbolicExpr.h.

inlinevirtual 
Property: integer value of expression node.
Returns the integer value of a node for which isKnown returns true. The highorder bits, those beyond the number of significant bits returned by the nBits propert, are guaranteed to be zero.
Implements Rose::BinaryAnalysis::SymbolicExpr::Node.
Definition at line 760 of file BinarySymbolicExpr.h.

virtual 
Traverse the expression.
The expression is traversed in a depthfirst visit. The final return value is the final return value of the last call to the visitor.
Implements Rose::BinaryAnalysis::SymbolicExpr::Node.

inlinevirtual 
Computes the size of an expression by counting the number of nodes.
Operates in constant time. Note that it is possible (even likely) for the 64bit return value to overflow in expressions when many nodes are shared. For instance, the following loop will create an expression that contains more than 2^64 nodes:
When an overflow occurs the result is meaningless.
Implements Rose::BinaryAnalysis::SymbolicExpr::Node.
Definition at line 762 of file BinarySymbolicExpr.h.

inline 
Returns the number of children.
Definition at line 765 of file BinarySymbolicExpr.h.

inline 
Returns the specified child.
Definition at line 768 of file BinarySymbolicExpr.h.

inline 
Property: Children.
The children are the operands for an operator expression.
Definition at line 773 of file BinarySymbolicExpr.h.

inline 
Returns the operator.
Definition at line 776 of file BinarySymbolicExpr.h.
Ptr Rose::BinaryAnalysis::SymbolicExpr::Interior::simplifyTop  (  const SmtSolverPtr &  solver = SmtSolverPtr()  ) 
Simplifies the specified interior node.
Returns a new node if necessary, otherwise returns this. The SMT solver is optional and my be the null pointer.
Ptr Rose::BinaryAnalysis::SymbolicExpr::Interior::foldConstants  (  const Simplifier &  ) 
Perform constant folding.
This method returns either a new expression (if changes were mde) or the original expression. The simplifier is specific to the kind of operation at the node being simplified.
InteriorPtr Rose::BinaryAnalysis::SymbolicExpr::Interior::associative  (  ) 
Simplifies nonassociative operators by flattening the specified interior node with its children that are the same interior node type.
Call this only if the top node is a truly nonassociative. A new node is returned only if changed. When calling both nonassociative and commutative, it's usually more appropriate to call nonassociative first.
InteriorPtr Rose::BinaryAnalysis::SymbolicExpr::Interior::commutative  (  ) 
Simplifies commutative operators by sorting arguments.
The arguments are sorted so that all the interior nodes come before the leaf nodes. Call this only if the top node is truly commutative. A new node is returned only if changed. When calling both nonassociative and commutative, it's usually more appropriate to call nonassociative first.
Ptr Rose::BinaryAnalysis::SymbolicExpr::Interior::involutary  (  ) 
Simplifies involutary operators.
An involutary operator is one that is its own inverse. This method should only be called if this node is an interior node whose operator has the involutary property (such as invert or negate). Returns either a new expression that is simplified, or the original expression.
Ptr Rose::BinaryAnalysis::SymbolicExpr::Interior::additiveNesting  (  const SmtSolverPtr &  solver = SmtSolverPtr()  ) 
Simplifies nested shiftlike operators.
Simplifies (shift AMT1 (shift AMT2 X)) to (shift (add AMT1 AMT2) X). The SMT solver may be null.
Ptr Rose::BinaryAnalysis::SymbolicExpr::Interior::identity  (  uint64_t  ident, 
const SmtSolverPtr &  solver = SmtSolverPtr() 

) 
Removes identity arguments.
Returns either a new expression or the original expression. The solver may be a null pointer.
Ptr Rose::BinaryAnalysis::SymbolicExpr::Interior::unaryNoOp  (  ) 
Replaces a binary operator with its only argument.
Returns either a new expression or the original expression.
Ptr Rose::BinaryAnalysis::SymbolicExpr::Interior::rewrite  (  const Simplifier &  simplifier, 
const SmtSolverPtr &  solver = SmtSolverPtr() 

) 
Simplify an interior node.
Returns a new node if this node could be simplified, otherwise returns this node. When the simplification could result in a leaf node, we return an OP_NOOP interior node instead. The SMT solver is optional and may be the null pointer.

virtual 
Print the expression to a stream.
The output is an Sexpression with no linefeeds. The format of the output is controlled by the mutable Formatter argument.
Implements Rose::BinaryAnalysis::SymbolicExpr::Node.

protected 
Appends child
as a new child of this node.
This must only be called from constructors.

protected 
Adjust width based on operands.
This must only be called from constructors.

protected 
Adjust userdefined bit flags.
This must only be called from constructors. Flags are the union of the operand flags subject to simplification rules, unioned with the specified flags.