blob: 5957153a3af1b3a615308b363b1a7e2d51a988e1 [file] [log] [blame]
Zonr Changc383a502010-10-12 01:52:08 +08001/*
Stephen Hinesd369cda2012-02-13 12:00:03 -08002 * Copyright 2010-2012, The Android Open Source Project
Zonr Changc383a502010-10-12 01:52:08 +08003 *
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 Hinese639eb52010-11-08 19:27:20 -080017#ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_VAR_H_ // NOLINT
18#define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_VAR_H_
Shih-wei Liao462aefd2010-06-04 15:32:04 -070019
Zonr Changa41ce1d2010-10-06 02:23:12 +080020#include <string>
21
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070022#include "clang/AST/Decl.h"
23#include "clang/AST/Expr.h"
Shih-wei Liao462aefd2010-06-04 15:32:04 -070024
Stephen Hinese639eb52010-11-08 19:27:20 -080025#include "llvm/ADT/StringRef.h"
26
Stephen Hinesd369cda2012-02-13 12:00:03 -080027#include "slang_assert.h"
Zonr Changa41ce1d2010-10-06 02:23:12 +080028#include "slang_rs_exportable.h"
Shih-wei Liao462aefd2010-06-04 15:32:04 -070029
30namespace slang {
zonr6315f762010-10-05 15:35:14 +080031 class RSContext;
32 class RSExportType;
Shih-wei Liao462aefd2010-06-04 15:32:04 -070033
Zonr Changa41ce1d2010-10-06 02:23:12 +080034class RSExportVar : public RSExportable {
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070035 friend class RSContext;
36 private:
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070037 std::string mName;
38 const RSExportType *mET;
39 bool mIsConst;
Stephen Hines1f6c3312012-07-03 17:23:33 -070040 bool mIsUnsigned;
Shih-wei Liao462aefd2010-06-04 15:32:04 -070041
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070042 clang::Expr::EvalResult mInit;
Shih-wei Liao324c0472010-06-21 13:15:11 -070043
Stephen Hinesd369cda2012-02-13 12:00:03 -080044 size_t mArraySize;
45 size_t mNumInits;
46 llvm::SmallVector<clang::Expr::EvalResult, 0> mInitArray;
47
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070048 RSExportVar(RSContext *Context,
49 const clang::VarDecl *VD,
50 const RSExportType *ET);
Shih-wei Liao462aefd2010-06-04 15:32:04 -070051
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070052 public:
53 inline const std::string &getName() const { return mName; }
54 inline const RSExportType *getType() const { return mET; }
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070055 inline bool isConst() const { return mIsConst; }
Stephen Hines1f6c3312012-07-03 17:23:33 -070056 inline bool isUnsigned() const { return mIsUnsigned; }
Shih-wei Liao462aefd2010-06-04 15:32:04 -070057
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070058 inline const clang::APValue &getInit() const { return mInit.Val; }
Stephen Hinesd369cda2012-02-13 12:00:03 -080059
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 Liao9ef2f782010-10-01 12:31:37 -070066}; // RSExportVar
Shih-wei Liao462aefd2010-06-04 15:32:04 -070067
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070068} // namespace slang
Shih-wei Liao462aefd2010-06-04 15:32:04 -070069
Stephen Hinese639eb52010-11-08 19:27:20 -080070#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_VAR_H_ NOLINT