pub struct ForSpan {
pub iter: VarRef,
pub iter_pos: LineCol,
pub iter_double: bool,
pub start: Expr,
pub end: Expr,
pub next: Expr,
pub body: Vec<Statement>,
}
Expand description
Components of a FOR
statement.
Note that we do not store the original end and step values, and instead use expressions to represent the loop condition and the computation of the next iterator value. We do this for run-time efficiency. The reason this is possible is because we force the step to be an integer literal at parse time and do not allow it to be an expression.
Fields§
§iter: VarRef
Iterator name, expressed as a variable reference that must be either automatic or an integer.
iter_pos: LineCol
Position of the iterator.
iter_double: bool
If true, the iterator computation needs to be performed as a double so that, when the iterator variable is not yet defined, it gains the correct type.
start: Expr
Expression to compute the iterator’s initial value.
end: Expr
Condition to test after each iteration.
next: Expr
Expression to compute the iterator’s next value.
body: Vec<Statement>
Statements within the loop’s body.