pub struct FunctionContext<'llir_builder, 'ctx, 'params> {
    pub item_id: ItemId,
    pub parameters: &'params [ObjectRef],
    pub self_val: Option<ObjectRef>,
    pub nodes: Vec<Node>,
    pub span: Span,
    pub(crate) llir_function_builder: &'params mut LlirFunctionBuilder<'llir_builder, 'ctx>,
}
Expand description

The context which gets passed to a function

Fields§

§item_id: ItemId

The id of the returned value

§parameters: &'params [ObjectRef]

The parameters for this function call, excluding the self value

§self_val: Option<ObjectRef>

The self value

§nodes: Vec<Node>

The nodes that are emitted by this function

§span: Span§llir_function_builder: &'params mut LlirFunctionBuilder<'llir_builder, 'ctx>

Implementations§

source§

impl<'llir_builder, 'ctx, 'params> FunctionContext<'llir_builder, 'ctx, 'params>

source

pub fn emit(&mut self, node: Node)

Adds a node to the previously emitted nodes

source

pub fn self_value_as<T: ObjectPayload>(&self) -> Option<&T>

Returns self_val downcasted to the desired type or None

source

pub fn with_new_function_context<'a, T>( &'a mut self, parameters: &'a [ObjectRef], self_value: Option<ObjectRef>, f: impl FnOnce(&mut FunctionContext<'llir_builder, 'ctx, 'a>) -> T ) -> (T, Vec<Node>)

Generates a new function context which can be used for calling another function.

source

pub fn item_id_allocator(&self) -> &ItemIdAllocator

source

pub fn type_ctx(&self) -> &TypeContext

source

pub fn runtime_mut(&mut self) -> &mut FunctionBuilderRuntime

source

pub fn compile_native_function( &mut self, function_id: NativeFunctionId ) -> LangResult<BlockId>

source

pub fn call_function<'a>( &'a mut self, function: &ObjFunction, parameters: &'a [ObjectRef], self_value: Option<ObjectRef> ) -> LangResult<ObjectRef>

source

pub fn call_function_raw<'a>( &'a mut self, function: &ObjFunction, parameters: &'a [ObjectRef], self_value: Option<ObjectRef> ) -> Option<LangResult<ObjectRef>>

source

pub fn promote_obj( &mut self, value: ObjectRef, target: ObjectRef ) -> Option<LangResult<ObjectRef>>

Auto Trait Implementations§

§

impl<'llir_builder, 'ctx, 'params> !RefUnwindSafe for FunctionContext<'llir_builder, 'ctx, 'params>

§

impl<'llir_builder, 'ctx, 'params> !Send for FunctionContext<'llir_builder, 'ctx, 'params>

§

impl<'llir_builder, 'ctx, 'params> !Sync for FunctionContext<'llir_builder, 'ctx, 'params>

§

impl<'llir_builder, 'ctx, 'params> Unpin for FunctionContext<'llir_builder, 'ctx, 'params>

§

impl<'llir_builder, 'ctx, 'params> !UnwindSafe for FunctionContext<'llir_builder, 'ctx, 'params>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.