Struct Elaborator

Source
pub(super) struct Elaborator {
    pub(super) program: Program,
    pub(super) templates: BTreeMap<String, StructTemplate>,
    pub(super) enum_templates: BTreeMap<String, EnumTemplate>,
    pub(super) signatures: BTreeMap<String, FunctionSig>,
    pub(super) function_templates: BTreeMap<String, RuntimeFunctionTemplate>,
    pub(super) specializations: BTreeMap<SpecializationKey, String>,
    pub(super) concrete_structs: BTreeMap<String, StructDecl>,
    pub(super) instantiating_structs: BTreeSet<String>,
    pub(super) instantiating_functions: BTreeSet<SpecializationKey>,
    pub(super) next_function_instance_id: usize,
    pub(super) pass_timings: Vec<PassTiming>,
}

Fields§

§program: Program§templates: BTreeMap<String, StructTemplate>§enum_templates: BTreeMap<String, EnumTemplate>§signatures: BTreeMap<String, FunctionSig>§function_templates: BTreeMap<String, RuntimeFunctionTemplate>§specializations: BTreeMap<SpecializationKey, String>§concrete_structs: BTreeMap<String, StructDecl>§instantiating_structs: BTreeSet<String>§instantiating_functions: BTreeSet<SpecializationKey>§next_function_instance_id: usize§pass_timings: Vec<PassTiming>

Implementations§

Source§

impl Elaborator

Source

pub(super) fn bind_template_call_args( &mut self, callee_name: &str, template: &RuntimeFunctionTemplate, args: &mut Vec<CallArg>, locals: &mut Vec<(String, Ty)>, ) -> Result<TemplateCallBinding, ElabError>

Bind one runtime template call argument list to specialization inputs.

Source§

impl Elaborator

Source

pub(super) fn elaborate_call_expr( &mut self, callee: &mut Box<Expr>, args: &mut Vec<CallArg>, expected: Option<&Ty>, locals: &mut Vec<(String, Ty)>, ) -> Result<Ty, ElabError>

Elaborate one runtime call expression and return its resulting type.

Source

fn elaborate_enum_constructor_call( &mut self, callee: &mut Box<Expr>, callee_name: &str, callee_span: SourceSpan, args: &mut Vec<CallArg>, expected: Option<&Ty>, locals: &mut Vec<(String, Ty)>, ) -> Result<Ty, ElabError>

Elaborate one enum-constructor call expression and return its resulting type.

Source§

impl Elaborator

Source

pub(super) fn elaborate_intrinsic_call_expr( &mut self, name: &str, args: &mut [CallArg], locals: &mut Vec<(String, Ty)>, ) -> Result<Ty, ElabError>

Elaborate one intrinsic call expression and return its resulting type.

Source§

impl Elaborator

Source

pub(super) fn elaborate_struct_lit_expr( &mut self, name: &mut String, fields: &mut [NamedExprField], expected: Option<&Ty>, locals: &mut Vec<(String, Ty)>, ) -> Result<Ty, ElabError>

Elaborate one struct literal expression and return its resulting type.

Source§

impl Elaborator

Source

pub(super) fn instantiate_runtime_function( &mut self, callee_name: &str, template: &RuntimeFunctionTemplate, type_bindings: &BTreeMap<String, Ty>, meta_bindings: &BTreeMap<String, TemplateMetaBinding>, specialization_key: &SpecializationKey, variadic_pack_tys: &[Ty], ) -> Result<String, ElabError>

Instantiate a runtime template function with resolved specialization bindings.

Source§

impl Elaborator

Source

pub(super) fn ensure_ty_instantiated( &mut self, ty: &Ty, ) -> Result<(), ElabError>

Source

pub(super) fn unify_struct_type_param_bindings( &self, schema: &TypeExpr, actual: &Ty, type_params: &BTreeSet<String>, bindings: &mut BTreeMap<String, Ty>, ) -> Result<(), ElabError>

Source§

impl Elaborator

Source

pub(super) fn normalize_runtime_calls_and_spreads( &mut self, args: &mut Vec<CallArg>, locals: &mut Vec<(String, Ty)>, ) -> Result<(), ElabError>

Run call/spread normalization for one runtime call-site argument list.

Source§

impl Elaborator

Source

pub(super) fn pass_timings(&self) -> &[PassTiming]

Return recorded elaboration subpass timings.

Source

pub(super) fn record_subpass_timings(&mut self, timings: &[PassTiming])

Append one batch of elaboration subpass timings.

Source

pub(super) fn run_subpass<P>( pass: &mut P, input: P::In, ) -> Result<(P::Out, Vec<PassTiming>), P::Error>
where P: Pass,

Run one elaboration subpass and return output with collected timing samples.

Source§

impl Elaborator

Source

pub(super) fn elaborate_block( &mut self, block: &mut Block, expected_tail: Option<&Ty>, locals: &mut Vec<(String, Ty)>, ) -> Result<Ty, ElabError>

Source

pub(super) fn elaborate_stmt( &mut self, stmt: &mut Stmt, expected: Option<&Ty>, locals: &mut Vec<(String, Ty)>, ) -> Result<Ty, ElabError>

