pub struct LlirFunctionBuilder<'builder, 'ctx> {
    ancestor: Option<&'builder LlirFunctionBuilder<'builder, 'ctx>>,
    call_stack: CallStack<'builder>,
    pub(crate) shared: SharedState,
    block_id: BlockId,
    nodes: PeepholeOptimizer,
    pub(crate) builder: &'builder LlirBuilder<'ctx>,
    pub(crate) pending_runtime_functions: FunctionBuilderRuntime,
    contexts: &'ctx FxHashMap<MirContextId, MirContext>,
}

Fields§

§ancestor: Option<&'builder LlirFunctionBuilder<'builder, 'ctx>>§call_stack: CallStack<'builder>§shared: SharedState§block_id: BlockId§nodes: PeepholeOptimizer§builder: &'builder LlirBuilder<'ctx>§pending_runtime_functions: FunctionBuilderRuntime

Stores function ids pending to be added to the runtime

§contexts: &'ctx FxHashMap<MirContextId, MirContext>

Implementations§

source§

impl<'builder, 'ctx> LlirFunctionBuilder<'builder, 'ctx>

source

pub fn new( ancestor: Option<&'builder LlirFunctionBuilder<'builder, 'ctx>>, state_ancestor: Option<SharedStateId>, call_stack: CallStack<'builder>, block_id: BlockId, builder: &'builder LlirBuilder<'ctx>, contexts: &'ctx FxHashMap<MirContextId, MirContext> ) -> Self

source

pub fn build(&mut self, context: &'ctx MirContext) -> Result<()>

source

fn debug_print_stacktrace(&self)

Prints the current compiler stacktrace for debugging purposes

source

fn get_compiled_context(&self, context_id: MirContextId) -> Option<BlockId>

source

fn get_function(&self, block_id: BlockId) -> Option<&Function>

source

pub(crate) fn get_obj(&self, obj_id: MirObjectId) -> ObjectRef

Gets an object in the current state or panics

source

pub(crate) fn get_obj_opt(&self, obj_id: MirObjectId) -> Option<ObjectRef>

Tries to get an object in the current state

source

pub(crate) fn get_obj_in<'a>( &'a self, obj_id: MirObjectId, state: &'a SharedState ) -> Option<&CloneCell<ObjectRef>>

Gets an object in a specific SharedState

source

fn get_state(&self, id: SharedStateId) -> &SharedState

This method looks up a state from the global states map. If the state is not available yet, it is looked up in the ancestor hierarchy.

source

pub(crate) fn _set_obj(&mut self, obj_id: MirObjectId, value: ObjectRef)

source

fn get_function_generics( &self, function_id: NativeFunctionId ) -> &FunctionGenerics<'ctx>

source

fn compile_context( &mut self, context_id: MirContextId, call_stack_frame: CallStackFrame, mode: EvaluationMode ) -> Result<(BlockId, ObjectRef)>

source

fn force_compile_context( &mut self, context_id: MirContextId, block_id: BlockId, parameters: &[(MirObjectId, ObjectRef)], call_stack_frame: CallStackFrame, mode: EvaluationMode ) -> Result<(BlockId, ObjectRef)>

Compiles any context, even if it is already compiled. Force compiling a context does not modify the state of this context (Except for maybe some id counters) Returns the generated function, the return value, and the accumulated state

source

fn handle_on_tick_functions(&mut self) -> Result<()>

source

fn handle_exported_functions(&mut self) -> Result<()>

source

pub(crate) fn compile_null_function( &mut self, function_id: NativeFunctionId, span: Span ) -> Result<BlockId>

Helper to compile a function that takes no parameters and returns null

source

fn declare_obj( &mut self, target: MirObjectId, value: ObjectRef, target_span: Span ) -> Result<()>

Sets an object, with comptime_update_allowed set. This can be used for e.g. declarations or for places where it is known that this operation is valid to be performed at compile time

source

fn set_obj( &mut self, target: MirObjectId, value: ObjectRef, target_span: Span, comptime_update_allowed: bool ) -> Result<()>

source

fn promote_obj( ctx: &mut FunctionContext<'_, '_, '_> ) -> Option<Result<ObjectRef>>

Tries to promote an object to the target class and returns the promoted object in case of success. target must be a class object.

source

fn verify_parameters( &mut self, function_id: NativeFunctionId, parameters: &mut [ObjectRef], call_span: Span ) -> Result<()>

Verifies that the given parameters match the signature of a given function . and performs automatic value promotion if supported by the type (e.g. ComptimeInt -> Int). Returns a compile error if the parameters did not match the signature and value promotion was not possible.

source

fn call_builtin_function( &mut self, function: &ObjFunction, parameters: &[ObjectRef], self_value: Option<ObjectRef>, span: Span ) -> Result<ObjectRef>

source

fn copy_if_runtime(&mut self, obj: ObjectRef) -> ObjectRef

source

fn handle_node(&mut self, node: &'ctx MirNode) -> Result<()>

source

fn handle_branch(&mut self, branch: &Branch) -> Result<ObjectRef>

source

fn handle_static_branch( &mut self, branch: &Branch, condition: &ObjStaticBool ) -> Result<ObjectRef>

source

fn handle_dynamic_branch( &mut self, branch: &Branch, condition: &ObjBool ) -> Result<ObjectRef>

source

fn handle_primitive_declaration( &mut self, declaration: &'ctx PrimitiveDeclaration ) -> Result<()>

source

fn handle_variable_update( &mut self, variable_update: &VariableUpdate ) -> Result<()>

source

fn handle_property_update( &mut self, property_update: &PropertyUpdate ) -> Result<()>

source

fn handle_property_access( &mut self, property_access: &PropertyAccess ) -> Result<()>

source

fn handle_goto(&mut self, goto: &Goto) -> Result<()>

source

fn handle_module(&mut self, module: &MirModule) -> Result<ObjectRef>

source

fn handle_runtime_promotion( &mut self, runtime_promotion: &RuntimePromotion ) -> Result<()>

source

fn handle_runtime_copy(&mut self, runtime_copy: &RuntimeCopy) -> Result<()>

source

fn handle_function_call( &mut self, function_call: &FunctionCall ) -> Result<ObjectRef>

source

fn handle_native_function_call( &mut self, function_call: &FunctionCall, function: &ObjNativeFunction ) -> Result<ObjectRef>

source

fn call_native_function( &mut self, function_id: NativeFunctionId, is_fn_comptime: bool, parameters: Vec<ObjectRef>, self_value: Option<ObjectRef>, call_span: Span ) -> Result<ObjectRef>

source

fn call_native_function_no_alias( &mut self, function_id: usize, parameters: Vec<ObjectRef>, call_span: Span ) -> Result<ObjectRef>

Calls a native function where it has been verified that its parameters cannot reference the same value

source

fn compile_native_function( &mut self, function_id: NativeFunctionId, parameters: &mut [ObjectRef], call_span: Span ) -> Result<usize>

Compiles function with function_id. Caller has to guarantee that the parameters don’t alias.

Return

The index of the monomorphized function

source

fn monomorphize_native_function( &mut self, function_id: NativeFunctionId, params: &[ObjectRef] ) -> Result<MonomorphizedFunction>

Compiles the function with the given parameters into a new block. It is executed with the specific parameters and an entry in the function instantiations gets created.

source

fn monomorphize_raw( &mut self, function_id: usize, parameters: &[(MirObjectId, ObjectRef)] ) -> Result<(BlockId, ObjectRef)>

Actual monomorphization happening here Compiles the context of the function and assumes that all required parameters are set Returns the id of the generated block and the return value of the block

source

fn handle_builtin_function_call( &mut self, function_call: &FunctionCall, function: &ObjFunction ) -> Result<ObjectRef>

source

fn verify_value_comptime( &self, verify_value_comptime: &VerifyValueComptime ) -> Result<()>

source

fn verify_tuple_length(&self, tuple_length: &VerifyTupleLength) -> Result<()>

source

fn verify_property_exists( &self, verify_property_exists: &VerifyPropertyExists ) -> Result<()>

Auto Trait Implementations§

§

impl<'builder, 'ctx> !RefUnwindSafe for LlirFunctionBuilder<'builder, 'ctx>

§

impl<'builder, 'ctx> !Send for LlirFunctionBuilder<'builder, 'ctx>

§

impl<'builder, 'ctx> !Sync for LlirFunctionBuilder<'builder, 'ctx>

§

impl<'builder, 'ctx> Unpin for LlirFunctionBuilder<'builder, 'ctx>

§

impl<'builder, 'ctx> !UnwindSafe for LlirFunctionBuilder<'builder, 'ctx>

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.