VariableRepeatBody
class VariableRepeatBody
Represents a body that repeats a block of code a specified number of times using a counter variable.
constructor VariableRepeatBody
| VariableRepeatBody | ( | std::shared_ptr< Scope > containing_scope, | |
| Location variable_location, | |||
| Symbol variable, | |||
| RepeatRange range, | |||
| Body body | ); |
| PARAMETER | DESCRIPTION |
|---|---|
containing_scope |
|
variable_location |
|
variable |
|
range |
|
body |
method cloneconst virtual
| virtual Body clone | ( | const CloneContext & context | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
context |
| RETURNS | DESCRIPTION |
|---|---|
Body |
method createstatic
| static Body create | ( | std::shared_ptr< Scope > containing_scope, | |
| Location variable_location, | |||
| Symbol variable, | |||
| RepeatRange range, | |||
| Body body | ); |
| PARAMETER | DESCRIPTION |
|---|---|
containing_scope |
|
variable_location |
|
variable |
|
range |
|
body |
| RETURNS | DESCRIPTION |
|---|---|
Body |
method createstatic
| static Body create | ( | std::shared_ptr< Scope > containing_scope, | |
| Location variable_location, | |||
| Symbol variable, | |||
| Expression start, | |||
| Expression end, | |||
| Body body | ); |
| PARAMETER | DESCRIPTION |
|---|---|
containing_scope |
|
variable_location |
|
variable |
|
start |
|
end |
|
body |
| RETURNS | DESCRIPTION |
|---|---|
Body |
method encodevirtual
Encode the BodyElement into a byte string.
The default implementation does nothing. Subclasses that represent data or instructions should override this method.
| virtual void encode | ( | std::string & bytes, | |
| const Memory * memory | ); |
| PARAMETER | DESCRIPTION |
|---|---|
bytes |
The byte string to encode into. |
memory |
The memory context for encoding. |
method evaluatevirtual
Evaluate the BodyElement in a given context.
Subclasses must implement this method.
If an error occurs during evaluation, either an error should be reported via DiagnosticOutput and the BodyElement marked as invalid, or an exception should be thrown.
| virtual std::optional< Body > evaluate | ( | const EvaluationContext & context | ); |
| PARAMETER | DESCRIPTION |
|---|---|
context |
The evaluation context. |
| RETURNS | DESCRIPTION |
|---|---|
std::optional< Body > |
The Body to replace this BodyElement with, {} if no replacement is needed. |
method expandprivate
| Body expand | ( | ); |
| RETURNS | DESCRIPTION |
|---|---|
Body |
method resolvevirtual
Resolve all names in the BodyElement.
If a name cannot be resolved, an error should be reported via DiagnosticOutput and the BodyElement marked as invalid, or an exception should be thrown.
The default implementation calls resolve() on all sub-body-elements and sub-expressions using traverse().
| virtual void resolve | ( | Scope * scope, | |
| Entity * containing_entity | ); |
| PARAMETER | DESCRIPTION |
|---|---|
scope |
The scope to resolve names in. |
containing_entity |
The entity that contains the BodyElement. |
method serializeconst virtual
Serialize the BodyElement to a stream.
Subclasses must implement this method.
| virtual void serialize | ( | std::ostream & stream, | |
| const std::string & prefix | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
stream |
The stream to serialize to. |
prefix |
The prefix for each line of the serialized output. |