Source

pub(super) fn elaborate_expr( &mut self, expr: &mut Expr, expected: Option<&Ty>, locals: &mut Vec<(String, Ty)>, ) -> Result<Ty, ElabError>

Source

pub(super) fn resolve_struct_field_ty( &self, base_ty: &Ty, field: &str, ) -> Result<Ty, ElabError>

Source

pub(super) fn resolve_enum_variant_payload_tys( &self, enum_name: &str, enum_args: &[Ty], variant: &str, ) -> Result<Vec<Ty>, ElabError>

Source

pub(super) fn resolve_type_expr( &self, ty: &TypeExpr, type_bindings: &BTreeMap<String, Ty>, type_params: &BTreeSet<String>, self_ty: Option<&Ty>, ) -> Result<Ty, ElabError>

Source§

impl Elaborator

Source

pub(super) fn new(program: &Program) -> Result<Self, ElabError>

Source

pub(super) fn elaborate(&mut self) -> Result<Program, ElabError>

Source

pub(super) fn resolve_signatures(&mut self) -> Result<(), ElabError>

Source§

impl Elaborator

Source

pub(super) fn elaborate_function_body( &mut self, function: &mut FunctionDecl, ) -> Result<(), ElabError>

Source

pub(super) fn bind_meta_arg( &self, callee_name: &str, param: &Param, expr: &Expr, ) -> Result<TemplateMetaBinding, ElabError>

Source

pub(super) fn next_instance_name(&mut self, callee_name: &str) -> String

Source

pub(super) fn elaborate_call_runtime_args( &mut self, args: &mut Vec<CallArg>, params: &[(OwnershipMode, Ty)], locals: &mut Vec<(String, Ty)>, callee_name: &str, ) -> Result<(), ElabError>

Source

pub(super) fn resolve_function_signature( &mut self, function: &FunctionDecl, type_params: &[String], bindings: &BTreeMap<String, Ty>, ) -> Result<FunctionSig, ElabError>

Source

pub(super) fn apply_type_bindings_to_function( &mut self, function: &mut FunctionDecl, bindings: &BTreeMap<String, Ty>, type_params: &[String], ) -> Result<(), ElabError>

Source

pub(super) fn specialize_function_params( &mut self, function: &mut FunctionDecl, variadic_pack_tys: &[Ty], ) -> Result<(), ElabError>

Source

pub(super) fn apply_variadic_param_substitutions( &mut self, function: &mut FunctionDecl, original_params: &[Param], variadic_pack_tys: &[Ty], ) -> Result<(), ElabError>

Source

pub(super) fn apply_meta_bindings_to_function( &mut self, function: &mut FunctionDecl, bindings: &BTreeMap<String, TemplateMetaBinding>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_expr_replacements_to_block( &mut self, block: &mut Block, replacements: &BTreeMap<String, Expr>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_expr_replacements_to_stmt( &mut self, stmt: &mut Stmt, replacements: &BTreeMap<String, Expr>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_expr_replacements_to_meta_block( &mut self, block: &mut MetaBlock, replacements: &BTreeMap<String, Expr>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_expr_replacements_to_meta_expr( &mut self, expr: &mut MetaExpr, replacements: &BTreeMap<String, Expr>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_expr_replacements_to_quoted_code( &mut self, quoted: &mut QuotedCode, replacements: &BTreeMap<String, Expr>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_expr_replacements_to_expr( &mut self, expr: &mut Expr, replacements: &BTreeMap<String, Expr>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_meta_bindings_to_block( &mut self, block: &mut Block, bindings: &BTreeMap<String, TemplateMetaBinding>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_meta_bindings_to_stmt( &mut self, stmt: &mut Stmt, bindings: &BTreeMap<String, TemplateMetaBinding>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_meta_bindings_to_expr( &mut self, expr: &mut Expr, bindings: &BTreeMap<String, TemplateMetaBinding>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_type_bindings_to_block( &mut self, block: &mut Block, bindings: &BTreeMap<String, Ty>, type_params: &BTreeSet<String>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_type_bindings_to_stmt( &mut self, stmt: &mut Stmt, bindings: &BTreeMap<String, Ty>, type_params: &BTreeSet<String>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_type_bindings_to_expr( &mut self, expr: &mut Expr, bindings: &BTreeMap<String, Ty>, type_params: &BTreeSet<String>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_type_bindings_to_call_arg( &mut self, arg: &mut CallArg, bindings: &BTreeMap<String, Ty>, type_params: &BTreeSet<String>, ) -> Result<(), ElabError>

Source

pub(super) fn apply_type_bindings_to_type_ref( &mut self, ty: &mut TypeRef, bindings: &BTreeMap<String, Ty>, type_params: &BTreeSet<String>, ) -> Result<(), ElabError>

Source§

impl Elaborator

Source

pub(super) fn validate_runtime_call_args( &mut self, args: &mut Vec<CallArg>, params: &[(OwnershipMode, Ty)], locals: &mut Vec<(String, Ty)>, callee_name: &str, ) -> Result<(), ElabError>

Validate and elaborate one runtime call argument list.

Auto Trait Implementations§

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