pub struct PolyProcedure { /* private fields */ }
Expand description
A polymorphic procedure of LIR code which can be applied to a list of arguments with type arguments.
This is mono-morphed into a Procedure
when it is called with a list of type arguments.
A procedure is compiled down to a label in the assembly code.
Implementations§
Source§impl PolyProcedure
impl PolyProcedure
Sourcepub fn new(
name: String,
ty_params: Vec<(String, Option<Type>)>,
args: Vec<(String, Mutability, Type)>,
ret: Type,
body: impl Into<Expr>,
) -> Self
pub fn new( name: String, ty_params: Vec<(String, Option<Type>)>, args: Vec<(String, Mutability, Type)>, ret: Type, body: impl Into<Expr>, ) -> Self
Construct a new polymorphic procedure with type parameters, a list of arguments + their types, a return type, and the body of the procedure.
pub fn with(&self, decls: impl Into<Declaration>) -> Self
pub fn get_type_params(&self) -> &Vec<(String, Option<Type>)>
pub fn from_mono( mono: Procedure, ty_params: Vec<(String, Option<Type>)>, ) -> Self
Sourcepub fn get_name(&self) -> &str
pub fn get_name(&self) -> &str
Get the name of this polymorphic procedure. This is not the mangled name, but the name known to the LIR front-end. The mangled name is unique for each monomorph of the procedure.
Sourcepub fn monomorphize(
&self,
ty_args: Vec<Type>,
env: &Env,
) -> Result<Procedure, Error>
pub fn monomorphize( &self, ty_args: Vec<Type>, env: &Env, ) -> Result<Procedure, Error>
Take some type arguments and produce a monomorphized version of the procedure. This monomorphized version can then be compiled directly. Additionally, the mono version of the procedure is memoized, so that it is only compiled once.
Trait Implementations§
Source§impl Clone for PolyProcedure
impl Clone for PolyProcedure
Source§fn clone(&self) -> PolyProcedure
fn clone(&self) -> PolyProcedure
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PolyProcedure
impl Debug for PolyProcedure
Source§impl<'de> Deserialize<'de> for PolyProcedure
impl<'de> Deserialize<'de> for PolyProcedure
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for PolyProcedure
impl Display for PolyProcedure
Source§impl From<PolyProcedure> for ConstExpr
impl From<PolyProcedure> for ConstExpr
Source§fn from(value: PolyProcedure) -> Self
fn from(value: PolyProcedure) -> Self
Source§impl GetType for PolyProcedure
impl GetType for PolyProcedure
Source§fn get_type_checked(&self, _env: &Env, _i: usize) -> Result<Type, Error>
fn get_type_checked(&self, _env: &Env, _i: usize) -> Result<Type, Error>
Source§fn substitute(&mut self, name: &str, ty: &Type)
fn substitute(&mut self, name: &str, ty: &Type)
Source§fn get_type(&self, env: &Env) -> Result<Type, Error>
fn get_type(&self, env: &Env) -> Result<Type, Error>
fn substitute_types(&mut self, names: &[String], types: &[Type])
Source§impl Hash for PolyProcedure
impl Hash for PolyProcedure
Source§impl PartialEq for PolyProcedure
impl PartialEq for PolyProcedure
Source§impl Serialize for PolyProcedure
impl Serialize for PolyProcedure
Source§impl TypeCheck for PolyProcedure
impl TypeCheck for PolyProcedure
impl Eq for PolyProcedure
Auto Trait Implementations§
impl Freeze for PolyProcedure
impl RefUnwindSafe for PolyProcedure
impl Send for PolyProcedure
impl Sync for PolyProcedure
impl Unpin for PolyProcedure
impl UnwindSafe for PolyProcedure
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> GetSize for Twhere
T: GetType,
impl<T> GetSize for Twhere
T: GetType,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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