Skip to main content

luaur_bytecode/methods/
bytecode_builder_get_version.rs

1use crate::records::bytecode_builder::BytecodeBuilder;
2use luaur_common::FFlag;
3
4impl BytecodeBuilder {
5    pub fn get_version(&self) -> u8 {
6        if FFlag::LuauEmitCallFeedback.get() {
7            return 11;
8        }
9
10        if FFlag::DebugLuauUserDefinedClasses.get() {
11            return 10;
12        }
13
14        if FFlag::LuauCompileUdataDirect.get() {
15            return 9;
16        }
17
18        // LBC_CONSTANT_INTEGER requires version 8
19        if FFlag::LuauIntegerType2.get() {
20            return 8;
21        }
22
23        // LBC_CONSTANT_TABLE_WITH_CONSTANTS requires version 7
24        if FFlag::LuauCompileDuptableConstantPack2.get() {
25            return 7;
26        }
27
28        luaur_common::enums::luau_bytecode_tag::LBC_VERSION_TARGET.0 as u8
29    }
30}