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

source

pub fn clear(&mut self)

Resets internal state.

Use this to reuse memory between writing sessions.

source

pub fn enter_loop(&mut self)

Updates internal state to record entering a Loop statement.

source

pub fn exit_loop(&mut self)

Updates internal state to record exiting a Loop statement.

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl Default for ContinueCtx

source§

fn default() -> ContinueCtx

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.