xref: /aosp_15_r20/external/emboss/testdata/complex_offset.emb (revision 99e0aae7469b87d12f0ad23e61142c2d74c1ef70)
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15-- Test .emb with a struct with several consecutive packed fields.
16--
17-- This particular case stresses generated code; common subexpression
18-- elimination is needed in the code generator or else the generated code is
19-- very, *very* slow when compiled without optimizations.
20
21[$default byte_order: "BigEndian"]
22[(cpp) namespace: "emboss::test"]
23
24struct Length:
25  0 [+1]  UInt  length
26
27struct Data:
28  0 [+1]              Length    length
29  1 [+length.length]  UInt:8[]  data
30
31struct PackedFields:
32  0  [+1]            Length    length1 (l1)
33  0  [+l1.length+1]  Data      data1 (d1)
34  let o1 = d1.$size_in_bytes
35  o1 [+1]            Length    length2 (l2)
36  o1 [+l2.length+1]  Data      data2 (d2)
37  let o2 = o1 + d2.$size_in_bytes
38  o2 [+1]            Length    length3 (l3)
39  o2 [+l3.length+1]  Data      data3 (d3)
40  let o3 = o2 + d3.$size_in_bytes
41  o3 [+1]            Length    length4 (l4)
42  o3 [+l4.length+1]  Data      data4 (d4)
43  let o4 = o3 + d4.$size_in_bytes
44  o4 [+1]            Length    length5 (l5)
45  o4 [+l5.length+1]  Data      data5 (d5)
46  let o5 = o4 + d5.$size_in_bytes
47  o5 [+1]            Length    length6 (l6)
48  o5 [+l6.length+1]  Data      data6 (d6)
49