Struct debris_llir::objects::obj_function::FunctionContext
source · 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>
impl<'llir_builder, 'ctx, 'params> FunctionContext<'llir_builder, 'ctx, 'params>
sourcepub fn self_value_as<T: ObjectPayload>(&self) -> Option<&T>
pub fn self_value_as<T: ObjectPayload>(&self) -> Option<&T>
Returns self_val
downcasted to the desired type or None
sourcepub 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>)
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.
pub fn item_id_allocator(&self) -> &ItemIdAllocator
pub fn type_ctx(&self) -> &TypeContext
pub fn runtime_mut(&mut self) -> &mut FunctionBuilderRuntime
pub fn compile_native_function( &mut self, function_id: NativeFunctionId ) -> LangResult<BlockId>
pub fn call_function<'a>( &'a mut self, function: &ObjFunction, parameters: &'a [ObjectRef], self_value: Option<ObjectRef> ) -> LangResult<ObjectRef>
pub fn call_function_raw<'a>( &'a mut self, function: &ObjFunction, parameters: &'a [ObjectRef], self_value: Option<ObjectRef> ) -> Option<LangResult<ObjectRef>>
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> 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