Type Definition sway_core::NamespaceRef
source · [−]pub type NamespaceRef = Index;Trait Implementations
fn 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.
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<TypeId>>
fn get_struct_type_fields(
&self,
ty: TypeId,
debug_string: impl Into<String>,
debug_span: &Span
) -> CompileResult<(Vec<OwnedTypedStructField>, String)>
fn get_struct_type_fields(
&self,
ty: TypeId,
debug_string: impl Into<String>,
debug_span: &Span
) -> CompileResult<(Vec<OwnedTypedStructField>, String)>
given a declaration that may refer to a variable which contains a struct, find that struct’s fields and name for use in determining if a subfield expression is valid e.g. foo.bar.baz is foo a struct? does it contain a field bar? is foo.bar a struct? does foo.bar contain a field baz? this is the problem this function addresses Read more
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 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
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>
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 insert_trait_implementation(
&self,
trait_name: CallPath,
type_implementing_for: TypeInfo,
functions_buf: Vec<TypedFunctionDeclaration>
) -> CompileResult<()>
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