LabelOffsetExpression
class LabelOffsetExpression
Represents a label expression, which refers to a label in an object.
This is the Expression entered into the environment for a label definition. It refers back to the defining BodyElement, which is used to compute the label's value.
constructor LabelOffsetExpression
| LabelOffsetExpression | ( | const Location & location, | |
| Symbol entity_name, | |||
| Symbol label_name, | |||
| size_t unnamed_label_index, | |||
| std::shared_ptr< LabelBody > body | ); |
| PARAMETER | DESCRIPTION |
|---|---|
location |
|
entity_name |
|
label_name |
|
unnamed_label_index |
|
body |
destructor ~LabelOffsetExpressionvirtual
| virtual ~LabelOffsetExpression | ( | ); |
method bodyconst
| std::shared_ptr< LabelBody > body | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
std::shared_ptr< LabelBody > |
method createstatic
| static Expression create | ( | const Location & location, | |
| Symbol entity_name, | |||
| Symbol label_name, | |||
| std::shared_ptr< LabelBody > body | ); |
| PARAMETER | DESCRIPTION |
|---|---|
location |
|
entity_name |
|
label_name |
|
body |
| RETURNS | DESCRIPTION |
|---|---|
Expression |
method createstatic
| static Expression create | ( | const Location & location, | |
| Symbol entity_name, | |||
| size_t unnamed_label_index, | |||
| std::shared_ptr< LabelBody > body | ); |
| PARAMETER | DESCRIPTION |
|---|---|
location |
|
entity_name |
|
unnamed_label_index |
|
body |
| RETURNS | DESCRIPTION |
|---|---|
Expression |
method entityconst
| Symbol entity | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
Symbol |
method evaluatevirtual protected
Evaluate the expression in the given context.
The default implementation calls evaluate() on all sub-expressions using traverse(), and then calls evaluate_process().
Errors during evaluation should either be reported via DiagnosticOutput and result in the expression being marked as invalid, or an exception should be thrown.
| virtual std::optional< Expression > evaluate | ( | const EvaluationContext & context | ); |
| PARAMETER | DESCRIPTION |
|---|---|
context |
The evaluation context. |
| RETURNS | DESCRIPTION |
|---|---|
std::optional< Expression > |
The Expression to replace this expression with, {} if no replacement is needed. |
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.
| virtual bool has_value | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method labelconst
| Symbol label | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
Symbol |
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 operator==const
Compare two label offset expressions for equality.
| bool operator== | ( | const LabelOffsetExpression & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The other label offset expression to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
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 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. |
method unnamed_indexconst
| size_t unnamed_index | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
size_t |
method valueconst virtual
Get the value of the expression if it is known.
Subclasses should override this method. The default implementation returns {}.
| virtual std::optional< Value > value | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
std::optional< Value > |
The value of the expression, if it is known. |