neo_solidity/cli/bytecode/bytecode_builtins/builtin_call/
storage.rs

1fn emit_storage_find(bytecode: &mut Vec<u8>, arg_count: usize) {
2    // Stack input: [prefix] or [prefix, options]
3    // Neo N3 Find signature: Find(context, prefix, options)
4    // Stack order for syscall: [options, prefix, context]
5    if arg_count == 1 {
6        bytecode.push(0x10); // PUSH0 (FindOptions.None)
7        bytecode.push(0x50); // SWAP -> [options, prefix]
8    } else {
9        // Assume the last arg is `options`.
10        bytecode.push(0x50); // SWAP -> [options, prefix]
11    }
12    emit_syscall(bytecode, "System.Storage.GetContext");
13    emit_syscall(bytecode, "System.Storage.Find");
14}
15
16fn emit_storage_put(bytecode: &mut Vec<u8>) {
17    // Stack input: [key, value]
18    // Stack order for System.Storage.Put: [value, key, context]
19    bytecode.push(0x50); // SWAP -> [value, key]
20    emit_syscall(bytecode, "System.Storage.GetContext");
21    emit_syscall(bytecode, "System.Storage.Put");
22    bytecode.push(0x11); // PUSH1 to avoid stack underflow on statement calls
23}
24
25fn emit_storage_get(bytecode: &mut Vec<u8>) {
26    emit_syscall(bytecode, "System.Storage.GetReadOnlyContext");
27    emit_syscall(bytecode, "System.Storage.Get");
28}
29
30fn emit_storage_delete(bytecode: &mut Vec<u8>) {
31    emit_syscall(bytecode, "System.Storage.GetContext");
32    emit_syscall(bytecode, "System.Storage.Delete");
33    bytecode.push(0x11); // PUSH1
34}