blob: 4d9f2a5716766157a015b5acdb4b7b1832f117bc [file] [log] [blame]
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[$default byte_order: "LittleEndian"]
[(cpp) namespace: "emboss::test"]
struct BasicConditional:
0 [+1] UInt x
if x == 0:
1 [+1] UInt xc
struct NegativeConditional:
0 [+1] UInt x
if x != 0:
1 [+1] UInt xc
struct ConditionalAndUnconditionalOverlappingFinalField:
0 [+1] UInt x
if x == 0:
1 [+1] UInt xc
1 [+1] UInt z
struct ConditionalBasicConditionalFieldFirst:
if x == 0:
0 [+1] UInt xc
1 [+1] UInt x
struct ConditionalAndDynamicLocation:
0 [+1] UInt x
2 [+1] UInt y
if x == 0:
y [+1] UInt xc
struct ConditionUsesMinInt:
0 [+1] Int x
if x - 0x7fff_ffff_ffff_ff80 == -0x8000_0000_0000_0000:
1 [+1] UInt xc
struct NestedConditional:
0 [+1] UInt x
if x == 0:
1 [+1] UInt xc
if xc == 0:
2 [+1] UInt xcc
struct CorrectNestedConditional:
0 [+1] UInt x
if x == 0:
1 [+1] UInt xc
if x == 0 && xc == 0:
2 [+1] UInt xcc
struct AlwaysFalseCondition:
0 [+1] UInt x
if false:
1 [+1] UInt xc
struct OnlyAlwaysFalseCondition:
if false:
0 [+1] UInt xc
struct EmptyStruct:
-- Empty structure.
struct AlwaysFalseConditionDynamicSize:
0 [+1] UInt x
x [+1] UInt y
if false:
1 [+1] UInt xc
struct ConditionDoesNotContributeToSize:
0 [+1] UInt x
if x == 0:
1 [+1] UInt xc
2 [+1] UInt y
enum OnOff:
OFF = 0
ON = 1
struct EnumCondition:
0 [+1] OnOff x
if x == OnOff.ON:
1 [+1] UInt xc
if x > OnOff.OFF:
1 [+1] UInt xc2
struct NegativeEnumCondition:
0 [+1] OnOff x
if x != OnOff.ON:
1 [+1] UInt xc
struct LessThanCondition:
0 [+1] UInt x
if x < 5:
1 [+1] UInt xc
struct LessThanOrEqualCondition:
0 [+1] UInt x
if x <= 5:
1 [+1] UInt xc
struct GreaterThanOrEqualCondition:
0 [+1] UInt x
if x >= 5:
1 [+1] UInt xc
struct GreaterThanCondition:
0 [+1] UInt x
if x > 5:
1 [+1] UInt xc
struct RangeCondition:
0 [+1] UInt x
1 [+1] UInt y
if 5 < x <= y < 10:
2 [+1] UInt xc
struct ReverseRangeCondition:
0 [+1] UInt x
1 [+1] UInt y
if 10 > y >= x > 5:
2 [+1] UInt xc
struct AndCondition:
0 [+1] UInt x
1 [+1] UInt y
if x == 5 && y == 5:
2 [+1] UInt xc
struct OrCondition:
0 [+1] UInt x
1 [+1] UInt y
if x == 5 || y == 5:
2 [+1] UInt xc
struct ChoiceCondition:
0 [+1] enum field:
USE_X = 1
USE_Y = 2
1 [+1] UInt x
2 [+1] UInt y
if (field == Field.USE_X ? x : y) == 5:
3 [+1] UInt xyc
struct ContainsBits:
0 [+1] bits:
7 [+1] UInt has_top
0 [+1] UInt has_bottom
struct ContainsContainsBits:
0 [+1] ContainsBits condition
# TODO(bolms): allow Flags to be used as booleans in conditions.
if condition.has_top == 1:
1 [+1] UInt top
struct ConditionalInline:
0 [+1] UInt payload_id
if payload_id == 0:
1 [+3] struct type_0:
0 [+1] UInt a
1 [+1] UInt b
2 [+1] UInt c
if payload_id == 1:
1 [+3] struct type_1:
0 [+1] UInt a
1 [+1] UInt b
2 [+1] UInt c
struct ConditionalAnonymous:
0 [+1] UInt x
if x > 10:
1 [+1] bits:
0 [+1] UInt low
if low == 1:
3 [+2] UInt mid
7 [+1] UInt high
struct ConditionalOnFlag:
0 [+1] bits:
0 [+1] Flag enabled
if enabled:
1 [+1] UInt value