-
Notifications
You must be signed in to change notification settings - Fork 9
/
avm_ops_models.py
47 lines (34 loc) · 985 Bytes
/
avm_ops_models.py
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
import enum
from collections.abc import Sequence
import attrs
class StackType(enum.StrEnum):
uint64 = enum.auto()
bytes = "[]byte"
bool = enum.auto()
address = enum.auto()
address_or_index = enum.auto()
any = enum.auto()
bigint = enum.auto()
box_name = "boxName"
def __repr__(self) -> str:
return f"{type(self).__name__}.{self.name}"
class ImmediateKind(enum.StrEnum):
uint8 = enum.auto()
arg_enum = enum.auto()
def __repr__(self) -> str:
return f"{type(self).__name__}.{self.name}"
@attrs.frozen
class OpSignature:
args: Sequence[StackType]
returns: Sequence[StackType]
@attrs.frozen
class DynamicSignatures:
immediate_index: int
signatures: dict[str, OpSignature]
@attrs.define(kw_only=True)
class AVMOpData:
op_code: str
signature: OpSignature | DynamicSignatures
immediate_types: Sequence[ImmediateKind] = attrs.field(default=())
cost: int | None
min_avm_version: int