Struct naga::back::continue_forward::ContinueCtx
source · pub(super) struct ContinueCtx {
stack: Vec<Nesting>,
}
Expand description
Utility for tracking nesting of loops and switches to orchestrate forwarding of continue statements inside of a switch to the enclosing loop.
See module docs for why we need this.
Fields§
§stack: Vec<Nesting>
Implementations§
source§impl ContinueCtx
impl ContinueCtx
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Resets internal state.
Use this to reuse memory between writing sessions.
sourcepub fn enter_loop(&mut self)
pub fn enter_loop(&mut self)
Updates internal state to record entering a Loop
statement.
sourcepub fn enter_switch(&mut self, namer: &mut Namer) -> Option<Rc<String>>
pub fn enter_switch(&mut self, namer: &mut Namer) -> Option<Rc<String>>
Updates internal state to record entering a Switch
statement.
Return Some(variable)
if this Switch
is nested within a Loop
,
and the caller should introcue a new bool
local variable named
variable
above the switch
, for forwarding Continue
statements.
variable
is guaranteed not to conflict with any names used by the
program itself.
sourcepub fn exit_switch(&mut self) -> ExitControlFlow
pub fn exit_switch(&mut self) -> ExitControlFlow
Update internal state to record leaving a Switch
statement.
Return an ExitControlFlow
value indicating what code should be
introduced after the generated switch
to forward continues.
sourcepub fn continue_encountered(&mut self) -> Option<&str>
pub fn continue_encountered(&mut self) -> Option<&str>
Determine what to generate for a Continue
statement.
If we can generate an ordinary continue
statement, return None
.
Otherwise, we’re enclosed by a Switch
that is itself enclosed by a
Loop
. Return Some(variable)
to indicate that the Continue
should be rendered as setting variable
to true
, and then doing a
break
.
This also notes that we’ve encountered a Continue
statement, so that
we can generate the right code to forward the branch following the
enclosing switch
.