Split FnPtr into own file.

This commit is contained in:
Stephen Chung
2021-06-17 09:50:32 +08:00
parent 40e33fa6f9
commit 425e038f4b
11 changed files with 235 additions and 215 deletions

View File

@@ -1232,7 +1232,7 @@ impl Engine {
}
}
let is_ref = target.is_ref();
let is_ref_mut = target.is_ref();
// Pop the last index value
let idx_val = idx_values
@@ -1295,8 +1295,8 @@ impl Engine {
let pos = Position::NONE;
self.exec_fn_call(
mods, state, lib, FN_IDX_SET, hash_set, args, is_ref, true, pos,
None, level,
mods, state, lib, FN_IDX_SET, hash_set, args, is_ref_mut, true,
pos, None, level,
)?;
}
@@ -1374,8 +1374,8 @@ impl Engine {
let args = &mut [target.as_mut()];
let (mut orig_val, _) = self
.exec_fn_call(
mods, state, lib, getter, hash, args, is_ref, true, *pos, None,
level,
mods, state, lib, getter, hash, args, is_ref_mut, true, *pos,
None, level,
)
.or_else(|err| match *err {
// Try an indexer if property does not exist
@@ -1417,7 +1417,8 @@ impl Engine {
let hash = FnCallHashes::from_native(*hash_set);
let args = &mut [target.as_mut(), &mut new_val];
self.exec_fn_call(
mods, state, lib, setter, hash, args, is_ref, true, *pos, None, level,
mods, state, lib, setter, hash, args, is_ref_mut, true, *pos, None,
level,
)
.or_else(|err| match *err {
// Try an indexer if property does not exist
@@ -1428,7 +1429,7 @@ impl Engine {
let pos = Position::NONE;
self.exec_fn_call(
mods, state, lib, FN_IDX_SET, hash_set, args, is_ref, true,
mods, state, lib, FN_IDX_SET, hash_set, args, is_ref_mut, true,
pos, None, level,
)
.map_err(
@@ -1447,7 +1448,8 @@ impl Engine {
let hash = FnCallHashes::from_native(*hash_get);
let args = &mut [target.as_mut()];
self.exec_fn_call(
mods, state, lib, getter, hash, args, is_ref, true, *pos, None, level,
mods, state, lib, getter, hash, args, is_ref_mut, true, *pos, None,
level,
)
.map_or_else(
|err| match *err {
@@ -1518,7 +1520,7 @@ impl Engine {
let args = &mut arg_values[..1];
let (mut val, updated) = self
.exec_fn_call(
mods, state, lib, getter, hash_get, args, is_ref, true,
mods, state, lib, getter, hash_get, args, is_ref_mut, true,
*pos, None, level,
)
.or_else(|err| match *err {
@@ -1564,7 +1566,7 @@ impl Engine {
let mut arg_values = [target.as_mut(), val];
let args = &mut arg_values;
self.exec_fn_call(
mods, state, lib, setter, hash_set, args, is_ref, true,
mods, state, lib, setter, hash_set, args, is_ref_mut, true,
*pos, None, level,
)
.or_else(
@@ -1578,7 +1580,7 @@ impl Engine {
);
self.exec_fn_call(
mods, state, lib, FN_IDX_SET, hash_set, args,
is_ref, true, *pos, None, level,
is_ref_mut, true, *pos, None, level,
)
.or_else(|idx_err| match *idx_err {
EvalAltResult::ErrorIndexingType(_, _) => {