neo_solidity/cli/bytecode/bytecode_helpers/storage/structs/
value.rs1fn emit_load_struct_value_from_slot(
2 bytecode: &mut Vec<u8>,
3 fields: &[ir::StructField],
4 use_callt: bool,
5 token_patches: &mut Vec<MethodTokenPatch>,
6) {
7 push_integer_bigint(bytecode, &BigInt::from(fields.len() as u64));
10 bytecode.push(0xC3); for (field_index, field) in fields.iter().enumerate() {
14 bytecode.push(0x4B); push_data(bytecode, &field.key);
18 bytecode.push(0x50); bytecode.push(0x8B); emit_native_contract_call(
21 bytecode,
22 ir::NativeContract::CryptoLib,
23 "keccak256",
24 1,
25 use_callt,
26 token_patches,
27 );
28
29 match &field.ty {
31 ValueType::Struct { fields, .. } => {
32 emit_load_struct_value_from_slot(bytecode, fields, use_callt, token_patches);
33 }
34 _ => {
35 emit_syscall(bytecode, "System.Storage.GetContext");
36 emit_syscall(bytecode, "System.Storage.Get");
37 emit_coerce_storage_value(bytecode, &field.ty);
38 }
39 }
40
41 bytecode.push(0x4B); bytecode.push(0x50); push_integer_bigint(bytecode, &BigInt::from(field_index as u64));
45 bytecode.push(0x50); bytecode.push(0xD0); }
48
49 bytecode.push(0x50); bytecode.push(0x45); }
53
54fn emit_store_struct_value_to_slot(
55 bytecode: &mut Vec<u8>,
56 fields: &[ir::StructField],
57 use_callt: bool,
58 token_patches: &mut Vec<MethodTokenPatch>,
59) {
60 for (field_index, field) in fields.iter().enumerate() {
63 bytecode.push(0x4B); push_data(bytecode, &field.key);
66 bytecode.push(0x50); bytecode.push(0x8B); emit_native_contract_call(
69 bytecode,
70 ir::NativeContract::CryptoLib,
71 "keccak256",
72 1,
73 use_callt,
74 token_patches,
75 );
76
77 bytecode.push(0x4B); push_integer_bigint(bytecode, &BigInt::from(field_index as u64));
81 bytecode.push(0xCE); match &field.ty {
84 ValueType::Struct { fields, .. } => {
85 emit_store_struct_value_to_slot(bytecode, fields, use_callt, token_patches);
86 }
87 _ => {
88 bytecode.push(0x50); emit_syscall(bytecode, "System.Storage.GetContext");
91 emit_syscall(bytecode, "System.Storage.Put");
92 }
93 }
94 }
95
96 bytecode.push(0x45); bytecode.push(0x45); }