hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 21b8de43955c27fae984aa005d70469dd291cd30
parent c3f15effd8ebc305f83d3d34f88c2f353e469fe1
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  4 May 2021 13:29:34 -0400

hare::types +test: test field alignment

Diffstat:
Mhare/types/+test.ha | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/hare/types/+test.ha b/hare/types/+test.ha @@ -77,7 +77,21 @@ fn parse_type(in: str) ast::_type = { assert(y._type._type as builtin == builtin::INT); // Alignment - // TODO + let atype = parse_type("struct { w: u8, x: u32, y: u8, z: u64 }"); + defer ast::type_free(atype); + let htype = lookup(st, &atype)!; + assert(htype.sz == 24); + let stype = htype._type as _struct; + assert(stype.kind == struct_union::STRUCT); + + let w = stype.fields[0]; + assert(w.offs == 0); + let x = stype.fields[1]; + assert(x.offs == 4); + let y = stype.fields[2]; + assert(y.offs == 8); + let z = stype.fields[3]; + assert(z.offs == 16); // Sort order // TODO