diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-09-04 19:53:05 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-09-04 20:25:23 +0200 |
| commit | 399addc8754ed0b484d3c159ac35befe1d3f652c (patch) | |
| tree | 38f937a6c625d253b50b0f51e988ed1c22630b57 /pkg/compiler/compiler_test.go | |
| parent | 94e151ceb51191698a068d96191cdd86326050f9 (diff) | |
sys, pkg/compiler: move padding computation to compiler
This makes types constant during execution, everything is precomputed.
Diffstat (limited to 'pkg/compiler/compiler_test.go')
| -rw-r--r-- | pkg/compiler/compiler_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
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) +} |
