pub struct Symbol { /* private fields */ }
Expand description
Symbol
Every Symbol
has a SymbolDefinition
, a parent and children stored within a Rc<RefCell<
SymbolInner
>
.
So Symbol
is meant as a tree which is used by [SymbolTable
] to store
the resolved symbols by it’s original structure in the source code and by it’s id.
Symbol
can be shared as mutable.
Implementations§
Source§impl Symbol
impl Symbol
Sourcepub fn new(def: SymbolDefinition, parent: Option<Symbol>) -> Self
pub fn new(def: SymbolDefinition, parent: Option<Symbol>) -> Self
Create new symbol without children.
§Arguments
visibility
: Visibility of the symboldef
: Symbol definitionparent
: Symbol’s parent symbol or none for root
Sourcepub fn new_builtin(
id: Identifier,
parameters: Option<ParameterValueList>,
f: &'static BuiltinFn,
) -> Symbol
pub fn new_builtin( id: Identifier, parameters: Option<ParameterValueList>, f: &'static BuiltinFn, ) -> Symbol
Create a symbol node for a built-in.
§Arguments
id
: Name of the symbolparameters
: Optional parameter listf
: The builtin function
Sourcepub fn new_call_argument(id: Identifier, value: Value) -> Symbol
pub fn new_call_argument(id: Identifier, value: Value) -> Symbol
Create a new argument (SymbolDefinition::Argument
).
Sourcepub fn print_symbol(
&self,
f: &mut impl Write,
id: Option<&Identifier>,
depth: usize,
children: bool,
) -> Result
pub fn print_symbol( &self, f: &mut impl Write, id: Option<&Identifier>, depth: usize, children: bool, ) -> Result
Print out symbols from that point.
§Arguments
f
: Output formatterid
: Overwrite symbol’s internalid
with this one if given (e.g. when using in a map).depth
: Indention depth to use
Sourcepub fn add_child(parent: &Symbol, child: Symbol)
pub fn add_child(parent: &Symbol, child: Symbol)
Insert child and change parent of child to new parent.
§Arguments
parent
: New parent symbol (will be changed in child!).child
: Child to insert
Sourcepub fn move_children(&self, from: &Symbol)
pub fn move_children(&self, from: &Symbol)
Move all children from another symbol into this one.
§Arguments
from
: Append this symbol’s children
Technically, nothing will be moved here because of the Rc<RefCell<>>
,
but by resetting the parent of all moved children, those will see
themselves as child of self
(e.g when providing fully qualified name).
Sourcepub fn clone_with_visibility(&self, visibility: Visibility) -> Self
pub fn clone_with_visibility(&self, visibility: Visibility) -> Self
Clone this symbol but give the clone another visibility.
Sourcepub fn id(&self) -> Identifier
pub fn id(&self) -> Identifier
Return the internal id of this symbol.
Sourcepub fn get(&self, id: &Identifier) -> Option<Symbol>
pub fn get(&self, id: &Identifier) -> Option<Symbol>
Sourcepub fn visibility(&self) -> Visibility
pub fn visibility(&self) -> Visibility
Return true
if symbol’s visibility is private
Sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Return true
if symbol’s visibility set to is non-public.
Sourcepub fn search(&self, name: &QualifiedName) -> Option<Symbol>
pub fn search(&self, name: &QualifiedName) -> Option<Symbol>
Sourcepub fn can_value(&self) -> bool
pub fn can_value(&self) -> bool
check if a value on the stack may be declared within this symbol
Sourcepub fn set_value(&self, new_value: Value) -> ResolveResult<()>
pub fn set_value(&self, new_value: Value) -> ResolveResult<()>
Overwrite any value in this symbol
Sourcepub fn get_value(&self) -> ResolveResult<Value>
pub fn get_value(&self) -> ResolveResult<Value>
Get any value of this symbol
Trait Implementations§
Source§impl FromIterator<Symbol> for Symbols
impl FromIterator<Symbol> for Symbols
Source§impl FullyQualify for Symbol
impl FullyQualify for Symbol
Source§fn full_name(&self) -> QualifiedName
fn full_name(&self) -> QualifiedName
Get fully qualified name.
Auto Trait Implementations§
impl Freeze for Symbol
impl !RefUnwindSafe for Symbol
impl !Send for Symbol
impl !Sync for Symbol
impl Unpin for Symbol
impl !UnwindSafe for Symbol
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()
Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
. Read more