blob: 6eb5b2a4b789f410044f87a9a2a36ba4d7985eb5 [file] [log] [blame]
Martijn Coenencbe590c2016-08-30 11:27:56 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Yifan Hongab407f02016-08-12 17:39:44 -070017package android.hardware.tests.expression@1.0;
Yifan Hong252c1c52016-09-19 10:19:24 -070018
Yifan Hongab407f02016-08-12 17:39:44 -070019interface IExpression {
Yifan Honga4016802016-08-18 15:09:28 -070020 enum UInt64LiteralTypeGuessing : uint64_t {
21 noSuffixDec1 = 0,
22 noSuffixDec2 = 1,
23 noSuffixDec3 = -1,
24 noSuffixDec4 = ~0,
25 noSuffixDec5 = 2147483647,
26 noSuffixDec6 = -2147483648,
27 noSuffixDec7 = 2147483648,
28 noSuffixDec8 = -2147483649,
29 noSuffixDec9 = ~(-1),
30 noSuffixHex1 = 0x7fffffff,
31 noSuffixHex2 = 0x80000000,
32 noSuffixHex3 = 0xffffffff,
33 longHex1 = 0xffffffffl,
Yifan Honge3120062016-10-07 16:32:57 -070034 longHex2 = 0Xfffffffff,
Yifan Honga4016802016-08-18 15:09:28 -070035 longHex3 = 0x7fffffffffffffff,
36 longHex4 = 0x8000000000000000,
37 longHex5 = 0xFFFFFFFFFFFFFFFF,
38 };
39
40 enum SuffixedLiteralTypeGuessing : int32_t {
41 // Should be all true / ones.
42 // dec literals are either int32_t or int64_t
43 decInt32_1 = (~(-1)) == 0,
44 decInt32_2 = -(1 << 31) == (1 << 31),
45 decInt64_1 = (~(-1l)) == 0,
46 decInt64_2 = (~4294967295) != 0,
47 decInt64_3 = (~4294967295l) != 0,
48 decInt64_4 = -(1l << 63) == (1l << 63),
49 // hex literals could be (u)int32_t or (u)int64_t
50 // 0x7fffffff is int32_t, hence can be negated
51 hexInt32_1 = -0x7fffffff < 0,
52 // 0x80000000 is uint32_t; if it were int32_t then -(int32_t)0x80000000 == (int32_t)0x80000000 > 0
53 hexUInt32_1 = -0x80000000 > 0,
54 // 0xFFFFFFFF is uint32_t, not int64_t; if it were int64_t then ~(int64_t)0xFFFFFFFF != 0
55 hexUInt32_2 = ~0xFFFFFFFF == 0,
56 // 0x7FFFFFFFFFFFFFFF is int64_t, hence can be negated
57 hexInt64_1 = -0x7FFFFFFFFFFFFFFF < 0,
58 // 0x8000000000000000 is uint64_t
59 hexUInt64_1 = -0x8000000000000000 > 0,
60 };
61
62 enum Int64LiteralTypeGuessing : int64_t {
63 // both treated int32_t, sum = (int64_t)(int32_t)0x80000000 = (int64_t)(-2147483648)
64 noSuffixDec11 = 1 + 0x7fffffff,
65 // 0x80000000 is uint32_t, sum = (int64_t)(uint32_t)0x7fffffff = (int64_t)(2147483647)
66 noSuffixDec12 = 0x80000000 - 1,
67 };
68
69 enum Int32BitShifting : int32_t {
70 // Shifting for more than 31 bits are undefined. Not tested.
71 int32BitShift1 = 1 << 31,
72 };
73
74 enum UInt32BitShifting : uint32_t {
75 uint32BitShift1 = 1 << 31,
76 };
77
78 enum Int64BitShifting : int64_t {
79 int64BitShift1 = 1l << 63,
80 };
81
82 enum UInt64BitShifting : uint64_t {
83 uint64BitShift1 = 1l << 63,
84 };
85
86 enum Precedence : int32_t {
Yifan Hongab407f02016-08-12 17:39:44 -070087 literal = 4,
Yifan Honga4016802016-08-18 15:09:28 -070088 neg = -4,
Yifan Hongab407f02016-08-12 17:39:44 -070089 literalL = -4L,
Yifan Honga4016802016-08-18 15:09:28 -070090 hex = 0xffffffff,
91 hexLong = 0xffffffffl,
92 hexLong2 = 0xfffffffff,
Yifan Hongab407f02016-08-12 17:39:44 -070093 simpleArithmetic = 4 + 1,
Yifan Honga4016802016-08-18 15:09:28 -070094 simpleArithmetic2 = 2 + 3 - 4,
95 simpleBoolExpr = 1 == 4,
96 simpleLogical = 1 && 1,
97 simpleComp = 1 < 2,
98 boolExpr1 = !((3 != 4 || (2 < 3 <= 3 > 4)) >= 0),
Yifan Hongab407f02016-08-12 17:39:44 -070099 boolExpr = 1 == 7 && !((3 != 4 || (2 < 3 <= 3 > 4)) >= 0),
Yifan Honga4016802016-08-18 15:09:28 -0700100 simpleBitShift = 1 << 2,
101 simpleBitShift2 = 4 >> 1,
102 simpleBitShiftNeg = 4 << -1,
103 simpleArithmeticRightShift = 1 << 31 >> 31,
104 simpleBitExpr = 1 | 16 >> 2,
Yifan Hongab407f02016-08-12 17:39:44 -0700105 bitExpr = ~42 & (1 << 3 | 16 >> 2) ^ 7,
106 arithmeticExpr = 2 + 3 - 4 * -7 / (10 % 3),
Yifan Honga4016802016-08-18 15:09:28 -0700107 messyExpr = 2 + (-3&4 / 7),
Yifan Hongab407f02016-08-12 17:39:44 -0700108 paranExpr = (((((1 + 1))))),
109 ternary = 1?2:3,
110 ternary2 = 1&&2?3:4,
Yifan Honga4016802016-08-18 15:09:28 -0700111 complicatedTernary2 = 1 - 1 && 2 + 3 || 5 ? 7 * 8 : -3,
Yifan Hongab407f02016-08-12 17:39:44 -0700112 };
Yifan Honga4016802016-08-18 15:09:28 -0700113
114 enum OperatorSanityCheck : int32_t {
115 // Should be all true / ones.
116 plus = (1 + 2) == 3,
117 minus = (8 - 9) == -1,
118 product = (9 * 9) == 81,
119 division = (29 / 3) == 9,
120 mod = (29 % 3) == 2,
121 bit_or = (0xC0010000 | 0xF00D) == (0xC001F00D),
122 bit_or2 = (10 | 6) == 14,
123 bit_and = (10 & 6) == 2,
124 bit_xor = (10 ^ 6) == 12,
125 lt1 = 6 < 10,
126 lt2 = (10 < 10) == 0,
127 gt1 = (6 > 10) == 0,
128 gt2 = (10 > 10) == 0,
129 gte1 = 19 >= 10,
130 gte2 = 10 >= 10,
131 lte1 = 5 <= 10,
132 lte2 = (19 <= 10) == 0,
133 ne1 = 19 != 10,
134 ne2 = (10 != 10) == 0,
135 lshift = (22 << 1) == 44,
136 rshift = (11 >> 1) == 5,
137 logor1 = (1 || 0) == 1,
138 logor2 = (1 || 1) == 1,
139 logor3 = (0 || 0) == 0,
140 logor4 = (0 || 1) == 1,
141 logand1 = (1 && 0) == 0,
142 logand2 = (1 && 1) == 1,
143 logand3 = (0 && 0) == 0,
144 logand4 = (0 && 1) == 0,
145 };
146
Yifan Hong467bb282016-09-20 13:41:30 -0700147 enum Grayscale : int8_t {
148 WHITE = 126,
149 GRAY, // 127
150 DARK_GRAY, // -128
151 BLACK // -127
152 };
153
154 enum Color : Grayscale {
155 RED, // -126
156 RUBY = 0,
157 GREEN, // 1
158 BLUE = 5,
159 CYAN, // 6
160 ORANGE, // 7
161 ROSE = WHITE,
162 };
163
164 enum Foo1 : int8_t {};
165 enum Foo2 : Foo1 {};
166 enum Foo3 : Foo2 {
167 BAR1, // 0
168 BAR2 = 10,
169 };
170 enum Foo4 : Foo3 {
171 BAR3, // 11
172 BAR4 = BAR2 + BAR3 // 21
173 };
174
175 enum Number : uint8_t {
176 MAX = 255,
177 MAX_PLUS_1, // 0
178 MAX_PLUS_2 // 1
179 };
180
Steven Morelandd26dc502016-11-29 14:07:27 -0800181 enum Constants : int32_t {
Yifan Hong467bb282016-09-20 13:41:30 -0700182 CONST_FOO,
183 CONST_BAR = 70,
184 MAX_ARRAY_SIZE = 20,
185 MAX_ARRAY_SIZE2,
186 MAX_ARRAY_SIZE3 = MAX_ARRAY_SIZE + MAX_ARRAY_SIZE,
187 MY_INT32_MAX_MINUS_1 = 0x7FFFFFFE,
188 MY_INT32_MAX, // 0x7FFFFFFF
189 MY_INT32_MIN, // 0x80000000
190 MY_INT32_MIN_PLUS_1, // 0x80000001
191 };
192
193 @callflow(key=Constants:CONST_FOO + 1)
194 foo1(int32_t[Constants:CONST_FOO + 1] array);
195 foo2(int32_t[5 + 8] array);
196 foo3(int32_t[Constants:MAX_ARRAY_SIZE] array);
Yifan Hongab407f02016-08-12 17:39:44 -0700197};