Open sirisian opened 2 years ago
More thoughts related to this.
In the generics extension I refer to the point there's no int
or uint
base type. This can be remedied by changing the types to be uint<N>
and int<N>
where both extend from uint
and int
respectively.
boolean at least for SIMD masks can be thought of as uint<1>
.
type boolean1 = uint<1>;
type boolean8 = vector<boolean1, 8>;
type boolean8x16 = vector<boolean8, 16>; // vector<vector<uint<1>, 8>, 16>
Further down in the current spec I mention allowing bit fields. Weirdly enough ECMAScript is seeing use in embedded systems. Sometimes it's things like devices having web interfaces. As computing power continues to increase there are more low level libraries being used by developers.
class Vector2 {
x:uint<4>; // 4 bits
y:uint<4>; // 4 bits
}
It's important to quickly mock up such bitfield syntax and ensure the language defines the memory layout as it can't be changed later.
WIP: Continue this later...
Updated https://github.com/sirisian/ecmascript-types/blob/master/README.md#types-proposed with these changes.
TODO: Update the bit-fields section and the memory layout sections to support bit alignment and sizes optionally.
WIP issue with thoughts.
Currently the SIMD types are:
Been thinking they could just be aliases. They're really nice to have as they make math code compact. One of the main reasons I originally defined them as separate types is because they need component accessors in the form of:
These would be part of the swizzling operators on vectors of size 2 and 4.
There are vectors with sizes 2, 4, 8, 16, and 32. These could all be defined like:
We'd need to make the boolean bitflag types real:
boolean8, boolean16, boolean32, boolean64
. These array syntax to access bitflags probably.