#[non_exhaustive]pub enum Expr {
Show 22 variants
DynamicConstant(Box<Dynamic>, Position),
BoolConstant(bool, Position),
IntegerConstant(INT, Position),
FloatConstant(FloatWrapper<FLOAT>, Position),
CharConstant(char, Position),
StringConstant(ImmutableString, Position),
InterpolatedString(ThinVec<Expr>, Position),
Array(ThinVec<Expr>, Position),
Map(Box<(StaticVec<(Ident, Expr)>, BTreeMap<Identifier, Dynamic>)>, Position),
Unit(Position),
Variable(Box<(Option<NonZeroUsize>, ImmutableString, Namespace, u64)>, Option<NonZeroU8>, Position),
ThisPtr(Position),
Property(Box<((ImmutableString, u64), (ImmutableString, 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),
Coalesce(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.
The Dynamic
value is boxed in order to avoid bloating the size of Expr
.
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(ThinVec<Expr>, Position)
An interpolated string.
Array(ThinVec<Expr>, Position)
[ expr, … ]
Map(Box<(StaticVec<(Ident, Expr)>, BTreeMap<Identifier, Dynamic>)>, Position)
#{ name:expr, … }
Unit(Position)
()
Variable(Box<(Option<NonZeroUsize>, ImmutableString, Namespace, u64)>, Option<NonZeroU8>, Position)
Variable access - (optional long index, variable name, namespace, namespace hash), 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.
ThisPtr(Position)
this
.
Property(Box<((ImmutableString, u64), (ImmutableString, 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 | lhs ?.
rhs
§Flags
Index(Box<BinaryExpr>, ASTFlags, Position)
lhs [
rhs ]
§Flags
And(Box<BinaryExpr>, Position)
lhs &&
rhs
Or(Box<BinaryExpr>, Position)
lhs ||
rhs
Coalesce(Box<BinaryExpr>, Position)
lhs ??
rhs
Custom(Box<CustomExpr>, Position)
Custom syntax
Implementations§
source§impl 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?
sourcepub fn take(&mut self) -> Self
pub fn take(&mut self) -> Self
Return this Expr
, replacing it with Expr::Unit
.
Trait Implementations§
source§impl AsRef<Expr> for Expression<'_>
impl AsRef<Expr> for Expression<'_>
source§impl Borrow<Expr> for Expression<'_>
impl Borrow<Expr> for Expression<'_>
source§impl<'a> From<&'a Expr> for Expression<'a>
impl<'a> From<&'a Expr> for Expression<'a>
Auto Trait Implementations§
impl Freeze for Expr
impl !RefUnwindSafe for Expr
impl !Send for Expr
impl !Sync for Expr
impl Unpin for Expr
impl !UnwindSafe for Expr
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> Variant for T
impl<T> Variant for T
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Variant
trait object to &mut dyn Any
.source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Variant
trait object to Box<dyn Any>
.