cairo_lang_lowering::lower::context

Struct LoweringContext

Source
pub struct LoweringContext<'a, 'db> {
    pub encapsulating_ctx: Option<&'a mut EncapsulatingLoweringContext<'db>>,
    pub variables: VariableAllocator<'db>,
    pub signature: Signature,
    pub function_id: FunctionWithBodyId,
    pub concrete_function_id: ConcreteFunctionWithBodyId,
    pub current_loop_expr_id: Option<ExprId>,
    pub diagnostics: LoweringDiagnostics,
    pub blocks: FlatBlocksBuilder,
}

Fields§

§encapsulating_ctx: Option<&'a mut EncapsulatingLoweringContext<'db>>§variables: VariableAllocator<'db>

Variable allocator.

§signature: Signature

Current function signature.

§function_id: FunctionWithBodyId

Id for the current function being lowered.

§concrete_function_id: ConcreteFunctionWithBodyId

Id for the current concrete function to be used when generating recursive calls. This it the generic function specialized with its own generic parameters.

§current_loop_expr_id: Option<ExprId>

Current loop expression needed for recursive calls in continue

§diagnostics: LoweringDiagnostics

Current emitted diagnostics.

§blocks: FlatBlocksBuilder

Lowered blocks of the function.

Implementations§

Source§

impl<'a, 'db> LoweringContext<'a, 'db>

Source

pub fn new( global_ctx: &'a mut EncapsulatingLoweringContext<'db>, function_id: FunctionWithBodyId, signature: Signature, ) -> Maybe<Self>
where 'db: 'a,

Source§

impl<'a, 'db> LoweringContext<'a, 'db>

Source

pub fn new_var(&mut self, req: VarRequest) -> VariableId

Allocates a new variable in the context’s variable arena according to the context.

Source

pub fn new_var_usage(&mut self, req: VarRequest) -> VarUsage

Same as new_var but returns it as a VarUsage. This is useful when the variable definition and usage locations are the same.

Source

pub fn get_location(&self, stable_ptr: SyntaxStablePtrId) -> LocationId

Retrieves the LocationId of a stable syntax pointer in the current function file.

Trait Implementations§

Source§

impl<'a, 'db> Deref for LoweringContext<'a, 'db>

Source§

type Target = EncapsulatingLoweringContext<'db>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, 'db> DerefMut for LoweringContext<'a, 'db>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a, 'db> Freeze for LoweringContext<'a, 'db>

§

impl<'a, 'db> !RefUnwindSafe for LoweringContext<'a, 'db>

§

impl<'a, 'db> !Send for LoweringContext<'a, 'db>

§

impl<'a, 'db> !Sync for LoweringContext<'a, 'db>

§

impl<'a, 'db> Unpin for LoweringContext<'a, 'db>

§

impl<'a, 'db> !UnwindSafe for LoweringContext<'a, 'db>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T0, T1, E, TRewriter> SemanticRewriter<(T0, T1), E> for TRewriter
where TRewriter: SemanticRewriter<T0, E> + SemanticRewriter<T1, E>,

Source§

fn internal_rewrite(&mut self, value: &mut (T0, T1)) -> Result<RewriteResult, E>

Source§

fn rewrite(&mut self, value: T) -> Result<T, Error>

Source§

impl<T, E, TRewriter> SemanticRewriter<Box<T>, E> for TRewriter
where TRewriter: SemanticRewriter<T, E>,

Source§

fn internal_rewrite(&mut self, value: &mut Box<T>) -> Result<RewriteResult, E>

Source§

fn rewrite(&mut self, value: T) -> Result<T, Error>

Source§

impl<T, E, TRewriter> SemanticRewriter<Option<T>, E> for TRewriter
where TRewriter: SemanticRewriter<T, E>,

Source§

fn internal_rewrite( &mut self, value: &mut Option<T>, ) -> Result<RewriteResult, E>

Source§

fn rewrite(&mut self, value: T) -> Result<T, Error>

Source§

impl<T, V, E, TRewriter> SemanticRewriter<OrderedHashMap<T, V>, E> for TRewriter
where T: Clone, V: Clone, TRewriter: SemanticRewriter<V, E>,

Source§

fn internal_rewrite( &mut self, value: &mut OrderedHashMap<T, V>, ) -> Result<RewriteResult, E>

Source§

fn rewrite(&mut self, value: T) -> Result<T, Error>

Source§

impl<T, E, TRewriter, E2> SemanticRewriter<Result<T, E2>, E> for TRewriter
where TRewriter: SemanticRewriter<T, E>,

Source§

fn internal_rewrite( &mut self, value: &mut Result<T, E2>, ) -> Result<RewriteResult, E>

Source§

fn rewrite(&mut self, value: T) -> Result<T, Error>

Source§

impl<T, E, TRewriter> SemanticRewriter<Vec<T>, E> for TRewriter
where T: Clone, TRewriter: SemanticRewriter<T, E>,

Source§

fn internal_rewrite(&mut self, value: &mut Vec<T>) -> Result<RewriteResult, E>

Source§

fn rewrite(&mut self, value: T) -> Result<T, Error>

Source§

impl<T, E, TRewriter> SemanticRewriter<VecDeque<T>, E> for TRewriter
where TRewriter: SemanticRewriter<T, E>,

Source§

fn internal_rewrite( &mut self, value: &mut VecDeque<T>, ) -> Result<RewriteResult, E>

Source§

fn rewrite(&mut self, value: T) -> Result<T, Error>

Source§

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

Source§

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>,

Source§

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.
Source§

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

Source§

fn upcast(&self) -> &T

Source§

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

Source§

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more