Zonr Chang | c383a50 | 2010-10-12 01:52:08 +0800 | [diff] [blame] | 1 | /* |
Stephen Hines | d369cda | 2012-02-13 12:00:03 -0800 | [diff] [blame] | 2 | * Copyright 2010-2012, The Android Open Source Project |
Zonr Chang | c383a50 | 2010-10-12 01:52:08 +0800 | [diff] [blame] | 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 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 17 | #ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_VAR_H_ // NOLINT |
| 18 | #define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_VAR_H_ |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 19 | |
Zonr Chang | a41ce1d | 2010-10-06 02:23:12 +0800 | [diff] [blame] | 20 | #include <string> |
| 21 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 22 | #include "clang/AST/Decl.h" |
| 23 | #include "clang/AST/Expr.h" |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 24 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 25 | #include "llvm/ADT/StringRef.h" |
| 26 | |
Stephen Hines | d369cda | 2012-02-13 12:00:03 -0800 | [diff] [blame] | 27 | #include "slang_assert.h" |
Zonr Chang | a41ce1d | 2010-10-06 02:23:12 +0800 | [diff] [blame] | 28 | #include "slang_rs_exportable.h" |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 29 | |
| 30 | namespace slang { |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 31 | class RSContext; |
| 32 | class RSExportType; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 33 | |
Zonr Chang | a41ce1d | 2010-10-06 02:23:12 +0800 | [diff] [blame] | 34 | class RSExportVar : public RSExportable { |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 35 | friend class RSContext; |
| 36 | private: |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 37 | std::string mName; |
| 38 | const RSExportType *mET; |
| 39 | bool mIsConst; |
Stephen Hines | 1f6c331 | 2012-07-03 17:23:33 -0700 | [diff] [blame] | 40 | bool mIsUnsigned; |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 41 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 42 | clang::Expr::EvalResult mInit; |
Shih-wei Liao | 324c047 | 2010-06-21 13:15:11 -0700 | [diff] [blame] | 43 | |
David Gross | 657d20a | 2015-12-16 16:23:51 -0800 | [diff] [blame] | 44 | size_t mArraySize; // number of elements |
Stephen Hines | d369cda | 2012-02-13 12:00:03 -0800 | [diff] [blame] | 45 | size_t mNumInits; |
| 46 | llvm::SmallVector<clang::Expr::EvalResult, 0> mInitArray; |
| 47 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 48 | RSExportVar(RSContext *Context, |
| 49 | const clang::VarDecl *VD, |
| 50 | const RSExportType *ET); |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 51 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 52 | public: |
| 53 | inline const std::string &getName() const { return mName; } |
| 54 | inline const RSExportType *getType() const { return mET; } |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 55 | inline bool isConst() const { return mIsConst; } |
Stephen Hines | 1f6c331 | 2012-07-03 17:23:33 -0700 | [diff] [blame] | 56 | inline bool isUnsigned() const { return mIsUnsigned; } |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 57 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 58 | inline const clang::APValue &getInit() const { return mInit.Val; } |
Stephen Hines | d369cda | 2012-02-13 12:00:03 -0800 | [diff] [blame] | 59 | |
| 60 | inline size_t getArraySize() const { return mArraySize; } |
| 61 | inline size_t getNumInits() const { return mNumInits; } |
| 62 | inline const clang::APValue &getInitArray(unsigned int i) const { |
| 63 | slangAssert(i < mNumInits); |
| 64 | return mInitArray[i].Val; |
| 65 | } |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 66 | }; // RSExportVar |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 67 | |
Shih-wei Liao | 9ef2f78 | 2010-10-01 12:31:37 -0700 | [diff] [blame] | 68 | } // namespace slang |
Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 69 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 70 | #endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_VAR_H_ NOLINT |