evmil/il/term.rs
1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5// http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12
13// ============================================================================
14// Terms
15// ============================================================================
16
17#[derive(Clone)]
18pub enum Term {
19 // Statements
20 Assert(Box<Term>),
21 Assignment(Box<Term>, Box<Term>),
22 Goto(String),
23 IfGoto(Box<Term>, String),
24 Label(String),
25 Succeed(Vec<Term>),
26 Revert(Vec<Term>),
27 Return(Vec<Term>),
28 Fail,
29 Stop,
30 // Expressions
31 Binary(BinOp, Box<Term>, Box<Term>),
32 ArrayAccess(Box<Term>, Box<Term>),
33 MemoryAccess(Region),
34 Call(String,Vec<Term>),
35 // Values
36 Int(Vec<u8>),
37 Hex(Vec<u8>),
38}
39
40// ============================================================================
41// Binary Operators
42// ============================================================================
43
44#[derive(Copy, Clone, PartialEq, Debug)]
45pub enum BinOp {
46 // Arithmetic
47 Add,
48 Subtract,
49 Divide,
50 Multiply,
51 Remainder,
52 // Comparators
53 Equals,
54 NotEquals,
55 LessThan,
56 LessThanOrEquals,
57 GreaterThan,
58 GreaterThanOrEquals,
59 // Logical
60 LogicalAnd,
61 LogicalOr,
62}
63
64// ============================================================================
65// Memory Regions
66// ============================================================================
67
68#[derive(Copy, Clone, PartialEq, Debug)]
69pub enum Region {
70 Memory,
71 Storage,
72 CallData,
73}