Skip to content

Commit 0756139

Browse files
committed
wasm/wat debug name for gas func
1 parent d036a6b commit 0756139

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

wasm-utils/src/gas.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ fn inject_inline_gas(module: elements::Module) -> elements::Module {
144144
let global_gas_index = module.globals_space() as u32;
145145
println!("total globals before injecting gas global: {:?}", global_gas_index);
146146

147-
let b = builder::from_module(module);
147+
let gas_func_index = module.functions_space() as u32;
148+
149+
let b = builder::from_module(module)
150+
// the export is a workaround to add debug name "useGas"
151+
.with_export(elements::ExportEntry::new("useGas".to_string(), elements::Internal::Function(gas_func_index)));
148152

149153
let mut b2 = b.global().mutable()
150154
.value_type().i32().init_expr(elements::Instruction::I32Const(DEFAULT_START_GAS))

0 commit comments

Comments
 (0)