You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: include/Ark/Compiler/Instructions.hpp
+70-66Lines changed: 70 additions & 66 deletions
Original file line number
Diff line number
Diff line change
@@ -137,231 +137,234 @@ namespace Ark::internal
137
137
// @role Remove the top of the stack
138
138
POP = 0x1b,
139
139
140
-
// @role Duplicate the top of the stack
141
-
DUP = 0x1c,
140
+
// @role Pop the top of the stack, if it's false, jump to an address
141
+
SHORTCIRCUIT_AND = 0x1c,
142
+
143
+
// @role Pop the top of the stack, if it's true, jump to an address
144
+
SHORTCIRCUIT_OR = 0x1d,
142
145
143
146
// @role Create a new local scope
144
-
CREATE_SCOPE = 0x1d,
147
+
CREATE_SCOPE = 0x1e,
145
148
146
149
// @role Reset the current scope so that it is empty, and jump to a given location
147
-
RESET_SCOPE_JUMP = 0x1e,
150
+
RESET_SCOPE_JUMP = 0x1f,
148
151
149
152
// @role Destroy the last local scope
150
-
POP_SCOPE = 0x1f,
153
+
POP_SCOPE = 0x20,
151
154
152
-
FIRST_OPERATOR = 0x20,
155
+
FIRST_OPERATOR = 0x21,
153
156
154
157
// @role Push #[code TS1 + TS]
155
-
ADD = 0x20,
158
+
ADD = 0x21,
156
159
157
160
// @role Push #[code TS1 - TS]
158
-
SUB = 0x21,
161
+
SUB = 0x22,
159
162
160
163
// @role Push #[code TS1 * TS]
161
-
MUL = 0x22,
164
+
MUL = 0x23,
162
165
163
166
// @role Push #[code TS1 / TS]
164
-
DIV = 0x23,
167
+
DIV = 0x24,
165
168
166
169
// @role Push #[code TS1 > TS]
167
-
GT = 0x24,
170
+
GT = 0x25,
168
171
169
172
// @role Push #[code TS1 < TS]
170
-
LT = 0x25,
173
+
LT = 0x26,
171
174
172
175
// @role Push #[code TS1 <= TS]
173
-
LE = 0x26,
176
+
LE = 0x27,
174
177
175
178
// @role Push #[code TS1 >= TS]
176
-
GE = 0x27,
179
+
GE = 0x28,
177
180
178
181
// @role Push #[code TS1 != TS]
179
-
NEQ = 0x28,
182
+
NEQ = 0x29,
180
183
181
184
// @role Push #[code TS1 == TS]
182
-
EQ = 0x29,
185
+
EQ = 0x2a,
183
186
184
187
// @role Push #[code len(TS)], TS must be a list
185
-
LEN = 0x2a,
188
+
LEN = 0x2b,
186
189
187
190
// @role Push #[code empty?(TS)], TS must be a list or string
188
-
EMPTY = 0x2b,
191
+
EMPTY = 0x2c,
189
192
190
193
// @role Push #[code tail(TS)], all the elements of TS except the first one. TS must be a list or string
191
-
TAIL = 0x2c,
194
+
TAIL = 0x2d,
192
195
193
196
// @role Push #[code head(TS)], the first element of TS or nil if empty. TS must be a list or string
194
-
HEAD = 0x2d,
197
+
HEAD = 0x2e,
195
198
196
199
// @role Push true if TS is nil, false otherwise
197
-
ISNIL = 0x2e,
200
+
ISNIL = 0x2f,
198
201
199
202
// @role Throw an exception if TS1 is false, and display TS (must be a string). Do not push anything on the stack
200
-
ASSERT = 0x2f,
203
+
ASSERT = 0x30,
201
204
202
205
// @role Convert TS to number (must be a string)
203
-
TO_NUM = 0x30,
206
+
TO_NUM = 0x31,
204
207
205
208
// @role Convert TS to string
206
-
TO_STR = 0x31,
209
+
TO_STR = 0x32,
207
210
208
211
// @role Push the value at index TS (must be a number) in TS1, which must be a list or string
209
-
AT = 0x32,
212
+
AT = 0x33,
210
213
211
214
// @role Push the value at index TS (must be a number), inside the list or string at index TS1 (must be a number) in the list at TS2
212
-
AT_AT = 0x33,
215
+
AT_AT = 0x34,
213
216
214
217
// @role Push #[code TS1 % TS]
215
-
MOD = 0x34,
218
+
MOD = 0x35,
216
219
217
220
// @role Push the type of TS as a string
218
-
TYPE = 0x35,
221
+
TYPE = 0x36,
219
222
220
223
// @role Check if TS1 is a closure field of TS. TS must be a Closure, TS1 a String
221
-
HASFIELD = 0x36,
224
+
HASFIELD = 0x37,
222
225
223
226
// @role Push #[code !TS]
224
-
NOT = 0x37,
227
+
NOT = 0x38,
225
228
226
229
// @args constant id, constant id
227
230
// @role Load two consts (#[code primary] then #[code secondary]) on the stack in one instruction
228
-
LOAD_CONST_LOAD_CONST = 0x38,
231
+
LOAD_CONST_LOAD_CONST = 0x39,
229
232
230
233
// @args constant id, symbol id
231
234
// @role Load const #[code primary] into the symbol #[code secondary] (create a variable)
232
-
LOAD_CONST_STORE = 0x39,
235
+
LOAD_CONST_STORE = 0x3a,
233
236
234
237
// @args constant id, symbol id
235
238
// @role Load const #[code primary] into the symbol #[code secondary] (search for the variable with the given symbol id)
236
-
LOAD_CONST_SET_VAL = 0x3a,
239
+
LOAD_CONST_SET_VAL = 0x3b,
237
240
238
241
// @args symbol id, symbol id
239
242
// @role Store the value of the symbol #[code primary] into a new variable #[code secondary]
240
-
STORE_FROM = 0x3b,
243
+
STORE_FROM = 0x3c,
241
244
242
245
// @args symbol index, symbol id
243
246
// @role Store the value of the symbol #[code primary] into a new variable #[code secondary]
244
-
STORE_FROM_INDEX = 0x3c,
247
+
STORE_FROM_INDEX = 0x3d,
245
248
246
249
// @args symbol id, symbol id
247
250
// @role Store the value of the symbol #[code primary] into an existing variable #[code secondary]
248
-
SET_VAL_FROM = 0x3d,
251
+
SET_VAL_FROM = 0x3e,
249
252
250
253
// @args symbol index, symbol id
251
254
// @role Store the value of the symbol #[code primary] into an existing variable #[code secondary]
252
-
SET_VAL_FROM_INDEX = 0x3e,
255
+
SET_VAL_FROM_INDEX = 0x3f,
253
256
254
257
// @args symbol id, count
255
258
// @role Increment the variable #[code primary] by #[code count] and push its value on the stack
256
-
INCREMENT = 0x3f,
259
+
INCREMENT = 0x40,
257
260
258
261
// @args symbol index, count
259
262
// @role Increment the variable #[code primary] by #[code count] and push its value on the stack
260
-
INCREMENT_BY_INDEX = 0x40,
263
+
INCREMENT_BY_INDEX = 0x41,
261
264
262
265
// @args symbol id, count
263
266
// @role Decrement the variable #[code primary] by #[code count] and push its value on the stack
264
-
DECREMENT = 0x41,
267
+
DECREMENT = 0x42,
265
268
266
269
// @args symbol index, count
267
270
// @role Decrement the variable #[code primary] by #[code count] and push its value on the stack
268
-
DECREMENT_BY_INDEX = 0x42,
271
+
DECREMENT_BY_INDEX = 0x43,
269
272
270
273
// @args symbol id, symbol id
271
274
// @role Load the symbol #[code primary], compute its tail, store it in a new variable #[code secondary]
272
-
STORE_TAIL = 0x43,
275
+
STORE_TAIL = 0x44,
273
276
274
277
// @args symbol index, symbol id
275
278
// @role Load the symbol #[code primary], compute its tail, store it in a new variable #[code secondary]
276
-
STORE_TAIL_BY_INDEX = 0x44,
279
+
STORE_TAIL_BY_INDEX = 0x45,
277
280
278
281
// @args symbol id, symbol id
279
282
// @role Load the symbol #[code primary], compute its head, store it in a new variable #[code secondary]
280
-
STORE_HEAD = 0x45,
283
+
STORE_HEAD = 0x46,
281
284
282
285
// @args symbol index, symbol id
283
286
// @role Load the symbol #[code primary], compute its head, store it in a new variable #[code secondary]
284
-
STORE_HEAD_BY_INDEX = 0x46,
287
+
STORE_HEAD_BY_INDEX = 0x47,
285
288
286
289
// @args symbol id, symbol id
287
290
// @role Load the symbol #[code primary], compute its tail, store it in an existing variable #[code secondary]
288
-
SET_VAL_TAIL = 0x47,
291
+
SET_VAL_TAIL = 0x48,
289
292
290
293
// @args symbol index, symbol id
291
294
// @role Load the symbol #[code primary], compute its tail, store it in an existing variable #[code secondary]
292
-
SET_VAL_TAIL_BY_INDEX = 0x48,
295
+
SET_VAL_TAIL_BY_INDEX = 0x49,
293
296
294
297
// @args symbol id, symbol id
295
298
// @role Load the symbol #[code primary], compute its head, store it in an existing variable #[code secondary]
296
-
SET_VAL_HEAD = 0x49,
299
+
SET_VAL_HEAD = 0x4a,
297
300
298
301
// @args symbol index, symbol id
299
302
// @role Load the symbol #[code primary], compute its head, store it in an existing variable #[code secondary]
300
-
SET_VAL_HEAD_BY_INDEX = 0x4a,
303
+
SET_VAL_HEAD_BY_INDEX = 0x4b,
301
304
302
305
// @args builtin id, argument count
303
306
// @role Call a builtin by its id in #[code primary], with #[code secondary] arguments. Bypass the stack size check because we do not push IP/PP since builtins calls do not alter the stack
304
-
CALL_BUILTIN = 0x4b,
307
+
CALL_BUILTIN = 0x4c,
305
308
306
309
// @args constant id, absolute address to jump to
307
310
// @role Compare #[code TS < constant], if the comparison fails, jump to the given address. Otherwise, does nothing
308
-
LT_CONST_JUMP_IF_FALSE = 0x4c,
311
+
LT_CONST_JUMP_IF_FALSE = 0x4d,
309
312
310
313
// @args constant id, absolute address to jump to
311
314
// @role Compare #[code TS < constant], if the comparison succeeds, jump to the given address. Otherwise, does nothing
312
-
LT_CONST_JUMP_IF_TRUE = 0x4d,
315
+
LT_CONST_JUMP_IF_TRUE = 0x4e,
313
316
314
317
// @args symbol id, absolute address to jump to
315
318
// @role Compare #[code TS < symbol], if the comparison fails, jump to the given address. Otherwise, does nothing
316
-
LT_SYM_JUMP_IF_FALSE = 0x4e,
319
+
LT_SYM_JUMP_IF_FALSE = 0x4f,
317
320
318
321
// @args constant id, absolute address to jump to
319
322
// @role Compare #[code TS > constant], if the comparison succeeds, jump to the given address. Otherwise, does nothing
320
-
GT_CONST_JUMP_IF_TRUE = 0x4f,
323
+
GT_CONST_JUMP_IF_TRUE = 0x50,
321
324
322
325
// @args constant id, absolute address to jump to
323
326
// @role Compare #[code TS > constant], if the comparison fails, jump to the given address. Otherwise, does nothing
324
-
GT_CONST_JUMP_IF_FALSE = 0x50,
327
+
GT_CONST_JUMP_IF_FALSE = 0x51,
325
328
326
329
// @args symbol id, absolute address to jump to
327
330
// @role Compare #[code TS > symbol], if the comparison fails, jump to the given address. Otherwise, does nothing
328
-
GT_SYM_JUMP_IF_FALSE = 0x51,
331
+
GT_SYM_JUMP_IF_FALSE = 0x52,
329
332
330
333
// @args constant id, absolute address to jump to
331
334
// @role Compare #[code TS == constant], if the comparison succeeds, jump to the given address. Otherwise, does nothing
332
-
EQ_CONST_JUMP_IF_TRUE = 0x52,
335
+
EQ_CONST_JUMP_IF_TRUE = 0x53,
333
336
334
337
// @args symbol index, absolute address to jump to
335
338
// @role Compare #[code TS == symbol], if the comparison succeeds, jump to the given address. Otherwise, does nothing
336
-
EQ_SYM_INDEX_JUMP_IF_TRUE = 0x53,
339
+
EQ_SYM_INDEX_JUMP_IF_TRUE = 0x54,
337
340
338
341
// @args constant id, absolute address to jump to
339
342
// @role Compare #[code TS != constant], if the comparison succeeds, jump to the given address. Otherwise, does nothing
340
-
NEQ_CONST_JUMP_IF_TRUE = 0x54,
343
+
NEQ_CONST_JUMP_IF_TRUE = 0x55,
341
344
342
345
// @args symbol id, absolute address to jump to
343
346
// @role Compare #[code TS != symbol], if the comparison fails, jump to the given address. Otherwise, does nothing
344
-
NEQ_SYM_JUMP_IF_FALSE = 0x55,
347
+
NEQ_SYM_JUMP_IF_FALSE = 0x56,
345
348
346
349
// @args symbol id, argument count
347
350
// @role Call a symbol by its id in #[code primary], with #[code secondary] arguments
348
-
CALL_SYMBOL = 0x56,
351
+
CALL_SYMBOL = 0x57,
349
352
350
353
// @args symbol id, field id in symbols table
351
354
// @role Push the field of a given symbol (which has to be a closure) on the stack
352
-
GET_FIELD_FROM_SYMBOL = 0x57,
355
+
GET_FIELD_FROM_SYMBOL = 0x58,
353
356
354
357
// @args symbol index, field id in symbols table
355
358
// @role Push the field of a given symbol (which has to be a closure) on the stack
0 commit comments