slang_rs_export_var.h revision dc8853ace563c3a7e1976d570bf8fe96cfb11446
1/*
2 * Copyright 2010-2012, 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
17#ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_VAR_H_  // NOLINT
18#define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_VAR_H_
19
20#include <string>
21
22#include "clang/AST/Decl.h"
23#include "clang/AST/Expr.h"
24
25#include "llvm/ADT/StringRef.h"
26
27#include "slang_assert.h"
28#include "slang_rs_exportable.h"
29
30namespace clang {
31  class APValue;
32}
33
34namespace slang {
35  class RSContext;
36  class RSExportType;
37
38class RSExportVar : public RSExportable {
39  friend class RSContext;
40 private:
41  std::string mName;
42  const RSExportType *mET;
43  bool mIsConst;
44
45  clang::Expr::EvalResult mInit;
46
47  size_t mArraySize;
48  size_t mNumInits;
49  llvm::SmallVector<clang::Expr::EvalResult, 8> mInitArray;
50
51  RSExportVar(RSContext *Context,
52              const clang::VarDecl *VD,
53              const RSExportType *ET);
54
55 public:
56  inline const std::string &getName() const { return mName; }
57  inline const RSExportType *getType() const { return mET; }
58  inline bool isConst() const { return mIsConst; }
59
60  inline const clang::APValue &getInit() const { return mInit.Val; }
61
62  inline size_t getArraySize() const { return mArraySize; }
63  inline size_t getNumInits() const { return mNumInits; }
64  inline const clang::APValue &getInitArray(unsigned int i) const {
65    slangAssert(i < mNumInits);
66    return mInitArray[i].Val;
67  }
68};  // RSExportVar
69
70}   // namespace slang
71
72#endif  // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_VAR_H_  NOLINT
73