Remove constants in function call expressions.

This commit is contained in:
Stephen Chung
2022-03-05 12:06:47 +08:00
parent 0335035b0f
commit e06c2b2abb
7 changed files with 77 additions and 124 deletions

View File

@@ -684,16 +684,13 @@ impl Engine {
Expr::MethodCall(x, ..)
if _parent_chain_type == ChainType::Dotting && !x.is_qualified() =>
{
let crate::ast::FnCallExpr {
args, constants, ..
} = x.as_ref();
let crate::ast::FnCallExpr { args, .. } = x.as_ref();
let (values, pos) = args.iter().try_fold(
(crate::FnArgsVec::with_capacity(args.len()), Position::NONE),
|(mut values, mut pos), expr| {
let (value, arg_pos) = self.get_arg_value(
scope, global, state, lib, this_ptr, expr, constants, level,
)?;
let (value, arg_pos) =
self.get_arg_value(scope, global, state, lib, this_ptr, expr, level)?;
if values.is_empty() {
pos = arg_pos;
}
@@ -732,15 +729,13 @@ impl Engine {
Expr::MethodCall(x, ..)
if _parent_chain_type == ChainType::Dotting && !x.is_qualified() =>
{
let crate::ast::FnCallExpr {
args, constants, ..
} = x.as_ref();
let crate::ast::FnCallExpr { args, .. } = x.as_ref();
let (values, pos) = args.iter().try_fold(
(crate::FnArgsVec::with_capacity(args.len()), Position::NONE),
|(mut values, mut pos), expr| {
let (value, arg_pos) = self.get_arg_value(
scope, global, state, lib, this_ptr, expr, constants, level,
scope, global, state, lib, this_ptr, expr, level,
)?;
if values.is_empty() {
pos = arg_pos

View File

@@ -212,7 +212,6 @@ impl Engine {
capture_parent_scope: capture,
hashes,
args,
constants,
..
} = expr;
@@ -222,8 +221,7 @@ impl Engine {
let hash = hashes.native;
return self.make_qualified_function_call(
scope, global, state, lib, this_ptr, namespace, name, args, constants, hash, pos,
level,
scope, global, state, lib, this_ptr, namespace, name, args, hash, pos, level,
);
}
@@ -234,8 +232,8 @@ impl Engine {
);
self.make_function_call(
scope, global, state, lib, this_ptr, name, first_arg, args, constants, *hashes,
*capture, pos, level,
scope, global, state, lib, this_ptr, name, first_arg, args, *hashes, *capture, pos,
level,
)
}