Skip to content

Commit 0b769b0

Browse files
cdetrioaxic
authored andcommitted
wasm/wat debug name for gas func
1 parent e4b98aa commit 0b769b0

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
@@ -130,7 +130,11 @@ fn inject_inline_gas(module: elements::Module) -> elements::Module {
130130
let global_gas_index = module.globals_space() as u32;
131131
println!("total globals before injecting gas global: {:?}", global_gas_index);
132132

133-
let b = builder::from_module(module);
133+
let gas_func_index = module.functions_space() as u32;
134+
135+
let b = builder::from_module(module)
136+
// the export is a workaround to add debug name "useGas"
137+
.with_export(elements::ExportEntry::new("useGas".to_string(), elements::Internal::Function(gas_func_index)));
134138

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

0 commit comments

Comments
 (0)