Summary

Topics: Saturating signed division - Fixed width arithmetic in devel branch and Preparations for better type checker

Last two weeks were slow. Not much happened. Mostly small improvements, and some work around the VM (CI maintenance, checking compiler behaviour, etc.).


Saturating signed division

Saturating signed division instruction saturatingsdiv was implemented. This was the last instruction to be implemented for signed values, which means that the signed fixed-width arithmetic implementation is now (mostly) complete.

Fixed width arithmetic in devel branch

Signed fixed-width arithmetic instructions were merged into devel branch.

Preparations for better type checker

Current type checker for Viua VM assembly is incredibly limited, and is unable to check more complex types. This comes mostly from the limitations of the type inferencer. "Complex type" means that the type is parametrised by more than one value (or the parametrisation goes more than one level deep).

As an example: the inferencer is able to correctly and fully deduce a type "pointer to T", but is unable to deduce "vector of pointer to T" and will leave such values as "vector of pointer to value" which means that anything goes. The final goal for the inferencer and checker is to be able to deduce arbitratily nested types, e.g. "pointer to vector of vector of pointer to text" (in C++ this would be "std::vector<std::vector<std::string*>>*". Type checker could then use the detailed types to better verify programs.

What is more, the static analyser could employ the richer type information provided by the enhanced inferencer to check things other than types: 1/ process joinability, 2/ bit shifts and operations (i.e. ensuring that matching widths are used, or that no narrowing conversions happen), 3/ whether fixed width arithmetic operations are used consistently, etc.

There are no plans, though, to extend the support to verify types of fields in structures. The type checker and static analyser will only ensure that the types are used consistently, but Viua VM assembly will not provide a way to declare types for structure fields (similarly as it does not provide a way to declare types of functions - they are only verified for consistency of use, not declared explicitly). This functionality will be left for higher-level languages.