Shih-wei Liao | 462aefd | 2010-06-04 15:32:04 -0700 | [diff] [blame] | 1 | #ifndef _SLANG_COMPILER_RS_EXPORT_FUNC_HPP |
| 2 | # define _SLANG_COMPILER_RS_EXPORT_FUNC_HPP |
| 3 | |
| 4 | #include "llvm/ADT/StringRef.h" /* for class llvm::StringRef */ |
| 5 | |
| 6 | #include <list> |
| 7 | #include <string> |
| 8 | |
| 9 | namespace clang { |
| 10 | class FunctionDecl; |
| 11 | } /* namespace clang */ |
| 12 | |
| 13 | namespace slang { |
| 14 | |
| 15 | using namespace clang; |
| 16 | |
| 17 | class RSContext; |
| 18 | class RSExportType; |
| 19 | class RSExportRecordType; |
| 20 | |
| 21 | class RSExportFunc { |
| 22 | friend class RSContext; |
| 23 | public: |
| 24 | class Parameter { |
| 25 | private: |
| 26 | RSExportType* mType; |
| 27 | std::string mName; |
| 28 | |
| 29 | public: |
| 30 | Parameter(RSExportType* T, const llvm::StringRef& Name) : |
| 31 | mType(T), |
| 32 | mName(Name.data(), Name.size()) |
| 33 | { |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | inline const RSExportType* getType() const { return mType; } |
| 38 | inline const std::string& getName() const { return mName; } |
| 39 | }; |
| 40 | |
| 41 | private: |
| 42 | RSContext* mContext; |
| 43 | std::string mName; |
| 44 | std::list<const Parameter*> mParams; |
| 45 | mutable RSExportRecordType* mParamPacketType; |
| 46 | |
| 47 | RSExportFunc(RSContext* Context, const llvm::StringRef& Name) : |
| 48 | mContext(Context), |
| 49 | mName(Name.data(), Name.size()), |
| 50 | mParamPacketType(NULL) |
| 51 | { |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | public: |
| 56 | static RSExportFunc* Create(RSContext* Context, const FunctionDecl* FD); |
| 57 | |
| 58 | typedef std::list<const Parameter*>::const_iterator const_param_iterator; |
| 59 | |
| 60 | inline const_param_iterator params_begin() const { return this->mParams.begin(); } |
| 61 | inline const_param_iterator params_end() const { return this->mParams.end(); } |
| 62 | |
| 63 | inline const std::string& getName() const { return mName; } |
| 64 | inline RSContext* getRSContext() const { return mContext; } |
| 65 | |
| 66 | inline bool hasParam() const { return !mParams.empty(); } |
| 67 | inline int getNumParameters() const { return mParams.size(); } |
| 68 | |
| 69 | const RSExportRecordType* getParamPacketType() const; |
| 70 | |
| 71 | ~RSExportFunc(); |
| 72 | |
| 73 | }; /* RSExportFunc */ |
| 74 | |
| 75 | |
| 76 | } /* namespace slang */ |
| 77 | |
| 78 | #endif /* _SLANG_COMPILER_RS_EXPORT_FUNC_HPP */ |