-
Notifications
You must be signed in to change notification settings - Fork 1k
/
ApplicationEngine.OpCodePrices.cs
217 lines (215 loc) · 7.81 KB
/
ApplicationEngine.OpCodePrices.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// Copyright (C) 2015-2022 The Neo Project.
//
// The neo is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project or http://www.opensource.org/licenses/mit-license.php
// for more details.
//
// Redistribution and use in source and binary forms with or without
// modifications are permitted.
using Neo.VM;
using System.Collections.Generic;
namespace Neo.SmartContract
{
partial class ApplicationEngine
{
/// <summary>
/// The prices of all the opcodes.
/// </summary>
public static readonly IReadOnlyDictionary<OpCode, long> OpCodePrices = new Dictionary<OpCode, long>
{
[OpCode.PUSHINT8] = 1 << 0,
[OpCode.PUSHINT16] = 1 << 0,
[OpCode.PUSHINT32] = 1 << 0,
[OpCode.PUSHINT64] = 1 << 0,
[OpCode.PUSHINT128] = 1 << 2,
[OpCode.PUSHINT256] = 1 << 2,
[OpCode.PUSHA] = 1 << 2,
[OpCode.PUSHNULL] = 1 << 0,
[OpCode.PUSHDATA1] = 1 << 3,
[OpCode.PUSHDATA2] = 1 << 9,
[OpCode.PUSHDATA4] = 1 << 12,
[OpCode.PUSHM1] = 1 << 0,
[OpCode.PUSH0] = 1 << 0,
[OpCode.PUSH1] = 1 << 0,
[OpCode.PUSH2] = 1 << 0,
[OpCode.PUSH3] = 1 << 0,
[OpCode.PUSH4] = 1 << 0,
[OpCode.PUSH5] = 1 << 0,
[OpCode.PUSH6] = 1 << 0,
[OpCode.PUSH7] = 1 << 0,
[OpCode.PUSH8] = 1 << 0,
[OpCode.PUSH9] = 1 << 0,
[OpCode.PUSH10] = 1 << 0,
[OpCode.PUSH11] = 1 << 0,
[OpCode.PUSH12] = 1 << 0,
[OpCode.PUSH13] = 1 << 0,
[OpCode.PUSH14] = 1 << 0,
[OpCode.PUSH15] = 1 << 0,
[OpCode.PUSH16] = 1 << 0,
[OpCode.NOP] = 1 << 0,
[OpCode.JMP] = 1 << 1,
[OpCode.JMP_L] = 1 << 1,
[OpCode.JMPIF] = 1 << 1,
[OpCode.JMPIF_L] = 1 << 1,
[OpCode.JMPIFNOT] = 1 << 1,
[OpCode.JMPIFNOT_L] = 1 << 1,
[OpCode.JMPEQ] = 1 << 1,
[OpCode.JMPEQ_L] = 1 << 1,
[OpCode.JMPNE] = 1 << 1,
[OpCode.JMPNE_L] = 1 << 1,
[OpCode.JMPGT] = 1 << 1,
[OpCode.JMPGT_L] = 1 << 1,
[OpCode.JMPGE] = 1 << 1,
[OpCode.JMPGE_L] = 1 << 1,
[OpCode.JMPLT] = 1 << 1,
[OpCode.JMPLT_L] = 1 << 1,
[OpCode.JMPLE] = 1 << 1,
[OpCode.JMPLE_L] = 1 << 1,
[OpCode.CALL] = 1 << 9,
[OpCode.CALL_L] = 1 << 9,
[OpCode.CALLA] = 1 << 9,
[OpCode.CALLT] = 1 << 15,
[OpCode.ABORT] = 0,
[OpCode.ASSERT] = 1 << 0,
[OpCode.THROW] = 1 << 9,
[OpCode.TRY] = 1 << 2,
[OpCode.TRY_L] = 1 << 2,
[OpCode.ENDTRY] = 1 << 2,
[OpCode.ENDTRY_L] = 1 << 2,
[OpCode.ENDFINALLY] = 1 << 2,
[OpCode.RET] = 0,
[OpCode.SYSCALL] = 0,
[OpCode.DEPTH] = 1 << 1,
[OpCode.DROP] = 1 << 1,
[OpCode.NIP] = 1 << 1,
[OpCode.XDROP] = 1 << 4,
[OpCode.CLEAR] = 1 << 4,
[OpCode.DUP] = 1 << 1,
[OpCode.OVER] = 1 << 1,
[OpCode.PICK] = 1 << 1,
[OpCode.TUCK] = 1 << 1,
[OpCode.SWAP] = 1 << 1,
[OpCode.ROT] = 1 << 1,
[OpCode.ROLL] = 1 << 4,
[OpCode.REVERSE3] = 1 << 1,
[OpCode.REVERSE4] = 1 << 1,
[OpCode.REVERSEN] = 1 << 4,
[OpCode.INITSSLOT] = 1 << 4,
[OpCode.INITSLOT] = 1 << 6,
[OpCode.LDSFLD0] = 1 << 1,
[OpCode.LDSFLD1] = 1 << 1,
[OpCode.LDSFLD2] = 1 << 1,
[OpCode.LDSFLD3] = 1 << 1,
[OpCode.LDSFLD4] = 1 << 1,
[OpCode.LDSFLD5] = 1 << 1,
[OpCode.LDSFLD6] = 1 << 1,
[OpCode.LDSFLD] = 1 << 1,
[OpCode.STSFLD0] = 1 << 1,
[OpCode.STSFLD1] = 1 << 1,
[OpCode.STSFLD2] = 1 << 1,
[OpCode.STSFLD3] = 1 << 1,
[OpCode.STSFLD4] = 1 << 1,
[OpCode.STSFLD5] = 1 << 1,
[OpCode.STSFLD6] = 1 << 1,
[OpCode.STSFLD] = 1 << 1,
[OpCode.LDLOC0] = 1 << 1,
[OpCode.LDLOC1] = 1 << 1,
[OpCode.LDLOC2] = 1 << 1,
[OpCode.LDLOC3] = 1 << 1,
[OpCode.LDLOC4] = 1 << 1,
[OpCode.LDLOC5] = 1 << 1,
[OpCode.LDLOC6] = 1 << 1,
[OpCode.LDLOC] = 1 << 1,
[OpCode.STLOC0] = 1 << 1,
[OpCode.STLOC1] = 1 << 1,
[OpCode.STLOC2] = 1 << 1,
[OpCode.STLOC3] = 1 << 1,
[OpCode.STLOC4] = 1 << 1,
[OpCode.STLOC5] = 1 << 1,
[OpCode.STLOC6] = 1 << 1,
[OpCode.STLOC] = 1 << 1,
[OpCode.LDARG0] = 1 << 1,
[OpCode.LDARG1] = 1 << 1,
[OpCode.LDARG2] = 1 << 1,
[OpCode.LDARG3] = 1 << 1,
[OpCode.LDARG4] = 1 << 1,
[OpCode.LDARG5] = 1 << 1,
[OpCode.LDARG6] = 1 << 1,
[OpCode.LDARG] = 1 << 1,
[OpCode.STARG0] = 1 << 1,
[OpCode.STARG1] = 1 << 1,
[OpCode.STARG2] = 1 << 1,
[OpCode.STARG3] = 1 << 1,
[OpCode.STARG4] = 1 << 1,
[OpCode.STARG5] = 1 << 1,
[OpCode.STARG6] = 1 << 1,
[OpCode.STARG] = 1 << 1,
[OpCode.NEWBUFFER] = 1 << 8,
[OpCode.MEMCPY] = 1 << 11,
[OpCode.CAT] = 1 << 11,
[OpCode.SUBSTR] = 1 << 11,
[OpCode.LEFT] = 1 << 11,
[OpCode.RIGHT] = 1 << 11,
[OpCode.INVERT] = 1 << 2,
[OpCode.AND] = 1 << 3,
[OpCode.OR] = 1 << 3,
[OpCode.XOR] = 1 << 3,
[OpCode.EQUAL] = 1 << 5,
[OpCode.NOTEQUAL] = 1 << 5,
[OpCode.SIGN] = 1 << 2,
[OpCode.ABS] = 1 << 2,
[OpCode.NEGATE] = 1 << 2,
[OpCode.INC] = 1 << 2,
[OpCode.DEC] = 1 << 2,
[OpCode.ADD] = 1 << 3,
[OpCode.SUB] = 1 << 3,
[OpCode.MUL] = 1 << 3,
[OpCode.DIV] = 1 << 3,
[OpCode.MOD] = 1 << 3,
[OpCode.POW] = 1 << 6,
[OpCode.SQRT] = 1 << 6,
[OpCode.MODMUL] = 1 << 5,
[OpCode.MODPOW] = 1 << 11,
[OpCode.SHL] = 1 << 3,
[OpCode.SHR] = 1 << 3,
[OpCode.NOT] = 1 << 2,
[OpCode.BOOLAND] = 1 << 3,
[OpCode.BOOLOR] = 1 << 3,
[OpCode.NZ] = 1 << 2,
[OpCode.NUMEQUAL] = 1 << 3,
[OpCode.NUMNOTEQUAL] = 1 << 3,
[OpCode.LT] = 1 << 3,
[OpCode.LE] = 1 << 3,
[OpCode.GT] = 1 << 3,
[OpCode.GE] = 1 << 3,
[OpCode.MIN] = 1 << 3,
[OpCode.MAX] = 1 << 3,
[OpCode.WITHIN] = 1 << 3,
[OpCode.PACKMAP] = 1 << 11,
[OpCode.PACKSTRUCT] = 1 << 11,
[OpCode.PACK] = 1 << 11,
[OpCode.UNPACK] = 1 << 11,
[OpCode.NEWARRAY0] = 1 << 4,
[OpCode.NEWARRAY] = 1 << 9,
[OpCode.NEWARRAY_T] = 1 << 9,
[OpCode.NEWSTRUCT0] = 1 << 4,
[OpCode.NEWSTRUCT] = 1 << 9,
[OpCode.NEWMAP] = 1 << 3,
[OpCode.SIZE] = 1 << 2,
[OpCode.HASKEY] = 1 << 6,
[OpCode.KEYS] = 1 << 4,
[OpCode.VALUES] = 1 << 13,
[OpCode.PICKITEM] = 1 << 6,
[OpCode.APPEND] = 1 << 13,
[OpCode.SETITEM] = 1 << 13,
[OpCode.REVERSEITEMS] = 1 << 13,
[OpCode.REMOVE] = 1 << 4,
[OpCode.CLEARITEMS] = 1 << 4,
[OpCode.POPITEM] = 1 << 4,
[OpCode.ISNULL] = 1 << 1,
[OpCode.ISTYPE] = 1 << 1,
[OpCode.CONVERT] = 1 << 13,
};
}
}