Fix op-assignment hashes.

This commit is contained in:
Stephen Chung
2023-02-11 15:06:17 +08:00
parent 9cb5154979
commit 557b368fdb
6 changed files with 57 additions and 38 deletions

View File

@@ -621,7 +621,7 @@ impl Engine {
self.eval_op_assignment(
global, caches, op_info, root, obj_ptr, new_val,
)?;
self.check_data_size(obj_ptr.as_ref(), op_info.pos)?;
self.check_data_size(obj_ptr.as_ref(), op_info.position())?;
None
}
// Indexed value cannot be referenced - use indexer
@@ -647,7 +647,7 @@ impl Engine {
)?;
// Replace new value
new_val = val.take_or_clone();
self.check_data_size(&new_val, op_info.pos)?;
self.check_data_size(&new_val, op_info.position())?;
}
}
@@ -729,7 +729,7 @@ impl Engine {
global, caches, op_info, root, val_target, new_val,
)?;
}
self.check_data_size(target.source(), op_info.pos)?;
self.check_data_size(target.source(), op_info.position())?;
Ok((Dynamic::UNIT, true))
}
// {xxx:map}.id

View File

@@ -125,18 +125,10 @@ impl Engine {
return Err(ERR::ErrorAssignmentToConstant(name.to_string(), pos).into());
}
if op_info.is_op_assignment() {
let OpAssignment {
hash_op_assign,
hash_op,
op_assign,
op,
pos,
} = op_info;
let pos = op_info.position();
if let Some((hash1, hash2, op_assign, op)) = op_info.get_op_assignment_info() {
let mut lock_guard = target.write_lock::<Dynamic>().unwrap();
let hash = *hash_op_assign;
let args = &mut [&mut *lock_guard, &mut new_val];
if self.fast_operators() {
@@ -149,7 +141,7 @@ impl Engine {
let context = if need_context {
let op = op_assign.literal_syntax();
let source = global.source();
Some((self, op, source, &*global, *pos).into())
Some((self, op, source, &*global, pos).into())
} else {
None
};
@@ -160,7 +152,7 @@ impl Engine {
let token = Some(op_assign);
let op_assign = op_assign.literal_syntax();
match self.exec_native_fn_call(global, caches, op_assign, token, hash, args, true, *pos)
match self.exec_native_fn_call(global, caches, op_assign, token, hash1, args, true, pos)
{
Ok(_) => (),
Err(err) if matches!(*err, ERR::ErrorFunctionNotFound(ref f, ..) if f.starts_with(op_assign)) =>
@@ -170,7 +162,7 @@ impl Engine {
let op = op.literal_syntax();
*args[0] = self
.exec_native_fn_call(global, caches, op, token, *hash_op, args, true, *pos)?
.exec_native_fn_call(global, caches, op, token, hash2, args, true, pos)?
.0;
}
Err(err) => return Err(err),
@@ -189,7 +181,7 @@ impl Engine {
}
}
target.propagate_changed_value(op_info.pos)
target.propagate_changed_value(pos)
}
/// Evaluate a statement.