Files: 099ac07e30fe8b32def266ff2c809350f4a7ce0b / wasm / interface.wast
1409 bytesRaw
1 | (module |
2 | (import "interface" "useGas" (func $useGas (param i32 i32))) |
3 | (import "interface" "getGasLeftHigh" (func $getGasLeftHigh (result i32))) |
4 | (import "interface" "getGasLeftLow" (func $getGasLeftLow (result i32))) |
5 | (import "interface" "call" (func $call (param i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32))) |
6 | |
7 | (export "useGas" (func $useGasShim)) |
8 | (export "getGasLeft" (func $getGasLeft)) |
9 | (export "call" (func $callShim)) |
10 | |
11 | (func $useGasShim |
12 | (param $amount i64) |
13 | (call $useGas |
14 | (i32.wrap/i64 |
15 | (i64.shr_u (get_local $amount) (i64.const 32))) |
16 | (i32.wrap/i64 (get_local $amount))) |
17 | ) |
18 | |
19 | (func $getGasLeft |
20 | (result i64) |
21 | (call $useGas (i32.const 0) (i32.const 2)) |
22 | (return |
23 | (i64.add |
24 | (i64.shl (i64.extend_u/i32 (call $getGasLeftHigh)) (i64.const 32)) |
25 | (i64.extend_u/i32 (call $getGasLeftLow)))) |
26 | ) |
27 | |
28 | ;; call |
29 | ;; (import $call "ethereum" "call" (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32)) |
30 | (func $callShim |
31 | (param i64 i32 i32 i32 i32 i32 i32 i32) |
32 | (result i32) |
33 | (call $call |
34 | (i32.wrap/i64 |
35 | (i64.shr_u (get_local 0) (i64.const 32))) |
36 | (i32.wrap/i64 (get_local 0)) |
37 | (get_local 1) |
38 | (get_local 2) |
39 | (get_local 3) |
40 | (get_local 4) |
41 | (get_local 5) |
42 | (get_local 6) |
43 | (get_local 7) |
44 | ) |
45 | ) |
46 | ) |
47 |
Built with git-ssb-web