ArkScript
A small, fast, functional and scripting language for video games
Instructions.hpp
Go to the documentation of this file.
1 /**
2  * @file Instructions.hpp
3  * @author Alexandre Plateau (lexplt.dev@gmail.com)
4  * @brief The different instructions used by the compiler and virtual machine
5  * @version 0.1
6  * @date 2020-10-27
7  *
8  * @copyright Copyright (c) 2020-2021
9  *
10  */
11 
12 #ifndef ARK_COMPILER_INSTRUCTIONS_HPP
13 #define ARK_COMPILER_INSTRUCTIONS_HPP
14 
15 #include <cinttypes>
16 
17 namespace Ark::internal
18 {
19  /**
20  * @brief The different bytecodes are stored here
21  * @par Adding an operator
22  * It must be referenced as well under include/Ark/Compiler/Common.hpp, in
23  * the operators table. The order of the operators below <code>FIRST_OPERATOR</code>
24  * must be the same as the one in the operators table from the aforementioned file.
25  *
26  */
27  enum Instruction : uint8_t
28  {
29  NOP = 0x00,
32  NUMBER_TYPE = 0x01,
33  STRING_TYPE = 0x02,
34  FUNC_TYPE = 0x03,
36 
37  FIRST_COMMAND = 0x01,
38  LOAD_SYMBOL = 0x01,
39  LOAD_CONST = 0x02,
41  STORE = 0x04,
42  LET = 0x05,
44  JUMP = 0x07,
45  RET = 0x08,
46  HALT = 0x09,
47  CALL = 0x0a,
48  CAPTURE = 0x0b,
49  BUILTIN = 0x0c,
50  MUT = 0x0d,
51  DEL = 0x0e,
52  SAVE_ENV = 0x0f,
53  GET_FIELD = 0x10,
54  PLUGIN = 0x11,
55  LIST = 0x12,
56  APPEND = 0x13,
57  CONCAT = 0x14,
60  POP_LIST = 0x17,
62  POP = 0x19,
63  LAST_COMMAND = 0x19,
64 
66  ADD = 0x20,
67  SUB = 0x21,
68  MUL = 0x22,
69  DIV = 0x23,
70  GT = 0x24,
71  LT = 0x25,
72  LE = 0x26,
73  GE = 0x27,
74  NEQ = 0x28,
75  EQ = 0x29,
76  LEN = 0x2a,
77  EMPTY = 0x2b,
78  TAIL = 0x2c,
79  HEAD = 0x2d,
80  ISNIL = 0x2e,
81  ASSERT = 0x2f,
82  TO_NUM = 0x30,
83  TO_STR = 0x31,
84  AT = 0x32,
85  AND_ = 0x33,
86  OR_ = 0x34,
87  MOD = 0x35,
88  TYPE = 0x36,
89  HASFIELD = 0x37,
90  NOT = 0x38,
91  LAST_OPERATOR = 0x38,
92 
93  LAST_INSTRUCTION = 0x38
94  };
95 }
96 
97 #endif
Instruction
The different bytecodes are stored here.