Roots of Pacha is a pixel art sandbox about village development in the Stone Age.

Developers of the JavaScript engine V8 have introduced utility wasm-decompile, allowing the decompilation of an intermediate binary representation WebAssembly into a readable pseudo-language resembling JavaScript and C. The proposed pseudo-language is significantly easier to understand and more suitable for manual parsing than the textual representation of WebAssembly in the '.wat' format, which is closer to assembly language than high-level languages. The decompilation, wherever possible, fully reflects the representation of Wasm.

Decompiler included in the toolkit WABT, which provides translation between binary and textual representations of WebAssembly, as well as parsing, processing, modifying, and verifying wasm files. The WABT suite also includes the utility wasm2c, which allows decompiling wasm files into equivalent C code that can be compiled by a C compiler, but in terms of readability, it is not much different from the text representation 'wat'.

For example, a C function compiled to wasm

typedef struct { float x, y, z; } vec3;

float dot(const vec3 *a, const vec3 *b) {
return a->x * b->x +
a->y * b->y +
a->z * b->z;
}

will be decompiled by the wasm-decompile utility into the pseudo-language

function dot(a:{ a:float, b:float, c:float },
b:{ a:float, b:float, c:float }):float {
return a.a * b.a + a.b * b.b + a.c * b.c
}

while the conversion to the textual format '.wat' will look like this

(func $dot (type 0) (param i32 i32) (result f32)
(f32.add
(f32.add
(f32.mul
(f32.load
(local.get 0))
(f32.load
(local.get 1)))
(f32.mul
(f32.load offset=4
(local.get 0))
(f32.load offset=4
(local.get 1))))
(f32.mul
(f32.load offset=8
(local.get 0))
(f32.load offset=8
(local.get 1))))))

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster