Skip to content

Commit c0779d5

Browse files
committed
Add comments for trap::codegen_print gv and fn defs
1 parent 2eae6bc commit c0779d5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/trap.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms
77
returns: vec![],
88
}).unwrap();
99
let puts = fx.module.declare_func_in_func(puts, &mut fx.bcx.func);
10+
fx.add_entity_comment(puts, "puts");
1011

1112
let symbol_name = fx.tcx.symbol_name(fx.instance);
12-
let msg_bytes = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg).into_bytes().into_boxed_slice();
13+
let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg);
1314
let mut data_ctx = DataContext::new();
14-
data_ctx.define(msg_bytes);
15+
data_ctx.define(real_msg.as_bytes().to_vec().into_boxed_slice());
1516
let msg_id = fx.module.declare_data(&(symbol_name.as_str().to_string() + msg), Linkage::Local, false, None).unwrap();
1617

1718
// Ignore DuplicateDefinition error, as the data will be the same
1819
let _ = fx.module.define_data(msg_id, &data_ctx);
1920

2021
let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func);
22+
fx.add_entity_comment(local_msg_id, msg);
2123
let msg_ptr = fx.bcx.ins().global_value(pointer_ty(fx.tcx), local_msg_id);
2224
fx.bcx.ins().call(puts, &[msg_ptr]);
2325
}

0 commit comments

Comments
 (0)