Skip to content

BaseExpression

class BaseExpression

Abstract base class for all expressions.

DEFINITION
class BaseExpression;

constructor BaseExpression

DEFINITION
BaseExpression ( );

constructor BaseExpression

DEFINITION
BaseExpression ( const Location & location );
PARAMETERDESCRIPTION
location

destructor ~BaseExpressionvirtual

DEFINITION
virtual ~BaseExpression ( );

method collect_objectsconstvirtual

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

method evaluatedconstvirtual

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

method has_valueconstvirtual

Check if the expression has already been fully evaluated and has a value.

DEFINITION
virtual bool  has_value ( ) const;
RETURNSDESCRIPTION
bool

true if the expression has a value, false otherwise.

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 serializeconst

Serialize the expression to a stream.

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

The stream to serialize to.

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 = 0;
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.

method valueconstvirtual

Get the value of the expression if it has one.

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

The value of the expression.

member location

The location of the expression in the source code.

DEFINITION
Location  location;