Struct valkyrie_ast::ForLoop
source · pub struct ForLoop {
pub pattern: PatternNode,
pub iterator: ExpressionKind,
pub condition: Option<ExpressionKind>,
pub label: Option<IdentifierNode>,
pub body: StatementBlock,
pub span: Range<u32>,
}
Expand description
for ... in ... if ... #label {...}
§Simple For Loop
for i in j if c1 {
if c2 {
continue
}
else if c3 {
break
}
else {
return
}
}
"residual expression"
j = j.into_iterator()
let looper = {
if c2 {
looper()
}
else if c3 {
break()
}
else {
return
}
}
let break = {
"other"
}
j = j.into_iterator()
let looper = {
if c2 {
looper()
}
else if c3 {
break()
}
else {
return
}
}
let break = {
"other"
}
loop switch label {
᳀function.1.start:
j = j.into_iterator()
᳀for.1.start:
let next = j.next();
}
loop {
᳀for.1.start
let next = j.next();
if next != null && c1 {
᳀if.1.head
if c2 {
⤮for.1.start
}
else if c3 {
⤮for.1.tail
}
else {
⤮function.1.return
}
}
else {
break
}
᳀for.1.end
}
⤮for.1.tail
᳀function.1.return
§Nested For Loop
for i in j #outer {
for x in y #inner {
if c1 {
continue #outer
}
if c2 {
continue #inner
}
}
}
Fields§
§pattern: PatternNode
for pattern
iterator: ExpressionKind
in iterator
condition: Option<ExpressionKind>
if condition
label: Option<IdentifierNode>
#label
body: StatementBlock
{ body }
span: Range<u32>
The range of the node
Implementations§
source§impl ForLoop
impl ForLoop
pub fn standardization( self, iterator: IdentifierNode ) -> (VariableDeclaration, LoopStatement)
Trait Implementations§
source§impl From<ForLoop> for StatementKind
impl From<ForLoop> for StatementKind
source§impl PartialEq for ForLoop
impl PartialEq for ForLoop
source§impl ValkyrieNode for ForLoop
impl ValkyrieNode for ForLoop
impl Eq for ForLoop
impl StructuralPartialEq for ForLoop
Auto Trait Implementations§
impl RefUnwindSafe for ForLoop
impl Send for ForLoop
impl Sync for ForLoop
impl Unpin for ForLoop
impl UnwindSafe for ForLoop
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more