blob: 2462f56fcba288d8bc494c4a8fe32174f7ddeb79 [file] [log] [blame]
Andreas Huber1aec3972016-08-26 09:26:32 -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
Andreas Huberc9410c72016-07-28 12:18:40 -070017#ifndef TYPE_H_
18
19#define TYPE_H_
20
21#include <android-base/macros.h>
Andreas Huber881227d2016-08-02 14:20:21 -070022#include <utils/Errors.h>
Steven Moreland979e0992016-09-07 09:18:08 -070023#include <set>
Timur Iskhakovcec46c42017-08-09 00:22:02 -070024#include <string>
Timur Iskhakov458ca362017-09-12 23:16:03 -070025#include <unordered_map>
Timur Iskhakov33431e62017-08-21 17:31:23 -070026#include <unordered_set>
Timur Iskhakovcec46c42017-08-09 00:22:02 -070027#include <vector>
Andreas Huberc9410c72016-07-28 12:18:40 -070028
Steven Moreland49bad8d2018-05-17 15:45:26 -070029#include "DocComment.h"
Timur Iskhakov505316c2017-08-05 03:38:59 +000030#include "Reference.h"
31
Andreas Huberc9410c72016-07-28 12:18:40 -070032namespace android {
33
Timur Iskhakov891a8662017-08-25 21:53:48 -070034struct ConstantExpression;
Andreas Huberc9410c72016-07-28 12:18:40 -070035struct Formatter;
Steven Moreland979e0992016-09-07 09:18:08 -070036struct FQName;
Timur Iskhakov891a8662017-08-25 21:53:48 -070037struct ScalarType;
Timur Iskhakov63f39902017-08-29 15:47:29 -070038struct Scope;
Andreas Huberc9410c72016-07-28 12:18:40 -070039
Steven Moreland49bad8d2018-05-17 15:45:26 -070040struct Type : DocCommentable {
Timur Iskhakov63f39902017-08-29 15:47:29 -070041 Type(Scope* parent);
Andreas Huberc9410c72016-07-28 12:18:40 -070042 virtual ~Type();
43
Andreas Huber709b62d2016-09-19 11:21:18 -070044 virtual bool isArray() const;
Yifan Hongabf73ee2016-12-05 18:47:00 -080045 virtual bool isBitField() const;
Martijn Coenen99e6beb2016-12-01 15:48:42 +010046 virtual bool isCompoundType() const;
47 virtual bool isEnum() const;
Yifan Hongabf73ee2016-12-05 18:47:00 -080048 virtual bool isHandle() const;
Martijn Coenen99e6beb2016-12-01 15:48:42 +010049 virtual bool isInterface() const;
50 virtual bool isNamedType() const;
Steven Moreland397b5e12017-06-08 14:02:26 -070051 virtual bool isMemory() const;
Martijn Coenen99e6beb2016-12-01 15:48:42 +010052 virtual bool isPointer() const;
53 virtual bool isScope() const;
Yifan Hongabf73ee2016-12-05 18:47:00 -080054 virtual bool isScalar() const;
55 virtual bool isString() const;
56 virtual bool isTemplatedType() const;
Martijn Coenen99e6beb2016-12-01 15:48:42 +010057 virtual bool isTypeDef() const;
Andreas Huber709b62d2016-09-19 11:21:18 -070058 virtual bool isVector() const;
Andreas Huber8d3ac0c2016-08-04 14:49:23 -070059
Timur Iskhakovdbaed332017-08-31 16:33:41 -070060 // Resolves the type by unwrapping typedefs
61 Type* resolve();
62 virtual const Type* resolve() const;
63
Timur Iskhakov33431e62017-08-21 17:31:23 -070064 // All types defined in this type.
Timur Iskhakovb58f4182017-08-29 15:19:24 -070065 std::vector<Type*> getDefinedTypes();
66 virtual std::vector<const Type*> getDefinedTypes() const;
Timur Iskhakov33431e62017-08-21 17:31:23 -070067
68 // All types referenced in this type.
Timur Iskhakovb58f4182017-08-29 15:19:24 -070069 std::vector<Reference<Type>*> getReferences();
70 virtual std::vector<const Reference<Type>*> getReferences() const;
Timur Iskhakov33431e62017-08-21 17:31:23 -070071
Timur Iskhakov891a8662017-08-25 21:53:48 -070072 // All constant expressions referenced in this type.
Timur Iskhakovb58f4182017-08-29 15:19:24 -070073 std::vector<ConstantExpression*> getConstantExpressions();
74 virtual std::vector<const ConstantExpression*> getConstantExpressions() const;
Timur Iskhakov891a8662017-08-25 21:53:48 -070075
Timur Iskhakov40731af2017-08-24 14:18:35 -070076 // All types referenced in this type that must have completed
77 // definiton before being referenced.
Timur Iskhakovb58f4182017-08-29 15:19:24 -070078 std::vector<Reference<Type>*> getStrongReferences();
79 virtual std::vector<const Reference<Type>*> getStrongReferences() const;
Timur Iskhakov40731af2017-08-24 14:18:35 -070080
Yifan Hong0e192c42018-10-23 15:32:19 -070081 // Indicate stage of parsing.
82 enum class ParseStage {
83 // Indicate that the source file is being parsed and this object is being filled.
84 PARSE,
85 // Indicate that all source files are parsed, and program is working on type dependencies
86 // and validation.
87 POST_PARSE,
88 // Indicate that parsing is completed, and program is in code-generation stage.
89 COMPLETED,
90 };
91
Timur Iskhakov33431e62017-08-21 17:31:23 -070092 // Proceeds recursive pass
93 // Makes sure to visit each node only once.
Yifan Hong0e192c42018-10-23 15:32:19 -070094 // If mParseStage < stage, object is not ready for this recursivePass() call
95 // yet, and function will return error.
96 status_t recursivePass(ParseStage stage, const std::function<status_t(Type*)>& func,
Timur Iskhakov33431e62017-08-21 17:31:23 -070097 std::unordered_set<const Type*>* visited);
Yifan Hong0e192c42018-10-23 15:32:19 -070098 status_t recursivePass(ParseStage stage, const std::function<status_t(const Type*)>& func,
Timur Iskhakov33431e62017-08-21 17:31:23 -070099 std::unordered_set<const Type*>* visited) const;
100
Timur Iskhakovcec46c42017-08-09 00:22:02 -0700101 // Recursive tree pass that completes type declarations
102 // that depend on super types
103 virtual status_t resolveInheritance();
104
Timur Iskhakovcec46c42017-08-09 00:22:02 -0700105 // Recursive tree pass that validates all type-related
106 // syntax restrictions
107 virtual status_t validate() const;
108
Timur Iskhakov40731af2017-08-24 14:18:35 -0700109 // Recursive tree pass checkAcyclic return type.
110 // Stores cycle end for nice error messages.
111 struct CheckAcyclicStatus {
112 CheckAcyclicStatus(status_t status, const Type* cycleEnd = nullptr);
113
114 status_t status;
115
116 // If a cycle is found, stores the end of cycle.
117 // While going back in recursion, this is used to stop printing the cycle.
118 const Type* cycleEnd;
119 };
120
121 // Recursive tree pass that ensures that type definitions and references
Timur Iskhakov458ca362017-09-12 23:16:03 -0700122 // are acyclic and builds reversed topological order of the types.
Timur Iskhakov40731af2017-08-24 14:18:35 -0700123 // If some cases allow using of incomplete types, these cases are to be
124 // declared in Type::getStrongReferences.
Timur Iskhakov458ca362017-09-12 23:16:03 -0700125 CheckAcyclicStatus topologicalOrder(std::unordered_map<const Type*, size_t>* reversedOrder,
126 std::unordered_set<const Type*>* stack) const;
Timur Iskhakov40731af2017-08-24 14:18:35 -0700127
Timur Iskhakov041fdfe2017-09-06 15:56:01 -0700128 // Checks following C++ restriction on forward declaration:
129 // inner struct could be forward declared only inside its parent.
Timur Iskhakov458ca362017-09-12 23:16:03 -0700130 status_t checkForwardReferenceRestrictions(const Reference<Type>& ref) const;
Timur Iskhakov041fdfe2017-09-06 15:56:01 -0700131
Andreas Huber737080b2016-08-02 15:38:04 -0700132 virtual const ScalarType *resolveToScalarType() const;
Andreas Huberc9410c72016-07-28 12:18:40 -0700133
Steven Moreland0ecc7b82017-07-19 12:59:23 -0700134 virtual std::string typeName() const = 0;
Steven Moreland30bb6a82016-11-30 09:18:34 -0800135
Andreas Huber8d3ac0c2016-08-04 14:49:23 -0700136 bool isValidEnumStorageType() const;
Steven Moreland9df52442016-12-12 08:51:14 -0800137 virtual bool isElidableType() const;
Timur Iskhakov5dc72fe2017-09-07 23:13:44 -0700138
Yifan Hongc6752dc2016-12-20 14:00:14 -0800139 virtual bool canCheckEquality() const;
Timur Iskhakov5dc72fe2017-09-07 23:13:44 -0700140 bool canCheckEquality(std::unordered_set<const Type*>* visited) const;
141 virtual bool deepCanCheckEquality(std::unordered_set<const Type*>* visited) const;
Andreas Huber8d3ac0c2016-08-04 14:49:23 -0700142
Yifan Hong0e192c42018-10-23 15:32:19 -0700143 // ParseStage can only be incremented.
144 ParseStage getParseStage() const;
145 void setParseStage(ParseStage stage);
Timur Iskhakov35930c42017-08-28 18:49:54 -0700146
Timur Iskhakov63f39902017-08-29 15:47:29 -0700147 Scope* parent();
Timur Iskhakov041fdfe2017-09-06 15:56:01 -0700148 const Scope* parent() const;
Timur Iskhakov63f39902017-08-29 15:47:29 -0700149
Andreas Huber881227d2016-08-02 14:20:21 -0700150 enum StorageMode {
151 StorageMode_Stack,
152 StorageMode_Argument,
Martijn Coenenac587892016-11-17 15:14:19 +0100153 StorageMode_Result,
Andreas Huber881227d2016-08-02 14:20:21 -0700154 };
Yifan Hong3b320f82016-11-01 15:15:54 -0700155
Steven Morelande30ee9b2017-05-09 13:31:01 -0700156 // specifyNamespaces: whether to specify namespaces for built-in types
Andreas Huber881227d2016-08-02 14:20:21 -0700157 virtual std::string getCppType(
Steven Moreland979e0992016-09-07 09:18:08 -0700158 StorageMode mode,
Yifan Hong3b320f82016-11-01 15:15:54 -0700159 bool specifyNamespaces) const;
160
161 std::string decorateCppName(
162 const std::string &name,
163 StorageMode mode,
Steven Moreland979e0992016-09-07 09:18:08 -0700164 bool specifyNamespaces) const;
165
Yifan Hong3b320f82016-11-01 15:15:54 -0700166 std::string getCppStackType(bool specifyNamespaces = true) const;
Andreas Huber881227d2016-08-02 14:20:21 -0700167
Yifan Hong3b320f82016-11-01 15:15:54 -0700168 std::string getCppResultType(bool specifyNamespaces = true) const;
Andreas Huber881227d2016-08-02 14:20:21 -0700169
Yifan Hong3b320f82016-11-01 15:15:54 -0700170 std::string getCppArgumentType(bool specifyNamespaces = true) const;
Andreas Huber4c865b72016-09-14 15:26:27 -0700171
Nirav Atreca7a5022018-06-29 20:43:49 -0700172 std::string getCppTypeCast(const std::string& objName,
173 bool specifyNamespaces = true) const;
174
Yifan Hong4ed13472016-11-02 10:44:11 -0700175 // For an array type, dimensionality information will be accumulated at the
176 // end of the returned string.
Andreas Huber4c865b72016-09-14 15:26:27 -0700177 // if forInitializer == true, actual dimensions are included, i.e. [3][5],
178 // otherwise (and by default), they are omitted, i.e. [][].
Yifan Hong4ed13472016-11-02 10:44:11 -0700179 virtual std::string getJavaType(bool forInitializer = false) const;
Andreas Huber4c865b72016-09-14 15:26:27 -0700180
Nirav Atre66842a92018-06-28 18:14:13 -0700181 // Identical to getJavaType() for most types, except: primitives, in which
182 // case the wrapper type is returned, and generics (such as ArrayList<?>),
183 // where the type specialization is omitted to facilitate use of
184 // instanceof or class.isInstance().
185 virtual std::string getJavaTypeClass() const;
186
187 virtual std::string getJavaTypeCast(const std::string& objName) const;
Andreas Huber2831d512016-08-15 09:33:47 -0700188 virtual std::string getJavaSuffix() const;
189
Zhuoyao Zhangc5ea9f52016-10-06 15:05:39 -0700190 virtual std::string getVtsType() const;
Zhuoyao Zhange9667842017-01-19 12:35:32 -0800191 virtual std::string getVtsValueName() const;
Zhuoyao Zhangc5ea9f52016-10-06 15:05:39 -0700192
Andreas Huber881227d2016-08-02 14:20:21 -0700193 enum ErrorMode {
194 ErrorMode_Ignore,
195 ErrorMode_Goto,
196 ErrorMode_Break,
Andreas Huber737080b2016-08-02 15:38:04 -0700197 ErrorMode_Return,
Andreas Huber881227d2016-08-02 14:20:21 -0700198 };
199 virtual void emitReaderWriter(
200 Formatter &out,
201 const std::string &name,
202 const std::string &parcelObj,
203 bool parcelObjIsPointer,
204 bool isReader,
205 ErrorMode mode) const;
206
207 virtual void emitReaderWriterEmbedded(
208 Formatter &out,
Andreas Huberf9d49f12016-09-12 14:58:36 -0700209 size_t depth,
Andreas Huber881227d2016-08-02 14:20:21 -0700210 const std::string &name,
Yifan Hongbe2a3732016-10-05 13:33:41 -0700211 const std::string &sanitizedName,
Andreas Huber881227d2016-08-02 14:20:21 -0700212 bool nameIsPointer,
213 const std::string &parcelObj,
214 bool parcelObjIsPointer,
215 bool isReader,
216 ErrorMode mode,
217 const std::string &parentName,
218 const std::string &offsetText) const;
219
Yifan Hongbf459bc2016-08-23 16:50:37 -0700220 virtual void emitResolveReferences(
221 Formatter &out,
222 const std::string &name,
223 bool nameIsPointer,
224 const std::string &parcelObj,
225 bool parcelObjIsPointer,
226 bool isReader,
227 ErrorMode mode) const;
228
229 virtual void emitResolveReferencesEmbedded(
230 Formatter &out,
231 size_t depth,
232 const std::string &name,
233 const std::string &sanitizedName,
234 bool nameIsPointer,
235 const std::string &parcelObj,
236 bool parcelObjIsPointer,
237 bool isReader,
238 ErrorMode mode,
239 const std::string &parentName,
240 const std::string &offsetText) const;
241
Yifan Hongf5cc2f72017-01-04 18:02:34 -0800242 virtual void emitDump(
243 Formatter &out,
244 const std::string &streamName,
245 const std::string &name) const;
246
Yifan Honge45b5302017-02-22 10:49:07 -0800247 virtual void emitJavaDump(
248 Formatter &out,
249 const std::string &streamName,
250 const std::string &name) const;
251
Yifan Hong00f47172016-09-30 14:40:45 -0700252 virtual bool useParentInEmitResolveReferencesEmbedded() const;
253
Andreas Huber2831d512016-08-15 09:33:47 -0700254 virtual void emitJavaReaderWriter(
255 Formatter &out,
256 const std::string &parcelObj,
257 const std::string &argName,
258 bool isReader) const;
259
Andreas Huber85eabdb2016-08-25 11:24:49 -0700260 virtual void emitJavaFieldInitializer(
261 Formatter &out,
262 const std::string &fieldName) const;
263
Nirav Atre66842a92018-06-28 18:14:13 -0700264 virtual void emitJavaFieldDefaultInitialValue(
265 Formatter &out,
266 const std::string &declaredFieldName) const;
267
Andreas Huber85eabdb2016-08-25 11:24:49 -0700268 virtual void emitJavaFieldReaderWriter(
269 Formatter &out,
Andreas Huber4c865b72016-09-14 15:26:27 -0700270 size_t depth,
Andreas Huber709b62d2016-09-19 11:21:18 -0700271 const std::string &parcelName,
Andreas Huber85eabdb2016-08-25 11:24:49 -0700272 const std::string &blobName,
273 const std::string &fieldName,
274 const std::string &offset,
275 bool isReader) const;
276
Steven Moreland368e4602018-02-16 14:21:49 -0800277 virtual void emitTypeDeclarations(Formatter& out) const;
Andreas Huber881227d2016-08-02 14:20:21 -0700278
Steven Moreland8e61c5a2017-11-17 15:55:28 -0800279 virtual void emitGlobalTypeDeclarations(Formatter& out) const;
280
Timur Iskhakovfd3f2502017-09-05 16:25:02 -0700281 // Emit scope C++ forward declaration.
282 // There is no need to forward declare interfaces, as
283 // they are always declared in global scope in dedicated file.
284 virtual void emitTypeForwardDeclaration(Formatter& out) const;
285
Andreas Hubere3f769a2016-10-10 10:54:44 -0700286 // Emit any declarations pertaining to this type that have to be
Steven Moreland09c6ebe2018-10-09 10:15:48 -0700287 // directly in a namespace, i.e. enum class operators.
Steven Moreland4b8f7a12017-11-17 15:39:54 -0800288 // For android.hardware.foo@1.0::*, this will be in namespace
289 // android::hardware::foo::V1_0
Steven Moreland368e4602018-02-16 14:21:49 -0800290 virtual void emitPackageTypeDeclarations(Formatter& out) const;
Andreas Hubere3f769a2016-10-10 10:54:44 -0700291
Steven Moreland09c6ebe2018-10-09 10:15:48 -0700292 // Emit any definitions pertaining to this type that have to be
293 // directly in a namespace. Typically, these are things that are only
294 // used for a small subset of types, so by putting them in the header,
295 // the space cost is moved to the small number of clients that use the
296 // feature.
297 // For android.hardware.foo@1.0::*, this will be in namespace
298 // android::hardware::foo::V1_0
299 virtual void emitPackageTypeHeaderDefinitions(Formatter& out) const;
300
Yifan Hong244e82d2016-11-11 11:13:57 -0800301 // Emit any declarations pertaining to this type that have to be
302 // at global scope for transport, e.g. read/writeEmbeddedTo/FromParcel
Steven Moreland4b8f7a12017-11-17 15:39:54 -0800303 // For android.hardware.foo@1.0::*, this will be in namespace
304 // android::hardware::foo::V1_0
Steven Moreland368e4602018-02-16 14:21:49 -0800305 virtual void emitPackageHwDeclarations(Formatter& out) const;
Yifan Hong244e82d2016-11-11 11:13:57 -0800306
Steven Moreland368e4602018-02-16 14:21:49 -0800307 virtual void emitTypeDefinitions(Formatter& out, const std::string& prefix) const;
Andreas Huber881227d2016-08-02 14:20:21 -0700308
Steven Moreland368e4602018-02-16 14:21:49 -0800309 virtual void emitJavaTypeDeclarations(Formatter& out, bool atTopLevel) const;
Andreas Huber2831d512016-08-15 09:33:47 -0700310
Andreas Huber881227d2016-08-02 14:20:21 -0700311 virtual bool needsEmbeddedReadWrite() const;
312 virtual bool resultNeedsDeref() const;
313
Timur Iskhakov5dc72fe2017-09-07 23:13:44 -0700314 bool needsResolveReferences() const;
315 bool needsResolveReferences(std::unordered_set<const Type*>* visited) const;
316 virtual bool deepNeedsResolveReferences(std::unordered_set<const Type*>* visited) const;
317
Zhuoyao Zhang5158db42016-08-10 10:25:20 -0700318 // Generates type declaration for vts proto file.
319 // TODO (b/30844146): make it a pure virtual method.
Steven Moreland368e4602018-02-16 14:21:49 -0800320 virtual void emitVtsTypeDeclarations(Formatter& out) const;
Zhuoyao Zhang864c7712016-08-16 15:35:28 -0700321 // Generates type declaration as attribute of method (return value or method
322 // argument) or attribute of compound type for vts proto file.
Steven Moreland368e4602018-02-16 14:21:49 -0800323 virtual void emitVtsAttributeType(Formatter& out) const;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -0700324
Andreas Huber70a59e12016-08-16 12:57:01 -0700325 // Returns true iff this type is supported through the Java backend.
Timur Iskhakov5dc72fe2017-09-07 23:13:44 -0700326 bool isJavaCompatible() const;
327 bool isJavaCompatible(std::unordered_set<const Type*>* visited) const;
328 virtual bool deepIsJavaCompatible(std::unordered_set<const Type*>* visited) const;
329 // Returns true iff type contains pointer
330 // (excluding methods and inner types).
331 bool containsPointer() const;
332 bool containsPointer(std::unordered_set<const Type*>* visited) const;
333 virtual bool deepContainsPointer(std::unordered_set<const Type*>* visited) const;
334
Andreas Huber85eabdb2016-08-25 11:24:49 -0700335 virtual void getAlignmentAndSize(size_t *align, size_t *size) const;
336
Andreas Huber019d21d2016-10-03 12:59:47 -0700337 virtual void appendToExportedTypesVector(
338 std::vector<const Type *> *exportedTypes) const;
339
Steven Moreland368e4602018-02-16 14:21:49 -0800340 virtual void emitExportedHeader(Formatter& out, bool forJava) const;
Andreas Huber019d21d2016-10-03 12:59:47 -0700341
Timur Iskhakovff5e64a2017-09-11 14:56:18 -0700342 virtual bool isNeverStrongReference() const;
343
344 protected:
Andreas Huber881227d2016-08-02 14:20:21 -0700345 void handleError(Formatter &out, ErrorMode mode) const;
Andreas Huber881227d2016-08-02 14:20:21 -0700346
347 void emitReaderWriterEmbeddedForTypeName(
348 Formatter &out,
349 const std::string &name,
350 bool nameIsPointer,
351 const std::string &parcelObj,
352 bool parcelObjIsPointer,
353 bool isReader,
354 ErrorMode mode,
355 const std::string &parentName,
356 const std::string &offsetText,
357 const std::string &typeName,
Yifan Hong244e82d2016-11-11 11:13:57 -0800358 const std::string &childName,
359 const std::string &funcNamespace) const;
Andreas Huber881227d2016-08-02 14:20:21 -0700360
Andreas Huber2831d512016-08-15 09:33:47 -0700361 void emitJavaReaderWriterWithSuffix(
362 Formatter &out,
363 const std::string &parcelObj,
364 const std::string &argName,
365 bool isReader,
366 const std::string &suffix,
367 const std::string &extra) const;
368
Yifan Hongf5cc2f72017-01-04 18:02:34 -0800369 void emitDumpWithMethod(
370 Formatter &out,
371 const std::string &streamName,
372 const std::string &methodName,
373 const std::string &name) const;
374
Timur Iskhakov35930c42017-08-28 18:49:54 -0700375 private:
Yifan Hong0e192c42018-10-23 15:32:19 -0700376 ParseStage mParseStage = ParseStage::PARSE;
Timur Iskhakov63f39902017-08-29 15:47:29 -0700377 Scope* const mParent;
Timur Iskhakov35930c42017-08-28 18:49:54 -0700378
Andreas Huberc9410c72016-07-28 12:18:40 -0700379 DISALLOW_COPY_AND_ASSIGN(Type);
380};
381
Yifan Hongbf459bc2016-08-23 16:50:37 -0700382/* Base type for VectorType and RefType. */
383struct TemplatedType : public Type {
Timur Iskhakov505316c2017-08-05 03:38:59 +0000384 void setElementType(const Reference<Type>& elementType);
Timur Iskhakov24e605b2017-08-30 14:02:55 -0700385 const Type* getElementType() const;
Timur Iskhakovcec46c42017-08-09 00:22:02 -0700386
Timur Iskhakov3f1d26e2017-08-30 15:35:53 -0700387 virtual std::string templatedTypeName() const = 0;
388 std::string typeName() const override;
389
Timur Iskhakov33431e62017-08-21 17:31:23 -0700390 bool isTemplatedType() const override;
391
Timur Iskhakov24e605b2017-08-30 14:02:55 -0700392 virtual bool isCompatibleElementType(const Type* elementType) const = 0;
Timur Iskhakov33431e62017-08-21 17:31:23 -0700393
Timur Iskhakovb58f4182017-08-29 15:19:24 -0700394 std::vector<const Reference<Type>*> getReferences() const override;
Timur Iskhakov33431e62017-08-21 17:31:23 -0700395
Timur Iskhakovcec46c42017-08-09 00:22:02 -0700396 virtual status_t validate() const override;
397
Steven Moreland368e4602018-02-16 14:21:49 -0800398 void emitVtsTypeDeclarations(Formatter& out) const override;
399 void emitVtsAttributeType(Formatter& out) const override;
Timur Iskhakov33431e62017-08-21 17:31:23 -0700400
Timur Iskhakovcec46c42017-08-09 00:22:02 -0700401 protected:
Timur Iskhakov63f39902017-08-29 15:47:29 -0700402 TemplatedType(Scope* parent);
Timur Iskhakov505316c2017-08-05 03:38:59 +0000403 Reference<Type> mElementType;
404
405 private:
Yifan Hongbf459bc2016-08-23 16:50:37 -0700406 DISALLOW_COPY_AND_ASSIGN(TemplatedType);
407};
408
Andreas Huberc9410c72016-07-28 12:18:40 -0700409} // namespace android
410
411#endif // TYPE_H_
412