neo_solidity/runtime/
spec.rs1use once_cell::sync::Lazy;
4use std::collections::HashMap;
5
6use crate::codegen::interop_id_bytes;
7
8#[derive(Debug, Clone, Copy)]
10pub struct OpcodeSpec {
11 pub code: u8,
12 pub name: &'static str,
13 pub gas: u64,
14}
15
16impl OpcodeSpec {
17 pub fn is_push(&self) -> bool {
19 self.code <= 0x20 || (self.code >= 0x0C && self.code <= 0x0E)
20 }
21
22 pub fn is_jump(&self) -> bool {
24 self.code >= 0x22 && self.code <= 0x33
25 }
26
27 pub fn is_call(&self) -> bool {
29 self.code >= 0x34 && self.code <= 0x37
30 }
31}
32
33#[derive(Debug, Clone, Copy)]
35pub struct SyscallSpec {
36 pub id: [u8; 4],
37 pub name: &'static str,
38}
39
40impl SyscallSpec {
41 pub fn id_hex(&self) -> String {
43 hex::encode(self.id)
44 }
45}
46
47#[derive(Debug, Clone, Copy)]
49pub struct NativeContractSpec {
50 pub hash: [u8; 20],
51 pub name: &'static str,
52}
53
54impl NativeContractSpec {
55 pub fn hash_hex(&self) -> String {
57 hex::encode(self.hash)
58 }
59}
60
61include!("spec/opcodes.rs");
62include!("spec/syscalls.rs");
63include!("spec/native_contracts.rs");
64include!("spec/gas.rs");
65
66#[cfg(test)]
67mod tests;