Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/Common/include/Luau/Bytecode.h
2727 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#pragma once
3
4
// clang-format off
5
6
// This header contains the bytecode definition for Luau interpreter
7
// Creating the bytecode is outside the scope of this file and is handled by bytecode builder (BytecodeBuilder.h) and bytecode compiler (Compiler.h)
8
// Note that ALL enums declared in this file are order-sensitive since the values are baked into bytecode that needs to be processed by legacy clients.
9
10
// # Bytecode definitions
11
// Bytecode instructions are using "word code" - each instruction is one or many 32-bit words.
12
// The first word in the instruction is always the instruction header, and *must* contain the opcode (enum below) in the least significant byte.
13
//
14
// Instruction word can be encoded using one of the following encodings:
15
// ABC - least-significant byte for the opcode, followed by three bytes, A, B and C; each byte declares a register index, small index into some other table or an unsigned integral value
16
// AD - least-significant byte for the opcode, followed by A byte, followed by D half-word (16-bit integer). D is a signed integer that commonly specifies constant table index or jump offset
17
// E - least-significant byte for the opcode, followed by E (24-bit integer). E is a signed integer that commonly specifies a jump offset
18
//
19
// Instruction word is sometimes followed by one extra word, indicated as AUX - this is just a 32-bit word and is decoded according to the specification for each opcode.
20
// For each opcode the encoding is *static* - that is, based on the opcode you know apriori how large the instruction is, with the exception of NEWCLOSURE
21
22
// # Bytecode indices
23
// Bytecode instructions commonly refer to integer values that define offsets or indices for various entities. For each type, there's a maximum encodable value.
24
// Note that in some cases, the compiler will set a lower limit than the maximum encodable value is to prevent fragile code into bumping against the limits whenever we change the compilation details.
25
// Additionally, in some specific instructions such as ANDK, the limit on the encoded value is smaller; this means that if a value is larger, a different instruction must be selected.
26
//
27
// Registers: 0-254. Registers refer to the values on the function's stack frame, including arguments.
28
// Upvalues: 0-199. Upvalues refer to the values stored in the closure object.
29
// Constants: 0-2^23-1. Constants are stored in a table allocated with each proto; to allow for future bytecode tweaks the encodable value is limited to 23 bits.
30
// Closures: 0-2^15-1. Closures are created from child protos via a child index; the limit is for the number of closures immediately referenced in each function.
31
// Jumps: -2^23..2^23. Jump offsets are specified in word increments, so jumping over an instruction may sometimes require an offset of 2 or more. Note that for jump instructions with AUX, the AUX word is included as part of the jump offset.
32
33
// # Bytecode versions
34
// Bytecode serialized format embeds a version number, that dictates both the serialized form as well as the allowed instructions. As long as the bytecode version falls into supported
35
// range (indicated by LBC_BYTECODE_MIN / LBC_BYTECODE_MAX) and was produced by Luau compiler, it should load and execute correctly.
36
//
37
// Note that Luau runtime doesn't provide indefinite bytecode compatibility: support for older versions gets removed over time. As such, bytecode isn't a durable storage format and it's expected
38
// that Luau users can recompile bytecode from source on Luau version upgrades if necessary.
39
40
// # Bytecode version history
41
//
42
// Note: due to limitations of the versioning scheme, some bytecode blobs that carry version 2 are using features from version 3. Starting from version 3, version should be sufficient to indicate bytecode compatibility.
43
//
44
// Version 1: Baseline version for the open-source release. Supported until 0.521.
45
// Version 2: Adds Proto::linedefined. Supported until 0.544.
46
// Version 3: Adds FORGPREP/JUMPXEQK* and enhances AUX encoding for FORGLOOP. Removes FORGLOOP_NEXT/INEXT and JUMPIFEQK/JUMPIFNOTEQK. Currently supported.
47
// Version 4: Adds Proto::flags, typeinfo, and floor division opcodes IDIV/IDIVK. Currently supported.
48
// Version 5: Adds SUBRK/DIVRK and vector constants. Currently supported.
49
// Version 6: Adds FASTCALL3. Currently supported.
50
// Version 7: Adds LBC_CONSTANT_TABLE_WITH_CONSTANTS for DUPTABLE with pre-filled constant values. Currently supported.
51
// Version 8: Adds LBC_CONSTANT_INTEGER for 64-bit integer constants. Currently supported.
52
53
// # Bytecode type information history
54
// Version 1: (from bytecode version 4) Type information for function signature. Currently supported.
55
// Version 2: (from bytecode version 4) Type information for arguments, upvalues, locals and some temporaries. Currently supported.
56
// Version 3: (from bytecode version 5) Type information for userdata type names and their index mapping. Currently supported.
57
58
// Bytecode opcode, part of the instruction header
59
enum LuauOpcode
60
{
61
// NOP: noop
62
LOP_NOP,
63
64
// BREAK: debugger break
65
LOP_BREAK,
66
67
// LOADNIL: sets register to nil
68
// A: target register
69
LOP_LOADNIL,
70
71
// LOADB: sets register to boolean and jumps to a given short offset (used to compile comparison results into a boolean)
72
// A: target register
73
// B: value (0/1)
74
// C: jump offset
75
LOP_LOADB,
76
77
// LOADN: sets register to a number literal
78
// A: target register
79
// D: value (-32768..32767)
80
LOP_LOADN,
81
82
// LOADK: sets register to an entry from the constant table from the proto (number/vector/string)
83
// A: target register
84
// D: constant table index (0..32767)
85
LOP_LOADK,
86
87
// MOVE: move (copy) value from one register to another
88
// A: target register
89
// B: source register
90
LOP_MOVE,
91
92
// GETGLOBAL: load value from global table using constant string as a key
93
// A: target register
94
// C: predicted slot index (based on hash)
95
// AUX: constant table index
96
LOP_GETGLOBAL,
97
98
// SETGLOBAL: set value in global table using constant string as a key
99
// A: source register
100
// C: predicted slot index (based on hash)
101
// AUX: constant table index
102
LOP_SETGLOBAL,
103
104
// GETUPVAL: load upvalue from the upvalue table for the current function
105
// A: target register
106
// B: upvalue index
107
LOP_GETUPVAL,
108
109
// SETUPVAL: store value into the upvalue table for the current function
110
// A: target register
111
// B: upvalue index
112
LOP_SETUPVAL,
113
114
// CLOSEUPVALS: close (migrate to heap) all upvalues that were captured for registers >= target
115
// A: target register
116
LOP_CLOSEUPVALS,
117
118
// GETIMPORT: load imported global table global from the constant table
119
// A: target register
120
// D: constant table index (0..32767); we assume that imports are loaded into the constant table
121
// AUX: 3 10-bit indices of constant strings that, combined, constitute an import path; length of the path is set by the top 2 bits (1,2,3)
122
LOP_GETIMPORT,
123
124
// GETTABLE: load value from table into target register using key from register
125
// A: target register
126
// B: table register
127
// C: index register
128
LOP_GETTABLE,
129
130
// SETTABLE: store source register into table using key from register
131
// A: source register
132
// B: table register
133
// C: index register
134
LOP_SETTABLE,
135
136
// GETTABLEKS: load value from table into target register using constant string as a key
137
// A: target register
138
// B: table register
139
// C: predicted slot index (based on hash)
140
// AUX: constant table index
141
LOP_GETTABLEKS,
142
143
// SETTABLEKS: store source register into table using constant string as a key
144
// A: source register
145
// B: table register
146
// C: predicted slot index (based on hash)
147
// AUX: constant table index
148
LOP_SETTABLEKS,
149
150
// GETTABLEN: load value from table into target register using small integer index as a key
151
// A: target register
152
// B: table register
153
// C: index-1 (index is 1..256)
154
LOP_GETTABLEN,
155
156
// SETTABLEN: store source register into table using small integer index as a key
157
// A: source register
158
// B: table register
159
// C: index-1 (index is 1..256)
160
LOP_SETTABLEN,
161
162
// NEWCLOSURE: create closure from a child proto; followed by a CAPTURE instruction for each upvalue
163
// A: target register
164
// D: child proto index (0..32767)
165
LOP_NEWCLOSURE,
166
167
// NAMECALL: prepare to call specified method by name by loading function from source register using constant index into target register and copying source register into target register + 1
168
// A: target register
169
// B: source register
170
// C: predicted slot index (based on hash)
171
// AUX: constant table index
172
// Note that this instruction must be followed directly by CALL; it prepares the arguments
173
// This instruction is roughly equivalent to GETTABLEKS + MOVE pair, but we need a special instruction to support custom __namecall metamethod
174
LOP_NAMECALL,
175
176
// CALL: call specified function
177
// A: register where the function object lives, followed by arguments; results are placed starting from the same register
178
// B: argument count + 1, or 0 to preserve all arguments up to top (MULTRET)
179
// C: result count + 1, or 0 to preserve all values and adjust top (MULTRET)
180
LOP_CALL,
181
182
// RETURN: returns specified values from the function
183
// A: register where the returned values start
184
// B: number of returned values + 1, or 0 to return all values up to top (MULTRET)
185
LOP_RETURN,
186
187
// JUMP: jumps to target offset
188
// D: jump offset (-32768..32767; 0 means "next instruction" aka "don't jump")
189
LOP_JUMP,
190
191
// JUMPBACK: jumps to target offset; this is equivalent to JUMP but is used as a safepoint to be able to interrupt while/repeat loops
192
// D: jump offset (-32768..32767; 0 means "next instruction" aka "don't jump")
193
LOP_JUMPBACK,
194
195
// JUMPIF: jumps to target offset if register is not nil/false
196
// A: source register
197
// D: jump offset (-32768..32767; 0 means "next instruction" aka "don't jump")
198
LOP_JUMPIF,
199
200
// JUMPIFNOT: jumps to target offset if register is nil/false
201
// A: source register
202
// D: jump offset (-32768..32767; 0 means "next instruction" aka "don't jump")
203
LOP_JUMPIFNOT,
204
205
// JUMPIFEQ, JUMPIFLE, JUMPIFLT, JUMPIFNOTEQ, JUMPIFNOTLE, JUMPIFNOTLT: jumps to target offset if the comparison is true (or false, for NOT variants)
206
// A: source register 1
207
// D: jump offset (-32768..32767; 1 means "next instruction" aka "don't jump")
208
// AUX: source register 2
209
LOP_JUMPIFEQ,
210
LOP_JUMPIFLE,
211
LOP_JUMPIFLT,
212
LOP_JUMPIFNOTEQ,
213
LOP_JUMPIFNOTLE,
214
LOP_JUMPIFNOTLT,
215
216
// ADD, SUB, MUL, DIV, MOD, POW: compute arithmetic operation between two source registers and put the result into target register
217
// A: target register
218
// B: source register 1
219
// C: source register 2
220
LOP_ADD,
221
LOP_SUB,
222
LOP_MUL,
223
LOP_DIV,
224
LOP_MOD,
225
LOP_POW,
226
227
// ADDK, SUBK, MULK, DIVK, MODK, POWK: compute arithmetic operation between the source register and a constant and put the result into target register
228
// A: target register
229
// B: source register
230
// C: constant table index (0..255); must refer to a number
231
LOP_ADDK,
232
LOP_SUBK,
233
LOP_MULK,
234
LOP_DIVK,
235
LOP_MODK,
236
LOP_POWK,
237
238
// AND, OR: perform `and` or `or` operation (selecting first or second register based on whether the first one is truthy) and put the result into target register
239
// A: target register
240
// B: source register 1
241
// C: source register 2
242
LOP_AND,
243
LOP_OR,
244
245
// ANDK, ORK: perform `and` or `or` operation (selecting source register or constant based on whether the source register is truthy) and put the result into target register
246
// A: target register
247
// B: source register
248
// C: constant table index (0..255)
249
LOP_ANDK,
250
LOP_ORK,
251
252
// CONCAT: concatenate all strings between B and C (inclusive) and put the result into A
253
// A: target register
254
// B: source register start
255
// C: source register end
256
LOP_CONCAT,
257
258
// NOT, MINUS, LENGTH: compute unary operation for source register and put the result into target register
259
// A: target register
260
// B: source register
261
LOP_NOT,
262
LOP_MINUS,
263
LOP_LENGTH,
264
265
// NEWTABLE: create table in target register
266
// A: target register
267
// B: table size, stored as 0 for v=0 and ceil(log2(v))+1 for v!=0
268
// AUX: array size
269
LOP_NEWTABLE,
270
271
// DUPTABLE: duplicate table using the constant table template to target register
272
// A: target register
273
// D: constant table index (0..32767)
274
LOP_DUPTABLE,
275
276
// SETLIST: set a list of values to table in target register
277
// A: target register
278
// B: source register start
279
// C: value count + 1, or 0 to use all values up to top (MULTRET)
280
// AUX: table index to start from
281
LOP_SETLIST,
282
283
// FORNPREP: prepare a numeric for loop, jump over the loop if first iteration doesn't need to run
284
// A: target register; numeric for loops assume a register layout [limit, step, index, variable]
285
// D: jump offset (-32768..32767)
286
// limit/step are immutable, index isn't visible to user code since it's copied into variable
287
LOP_FORNPREP,
288
289
// FORNLOOP: adjust loop variables for one iteration, jump back to the loop header if loop needs to continue
290
// A: target register; see FORNPREP for register layout
291
// D: jump offset (-32768..32767)
292
LOP_FORNLOOP,
293
294
// FORGLOOP: adjust loop variables for one iteration of a generic for loop, jump back to the loop header if loop needs to continue
295
// A: target register; generic for loops assume a register layout [generator, state, index, variables...]
296
// D: jump offset (-32768..32767)
297
// AUX: variable count (1..255) in the low 8 bits, high bit indicates whether to use ipairs-style traversal in the fast path
298
// loop variables are adjusted by calling generator(state, index) and expecting it to return a tuple that's copied to the user variables
299
// the first variable is then copied into index; generator/state are immutable, index isn't visible to user code
300
LOP_FORGLOOP,
301
302
// FORGPREP_INEXT: prepare FORGLOOP with 2 output variables (no AUX encoding), assuming generator is luaB_inext, and jump to FORGLOOP
303
// A: target register (see FORGLOOP for register layout)
304
// D: jump offset (-32768..32767)
305
LOP_FORGPREP_INEXT,
306
307
// FASTCALL3: perform a fast call of a built-in function using 3 register arguments
308
// A: builtin function id (see LuauBuiltinFunction)
309
// B: source argument register
310
// C: jump offset to get to following CALL
311
// AUX: source register 2 in least-significant byte
312
// AUX: source register 3 in second least-significant byte
313
LOP_FASTCALL3,
314
315
// FORGPREP_NEXT: prepare FORGLOOP with 2 output variables (no AUX encoding), assuming generator is luaB_next, and jump to FORGLOOP
316
// A: target register (see FORGLOOP for register layout)
317
// D: jump offset (-32768..32767)
318
LOP_FORGPREP_NEXT,
319
320
// NATIVECALL: start executing new function in native code
321
// this is a pseudo-instruction that is never emitted by bytecode compiler, but can be constructed at runtime to accelerate native code dispatch
322
LOP_NATIVECALL,
323
324
// GETVARARGS: copy variables into the target register from vararg storage for current function
325
// A: target register
326
// B: variable count + 1, or 0 to copy all variables and adjust top (MULTRET)
327
LOP_GETVARARGS,
328
329
// DUPCLOSURE: create closure from a pre-created function object (reusing it unless environments diverge)
330
// A: target register
331
// D: constant table index (0..32767)
332
LOP_DUPCLOSURE,
333
334
// PREPVARARGS: prepare stack for variadic functions so that GETVARARGS works correctly
335
// A: number of fixed arguments
336
LOP_PREPVARARGS,
337
338
// LOADKX: sets register to an entry from the constant table from the proto (number/string)
339
// A: target register
340
// AUX: constant table index
341
LOP_LOADKX,
342
343
// JUMPX: jumps to the target offset; like JUMPBACK, supports interruption
344
// E: jump offset (-2^23..2^23; 0 means "next instruction" aka "don't jump")
345
LOP_JUMPX,
346
347
// FASTCALL: perform a fast call of a built-in function
348
// A: builtin function id (see LuauBuiltinFunction)
349
// C: jump offset to get to following CALL
350
// FASTCALL is followed by one of (GETIMPORT, MOVE, GETUPVAL) instructions and by CALL instruction
351
// This is necessary so that if FASTCALL can't perform the call inline, it can continue normal execution
352
// If FASTCALL *can* perform the call, it jumps over the instructions *and* over the next CALL
353
// Note that FASTCALL will read the actual call arguments, such as argument/result registers and counts, from the CALL instruction
354
LOP_FASTCALL,
355
356
// COVERAGE: update coverage information stored in the instruction
357
// E: hit count for the instruction (0..2^23-1)
358
// The hit count is incremented by VM every time the instruction is executed, and saturates at 2^23-1
359
LOP_COVERAGE,
360
361
// CAPTURE: capture a local or an upvalue as an upvalue into a newly created closure; only valid after NEWCLOSURE
362
// A: capture type, see LuauCaptureType
363
// B: source register (for VAL/REF) or upvalue index (for UPVAL/UPREF)
364
LOP_CAPTURE,
365
366
// SUBRK, DIVRK: compute arithmetic operation between the constant and a source register and put the result into target register
367
// A: target register
368
// B: constant table index (0..255); must refer to a number
369
// C: source register
370
LOP_SUBRK,
371
LOP_DIVRK,
372
373
// FASTCALL1: perform a fast call of a built-in function using 1 register argument
374
// A: builtin function id (see LuauBuiltinFunction)
375
// B: source argument register
376
// C: jump offset to get to following CALL
377
LOP_FASTCALL1,
378
379
// FASTCALL2: perform a fast call of a built-in function using 2 register arguments
380
// A: builtin function id (see LuauBuiltinFunction)
381
// B: source argument register
382
// C: jump offset to get to following CALL
383
// AUX: source register 2 in least-significant byte
384
LOP_FASTCALL2,
385
386
// FASTCALL2K: perform a fast call of a built-in function using 1 register argument and 1 constant argument
387
// A: builtin function id (see LuauBuiltinFunction)
388
// B: source argument register
389
// C: jump offset to get to following CALL
390
// AUX: constant index
391
LOP_FASTCALL2K,
392
393
// FORGPREP: prepare loop variables for a generic for loop, jump to the loop backedge unconditionally
394
// A: target register; generic for loops assume a register layout [generator, state, index, variables...]
395
// D: jump offset (-32768..32767)
396
LOP_FORGPREP,
397
398
// JUMPXEQKNIL, JUMPXEQKB: jumps to target offset if the comparison with constant is true (or false, see AUX)
399
// A: source register 1
400
// D: jump offset (-32768..32767; 1 means "next instruction" aka "don't jump")
401
// AUX: constant value (for boolean) in low bit, NOT flag (that flips comparison result) in high bit
402
LOP_JUMPXEQKNIL,
403
LOP_JUMPXEQKB,
404
405
// JUMPXEQKN, JUMPXEQKS: jumps to target offset if the comparison with constant is true (or false, see AUX)
406
// A: source register 1
407
// D: jump offset (-32768..32767; 1 means "next instruction" aka "don't jump")
408
// AUX: constant table index in low 24 bits, NOT flag (that flips comparison result) in high bit
409
LOP_JUMPXEQKN,
410
LOP_JUMPXEQKS,
411
412
// IDIV: compute floor division between two source registers and put the result into target register
413
// A: target register
414
// B: source register 1
415
// C: source register 2
416
LOP_IDIV,
417
418
// IDIVK compute floor division between the source register and a constant and put the result into target register
419
// A: target register
420
// B: source register
421
// C: constant table index (0..255)
422
LOP_IDIVK,
423
424
// Enum entry for number of opcodes, not a valid opcode by itself!
425
LOP__COUNT
426
};
427
428
// Bytecode instruction header: it's always a 32-bit integer, with low byte (first byte in little endian) containing the opcode
429
// Some instruction types require more data and have more 32-bit integers following the header
430
#define LUAU_INSN_OP(insn) ((insn) & 0xff)
431
432
// ABC encoding: three 8-bit values, containing registers or small numbers
433
#define LUAU_INSN_A(insn) (((insn) >> 8) & 0xff)
434
#define LUAU_INSN_B(insn) (((insn) >> 16) & 0xff)
435
#define LUAU_INSN_C(insn) (((insn) >> 24) & 0xff)
436
437
// AD encoding: one 8-bit value, one signed 16-bit value
438
#define LUAU_INSN_D(insn) (int32_t(insn) >> 16)
439
440
// E encoding: one signed 24-bit value
441
#define LUAU_INSN_E(insn) (int32_t(insn) >> 8)
442
443
// Auxiliary AB: two 8-bit values, containing registers or small numbers
444
// Used in FASTCALL3
445
#define LUAU_INSN_AUX_A(aux) ((aux) & 0xff)
446
#define LUAU_INSN_AUX_B(aux) (((aux) >> 8) & 0xff)
447
448
// Auxiliary KV: unsigned 24-bit constant index
449
// Used in LOP_JUMPXEQK* instructions
450
#define LUAU_INSN_AUX_KV(aux) ((aux) & 0xffffff)
451
452
// Auxiliary KB: 1-bit constant value
453
// Used in LOP_JUMPXEQKB instruction
454
#define LUAU_INSN_AUX_KB(aux) ((aux) & 0x1)
455
456
// Auxiliary NOT: 1-bit negation flag
457
// Used in LOP_JUMPXEQK* instructions
458
#define LUAU_INSN_AUX_NOT(aux) ((aux) >> 31)
459
460
// Bytecode tags, used internally for bytecode encoded as a string
461
enum LuauBytecodeTag
462
{
463
// Bytecode version; runtime supports [MIN, MAX], compiler emits TARGET by default but may emit a higher version when flags are enabled
464
LBC_VERSION_MIN = 3,
465
LBC_VERSION_MAX = 8,
466
LBC_VERSION_TARGET = 6,
467
// Type encoding version
468
LBC_TYPE_VERSION_MIN = 1,
469
LBC_TYPE_VERSION_MAX = 3,
470
LBC_TYPE_VERSION_TARGET = 3,
471
// Types of constant table entries
472
LBC_CONSTANT_NIL = 0,
473
LBC_CONSTANT_BOOLEAN,
474
LBC_CONSTANT_NUMBER,
475
LBC_CONSTANT_STRING,
476
LBC_CONSTANT_IMPORT,
477
LBC_CONSTANT_TABLE,
478
LBC_CONSTANT_CLOSURE,
479
LBC_CONSTANT_VECTOR,
480
LBC_CONSTANT_TABLE_WITH_CONSTANTS,
481
LBC_CONSTANT_INTEGER,
482
};
483
484
// Type table tags
485
enum LuauBytecodeType
486
{
487
LBC_TYPE_NIL = 0,
488
LBC_TYPE_BOOLEAN,
489
LBC_TYPE_NUMBER,
490
LBC_TYPE_STRING,
491
LBC_TYPE_TABLE,
492
LBC_TYPE_FUNCTION,
493
LBC_TYPE_THREAD,
494
LBC_TYPE_USERDATA,
495
LBC_TYPE_VECTOR,
496
LBC_TYPE_BUFFER,
497
LBC_TYPE_INTEGER,
498
499
LBC_TYPE_ANY = 15,
500
501
LBC_TYPE_TAGGED_USERDATA_BASE = 64,
502
LBC_TYPE_TAGGED_USERDATA_END = 64 + 32,
503
504
LBC_TYPE_OPTIONAL_BIT = 1 << 7,
505
506
LBC_TYPE_INVALID = 256,
507
};
508
509
// Builtin function ids, used in LOP_FASTCALL
510
enum LuauBuiltinFunction
511
{
512
LBF_NONE = 0,
513
514
// assert()
515
LBF_ASSERT,
516
517
// math.
518
LBF_MATH_ABS,
519
LBF_MATH_ACOS,
520
LBF_MATH_ASIN,
521
LBF_MATH_ATAN2,
522
LBF_MATH_ATAN,
523
LBF_MATH_CEIL,
524
LBF_MATH_COSH,
525
LBF_MATH_COS,
526
LBF_MATH_DEG,
527
LBF_MATH_EXP,
528
LBF_MATH_FLOOR,
529
LBF_MATH_FMOD,
530
LBF_MATH_FREXP,
531
LBF_MATH_LDEXP,
532
LBF_MATH_LOG10,
533
LBF_MATH_LOG,
534
LBF_MATH_MAX,
535
LBF_MATH_MIN,
536
LBF_MATH_MODF,
537
LBF_MATH_POW,
538
LBF_MATH_RAD,
539
LBF_MATH_SINH,
540
LBF_MATH_SIN,
541
LBF_MATH_SQRT,
542
LBF_MATH_TANH,
543
LBF_MATH_TAN,
544
545
// bit32.
546
LBF_BIT32_ARSHIFT,
547
LBF_BIT32_BAND,
548
LBF_BIT32_BNOT,
549
LBF_BIT32_BOR,
550
LBF_BIT32_BXOR,
551
LBF_BIT32_BTEST,
552
LBF_BIT32_EXTRACT,
553
LBF_BIT32_LROTATE,
554
LBF_BIT32_LSHIFT,
555
LBF_BIT32_REPLACE,
556
LBF_BIT32_RROTATE,
557
LBF_BIT32_RSHIFT,
558
559
// type()
560
LBF_TYPE,
561
562
// string.
563
LBF_STRING_BYTE,
564
LBF_STRING_CHAR,
565
LBF_STRING_LEN,
566
567
// typeof()
568
LBF_TYPEOF,
569
570
// string.
571
LBF_STRING_SUB,
572
573
// math.
574
LBF_MATH_CLAMP,
575
LBF_MATH_SIGN,
576
LBF_MATH_ROUND,
577
578
// raw*
579
LBF_RAWSET,
580
LBF_RAWGET,
581
LBF_RAWEQUAL,
582
583
// table.
584
LBF_TABLE_INSERT,
585
LBF_TABLE_UNPACK,
586
587
// vector ctor
588
LBF_VECTOR,
589
590
// bit32.count
591
LBF_BIT32_COUNTLZ,
592
LBF_BIT32_COUNTRZ,
593
594
// select(_, ...)
595
LBF_SELECT_VARARG,
596
597
// rawlen
598
LBF_RAWLEN,
599
600
// bit32.extract(_, k, k)
601
LBF_BIT32_EXTRACTK,
602
603
// get/setmetatable
604
LBF_GETMETATABLE,
605
LBF_SETMETATABLE,
606
607
// tonumber/tostring
608
LBF_TONUMBER,
609
LBF_TOSTRING,
610
611
// bit32.byteswap(n)
612
LBF_BIT32_BYTESWAP,
613
614
// buffer.
615
LBF_BUFFER_READI8,
616
LBF_BUFFER_READU8,
617
LBF_BUFFER_WRITEU8,
618
LBF_BUFFER_READI16,
619
LBF_BUFFER_READU16,
620
LBF_BUFFER_WRITEU16,
621
LBF_BUFFER_READI32,
622
LBF_BUFFER_READU32,
623
LBF_BUFFER_WRITEU32,
624
LBF_BUFFER_READF32,
625
LBF_BUFFER_WRITEF32,
626
LBF_BUFFER_READF64,
627
LBF_BUFFER_WRITEF64,
628
629
// vector.
630
LBF_VECTOR_MAGNITUDE,
631
LBF_VECTOR_NORMALIZE,
632
LBF_VECTOR_CROSS,
633
LBF_VECTOR_DOT,
634
LBF_VECTOR_FLOOR,
635
LBF_VECTOR_CEIL,
636
LBF_VECTOR_ABS,
637
LBF_VECTOR_SIGN,
638
LBF_VECTOR_CLAMP,
639
LBF_VECTOR_MIN,
640
LBF_VECTOR_MAX,
641
642
// math.lerp
643
LBF_MATH_LERP,
644
645
// vector.lerp
646
LBF_VECTOR_LERP,
647
648
// math.
649
LBF_MATH_ISNAN,
650
LBF_MATH_ISINF,
651
LBF_MATH_ISFINITE,
652
653
// integer
654
LBF_INTEGER_CREATE,
655
LBF_INTEGER_TONUMBER,
656
LBF_INTEGER_NEG,
657
LBF_INTEGER_ADD,
658
LBF_INTEGER_SUB,
659
LBF_INTEGER_MUL,
660
LBF_INTEGER_DIV,
661
LBF_INTEGER_MIN,
662
LBF_INTEGER_MAX,
663
LBF_INTEGER_REM,
664
LBF_INTEGER_IDIV,
665
LBF_INTEGER_UDIV,
666
LBF_INTEGER_UREM,
667
LBF_INTEGER_MOD,
668
LBF_INTEGER_CLAMP,
669
LBF_INTEGER_BAND,
670
LBF_INTEGER_BOR,
671
LBF_INTEGER_BNOT,
672
LBF_INTEGER_BXOR,
673
LBF_INTEGER_LT,
674
LBF_INTEGER_LE,
675
LBF_INTEGER_ULT,
676
LBF_INTEGER_ULE,
677
LBF_INTEGER_GT,
678
LBF_INTEGER_GE,
679
LBF_INTEGER_UGT,
680
LBF_INTEGER_UGE,
681
LBF_INTEGER_LSHIFT,
682
LBF_INTEGER_RSHIFT,
683
LBF_INTEGER_ARSHIFT,
684
LBF_INTEGER_LROTATE,
685
LBF_INTEGER_RROTATE,
686
LBF_INTEGER_EXTRACT,
687
LBF_INTEGER_BTEST,
688
LBF_INTEGER_COUNTRZ,
689
LBF_INTEGER_COUNTLZ,
690
LBF_INTEGER_BSWAP,
691
};
692
693
// Capture type, used in LOP_CAPTURE
694
enum LuauCaptureType
695
{
696
LCT_VAL = 0,
697
LCT_REF,
698
LCT_UPVAL,
699
};
700
701
// Proto flag bitmask, stored in Proto::flags
702
enum LuauProtoFlag
703
{
704
// used to tag main proto for modules with --!native
705
LPF_NATIVE_MODULE = 1 << 0,
706
// used to tag individual protos as not profitable to compile natively
707
LPF_NATIVE_COLD = 1 << 1,
708
// used to tag main proto for modules that have at least one function with native attribute
709
LPF_NATIVE_FUNCTION = 1 << 2,
710
};
711
712