Skip to content

Releases: ballercat/walt

Version 0.21.0

02 Jan 01:04
Compare
Choose a tag to compare

Version 0.21.0 of walt-compiler

Features

  • Type aliases. Any type can be aliased N-times. Eg. type Integer = i32;
  • Basic union types, only indexed (arrays) of native types are allowed to be combined with structs. Done via | operator in type declarations. Eg. type Indexed = SomeStruct | i32[];.
  • Arrays of structs properly supported. Indexing into struct arrays now returns offset to the desired memory address instead of a load operation at the address.
  • Direct addressing/offset in structs now supported. This allows indexing directly into memory mapped by a struct, instead of indirectly by loading the address stored in the struct property. Done by prefixing a key with a & operator. Eg. type String = { byteLength: i32, &data: i32[] };
  • Created dedicated specs to syntax features - work in progress.
  • Internal tests can now debug themselves via magic INTROSPECT_* exports, which can print debug version of the syntax without editing test harness logic.

Bugfixes

  • Multiple fixes of property access on struct types.
  • Multiple fixes to grammar (mostly struct/array related).
  • Struct validation fixes.
  • Fix structs as return values of functions.

Nested struct access.

17 Dec 14:11
Compare
Choose a tag to compare

Bugfix and stabilize nested property/struct access.

type Node = {
   value: i32,
   left: Node,
   right: Node
}
...
node.left.right.left; // etc.,

Throw syntax

09 Oct 22:56
Compare
Choose a tag to compare

This PR adds support for the throw keyword. It proxies to the unreachable instruction in the WebAssembly spec. As per spec nothing can be actually "thrown" with the runtime exception.

function test() {
   throw;
}

The syntax does reserve an expression after the throw keyword for future use so this code is also valid, although the expression is ignored after the throw.

function test() {
   // May throw the result of expression in the future if WebAssembly supports it
   throw somefunction(2 + 2, another());
}

Static Arrays (data sections), Memory resizing

06 Oct 17:01
Compare
Choose a tag to compare

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

(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.

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

Syntax Tokens

18 Sep 23:26
Compare
Choose a tag to compare
  • Added "core" language syntax tokens

ENBF Grammar and Plugins

18 Sep 23:29
Compare
Choose a tag to compare
  • Use nearley parser
  • Implement plugin API for grammar/syntax itself
  • Convert all of the syntax to an EBNF grammar
  • Convert all syntax validation to be just grammar