1use crate::namespace::types::Base;
2use strum::{AsRefStr, EnumIter, EnumString};
3
4#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, EnumString, AsRefStr)]
5#[strum(serialize_all = "snake_case")]
6pub enum ValueMethod {
7 ToMem,
8 AbiEncode,
9}
10
11#[derive(
12 Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, EnumString, AsRefStr, EnumIter,
13)]
14#[strum(serialize_all = "snake_case")]
15pub enum GlobalFunction {
16 Keccak256,
17}
18
19#[derive(Debug, Copy, Clone, PartialEq, Eq, EnumString, AsRefStr)]
20#[strum(serialize_all = "snake_case")]
21pub enum ContractTypeMethod {
22 Create,
23 Create2,
24}
25
26impl ContractTypeMethod {
27 pub fn arg_count(&self) -> usize {
28 match self {
29 ContractTypeMethod::Create => 2,
30 ContractTypeMethod::Create2 => 3,
31 }
32 }
33}
34
35#[allow(non_camel_case_types)]
37#[derive(
38 Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, EnumString, AsRefStr, EnumIter,
39)]
40pub enum Intrinsic {
41 __stop, __add, __sub, __mul, __div, __sdiv, __mod, __smod, __exp, __not, __lt, __gt, __slt, __sgt, __eq, __iszero, __and, __or, __xor, __byte, __shl, __shr, __sar, __addmod, __mulmod, __signextend, __keccak256, __pc, __pop, __mload, __mstore, __mstore8, __sload, __sstore, __msize, __gas, __address, __balance, __selfbalance, __caller, __callvalue, __calldataload, __calldatasize, __calldatacopy, __codesize, __codecopy, __extcodesize, __extcodecopy, __returndatasize, __returndatacopy, __extcodehash, __create, __create2, __call, __callcode, __delegatecall, __staticcall, __return, __revert, __selfdestruct, __invalid, __log0, __log1, __log2, __log3, __log4, __chainid, __basefee, __origin, __gasprice, __blockhash, __coinbase, __timestamp, __number, __prevrandao, __gaslimit, }
118
119impl Intrinsic {
120 pub fn arg_count(&self) -> usize {
121 use Intrinsic::*;
122 match self {
123 __stop | __basefee | __origin | __gasprice | __coinbase | __timestamp | __number
124 | __prevrandao | __gaslimit | __pc | __msize | __gas | __address | __selfbalance
125 | __caller | __callvalue | __calldatasize | __codesize | __returndatasize
126 | __invalid | __chainid => 0,
127
128 __not | __iszero | __pop | __mload | __balance | __sload | __calldataload
129 | __extcodesize | __extcodehash | __selfdestruct | __blockhash => 1,
130
131 __add | __sub | __mul | __div | __sdiv | __mod | __smod | __exp | __lt | __gt
132 | __slt | __sgt | __eq | __and | __or | __xor | __byte | __shl | __shr | __sar
133 | __signextend | __keccak256 | __mstore | __mstore8 | __sstore | __return
134 | __revert | __log0 => 2,
135
136 __addmod | __mulmod | __calldatacopy | __codecopy | __returndatacopy | __create
137 | __log1 => 3,
138 __extcodecopy | __create2 | __log2 => 4,
139 __log3 => 5,
140 __delegatecall | __staticcall | __log4 => 6,
141 __call | __callcode => 7,
142 }
143 }
144
145 pub fn return_type(&self) -> Base {
146 use Intrinsic::*;
147 match self {
148 __stop | __pop | __mstore | __mstore8 | __sstore | __calldatacopy | __codecopy
149 | __extcodecopy | __returndatacopy | __return | __revert | __selfdestruct
150 | __invalid | __log0 | __log1 | __log2 | __log3 | __log4 => Base::Unit,
151 _ => Base::u256(),
152 }
153 }
154}