Add ASTNode::position().
This commit is contained in:
parent
cbe08fb64e
commit
6a2c9f0293
@ -26,6 +26,7 @@ Enhancements
|
||||
* Added `Scope::is_constant` to check if a variable is constant.
|
||||
* Added `Scope::set_or_push` to add a new variable only if one doesn't already exist.
|
||||
* `Engine::register_type_XXX` are now available even under `no_object`.
|
||||
* Added `ASTNode::position`.
|
||||
|
||||
|
||||
Version 1.0.4
|
||||
|
10
src/ast.rs
10
src/ast.rs
@ -875,6 +875,16 @@ impl<'a> From<&'a Expr> for ASTNode<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl ASTNode<'_> {
|
||||
/// Get the [`Position`] of this [`ASTNode`].
|
||||
pub const fn position(&self) -> Position {
|
||||
match self {
|
||||
ASTNode::Stmt(stmt) => stmt.position(),
|
||||
ASTNode::Expr(expr) => expr.position(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// _(internals)_ A statements block.
|
||||
/// Exported under the `internals` feature only.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user