luaur_bytecode/methods/
bytecode_builder_add_constant_string.rs1use crate::enums::r#type::Type;
2use crate::records::bytecode_builder::BytecodeBuilder;
3use crate::records::constant::Constant;
4use crate::records::constant::ConstantValue;
5use crate::records::constant_key::ConstantKey;
6use crate::records::string_ref::StringRef;
7
8impl BytecodeBuilder {
9 pub fn add_constant_string(&mut self, value: StringRef) -> i32 {
10 let index = self.add_string_table_entry(value);
11
12 let c = Constant {
13 r#type: Type::Type_String,
14 value: ConstantValue { valueString: index },
15 };
16
17 let k = ConstantKey {
18 r#type: Type::Type_String,
19 value: index as u64,
20 extra: 0,
21 };
22
23 self.add_constant(k, c)
24 }
25}