Skip to content

BinaryExpression

class BinaryExpression

Expression representing a binary operation.

DEFINITION
class BinaryExpression;

constructor BinaryExpression

Create a binary expression.

DEFINITION
BinaryExpression ( const Location & location,
Expression  left,
Expression::BinaryOperation  operation,
Expression  right );
PARAMETERDESCRIPTION
location

The location of the expression in the source code.

left

The left operand.

operation

The binary operation.

right

The right operand.

method collect_objectsconstvirtual

DEFINITION
virtual void  collect_objects ( std::unordered_set< Object * > & objects ) const;
PARAMETERDESCRIPTION
objects

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).

DEFINITION
static Expression  create ( const Location & location,
const Expression & left,
Expression::BinaryOperation  operation,
const Expression & right );
PARAMETERDESCRIPTION
location

The location of the expression in the source code.

left

The left operand.

operation

The binary operation.

right

The right operand.

RETURNSDESCRIPTION
Expression

The created expression.

method evaluatedconstvirtual

DEFINITION
virtual std::optional< Expression >  evaluated ( const EvaluationContext & context ) const;
PARAMETERDESCRIPTION
context
RETURNSDESCRIPTION
std::optional< Expression >

method maximum_valueconstvirtual

Get the maximum possible value of the expression if it can be determined.

DEFINITION
virtual std::optional< Value >  maximum_value ( ) const;
RETURNSDESCRIPTION
std::optional< Value >

The maximum possible value of the expression.

method minimum_valueconstvirtual

Get the minimum possible value of the expression if it can be determined.

DEFINITION
virtual std::optional< Value >  minimum_value ( ) const;
RETURNSDESCRIPTION
std::optional< Value >

The minimum possible value of the expression.

method serialize_subconstvirtual

Serialize the expression to a stream.

This method must be implemented by derived classes.

DEFINITION
virtual void  serialize_sub ( std::ostream & stream ) const;
PARAMETERDESCRIPTION
stream

The stream to serialize to.

method typeconstvirtual

Get the type of the expression's value if it can be determined.

DEFINITION
virtual std::optional< Value::Type >  type ( ) const;
RETURNSDESCRIPTION
std::optional< Value::Type >

The type of the expression's value.