Add generic logical guards and atomic storage publication

This commit is contained in:
2026-10-22 22:24:28 +01:00
parent f7d7c16753
commit d9b9eeb171
17 changed files with 749 additions and 4 deletions
@@ -336,6 +336,22 @@ pub fn assemble(src: &str) -> Result<Vec<u8>, AsmError> {
emit_u32(parse_u32_any(ops)?, &mut out);
}
"INDEX_GUARD" => {
if !ops.is_empty() {
return Err(AsmError::InvalidOperand(line.into()));
}
emit_u16(CoreOpCode::IndexGuard as u16, &mut out);
}
"STORAGE_PUBLISH" => {
let parts: Vec<_> = ops.split(',').map(str::trim).collect();
if parts.len() != 4 {
return Err(AsmError::InvalidOperand(line.into()));
}
emit_u16(CoreOpCode::StoragePublish as u16, &mut out);
for part in parts {
emit_u32(parse_u32_any(part)?, &mut out);
}
}
"STRUCT_GET" | "STRUCT_SET" => {
let (a, b) = parse_keyvals(ops)?;
let (ty, field) = parse_pair(a, "type", b, "field")?;
@@ -345,7 +361,8 @@ pub fn assemble(src: &str) -> Result<Vec<u8>, AsmError> {
emit_u32(ty, &mut out);
emit_u32(field, &mut out);
}
"STRUCT_NEW" | "ARRAY_NEW" | "ARRAY_LEN" | "ARRAY_GET" | "ARRAY_SET" => {
"STRUCT_NEW" | "ARRAY_NEW" | "ARRAY_LEN" | "ARRAY_GET" | "ARRAY_SET"
| "ARRAY_CHECK_LENGTH" | "ARRAY_COPY" => {
if ops.is_empty() {
return Err(AsmError::MissingOperand(line.into()));
}
@@ -354,6 +371,8 @@ pub fn assemble(src: &str) -> Result<Vec<u8>, AsmError> {
"ARRAY_NEW" => CoreOpCode::ArrayNew,
"ARRAY_LEN" => CoreOpCode::ArrayLen,
"ARRAY_GET" => CoreOpCode::ArrayGet,
"ARRAY_CHECK_LENGTH" => CoreOpCode::ArrayCheckLength,
"ARRAY_COPY" => CoreOpCode::ArrayCopy,
_ => CoreOpCode::ArraySet,
};
emit_u16(op as u16, &mut out);