wasm_parser 0.0.1 copy "wasm_parser: ^0.0.1" to clipboard
wasm_parser: ^0.0.1 copied to clipboard

Parses Web Assembly (WASM), WASM Text Format (WAT) and Web Assembly Interface Types (WIT) files

example/wasm_parser_example.dart

import 'package:wasm_parser/wasm_parser.dart';
import 'package:wasm_wit_component/wasm_wit_component.dart';

Future<void> main() async {
  final world = await createWasmParser(
    wasiConfig: WasiConfig(preopenedDirs: [], webBrowserFileSystem: {}),
    imports: WasmParserWorldImports(),
  );

  final result = world.parseWat(
    input: WatInput.text(r'''
        (module
            (import "host" "hello" (func $host_hello (param i32)))
            (func (export "hello")
                (call $host_hello (i32.const 3))
            )
        )
    '''),
  );
  print(result);
  const expected = ModuleType(
    imports: [
      ModuleImport(
        module: 'host',
        name: 'hello',
        type: FunctionType(
          parameters: [ValueType.i32()],
          results: [],
        ),
      ),
    ],
    exports: [
      ModuleExport(
        name: 'hello',
        type: FunctionType(
          parameters: [],
          results: [],
        ),
      ),
    ],
  );
  assert(
    result == const Ok<WasmType, String>(expected),
  );
}
0
likes
160
pub points
23%
popularity

Publisher

unverified uploader

Parses Web Assembly (WASM), WASM Text Format (WAT) and Web Assembly Interface Types (WIT) files

Repository (GitHub)
View/report issues

Topics

#wasm #wit #parser #wat

Documentation

API reference

License

MIT (LICENSE)

Dependencies

wasm_run, wasm_wit_component

More

Packages that depend on wasm_parser