From 399addc8754ed0b484d3c159ac35befe1d3f652c Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 4 Sep 2017 19:53:05 +0200 Subject: sys, pkg/compiler: move padding computation to compiler This makes types constant during execution, everything is precomputed. --- pkg/compiler/compiler_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'pkg/compiler/compiler_test.go') diff --git a/pkg/compiler/compiler_test.go b/pkg/compiler/compiler_test.go index 08fb9a9b9..d6d139161 100644 --- a/pkg/compiler/compiler_test.go +++ b/pkg/compiler/compiler_test.go @@ -71,3 +71,33 @@ func TestFuzz(t *testing.T) { } } } + +func TestAlign(t *testing.T) { + const input = ` +foo$0(a ptr[in, s0]) +s0 { + f0 int8 + f1 int16 +} + +foo$1(a ptr[in, s1]) +s1 { + f0 ptr[in, s2, opt] +} +s2 { + f1 s1 + f2 array[s1, 2] + f3 array[array[s1, 2], 2] +} + ` + desc := ast.Parse([]byte(input), "input", nil) + if desc == nil { + t.Fatal("failed to parse") + } + p := Compile(desc, map[string]uint64{"__NR_foo": 1}, 8, nil) + if p == nil { + t.Fatal("failed to compile") + } + got := p.StructDescs[0].Desc + t.Logf("got: %#v", got) +} -- cgit mrf-deployment