Struct sway_core::language::ty::TyFunctionDeclaration
source · pub struct TyFunctionDeclaration {
pub name: Ident,
pub body: TyCodeBlock,
pub parameters: Vec<TyFunctionParameter>,
pub span: Span,
pub attributes: AttributesMap,
pub return_type: TypeId,
pub initial_return_type: TypeId,
pub type_parameters: Vec<TypeParameter>,
pub return_type_span: Span,
pub visibility: Visibility,
pub is_contract_call: bool,
pub purity: Purity,
}
Fields§
§name: Ident
§body: TyCodeBlock
§parameters: Vec<TyFunctionParameter>
§span: Span
§attributes: AttributesMap
§return_type: TypeId
§initial_return_type: TypeId
§type_parameters: Vec<TypeParameter>
§return_type_span: Span
Used for error messages – the span pointing to the return type annotation of the function
visibility: Visibility
§is_contract_call: bool
whether this function exists in another contract and requires a call to it or not
purity: Purity
Implementations§
source§impl TyFunctionDeclaration
impl TyFunctionDeclaration
pub fn to_fn_selector_value_untruncated(
&self,
type_engine: &TypeEngine
) -> CompileResult<Vec<u8>>
sourcepub fn to_fn_selector_value(
&self,
type_engine: &TypeEngine
) -> CompileResult<[u8; 4]>
pub fn to_fn_selector_value(
&self,
type_engine: &TypeEngine
) -> CompileResult<[u8; 4]>
Converts a TyFunctionDeclaration into a value that is to be used in contract function selectors. Hashes the name and parameters using SHA256, and then truncates to four bytes.
pub fn to_selector_name(&self, type_engine: &TypeEngine) -> CompileResult<String>
sourcepub fn is_main_entry(&self) -> bool
pub fn is_main_entry(&self) -> bool
Whether or not this function is the default entry point.
sourcepub fn is_test(&self) -> bool
pub fn is_test(&self) -> bool
Whether or not this function is a unit test, i.e. decorated with #[test]
.
pub fn inline(&self) -> Option<Inline>
source§impl TyFunctionDeclaration
impl TyFunctionDeclaration
pub fn type_check(
ctx: TypeCheckContext<'_>,
fn_decl: FunctionDeclaration,
is_method: bool,
is_in_impl_self: bool
) -> CompileResult<Self>
Trait Implementations§
source§impl Clone for TyFunctionDeclaration
impl Clone for TyFunctionDeclaration
source§fn clone(&self) -> TyFunctionDeclaration
fn clone(&self) -> TyFunctionDeclaration
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TyFunctionDeclaration
impl Debug for TyFunctionDeclaration
source§impl From<&TyFunctionDeclaration> for TyAstNode
impl From<&TyFunctionDeclaration> for TyAstNode
source§fn from(o: &TyFunctionDeclaration) -> Self
fn from(o: &TyFunctionDeclaration) -> Self
Converts to this type from the input type.