blob: d78b7c9486c505201cb245372635f4e21997b380 [file] [log] [blame]
Shih-wei Liao462aefd2010-06-04 15:32:04 -07001#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
9namespace clang {
10 class FunctionDecl;
11} /* namespace clang */
12
13namespace slang {
14
15using namespace clang;
16
17class RSContext;
18class RSExportType;
19class RSExportRecordType;
20
21class RSExportFunc {
22 friend class RSContext;
23public:
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
41private:
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
55public:
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 */