Extract constant arguments from function calls.
This commit is contained in:
15
src/ast.rs
15
src/ast.rs
@@ -1400,6 +1400,8 @@ pub struct FnCallExpr {
|
||||
pub capture: bool,
|
||||
/// List of function call arguments.
|
||||
pub args: StaticVec<Expr>,
|
||||
/// List of function call arguments that are constants.
|
||||
pub constant_args: StaticVec<(Dynamic, Position)>,
|
||||
/// Namespace of the function, if any. Boxed because it occurs rarely.
|
||||
pub namespace: Option<NamespaceRef>,
|
||||
/// Function name.
|
||||
@@ -1408,6 +1410,19 @@ pub struct FnCallExpr {
|
||||
pub name: Cow<'static, str>,
|
||||
}
|
||||
|
||||
impl FnCallExpr {
|
||||
/// Are there no arguments to this function call?
|
||||
#[inline(always)]
|
||||
pub fn is_args_empty(&self) -> bool {
|
||||
self.args.is_empty() && self.constant_args.is_empty()
|
||||
}
|
||||
/// Get the number of arguments to this function call.
|
||||
#[inline(always)]
|
||||
pub fn num_args(&self) -> usize {
|
||||
self.args.len() + self.constant_args.len()
|
||||
}
|
||||
}
|
||||
|
||||
/// A type that wraps a [`FLOAT`] and implements [`Hash`].
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
#[derive(Clone, Copy, PartialEq, PartialOrd)]
|
||||
|
Reference in New Issue
Block a user