NameExpression
class NameExpression
Expression node representing a variable.
constructor NameExpression
Create a variable expression.
| NameExpression | ( | const Location & location, | |
| Symbol symbol, | |||
| std::optional< Expression > expression = {} | ); |
| PARAMETER | DESCRIPTION |
|---|---|
location |
The location of the expression. |
symbol |
The name of the variable. |
expression |
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 a variable expression.
| static Expression create | ( | const Location & location, | |
| Symbol symbol | ); |
| PARAMETER | DESCRIPTION |
|---|---|
location |
The location of the expression. |
symbol |
The name of the variable. |
| RETURNS | DESCRIPTION |
|---|---|
Expression |
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 resolvevirtual protected
Resolve all names in the expression.
The default implementation calls resolve() on all sub-expressions using traverse().
If a name cannot be resolved, either an error should be reported via DiagnosticOutput and the expression marked as invalid, or an exception should be thrown.
| virtual void resolve | ( | Scope * scope, | |
| Entity * containing_entity | ); |
| PARAMETER | DESCRIPTION |
|---|---|
scope |
The scope to resolve names in. |
containing_entity |
The entity that contains the expression. |
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 variableconst
Get the name of the variable.
| Symbol variable | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
Symbol |
The name of the variable. |
member expressionprivate
The expression representing the value of the variable.
member symbolprivate
The name of the variable.