Cleanup #1489: Delete GPU dummy mempool
[charm.git] / src / xlat-i / xi-Template.h
blob5323f28900fcce866c3e9f3025aa41ad7107fa9b
1 #ifndef _TEMPLATE_H
2 #define _TEMPLATE_H
4 #include "xi-Construct.h"
5 #include "xi-Type.h"
7 namespace xi {
9 /****************** Template Support **************/
10 /* Template Instantiation Parameter */
11 class TParam : public Printable {
12 public:
13 virtual void genSpec(XStr& str) = 0;
16 /* List of Template Instantiation parameters */
17 class TParamList : public Printable {
18 TParam* tparam;
19 TParamList* next;
21 public:
22 TParamList(TParam* t, TParamList* n = 0);
23 void print(XStr& str);
24 void genSpec(XStr& str);
25 std::string to_string();
28 /* A type instantiation parameter */
29 class TParamType : public TParam {
30 Type* type;
32 public:
33 TParamType(Type* t);
34 void print(XStr& str);
35 void genSpec(XStr& str);
38 /* A Value instantiation parameter */
39 class TParamVal : public TParam {
40 const char* val;
42 public:
43 TParamVal(const char* v);
44 void print(XStr& str);
45 void genSpec(XStr& str);
48 class Scope : public ConstructList {
49 protected:
50 const char* name_;
52 public:
53 Scope(const char* name, ConstructList* contents);
54 void genDecls(XStr& str);
55 void genDefs(XStr& str);
56 void genReg(XStr& str);
57 void genGlobalCode(XStr scope, XStr& decls, XStr& defs);
58 void print(XStr& str);
59 void outputClosuresDecl(XStr& str);
60 void outputClosuresDef(XStr& str);
63 class UsingScope : public Construct {
64 protected:
65 const char* name_;
66 bool symbol_;
68 public:
69 UsingScope(const char* name, bool symbol = false);
70 virtual void genDecls(XStr& str);
71 virtual void print(XStr& str);
74 /* A template construct */
75 class TVarList;
76 class TEntity;
78 class Template : public Construct {
79 TVarList* tspec;
80 TEntity* entity;
82 public:
83 Template(TVarList* t, TEntity* e) : tspec(t), entity(e) {}
84 virtual void setExtern(int e);
85 void print(XStr& str);
86 void genDecls(XStr& str);
87 void genDefs(XStr& str);
88 void genSpec(XStr& str, bool printDefault = true);
89 void genVars(XStr& str);
90 void genGlobalCode(XStr scope, XStr& decls, XStr& defs);
91 void outputClosuresDecl(XStr& str);
92 void outputClosuresDef(XStr& str);
93 void preprocess();
94 void check();
96 // DMK - Accel Support
97 int genAccels_spe_c_funcBodies(XStr& str);
98 void genAccels_spe_c_regFuncs(XStr& str);
99 void genAccels_spe_c_callInits(XStr& str);
100 void genAccels_spe_h_includes(XStr& str);
101 void genAccels_spe_h_fiCountDefs(XStr& str);
102 void genAccels_ppe_c_regFuncs(XStr& str);
105 /* An entity that could be templated, i.e. chare, group or a message */
106 class TEntity : public Construct {
107 protected:
108 Template* templat;
110 public:
111 void setTemplate(Template* t);
112 virtual XStr tspec(bool printDefault = true) const;
113 virtual XStr tvars(void) const;
115 /* A formal argument of a template */
116 class TVar : public Printable {
117 public:
118 virtual void genLong(XStr& str, bool printDefault = true) = 0;
119 virtual void genShort(XStr& str) = 0;
122 /* a formal type argument with parameter pack */
123 class TTypeEllipsis : public TVar {
124 NamedEllipsisType* type;
125 Type* init;
127 public:
128 TTypeEllipsis(NamedEllipsisType* t, Type* i = 0);
129 void print(XStr& str);
130 void genLong(XStr& str, bool printDefault = true);
131 void genShort(XStr& str);
134 /* a formal type argument */
135 class TType : public TVar {
136 Type* type;
137 Type* init;
139 public:
140 TType(Type* t, Type* i = 0);
141 void print(XStr& str);
142 void genLong(XStr& str, bool printDefault = true);
143 void genShort(XStr& str);
146 /* a formal function argument */
147 class TFunc : public TVar {
148 FuncType* type;
149 const char* init;
151 public:
152 TFunc(FuncType* t, const char* v = 0);
153 void print(XStr& str);
154 void genLong(XStr& str, bool printDefault = true);
155 void genShort(XStr& str);
158 /* A formal variable argument */
159 class TName : public TVar {
160 Type* type;
161 const char* name;
162 const char* val;
164 public:
165 TName(Type* t, const char* n, const char* v = 0);
166 void print(XStr& str);
167 void genLong(XStr& str, bool printDefault = true);
168 void genShort(XStr& str);
171 /* A list of formal arguments to a template */
172 class TVarList : public Printable {
173 TVar* tvar;
174 TVarList* next;
176 public:
177 TVarList(TVar* v, TVarList* n = 0);
178 void print(XStr& str);
179 void genLong(XStr& str, bool printDefault = true);
180 void genShort(XStr& str);
183 } // namespace xi
185 #endif // ifndef _TEMPLATE_H