Type Definition sway_core::NamespaceRef
source · [−]pub type NamespaceRef = Index;Trait Implementations
sourceimpl NamespaceWrapper for NamespaceRef
impl NamespaceWrapper for NamespaceRef
sourcefn get_struct_type_fields(
&self,
ty: TypeId,
debug_string: impl Into<String>,
debug_span: &Span
) -> CompileResult<(Vec<TypedStructField>, Ident)>
fn get_struct_type_fields(
&self,
ty: TypeId,
debug_string: impl Into<String>,
debug_span: &Span
) -> CompileResult<(Vec<TypedStructField>, Ident)>
Returns a tuple of all of the fields of a struct and the struct’s name.
sourcefn item_import(
&self,
from_namespace: Option<NamespaceRef>,
path: Vec<Ident>,
item: &Ident,
alias: Option<Ident>
) -> CompileResult<()>
fn item_import(
&self,
from_namespace: Option<NamespaceRef>,
path: Vec<Ident>,
item: &Ident,
alias: Option<Ident>
) -> CompileResult<()>
Pull a single item from a module and import it into this namespace.
sourcefn self_import(
&self,
from_namespace: Option<NamespaceRef>,
path: Vec<Ident>,
alias: Option<Ident>
) -> CompileResult<()>
fn self_import(
&self,
from_namespace: Option<NamespaceRef>,
path: Vec<Ident>,
alias: Option<Ident>
) -> CompileResult<()>
Pull a single item from a module and import it into this namespace. The item we want to import is basically the last item in path because this is a self import.
fn apply_storage_load(
&self,
fields: Vec<Ident>,
storage_fields: &[TypedStorageField]
) -> CompileResult<(TypeCheckedStorageAccess, TypeId)>
fn set_storage_declaration(
&self,
decl: TypedStorageDeclaration
) -> CompileResult<()>
fn has_storage_declared(&self) -> bool
fn get_storage_field_descriptors(&self) -> CompileResult<Vec<TypedStorageField>>
fn insert_module_ref(&self, module_name: String, ix: NamespaceRef)
sourcefn find_subfield_type(
&self,
subfield_exp: &[Ident]
) -> CompileResult<(TypeId, TypeId)>
fn find_subfield_type(
&self,
subfield_exp: &[Ident]
) -> CompileResult<(TypeId, TypeId)>
Returns a tuple where the first element is the [ResolvedType] of the actual expression, and the second is the [ResolvedType] of its parent, for control-flow analysis. Read more
fn get_tuple_elems(
&self,
ty: TypeId,
debug_string: impl Into<String>,
debug_span: &Span
) -> CompileResult<Vec<TypeArgument>>
fn find_enum(&self, enum_name: &Ident) -> Option<TypedEnumDeclaration>
fn get_symbol(&self, symbol: &Ident) -> CompileResult<TypedDeclaration>
sourcefn get_call_path(&self, symbol: &CallPath) -> CompileResult<TypedDeclaration>
fn get_call_path(&self, symbol: &CallPath) -> CompileResult<TypedDeclaration>
Used for calls that look like this:
foo::bar::function
where foo and bar are the prefixes
and function is the suffix Read more
fn get_name_from_path(
&self,
path: &[Ident],
name: &Ident
) -> CompileResult<TypedDeclaration>
fn get_methods_for_type(&self, type: TypeId) -> Vec<TypedFunctionDeclaration>
fn copy_methods_to_type(
&self,
old_type: TypeInfo,
new_type: TypeInfo,
type_mapping: &[(TypeParameter, usize)]
)
sourcefn star_import(
&self,
from_module: Option<NamespaceRef>,
path: Vec<Ident>
) -> CompileResult<()>
fn star_import(
&self,
from_module: Option<NamespaceRef>,
path: Vec<Ident>
) -> CompileResult<()>
Given a path to a module, create synonyms to every symbol in that module. This is used when an import path contains an asterisk. Read more
sourcefn find_method_for_type(
&self,
type: TypeId,
method_name: &Ident,
method_path: &[Ident],
from_module: Option<NamespaceRef>,
self_type: TypeId,
args_buf: &VecDeque<TypedExpression>
) -> CompileResult<TypedFunctionDeclaration>
fn find_method_for_type(
&self,
type: TypeId,
method_name: &Ident,
method_path: &[Ident],
from_module: Option<NamespaceRef>,
self_type: TypeId,
args_buf: &VecDeque<TypedExpression>
) -> CompileResult<TypedFunctionDeclaration>
Given a method and a type (plus a self_type to potentially resolve it), find that
method in the namespace. Requires args_buf because of some special casing for the
standard library where we pull the type from the arguments buffer. Read more
fn find_module_relative(&self, path: &[Ident]) -> CompileResult<NamespaceRef>
fn insert_trait_implementation(
&self,
trait_name: CallPath,
type_implementing_for: TypeInfo,
functions_buf: Vec<TypedFunctionDeclaration>
) -> CompileResult<()>
fn insert_module(&self, module_name: String, module_contents: Namespace)
fn insert(&self, name: Ident, item: TypedDeclaration) -> CompileResult<()>
sourcefn resolve_type_with_self(
&self,
ty: TypeInfo,
self_type: TypeId,
span: Span,
enforce_type_args: bool
) -> CompileResult<TypeId>
fn resolve_type_with_self(
&self,
ty: TypeInfo,
self_type: TypeId,
span: Span,
enforce_type_args: bool
) -> CompileResult<TypeId>
this function either returns a struct (i.e. custom type), None, denoting the type that is
being looked for is actually a generic, not-yet-resolved type. Read more