[pointers] finished :-)
[ozulis.git] / src / ast / generator-data.cc
blob7e14639757aa6098b435e51aeebe0f711b0410d6
1 #include "generator.hh"
3 namespace ag = ast::generator;
5 const ag::Node ag::nodes[] = {
6 {"Node", "gc", "The root node", {
7 {"core::id_t", "nodeType"}
9 },
11 {"File", "Node", "Represent a file", {
12 {"Scope *", "scope"},
13 {"std::string", "path"},
14 {"std::vector<Node *> *", "decls"},
18 {"Symbol", "Node", "Represent a symbol", {
19 {"std::string", "name"},
20 {"Type *", "type"},
21 {"Address *", "address"}
25 {"Address", "Node", "Represent an address", {
26 {"", ""}
30 {"RegisterAddress", "Address", "Represent a register address", {
31 {"std::string", "name"}
35 {"MemoryAddress", "Address", "Represent a memory address", {
36 {"std::string", "name"}
40 /* Types */
41 {"Type", "Node", "Represent a type", {
42 {"std::string", "name"}, ///< @todo remove this
43 {"bool", "isConst"}
47 {"VoidType", "Type", "Represent the void type", {
48 {"", ""}
52 {"NumberType", "Type", "Represent an abstract number", {
53 {"", ""}
57 {"BoolType", "NumberType", "Represent a boolean value", {
58 {"", ""}
62 {"IntegerType", "NumberType", "Represent an integer", {
63 {"bool", "isSigned"},
64 {"int", "size"}
68 {"FloatType", "NumberType", "Represent a float", {
69 {"", ""}
73 {"DoubleType", "NumberType", "Represent a float", {
74 {"", ""}
78 {"PointerType", "Type", "Represent a pointer", {
79 {"Type *", "type"},
80 {"", ""}
84 {"ReferenceType", "Type", "Represent a reference", {
85 {"Type *", "type"},
86 {"", ""}
90 {"EnumType", "Type", "Represent an enum", {
91 {"Type *", "type"},
92 {"unsigned", "count"},
93 /* FIXME: elements */
94 {"", ""}
98 {"ArrayType", "Type", "Represent an array", {
99 {"Type *", "type"},
100 {"uint16_t", "size"},
101 {"", ""}
105 {"FunctionType", "Type", "Represent a function", {
106 {"Type *", "returnType"},
107 {"std::vector<Type *> *", "argsType"},
108 {"", ""}
112 {"VarDecl", "Node", "Represent a variable declaration", {
113 {"std::string", "name"},
114 {"Type *", "type"},
115 {"", ""}
119 /* Expressions */
120 {"Exp", "Node", "Represent an abstract expression", {
121 {"Type *", "type"}
125 {"VoidExp", "Exp", "Represent a void expression", {
126 {"", ""}
131 {"AssignExp", "Exp", "Represent an assignment expression", {
132 {"Symbol *", "dest"},
133 {"Exp *", "value"},
137 {"UnaryExp", "Exp", "Base class for unary expression", {
138 {"Exp *", "exp"},
142 {"NegExp", "UnaryExp", "Unary expression `-'", {
143 {"", ""}
147 {"BangExp", "UnaryExp", "Unary expression `!'", {
148 {"", ""}
152 {"NotExp", "UnaryExp", "Unary expression `~'", {
153 {"", ""}
157 {"CastExp", "UnaryExp", "A cast from exp->type to type", {
158 {"", ""}
162 {"DereferenceExp", "UnaryExp", "Derefence a pointer", {
163 {"", ""}
167 {"BinaryExp", "Exp", "Base class for binary expression", {
168 {"Exp *", "left"},
169 {"Exp *", "right"},
173 {"EqExp", "BinaryExp", "Expression `=='", {
174 {"", ""}
178 {"NeqExp", "BinaryExp", "Expression `!='", {
179 {"", ""}
183 {"LtExp", "BinaryExp", "Expression `<'", {
184 {"", ""}
188 {"LtEqExp", "BinaryExp", "Expression `<='", {
189 {"", ""}
193 {"GtExp", "BinaryExp", "Expression `>'", {
194 {"", ""}
198 {"GtEqExp", "BinaryExp", "Expression `>='", {
199 {"", ""}
203 {"AddExp", "BinaryExp", "Expression `+'", {
204 {"", ""}
208 {"SubExp", "BinaryExp", "Expression `-'", {
209 {"", ""}
213 {"MulExp", "BinaryExp", "Expression `*'", {
214 {"", ""}
218 {"DivExp", "BinaryExp", "Expression `/'", {
219 {"", ""}
223 {"ModExp", "BinaryExp", "Expression `%'", {
224 {"", ""}
228 {"AndExp", "BinaryExp", "Expression `&'", {
229 {"", ""}
233 {"OrExp", "BinaryExp", "Expression `|'", {
234 {"", ""}
238 {"XorExp", "BinaryExp", "Expression `^'", {
239 {"", ""}
243 {"AndAndExp", "BinaryExp", "Expression `&&'", {
244 {"", ""}
248 {"OrOrExp", "BinaryExp", "Expression `||'", {
249 {"", ""}
253 {"ShlExp", "BinaryExp", "Expression `>>'", {
254 {"", ""}
258 {"AShrExp", "BinaryExp", "Expression `<<'", {
259 {"", ""}
263 {"LShrExp", "BinaryExp", "Expression `<<<'", {
264 {"", ""}
268 {"NumberExp", "Exp", "A number", {
269 {"double", "number"}
273 {"IdExp", "Exp", "An identifier", {
274 {"Symbol *", "symbol"}
278 {"CallExp", "Exp", "A call to a function", {
279 {"std::string", "id"},
280 {"std::vector<Exp *> *", "args"},
281 {"FunctionType *", "ftype"}
285 /* Statements */
286 {"Block", "Node", "Represent a block with a new scope", {
287 {"Scope *", "scope"},
288 {"std::vector<VarDecl *> *", "varDecls"},
289 {"std::vector<Node *> *", "statements"},
290 {"", ""}
294 {"EmptyStatement", "Node", "An empty statement", {
295 {"", ""}
299 {"Label", "Node", "A label", {
300 {"std::string", "name"}
304 {"Goto", "Node", "goto statement", {
305 {"std::string", "label"}
309 {"Return", "Node", "return statement", {
310 {"Exp *", "exp"},
314 {"ConditionalBranch", "Node", "Factorisation code for loops", {
315 {"Exp *", "cond"},
316 {"Label *", "trueLabel"},
317 {"Label *", "falseLabel"},
321 {"If", "Node", "If statement", {
322 {"ConditionalBranch *", "branch"},
323 {"Node *", "trueBlock"},
324 {"Node *", "falseBlock"},
325 {"Label *", "endLabel"}
329 {"While", "Node", "While statement", {
330 {"ConditionalBranch *", "branch"},
331 {"Node *", "block"},
332 {"Label *", "beginLabel"}
336 {"DoWhile", "Node", "Do while statement", {
337 {"ConditionalBranch *", "branch"},
338 {"Node *", "block"},
342 /* Functions */
343 {"Function", "Node", "Represent a function declaration", {
344 {"std::string", "name"},
345 {"Type *", "returnType"},
346 {"std::vector<VarDecl *> *", "args"},
347 {"Scope *", "scope"},
348 {"Block *", "block"},
349 {"", ""}
353 /* 3 address decomposition */
354 {"LoadVar", "Node", "A temporary result, used for 3 address", {
355 {"Exp *", "from"},
356 {"std::string", "to"}
360 {"StoreVar", "Node", "A temporary result, used for 3 address", {
361 {"std::string", "name"},
362 {"Exp *", "value"}, // must be IdExp or NumberExp
366 {"", "", "", {{"", ""}}}