Add generic logical guards and atomic storage publication
This commit is contained in:
@@ -133,6 +133,38 @@ impl DecodedInstr<'_> {
|
||||
};
|
||||
(source_layout.storage.slots, pushes)
|
||||
}
|
||||
Op::ArrayCheckLength | Op::ArrayCopy | Op::StoragePublish => {
|
||||
let (array, owner, first, second) = if self.opcode == Op::StoragePublish {
|
||||
let [a, o, f, s] = self.imm_u32x4().map_err(|_| malformed())?;
|
||||
(a, o, f, s)
|
||||
} else {
|
||||
(self.imm_u32().map_err(|_| malformed())?, 0, 0, 0)
|
||||
};
|
||||
let (_, layout) = type_info(array)?;
|
||||
let element = layout.array.ok_or_else(|| bad_category(array))?.element_type_id;
|
||||
let width = registry.type_layout(element).unwrap().storage.slots;
|
||||
match self.opcode {
|
||||
Op::ArrayCheckLength => (1, 0),
|
||||
Op::ArrayCopy => (5, 0),
|
||||
_ => {
|
||||
let (_, layout) = type_info(owner)?;
|
||||
let instance =
|
||||
layout.instance.as_ref().ok_or_else(|| bad_category(owner))?;
|
||||
if first == second {
|
||||
return Err(bad_category(owner).member(second));
|
||||
}
|
||||
let mut slots = 8 + width;
|
||||
for field in [first, second] {
|
||||
let f = instance
|
||||
.fields
|
||||
.get(field as usize)
|
||||
.ok_or_else(|| bad_category(owner).member(field))?;
|
||||
slots += registry.type_layout(f.type_id).unwrap().storage.slots;
|
||||
}
|
||||
(slots, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
Op::StructNew
|
||||
| Op::StructGet
|
||||
| Op::StructSet
|
||||
|
||||
Reference in New Issue
Block a user