#[non_exhaustive]
pub enum Expr {
Show 20 variants
DynamicConstant(Box<Dynamic>, Position),
BoolConstant(bool, Position),
IntegerConstant(INT, Position),
FloatConstant(FloatWrapper<FLOAT>, Position),
CharConstant(char, Position),
StringConstant(ImmutableString, Position),
InterpolatedString(Box<StaticVec<Expr>>, Position),
Array(Box<StaticVec<Expr>>, Position),
Map(Box<(StaticVec<(Ident, Expr)>, BTreeMap<Identifier, Dynamic>)>, Position),
Unit(Position),
Variable(Box<(Option<NonZeroUsize>, Namespace, u64, Identifier)>, Option<NonZeroU8>, Position),
Property(Box<((Identifier, u64), (Identifier, u64), ImmutableString)>, Position),
MethodCall(Box<FnCallExpr>, Position),
Stmt(Box<StmtBlock>),
FnCall(Box<FnCallExpr>, Position),
Dot(Box<BinaryExpr>, ASTFlags, Position),
Index(Box<BinaryExpr>, ASTFlags, Position),
And(Box<BinaryExpr>, Position),
Or(Box<BinaryExpr>, Position),
Custom(Box<CustomExpr>, Position),
}
Expand description
(internals) An expression sub-tree.
Exported under the internals
feature only.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
DynamicConstant(Box<Dynamic>, Position)
Dynamic constant.
Used to hold complex constants such as Array
or Map
for quick cloning.
Primitive data types should use the appropriate variants to avoid an allocation.
BoolConstant(bool, Position)
Boolean constant.
IntegerConstant(INT, Position)
Integer constant.
FloatConstant(FloatWrapper<FLOAT>, Position)
Floating-point constant.
CharConstant(char, Position)
Character constant.
StringConstant(ImmutableString, Position)
String constant.
InterpolatedString(Box<StaticVec<Expr>>, Position)
An interpolated string.
Array(Box<StaticVec<Expr>>, Position)
[ expr, … ]
Map(Box<(StaticVec<(Ident, Expr)>, BTreeMap<Identifier, Dynamic>)>, Position)
#{ name:expr, … }
Unit(Position)
()
Variable(Box<(Option<NonZeroUsize>, Namespace, u64, Identifier)>, Option<NonZeroU8>, Position)
Variable access - (optional long index, namespace, namespace hash, variable name), optional short index, position
The short index is u8
which is used when the index is <= 255, which should be the vast
majority of cases (unless there are more than 255 variables defined!).
This is to avoid reading a pointer redirection during each variable access.
Property(Box<((Identifier, u64), (Identifier, u64), ImmutableString)>, Position)
Property access - ((getter, hash), (setter, hash), prop)
MethodCall(Box<FnCallExpr>, Position)
xxx .
method (
expr ,
… )
Stmt(Box<StmtBlock>)
{ statement … }
FnCall(Box<FnCallExpr>, Position)
func (
expr ,
… )
Dot(Box<BinaryExpr>, ASTFlags, Position)
lhs .
rhs
Index(Box<BinaryExpr>, ASTFlags, Position)
And(Box<BinaryExpr>, Position)
lhs &&
rhs
Or(Box<BinaryExpr>, Position)
lhs ||
rhs
Custom(Box<CustomExpr>, Position)
Custom syntax
Implementations
sourceimpl Expr
impl Expr
sourcepub fn get_literal_value(&self) -> Option<Dynamic>
pub fn get_literal_value(&self) -> Option<Dynamic>
sourcepub fn from_dynamic(value: Dynamic, pos: Position) -> Self
pub fn from_dynamic(value: Dynamic, pos: Position) -> Self
sourcepub fn start_position(&self) -> Position
pub fn start_position(&self) -> Position
Get the starting position of the expression. For a binary expression, this will be the left-most LHS instead of the operator.
sourcepub fn set_position(&mut self, new_pos: Position) -> &mut Self
pub fn set_position(&mut self, new_pos: Position) -> &mut Self
Override the position of the expression.
sourcepub fn is_constant(&self) -> bool
pub fn is_constant(&self) -> bool
Is the expression a constant?
sourcepub const fn is_valid_postfix(&self, token: &Token) -> bool
pub const fn is_valid_postfix(&self, token: &Token) -> bool
Is a particular token allowed as a postfix operator to this expression?
Trait Implementations
sourceimpl AsRef<Expr> for Expression<'_>
impl AsRef<Expr> for Expression<'_>
sourceimpl<'a> From<&'a Expr> for Expression<'a>
impl<'a> From<&'a Expr> for Expression<'a>
Auto Trait Implementations
impl !RefUnwindSafe for Expr
impl !Send for Expr
impl !Sync for Expr
impl Unpin for Expr
impl !UnwindSafe for Expr
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallHasher for T where
T: Hash + ?Sized,
impl<T> CallHasher for T where
T: Hash + ?Sized,
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more