Update to isl-0.20-65-gb822a210
[polly-mirror.git] / lib / External / isl / interface / generator.h
blob2f8d88dbef848bf2f50508643015c65698d2a760
1 #ifndef ISL_INTERFACE_GENERATOR_H
2 #define ISL_INTERFACE_GENERATOR_H
4 #include <map>
5 #include <set>
6 #include <string>
8 #include <clang/AST/Decl.h>
10 using namespace std;
11 using namespace clang;
13 /* isl_class collects all constructors and methods for an isl "class".
14 * "name" is the name of the class.
15 * "type" is the declaration that introduces the type.
16 * "methods" contains the set of methods, grouped by method name.
17 * "fn_to_str" is a reference to the *_to_str method of this class, if any.
18 * "fn_copy" is a reference to the *_copy method of this class, if any.
19 * "fn_free" is a reference to the *_free method of this class, if any.
21 struct isl_class {
22 string name;
23 RecordDecl *type;
24 set<FunctionDecl *> constructors;
25 map<string, set<FunctionDecl *> > methods;
26 FunctionDecl *fn_to_str;
27 FunctionDecl *fn_copy;
28 FunctionDecl *fn_free;
30 /* Return name of "fd" without type suffix, if any. */
31 static string name_without_type_suffix(FunctionDecl *fd);
32 /* Extract the method name corresponding to "fd". */
33 string method_name(FunctionDecl *fd) const {
34 string m_name = name_without_type_suffix(fd);
35 return m_name.substr(name.length() + 1);
39 /* Base class for interface generators.
41 class generator {
42 protected:
43 SourceManager &SM;
44 map<string,isl_class> classes;
45 map<string, FunctionDecl *> functions_by_name;
47 public:
48 generator(SourceManager &SM, set<RecordDecl *> &exported_types,
49 set<FunctionDecl *> exported_functions,
50 set<FunctionDecl *> functions);
52 virtual void generate() = 0;
53 virtual ~generator() {};
55 protected:
56 isl_class *method2class(FunctionDecl *fd);
57 bool callback_takes_argument(ParmVarDecl *param, int pos);
58 FunctionDecl *find_by_name(const string &name, bool required);
59 public:
60 static void die(const char *msg) __attribute__((noreturn));
61 static void die(string msg) __attribute__((noreturn));
62 static vector<string> find_superclasses(RecordDecl *decl);
63 static bool is_overload(Decl *decl);
64 static bool is_constructor(Decl *decl);
65 static bool takes(Decl *decl);
66 static bool keeps(Decl *decl);
67 static bool gives(Decl *decl);
68 static bool is_isl_ctx(QualType type);
69 static bool first_arg_is_isl_ctx(FunctionDecl *fd);
70 static bool is_isl_type(QualType type);
71 static bool is_isl_bool(QualType type);
72 static bool is_isl_stat(QualType type);
73 static bool is_long(QualType type);
74 static bool is_callback(QualType type);
75 static bool is_string(QualType type);
76 static bool is_static(const isl_class &clazz, FunctionDecl *method);
77 static string extract_type(QualType type);
78 static const FunctionProtoType *extract_prototype(QualType type);
81 #endif /* ISL_INTERFACE_GENERATOR_H */