All Projects → ewasm → Wasm Json Toolkit

ewasm / Wasm Json Toolkit

[ORPHANED] A small toolkit for converting wasm binaries into json and back.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Wasm Json Toolkit

Awesome Wasm Zh
WebAssembly(wasm)资源精选
Stars: ✭ 838 (+3543.48%)
Mutual labels:  webassembly, wasm
Wasm2kt
Web Assembly to Kotlin and Java converter. Allows to compile a C or C++ program/library, and generate a Kotlin or Java program/library.
Stars: ✭ 18 (-21.74%)
Mutual labels:  webassembly, wasm
Webassemblyjs
Toolchain for WebAssembly
Stars: ✭ 566 (+2360.87%)
Mutual labels:  webassembly, wasm
Raylib
A simple and easy-to-use library to enjoy videogames programming
Stars: ✭ 8,169 (+35417.39%)
Mutual labels:  wasm, webassembly
Wasmer Php
🐘🕸️ WebAssembly runtime for PHP
Stars: ✭ 796 (+3360.87%)
Mutual labels:  webassembly, wasm
Dotnet Webassembly
Create, read, modify, write and execute WebAssembly (WASM) files from .NET-based applications.
Stars: ✭ 535 (+2226.09%)
Mutual labels:  webassembly, wasm
Wasm Loader
✨ WASM webpack loader
Stars: ✭ 604 (+2526.09%)
Mutual labels:  webassembly, wasm
Zwitterion
A web dev server that lets you import anything*
Stars: ✭ 514 (+2134.78%)
Mutual labels:  webassembly, wasm
Awesome Wasm
😎 Curated list of awesome things regarding WebAssembly (wasm) ecosystem.
Stars: ✭ 6,377 (+27626.09%)
Mutual labels:  webassembly, wasm
Pib
PHP in Browser (powered by WebAssembly)
Stars: ✭ 649 (+2721.74%)
Mutual labels:  webassembly, wasm
Gameboy
🎮 Game Boy emulator written in Rust
Stars: ✭ 17 (-26.09%)
Mutual labels:  webassembly, wasm
Webassembly
A minimal toolkit and runtime to produce and run WebAssembly modules.
Stars: ✭ 786 (+3317.39%)
Mutual labels:  webassembly, wasm
Wasmtime
Standalone JIT-style runtime for WebAssembly, using Cranelift
Stars: ✭ 6,413 (+27782.61%)
Mutual labels:  webassembly, wasm
Ssvm
SSVM is a high performance, extensible, and hardware optimized WebAssembly Virtual Machine for cloud, AI, and blockchain applications.
Stars: ✭ 751 (+3165.22%)
Mutual labels:  webassembly, wasm
Vim.wasm
Vim editor ported to WebAssembly
Stars: ✭ 4,915 (+21269.57%)
Mutual labels:  webassembly, wasm
Astro
A fun safe language for rapid prototyping and high performance applications
Stars: ✭ 588 (+2456.52%)
Mutual labels:  webassembly, wasm
Awesome Wasm Runtimes
A list of webassemby runtimes
Stars: ✭ 490 (+2030.43%)
Mutual labels:  webassembly, wasm
Uno
Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
Stars: ✭ 6,029 (+26113.04%)
Mutual labels:  webassembly, wasm
Graphql Client
Typed, correct GraphQL requests and responses in Rust
Stars: ✭ 620 (+2595.65%)
Mutual labels:  webassembly, wasm
Markdown Wasm
Markdown parser and HTML generator implemented in WebAssembly, based on md4c
Stars: ✭ 833 (+3521.74%)
Mutual labels:  webassembly, wasm

SYNOPSIS

NPM Package Build Status Coverage Status

js-standard-style

A small toolkit for converting wasm binaries into json and back.

INSTALL

npm install wasm-json-toolkit

USAGE

const fs = require('fs')
const wasm2json = require('wasm-json-toolkit').wasm2json

const wasm = fs.readFileSync('./test.wasm')
const json = wasm2json(wasm)

console.log(JSON.stringify(json, null, 2))

CLI

Install -g global for cli usage.

wasm2json [FILE] given a file containing a wasm module produces a json representation
json2wasm [FILE] given a file containing a json representation produces a wasm module

API

wasm2json

converts a wasm binary into a json representation

Parameters

  • Buffer - The Webassembly Binary
  • filter - Set containing the name of sections to parse. If no filter is given all sections will be parsed

Returns Object

json2wasm

converts a json representation to a wasm binary

Parameters

  • Object

Returns Buffer

text2json

converts text to json. The only text accepted is a simple list of opcode name and immediates

Parameters

  • String

Examples

const codeStr = `
i64.const 1
i64.const 2
i64.add
`
const json = text2json(codeStr)

Returns Object

iterator

iterator.js:12-58

The Module Iterator allows for iteration over a webassembly module's sections. A section is wrapped in a section class. A section class instance allows you append entries to a given section

Examples

const it = new Iterator(wasm)
for (const section of it) {
  console.log(section.type)
  const json = section.toJSON()
}

wasm

iterator.js:26-32

if the orignal wasm module was modified then this will return the modified wasm module

iterator

iterator.js:38-52

Iterates through the module's sections return {Iterator. }

Section

iterator.js:64-110

The section class is always internal created by the Module class. And return through the Module's iternator

toJSON

iterator.js:83-85

Parses the section and return the JSON repesentation of it returns {Object}

appendEntries

iterator.js:92-109

Appends an array of entries to this section. NOTE: this will modify the parent wasm module.

Parameters

exammple json output

wast

(module
  (func $addTwo (param i32 i32) (result i32)
    (i32.add
      (get_local 0)
      (get_local 1)))
  (export "addTwo" (func $addTwo)))

wasm

0x010661646454776f00000a09010700200020016a0b

json

[
  {
    "name": "preramble",
    "magic": [0,97,115,109],
    "version": [13,0,0,0]
  },
  {
    "name": "type",
    "entries": [
      {
        "form": "func",
        "params": ["i32","i32"],
        "return_type": "i32"
      }
    ]
  },
  {
    "name": "function",
    "entries": [0]
  },
  {
    "name": "export",
    "entries": [
      {
        "field_str": "addTwo",
        "kind": "Function",
        "index": 0
      }
    ]
  },
  {
    "name": "code",
    "entries": [
      {
        "locals": [],
        "code": [
          {
            "name": "get_local",
            "immediaties": "0"
          },
          {
            "name": "get_local",
            "immediaties": "1"
          },
          {
            "return_type": "i32",
            "name": "add"
          },
          {
            "name": "end"
          }
        ]
      }
    ]
  }
]

LICENSE

MPL-2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].