LoweringContext

Struct LoweringContext 

Source
struct LoweringContext<'a> {
Show 29 fields function_name: String, is_safe: bool, param_index_map: HashMap<String, usize>, param_types: &'a [ValueType], return_slots: Vec<Option<usize>>, return_types: Vec<ValueType>, state_variables: &'a [StateVariableMetadata], state_index_map: &'a HashMap<String, usize>, state_types: &'a [ValueType], defined_struct_types: &'a [ValueType], event_index_map: &'a HashMap<String, usize>, event_signature_map: &'a HashMap<String, Vec<ManifestType>>, enum_variant_map: &'a HashMap<String, HashMap<String, u64>>, contract_types: &'a HashSet<String>, selector_registry: &'a SelectorRegistry, function_names: &'a HashSet<String>, function_overloads: &'a HashMap<(String, usize), String>, function_param_names: &'a HashMap<(String, usize), Vec<String>>, void_functions: &'a HashSet<String>, super_method_map: &'a HashMap<String, String>, local_index_map: HashMap<String, Vec<usize>>, local_types: HashMap<usize, ValueType>, scope_stack: Vec<Vec<String>>, storage_aliases: HashMap<String, StorageReference>, call_data_locals: HashMap<usize, String>, local_count: u16, label_counter: usize, loop_stack: Vec<LoopLabels>, errors: Vec<IrDiagnostic>,
}

Fields§

§function_name: String§is_safe: bool§param_index_map: HashMap<String, usize>§param_types: &'a [ValueType]§return_slots: Vec<Option<usize>>§return_types: Vec<ValueType>§state_variables: &'a [StateVariableMetadata]§state_index_map: &'a HashMap<String, usize>§state_types: &'a [ValueType]§defined_struct_types: &'a [ValueType]

Canonical struct type definitions available to the compilation unit.

This enables resolving user-defined structs even when they are only used in local variables (i.e., not present in state/param/return types).

§event_index_map: &'a HashMap<String, usize>§event_signature_map: &'a HashMap<String, Vec<ManifestType>>§enum_variant_map: &'a HashMap<String, HashMap<String, u64>>§contract_types: &'a HashSet<String>§selector_registry: &'a SelectorRegistry§function_names: &'a HashSet<String>§function_overloads: &'a HashMap<(String, usize), String>§function_param_names: &'a HashMap<(String, usize), Vec<String>>

Ordered parameter names for each function overload, keyed by (name, arg_count). Used to reorder named function call arguments into positional order.

§void_functions: &'a HashSet<String>

Functions that return void (empty return_parameters). Used to avoid emitting DROP after calling a void internal function as a statement.

§super_method_map: &'a HashMap<String, String>

Mapping from original method name to renamed super-method name. Used to resolve super.method() calls during IR lowering.

§local_index_map: HashMap<String, Vec<usize>>§local_types: HashMap<usize, ValueType>§scope_stack: Vec<Vec<String>>§storage_aliases: HashMap<String, StorageReference>§call_data_locals: HashMap<usize, String>§local_count: u16§label_counter: usize§loop_stack: Vec<LoopLabels>§errors: Vec<IrDiagnostic>

Implementations§

Source§

impl<'a> LoweringContext<'a>

Source

fn new( function_name: &str, is_safe: bool, param_index_map: HashMap<String, usize>, param_types: &'a [ValueType], state_variables: &'a [StateVariableMetadata], state_index_map: &'a HashMap<String, usize>, state_types: &'a [ValueType], defined_struct_types: &'a [ValueType], event_index_map: &'a HashMap<String, usize>, event_signature_map: &'a HashMap<String, Vec<ManifestType>>, enum_variant_map: &'a HashMap<String, HashMap<String, u64>>, contract_types: &'a HashSet<String>, selector_registry: &'a SelectorRegistry, function_names: &'a HashSet<String>, function_overloads: &'a HashMap<(String, usize), String>, function_param_names: &'a HashMap<(String, usize), Vec<String>>, void_functions: &'a HashSet<String>, super_method_map: &'a HashMap<String, String>, ) -> Self

Source

fn set_return_info(&mut self, slots: Vec<Option<usize>>, types: Vec<ValueType>)

Source

fn return_slots(&self) -> &[Option<usize>]

Source

fn return_types(&self) -> &[ValueType]

Source

fn next_label(&mut self) -> usize

Source

fn push_loop(&mut self, continue_label: usize, break_label: usize)

Source

fn pop_loop(&mut self)

Source

fn break_target(&self) -> Option<usize>

Source

fn continue_target(&self) -> Option<usize>

Source

fn record_error(&mut self, message: impl Into<String>)

Source

fn record_error_with_suggestion( &mut self, message: impl Into<String>, suggestion: impl Into<String>, )

Source

fn set_call_data_local(&mut self, local_index: usize, method: String)

Source

fn clear_call_data_local(&mut self, local_index: usize)

Source

fn call_data_method_for_local(&self, local_index: usize) -> Option<&str>

Source

fn is_contract_type_name(&self, name: &str) -> bool

Source

fn type_method_selectors( &self, type_name: &str, method_name: &str, ) -> Option<&Vec<[u8; 4]>>

Source

fn is_interface_type_name(&self, name: &str) -> bool

Source

fn interface_id_for_type(&self, type_name: &str) -> Option<[u8; 4]>

Source

fn state_type(&self, index: usize) -> Option<&ValueType>

Source

fn state_metadata(&self, index: usize) -> Option<&StateVariableMetadata>

Source

fn can_write_state(&self, state_index: usize) -> bool

Source

fn ensure_state_writable(&mut self, state_index: usize) -> bool

Source

fn parameter_type(&self, name: &str) -> Option<&ValueType>

Source

fn local_type(&self, index: usize) -> Option<&ValueType>

Source

fn variable_type(&self, name: &str) -> Option<ValueType>

Source

fn neo_function_name(&self, name: &str, arg_count: usize) -> Option<String>

Source

fn get_function_param_names( &self, name: &str, arg_count: usize, ) -> Option<&[String]>

Returns the ordered parameter names for a function overload, if known.

Source

fn is_void_function(&self, name: &str) -> bool

Returns true if the named function returns void (no return values).

Source

fn super_method_name(&self, method_name: &str) -> Option<&str>

Returns the renamed super-method name for super.method() resolution.

Source

fn event_signature(&self, event_name: &str) -> Option<&[ManifestType]>

Source

fn allocate_local( &mut self, name: String, value_type: Option<ValueType>, ) -> usize

Source

fn resolve_local(&self, name: &str) -> Option<usize>

Source

fn ensure_local(&mut self, name: &str) -> usize

Source

fn enter_scope(&mut self)

Source

fn exit_scope(&mut self)

Source

fn is_local_in_current_scope(&self, name: &str) -> bool

Source

fn set_storage_alias(&mut self, name: String, alias: StorageReference)

Source

fn storage_alias(&self, name: &str) -> Option<&StorageReference>

Auto Trait Implementations§

§

impl<'a> Freeze for LoweringContext<'a>

§

impl<'a> RefUnwindSafe for LoweringContext<'a>

§

impl<'a> Send for LoweringContext<'a>

§

impl<'a> Sync for LoweringContext<'a>

§

impl<'a> Unpin for LoweringContext<'a>

§

impl<'a> UnwindSafe for LoweringContext<'a>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.