1 #include "generator.hh"
2 #include <core/assert.hh>
5 namespace ag
= ast::generator
;
7 bool ag::isNode(const std::string
& type
)
10 type
== "Address *" ||
12 type
== "ConditionalBranch *" ||
21 bool ag::isPrintable(const std::string
& type
)
27 bool ag::isVectorOfNode(const std::string
& type
)
30 type
== "std::vector<Node *> *" ||
31 type
== "std::vector<Exp *> *" ||
32 type
== "std::vector<Type *> *" ||
33 type
== "std::vector<VarDecl *> *" ||
38 ag::findNodeByName(const std::string
& name
)
40 for (const ag::Node
* node
= ag::nodes
; !node
->name
.empty() > 0; node
++)
41 if (node
->name
== name
)
46 std::vector
<const ag::Attribute
*>
47 ag::allAttributes(const ag::Node
* node
)
49 std::vector
<const ag::Attribute
*> attrs
;
53 for (const ag::Attribute
* attr
= node
->attrs
; !attr
->type
.empty(); ++attr
)
54 attrs
.push_back(attr
);
55 } while ((node
= findNodeByName(node
->parent
)));
59 void ag::appendGeneratedWarning(std::ostream
& out
)
61 out
<< "/* DO NOT MODIFY THIS FILE (GENERATED) */" << std::endl
;
65 ag::deref(std::string type
)
67 std::string::iterator it
= type
.end() - 1;
69 while (it
!= type
.begin() && (*it
== '*' || *it
== ' '))
71 type
.erase(it
+ 1, type
.end());
75 template class std::vector
<ag::Attribute
*>;