Skip to content

ValueExpression

INCLUDE FILE
#include "Expression/ValueExpression.h"

class ValueExpression

Expression node representing a Value.

DEFINITION
class ValueExpression;

constructor ValueExpression

Create a value expression.

DEFINITION
ValueExpression ( const Location & location,
Value  value );
PARAMETERDESCRIPTION
location

The location of the expression.

value

The value of the expression.

constructor ValueExpression

Create a value expression with an unsigned integer value.

DEFINITION
ValueExpression ( const Location & location,
uint64_t  value );
PARAMETERDESCRIPTION
location

The location of the expression.

value

The unsigned integer value of the expression.

constructor ValueExpression

Create a value expression from a token.

DEFINITION
ValueExpression ( const Token & token );
PARAMETERDESCRIPTION
token

The token to create the expression from.

THROWSDESCRIPTION
Exception

if the token is not a value or string token.

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.

DEFINITION
virtual Expression  clone ( const CloneContext & context ) const;
PARAMETERDESCRIPTION
context
RETURNSDESCRIPTION
Expression

A shared pointer to the cloned expression.

method createstatic

Create a value expression.

DEFINITION
static Expression  create ( const Location & location,
Value  value );
PARAMETERDESCRIPTION
location

The location of the expression.

value

The value of the expression.

RETURNSDESCRIPTION
Expression

method has_valueconst virtual

Check if the value of the expression is known.

The default implementation returns true if value() returns a value, false otherwise. If the value is expensive to compute, subclasses may override this method to provide a more efficient implementation.

DEFINITION
virtual bool  has_value ( ) const;
RETURNSDESCRIPTION
bool

true if the value is known, false otherwise.

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.

DEFINITION
virtual std::optional< Value >  maximum_value ( ) const;
RETURNSDESCRIPTION
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.

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

The maximum possible value of the expression if it can be determined, {} otherwise.

method serialize_subconst virtual protected

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

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

The type of the expression's value if it can be determined, {} otherwise.

method valueconst virtual

Get the value of the expression if it is known.

Subclasses should override this method. The default implementation returns {}.

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

The value of the expression, if it is known.

member value_private

The value of the expression.

DEFINITION
Value  value_;