luaur_code_gen/functions/
to_string_ir_dump.rs1use crate::enums::ir_op_kind::IrOpKind;
2use crate::functions::append::append;
3use crate::functions::get_cmd_name::get_cmd_name;
4use crate::functions::has_result::has_result;
5use crate::functions::to_string_ir_dump_alt_d::to_string as to_string_op;
6use crate::records::ir_inst::IrInst;
7use crate::records::ir_to_string_context::IrToStringContext;
8
9pub fn to_string(ctx: &mut IrToStringContext, inst: &IrInst, index: u32) {
10 ctx.result.push_str(" ");
11
12 if has_result(inst.cmd) {
14 append(&mut ctx.result, format_args!("%{} = ", index));
15 }
16
17 ctx.result.push_str(get_cmd_name(inst.cmd));
18
19 for i in 0..inst.ops.size() as usize {
20 let op = inst.ops.as_slice()[i];
21
22 if op.kind() == IrOpKind::None {
23 continue;
24 }
25
26 ctx.result.push_str(if i == 0 { " " } else { ", " });
27 to_string_op(ctx, op);
28 }
29}