mirror of
https://github.com/fluencelabs/wasm-utils
synced 2025-05-29 15:41:20 +00:00
fix attempt
This commit is contained in:
parent
0345b7c9c8
commit
67a542927a
@ -41,16 +41,15 @@ fn add_grow_counter(module: elements::Module, rules: &rules::Set, gas_func: u32)
|
|||||||
let mut b = builder::from_module(module);
|
let mut b = builder::from_module(module);
|
||||||
b.push_function(
|
b.push_function(
|
||||||
builder::function()
|
builder::function()
|
||||||
.signature().params().i32().i32().build().with_return_type(Some(elements::ValueType::I32)).build()
|
.signature().params().i32().build().with_return_type(Some(elements::ValueType::I32)).build()
|
||||||
.body()
|
.body()
|
||||||
.with_opcodes(elements::Opcodes::new(vec![
|
.with_opcodes(elements::Opcodes::new(vec![
|
||||||
|
GetLocal(0),
|
||||||
GetLocal(0),
|
GetLocal(0),
|
||||||
I32Const(rules.grow_cost() as i32),
|
I32Const(rules.grow_cost() as i32),
|
||||||
I32Mul,
|
I32Mul,
|
||||||
TeeLocal(1),
|
|
||||||
// todo: there should be strong guarantee that it does not return anything on stack?
|
// todo: there should be strong guarantee that it does not return anything on stack?
|
||||||
Call(gas_func),
|
Call(gas_func),
|
||||||
GetLocal(1),
|
|
||||||
GrowMemory(0),
|
GrowMemory(0),
|
||||||
GetLocal(0),
|
GetLocal(0),
|
||||||
End,
|
End,
|
||||||
@ -241,12 +240,11 @@ mod tests {
|
|||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&vec![
|
&vec![
|
||||||
|
GetLocal(0),
|
||||||
GetLocal(0),
|
GetLocal(0),
|
||||||
I32Const(10000),
|
I32Const(10000),
|
||||||
I32Mul,
|
I32Mul,
|
||||||
TeeLocal(1),
|
|
||||||
Call(0),
|
Call(0),
|
||||||
GetLocal(1),
|
|
||||||
GrowMemory(0),
|
GrowMemory(0),
|
||||||
GetLocal(0),
|
GetLocal(0),
|
||||||
End,
|
End,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user