1use crate::vm::types::{
2 ArgIndex, ArraySize, CodeAddress, ConstantIndex, FunctionIndex, GlobalIndex, LocalIndex,
3};
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7pub enum Instruction {
8 PushConst(ConstantIndex),
9 Pop,
10 Dup,
11
12 Add,
13 Sub,
14 Mul,
15 Div,
16 Mod,
17 Exp,
18 Inc,
19 Dec,
20
21 And,
22 Or,
23 Not,
24 Xor,
25
26 Eq,
27 Ne,
28 Lt,
29 Gt,
30 Le,
31 Ge,
32 StrictEq,
33 StrictNe,
34
35 LoadGlobal(GlobalIndex),
36 StoreGlobal(GlobalIndex),
37 LoadLocal(LocalIndex),
38 StoreLocal(LocalIndex),
39 LoadArg(ArgIndex),
40 LoadThisFunction,
41 LoadThis,
42 LoadClosureVar(String),
43
44 Jump(CodeAddress),
45 JumpIfTrue(CodeAddress),
46 JumpIfFalse(CodeAddress),
47
48 Call(FunctionIndex),
49 Return,
50
51 NewObject,
52 NewArray(ArraySize),
53 SetProperty,
54 SetPropertyAssign,
55 GetProperty,
56
57 TypeOf,
58 InstanceOf,
59 In,
60 Delete,
61 New,
62
63 NewClass,
64 GetPrototype,
65 SetPrototype,
66
67 Await,
68 Yield,
69
70 Throw,
71 Try(CodeAddress, CodeAddress),
72 Catch,
73 Finally,
74
75 Spread,
76 Destructure,
77 OptionalChain,
78 NullishCoalesce,
79
80 PushNull,
81 PushUndefined,
82 PushTrue,
83 PushFalse,
84 PushSymbol(ConstantIndex),
85 PushBigInt(ConstantIndex),
86 CallFunction(FunctionIndex, ArgIndex),
87 CallBuiltin(String, ArgIndex),
88 RemoveObjectProperty,
89 CallObjectMethod(String, ArgIndex),
90 CallArrayMethod(String, ArgIndex),
91 GetArrayLength,
92 RemoveArrayElement(ArraySize),
93 PushArrayElement,
94 PopArrayElement,
95 ShiftArrayElement,
96 UnshiftArrayElement(ArraySize),
97 SliceArray(ArraySize, ArraySize),
98 ConcatArray(ArraySize),
99 IndexOfArray(ArraySize),
100 IncludesArray(ArraySize),
101
102 Halt,
103}