blob: 2db9f617ce9647b28f3230d52352e08d345f970a [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,
Yifan Hong07dd1bb2017-09-15 17:45:33 -070095 simpleArithmetic3 = 2 - 3 + 4,
Yifan Honga4016802016-08-18 15:09:28 -070096 simpleBoolExpr = 1 == 4,
97 simpleLogical = 1 && 1,
Yifan Hong07dd1bb2017-09-15 17:45:33 -070098 simpleLogical2 = 1 || 1 && 0, // && higher than ||
Yifan Honga4016802016-08-18 15:09:28 -070099 simpleComp = 1 < 2,
100 boolExpr1 = !((3 != 4 || (2 < 3 <= 3 > 4)) >= 0),
Yifan Hongab407f02016-08-12 17:39:44 -0700101 boolExpr = 1 == 7 && !((3 != 4 || (2 < 3 <= 3 > 4)) >= 0),
Yifan Honga4016802016-08-18 15:09:28 -0700102 simpleBitShift = 1 << 2,
103 simpleBitShift2 = 4 >> 1,
104 simpleBitShiftNeg = 4 << -1,
105 simpleArithmeticRightShift = 1 << 31 >> 31,
106 simpleBitExpr = 1 | 16 >> 2,
Yifan Hong07dd1bb2017-09-15 17:45:33 -0700107 simpleBitExpr2 = 0x0f ^ 0x33 & 0x99, // & higher than ^
Yifan Hongab407f02016-08-12 17:39:44 -0700108 bitExpr = ~42 & (1 << 3 | 16 >> 2) ^ 7,
109 arithmeticExpr = 2 + 3 - 4 * -7 / (10 % 3),
Yifan Honga4016802016-08-18 15:09:28 -0700110 messyExpr = 2 + (-3&4 / 7),
Yifan Hongab407f02016-08-12 17:39:44 -0700111 paranExpr = (((((1 + 1))))),
112 ternary = 1?2:3,
113 ternary2 = 1&&2?3:4,
Yifan Honga4016802016-08-18 15:09:28 -0700114 complicatedTernary2 = 1 - 1 && 2 + 3 || 5 ? 7 * 8 : -3,
Yifan Hongab407f02016-08-12 17:39:44 -0700115 };
Yifan Honga4016802016-08-18 15:09:28 -0700116
117 enum OperatorSanityCheck : int32_t {
118 // Should be all true / ones.
119 plus = (1 + 2) == 3,
120 minus = (8 - 9) == -1,
121 product = (9 * 9) == 81,
122 division = (29 / 3) == 9,
123 mod = (29 % 3) == 2,
124 bit_or = (0xC0010000 | 0xF00D) == (0xC001F00D),
125 bit_or2 = (10 | 6) == 14,
126 bit_and = (10 & 6) == 2,
127 bit_xor = (10 ^ 6) == 12,
128 lt1 = 6 < 10,
129 lt2 = (10 < 10) == 0,
130 gt1 = (6 > 10) == 0,
131 gt2 = (10 > 10) == 0,
132 gte1 = 19 >= 10,
133 gte2 = 10 >= 10,
134 lte1 = 5 <= 10,
135 lte2 = (19 <= 10) == 0,
136 ne1 = 19 != 10,
137 ne2 = (10 != 10) == 0,
138 lshift = (22 << 1) == 44,
139 rshift = (11 >> 1) == 5,
140 logor1 = (1 || 0) == 1,
141 logor2 = (1 || 1) == 1,
142 logor3 = (0 || 0) == 0,
143 logor4 = (0 || 1) == 1,
144 logand1 = (1 && 0) == 0,
145 logand2 = (1 && 1) == 1,
146 logand3 = (0 && 0) == 0,
147 logand4 = (0 && 1) == 0,
148 };
149
Yifan Hong467bb282016-09-20 13:41:30 -0700150 enum Grayscale : int8_t {
151 WHITE = 126,
152 GRAY, // 127
153 DARK_GRAY, // -128
154 BLACK // -127
155 };
156
157 enum Color : Grayscale {
158 RED, // -126
159 RUBY = 0,
160 GREEN, // 1
161 BLUE = 5,
162 CYAN, // 6
163 ORANGE, // 7
164 ROSE = WHITE,
165 };
166
167 enum Foo1 : int8_t {};
168 enum Foo2 : Foo1 {};
169 enum Foo3 : Foo2 {
170 BAR1, // 0
171 BAR2 = 10,
172 };
173 enum Foo4 : Foo3 {
174 BAR3, // 11
175 BAR4 = BAR2 + BAR3 // 21
176 };
177
178 enum Number : uint8_t {
179 MAX = 255,
180 MAX_PLUS_1, // 0
181 MAX_PLUS_2 // 1
182 };
183
Steven Morelandd26dc502016-11-29 14:07:27 -0800184 enum Constants : int32_t {
Yifan Hong467bb282016-09-20 13:41:30 -0700185 CONST_FOO,
186 CONST_BAR = 70,
187 MAX_ARRAY_SIZE = 20,
188 MAX_ARRAY_SIZE2,
189 MAX_ARRAY_SIZE3 = MAX_ARRAY_SIZE + MAX_ARRAY_SIZE,
190 MY_INT32_MAX_MINUS_1 = 0x7FFFFFFE,
191 MY_INT32_MAX, // 0x7FFFFFFF
192 MY_INT32_MIN, // 0x80000000
193 MY_INT32_MIN_PLUS_1, // 0x80000001
194 };
195
196 @callflow(key=Constants:CONST_FOO + 1)
197 foo1(int32_t[Constants:CONST_FOO + 1] array);
198 foo2(int32_t[5 + 8] array);
199 foo3(int32_t[Constants:MAX_ARRAY_SIZE] array);
Yifan Hongab407f02016-08-12 17:39:44 -0700200};