Add Stmt::FnCall.

This commit is contained in:
Stephen Chung
2021-04-21 18:16:24 +08:00
parent cc546fcaab
commit fe37edd123
4 changed files with 87 additions and 20 deletions

View File

@@ -1830,22 +1830,6 @@ impl Engine {
Ok(map.into())
}
// Normal function call
Expr::FnCall(x, pos) if !x.is_qualified() => {
let FnCallExpr {
name,
capture,
hashes,
args,
constant_args: c_args,
..
} = x.as_ref();
self.make_function_call(
scope, mods, state, lib, this_ptr, name, args, c_args, *hashes, *pos, *capture,
level,
)
}
// Namespace-qualified function call
Expr::FnCall(x, pos) if x.is_qualified() => {
let FnCallExpr {
@@ -1864,6 +1848,22 @@ impl Engine {
)
}
// Normal function call
Expr::FnCall(x, pos) => {
let FnCallExpr {
name,
capture,
hashes,
args,
constant_args: c_args,
..
} = x.as_ref();
self.make_function_call(
scope, mods, state, lib, this_ptr, name, args, c_args, *hashes, *pos, *capture,
level,
)
}
Expr::And(x, _) => {
Ok((self
.eval_expr(scope, mods, state, lib, this_ptr, &x.lhs, level)?
@@ -2390,6 +2390,40 @@ impl Engine {
// Break statement
Stmt::Break(pos) => EvalAltResult::LoopBreak(true, *pos).into(),
// Namespace-qualified function call
Stmt::FnCall(x, pos) if x.is_qualified() => {
let FnCallExpr {
name,
namespace,
hashes,
args,
constant_args: c_args,
..
} = x.as_ref();
let namespace = namespace.as_ref();
let hash = hashes.native_hash();
self.make_qualified_function_call(
scope, mods, state, lib, this_ptr, namespace, name, args, c_args, hash, *pos,
level,
)
}
// Normal function call
Stmt::FnCall(x, pos) => {
let FnCallExpr {
name,
capture,
hashes,
args,
constant_args: c_args,
..
} = x.as_ref();
self.make_function_call(
scope, mods, state, lib, this_ptr, name, args, c_args, *hashes, *pos, *capture,
level,
)
}
// Try/Catch statement
Stmt::TryCatch(x, _, _) => {
let (try_stmt, err_var, catch_stmt) = x.as_ref();