walt-compiler
Version:
Alternative syntax for WebAssembly text format
188 lines (173 loc) • 3.94 kB
Markdown
# Snapshot report for `src/utils/__tests__/print-node-spec.js`
The actual snapshot is saved in `print-node-spec.js.snap`.
Generated by [AVA](https://ava.li).
## assignment, ternary, if
> Snapshot 1
`(local x i32␊
(i32.const 0)␊
)␊
(export␊
(func test param(z i32) (result i32)␊
(block␊
(local y i32␊
(select␊
(i32.const 1)␊
(i32.const 0)␊
(i32.gt_s␊
(get_local z)␊
(i32.const 0)␊
)␊
)␊
)␊
(if␊
(i32.eq␊
(get_local z)␊
(i32.const 2)␊
)␊
(then␊
(block␊
(set_global x␊
(i32.const 2)␊
)␊
)␊
)␊
(else␊
(block␊
(set_global x␊
(i32.const 1)␊
)␊
)␊
)␊
)␊
(set_local y␊
(i32.add␊
(i32.const 1)␊
(i32.const 1)␊
)␊
)␊
(return␊
(i32.add␊
(get_global x)␊
(get_local y)␊
)␊
)␊
)␊
)␊
)␊
`
## full ast printer
> Snapshot 1
`(memory 1)␊
(func simple (result i32)␊
(block␊
(local x i32␊
(i32.add␊
(i32.const 1)␊
(i32.const 1)␊
)␊
)␊
(local y i32␊
(i32.const 2)␊
)␊
(return␊
(i32.add␊
(get_local x)␊
(get_local y)␊
)␊
)␊
)␊
)␊
(func multiple_args param(x i32 y f32) (result f32)␊
(block␊
(return␊
(f32.add␊
(f32.convert_s/i32␊
(get_local x)␊
)␊
(get_local y)␊
)␊
)␊
)␊
)␊
(func arrays (result i32)␊
(block␊
(local x i32␊
(i32.const 0)␊
)␊
(i32.store␊
(get_local x)␊
(i32.const 2)␊
)␊
(i32.store␊
(i32.add␊
(get_local x)␊
(i32.shl␊
(i32.const 1)␊
(i32.const 2)␊
)␊
)␊
(i32.const 2)␊
)␊
(return␊
(i32.add␊
(i32.load␊
(get_local x)␊
)␊
(i32.load␊
(i32.add␊
(get_local x)␊
(i32.shl␊
(i32.const 1)␊
(i32.const 2)␊
)␊
)␊
)␊
)␊
)␊
)␊
)␊
`
## imports/exports
> Snapshot 1
`(import "env" "foo" (type FooType (func (result i32))))␊
(import "env" "bar" (type FooType (func (result i32))))␊
(type FooType (func (result i32)))␊
(func two (result i32)␊
(block␊
(return␊
(i32.const 2)␊
)␊
)␊
)␊
(export␊
(func test (result i32)␊
(block␊
(return␊
(call foo␊
(i32.add␊
(call two)␊
(i32.const 2)␊
)␊
)␊
)␊
)␊
)␊
)␊
`
## plain ast parser
> Snapshot 1
`(type Type (func param(i32 f32) (result i32)))␊
(func simple param(y i32) (result i32)␊
(block␊
(local x i32␊
(i32.const 2)␊
)␊
(return␊
(??.add␊
(get_local x)␊
(get_local y)␊
)␊
)␊
)␊
)␊
`