Check if function calls cannot be scripted.

This commit is contained in:
Stephen Chung
2022-10-14 18:31:40 +08:00
parent ea63c66cf0
commit ac05f0a0a8
6 changed files with 142 additions and 102 deletions

View File

@@ -181,7 +181,7 @@ impl FnCallHashes {
/// _(internals)_ A function call.
/// Exported under the `internals` feature only.
#[derive(Clone, Default, Hash)]
#[derive(Clone, Hash)]
pub struct FnCallExpr {
/// Namespace of the function, if any.
#[cfg(not(feature = "no_module"))]
@@ -196,6 +196,9 @@ pub struct FnCallExpr {
pub capture_parent_scope: bool,
/// Is this function call a native operator?
pub operator_token: Option<Token>,
/// Can this function call be a scripted function?
#[cfg(not(feature = "no_function"))]
pub can_be_script: bool,
/// [Position] of the function name.
pub pos: Position,
}
@@ -215,6 +218,10 @@ impl fmt::Debug for FnCallExpr {
if let Some(ref token) = self.operator_token {
ff.field("operator_token", token);
}
#[cfg(not(feature = "no_function"))]
if self.can_be_script {
ff.field("can_be_script", &self.can_be_script);
}
ff.field("hash", &self.hashes)
.field("name", &self.name)
.field("args", &self.args);
@@ -684,6 +691,8 @@ impl Expr {
args: once(Self::StringConstant(f.fn_name().into(), pos)).collect(),
capture_parent_scope: false,
operator_token: None,
#[cfg(not(feature = "no_function"))]
can_be_script: true,
pos,
}
.into(),