neo_solidity/cli/bytecode/bytecode_helpers/storage/structs/
fields.rs

1fn emit_load_struct_field(
2    bytecode: &mut Vec<u8>,
3    module: &ir::Module,
4    state_index: usize,
5    key_types: &[ValueType],
6    field: StructFieldAccess<'_>,
7    use_callt: bool,
8    token_patches: &mut Vec<MethodTokenPatch>,
9) {
10    emit_struct_field_slot(
11        bytecode,
12        module,
13        state_index,
14        key_types,
15        field.field_keys,
16        use_callt,
17        token_patches,
18    );
19
20    match field.ty {
21        ValueType::Struct { fields, .. } => {
22            emit_load_struct_value_from_slot(bytecode, fields, use_callt, token_patches);
23        }
24        _ => {
25            emit_syscall(bytecode, "System.Storage.GetContext");
26            emit_syscall(bytecode, "System.Storage.Get");
27            emit_coerce_storage_value(bytecode, field.ty);
28        }
29    }
30}
31
32fn emit_store_struct_field(
33    bytecode: &mut Vec<u8>,
34    module: &ir::Module,
35    state_index: usize,
36    key_types: &[ValueType],
37    field: StructFieldAccess<'_>,
38    use_callt: bool,
39    token_patches: &mut Vec<MethodTokenPatch>,
40) {
41    emit_struct_field_slot(
42        bytecode,
43        module,
44        state_index,
45        key_types,
46        field.field_keys,
47        use_callt,
48        token_patches,
49    );
50    match field.ty {
51        ValueType::Struct { fields, .. } => {
52            bytecode.push(0x50); // SWAP -> [slot, value]
53            emit_store_struct_value_to_slot(bytecode, fields, use_callt, token_patches);
54        }
55        _ => {
56            emit_syscall(bytecode, "System.Storage.GetContext");
57            emit_syscall(bytecode, "System.Storage.Put");
58        }
59    }
60}