BinaryExpression
class BinaryExpression
Expression representing a binary operation.
class LabelEntityprivate
constructor LabelEntity
| LabelEntity | ( | uint64_t address | ); |
| PARAMETER | DESCRIPTION |
|---|---|
address |
constructor LabelEntity
| LabelEntity | ( | Entity * entity | ); |
| PARAMETER | DESCRIPTION |
|---|---|
entity |
method operator==const
| bool operator== | ( | const LabelEntity & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
| RETURNS | DESCRIPTION |
|---|---|
bool |
member entity_or_addressprivate
enum Operation
The operations supported by the BinaryExpression class.
| VALUE | DESCRIPTION |
|---|---|
ADD |
|
BITWISE_AND |
|
BITWISE_OR |
|
BITWISE_XOR |
|
DIVIDE |
|
EQUAL |
|
GREATER |
|
GREATER_EQUAL |
|
LESS |
|
LESS_EQUAL |
|
LOGICAL_AND |
|
LOGICAL_OR |
|
MODULO |
|
MULTIPLY |
|
NOT_EQUAL |
|
SHIFT_LEFT |
|
SHIFT_RIGHT |
|
SUBTRACT |
constructor BinaryExpression
Construct a binary expression.
| BinaryExpression | ( | const Location & location, | |
| Expression left, | |||
| Operation operation, | |||
| Expression right | ); |
| PARAMETER | DESCRIPTION |
|---|---|
location |
The location of the expression in the source code. |
left |
The left operand. |
operation |
The binary operation. |
right |
The right operand. |
method cloneconst virtual
Create a deep copy of the expression.
A subclass must override this method if it can occur in a macro or function definition, .repeat body, or instruction encoding.
| virtual Expression clone | ( | const CloneContext & context | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
context |
| RETURNS | DESCRIPTION |
|---|---|
Expression |
A shared pointer to the cloned expression. |
method createstatic
Create an expression from a binary operation.
This might not create a BinaryExpression if the operation can be simplified (e. g. if both operands have values).
| static Expression create | ( | const Location & location, | |
| const Expression & left, | |||
| Operation operation, | |||
| const Expression & right | ); |
| PARAMETER | DESCRIPTION |
|---|---|
location |
The location of the expression in the source code. |
left |
The left operand. |
operation |
The binary operation. |
right |
The right operand. |
| RETURNS | DESCRIPTION |
|---|---|
Expression |
The created expression. |
method deconstruct_labelstatic private
This deconstructs label expressions.
These are of the form entity or entity + label_offset. entity is an ObjectExpression or a ValueExpression representing an entity's address, and label_offset is a LabelOffsetExpression or ValueExpression.
If the expression is not a label expression, the pair {}, {} is returned.
| static std::pair< std::optional< LabelEntity >, std::optional< Expression > > deconstruct_label | ( | const Expression & expression | ); |
| PARAMETER | DESCRIPTION |
|---|---|
expression |
The expression to check. |
| RETURNS | DESCRIPTION |
|---|---|
std::pair< std::optional< LabelEntity >, std::optional< Expression > > |
The referenced entity or its address, or {} if there is none; and the label_offset or {} if there is none. |
method evaluate_processvirtual protected
Process the evaluation of the expression.
This method is called by the default implementation of evaluate() after calling evaluate() on all sub-expressions.
| virtual std::optional< Expression > evaluate_process | ( | const EvaluationContext & context | ); |
| PARAMETER | DESCRIPTION |
|---|---|
context |
The evaluation context. |
| RETURNS | DESCRIPTION |
|---|---|
std::optional< Expression > |
If the expression changed, returns the new expression, otherwise {}. |
method get_label_entitystatic private
Get the label entity referenced by an expression.
If this is an ObjectExpression, return the referenced entity. If it is an unsigned ValueExpression, return its value. If it is a ConstantExpression referencing either, return the referenced entity or value. Otherwise, return {}.
| static std::optional< LabelEntity > get_label_entity | ( | const Expression & expression | ); |
| PARAMETER | DESCRIPTION |
|---|---|
expression |
The expression to check. |
| RETURNS | DESCRIPTION |
|---|---|
std::optional< LabelEntity > |
The referenced entity, or {} if there is none. |
method maximum_valueconst virtual
Get the minimum possible value of the expression.
The default implementation returns the value of the expression if it is known, or {} otherwise. Subclasses should override this method if they can determine a minimum value without knowing the exact value of the expression.
| virtual std::optional< Value > maximum_value | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
std::optional< Value > |
The minimum possible value of the expression. if it can be determined, {} otherwise. |
method minimum_valueconst virtual
Get the maximum possible value of the expression.
The default implementation returns the value of the expression if it is known, or {} otherwise. Subclasses should override this method if they can determine a maximum value without knowing the exact value of the expression.
| virtual std::optional< Value > minimum_value | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
std::optional< Value > |
The maximum possible value of the expression if it can be determined, {} otherwise. |
method operation_nameconst private
Get the name of a binary operation.
| const std::string & operation_name | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
const std::string & |
The name of the binary operation. |
method operation_namestatic private
Get the name of a binary operation.
| static const std::string & operation_name | ( | Operation operation | ); |
| PARAMETER | DESCRIPTION |
|---|---|
operation |
The binary operation. |
| RETURNS | DESCRIPTION |
|---|---|
const std::string & |
The name of the binary operation. |
method serialize_subconst virtual protected
Serialize the expression to a stream.
This method must be implemented by derived classes.
| virtual void serialize_sub | ( | std::ostream & stream | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
stream |
The stream to serialize to. |
method simplifystatic private
Simplify a binary expression if possible.
| static std::optional< Expression > simplify | ( | const Location & location, | |
| const Expression & left, | |||
| Operation operation, | |||
| const Expression & right, | |||
| bool always_create | ); |
| PARAMETER | DESCRIPTION |
|---|---|
location |
The location of the expression in the source code. |
left |
The left operand. |
operation |
The binary operation. |
right |
The right operand. |
always_create |
Whether to always create a new expression even if it cannot be simplified. |
| RETURNS | DESCRIPTION |
|---|---|
std::optional< Expression > |
The simplified expression, or {} if no simplification is possible. |
method traversevirtual protected
Call a method on all sub-expressions of this expression.
It is used by the default implementations of resolve() and expand_calls(). Unless a subclass has no sub-expressions or overrides both of these methods, it should override traverse().
| virtual void traverse | ( | std::function< void(Expression &)> callable | ); |
| PARAMETER | DESCRIPTION |
|---|---|
callable |
A callable to apply to each sub-expression. |
method typeconst virtual
Get the type of the expression's value.
The default implementation returns the type of the value of the expression if it is known, or {} otherwise. Subclasses should override this method if they can determine the type of the expression without knowing the exact value of the expression.
| virtual std::optional< Value::Type > type | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
std::optional< Value::Type > |
The type of the expression's value if it can be determined, {} otherwise. |
member leftprivate
The left operand of the binary operation.
member operationprivate
The binary operation.
member operation_namesstatic private
The names of the binary operations.
member rightprivate
The right operand of the binary operation.
class LabelEntityprivate
constructor LabelEntity
| LabelEntity | ( | uint64_t address | ); |
| PARAMETER | DESCRIPTION |
|---|---|
address |
constructor LabelEntity
| LabelEntity | ( | Entity * entity | ); |
| PARAMETER | DESCRIPTION |
|---|---|
entity |
method operator==const
| bool operator== | ( | const LabelEntity & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
| RETURNS | DESCRIPTION |
|---|---|
bool |