Download Latest Version Version 0.21.0.zip (7.1 MB)
Email in envelope

Get an email when there's a new version of Walt

Home / walt-compiler@0.15.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2018-10-06 2.0 kB
Static Arrays (data sections), Memory resizing source code.tar.gz 2018-10-06 7.5 MB
Static Arrays (data sections), Memory resizing source code.zip 2018-10-06 7.6 MB
Totals: 3 Items   15.1 MB 0

This release adds new syntax sugar for data sections, memory size/resize operations and bug fixes to the CLI tool.

New - Static Arrays/Data sections

WebAssembly Spec allows for the declaration of static regions of memory which can be pre-defined in the wasm source.

https://github.com/WebAssembly/spec/blob/master/test/core/data.wast

:::wast
(module
  (memory $m 1)
  (data (i32.const 0))
  (data (i32.const 1) "a" "" "bcd")
  (data (offset (i32.const 0)))
  (data (offset (i32.const 0)) "" "a" "bc" "")
  (data 0 (i32.const 0))
  (data 0x0 (i32.const 1) "a" "" "bcd")
  (data 0x000 (offset (i32.const 0)))
  (data 0 (offset (i32.const 0)) "" "a" "bc" "")
  (data $m (i32.const 0))
  (data $m (i32.const 1) "a" "" "bcd")
  (data $m (offset (i32.const 0)))
  (data $m (offset (i32.const 0)) "" "a" "bc" "")
)

This exact pattern was impossible to implement in Walt previous. Now the developer may define these sections with an array literal syntax at global scope inside a walt module.

:::js
const array: i32[] = ['<', 'a', 'b', 1, 2, 3];

Any combination of Walt Primitives is allowed in the array literal as long as they map to the type of the array, however expressions and function calls are not.

New - Memory instructions

WebAssembly spec supports memory resizing from within the binary with a set of memory resizing instructions. This is now supported by Walt syntax by the following methods on an Object of type Memory:

  • memory.size() - maps to current_memory opcode
  • memory.grow() - maps to grow_memory opcode, requires a parameter
  • memory.dataSize() - syntax sugar for getting size of the combined data section regions. Reads zeroth word of memory.

Bug fixes

  • walt-cli has a number of bug fixes to make it operate as designed
  • walt-compiler fixed a bug with escape sequences not working as expected inside character literals
Source: README.md, updated 2018-10-06