1 #include "programsyntax.h"
7 namespace ProgramSyntax {
10 NodeContainer<C>::NodeContainer(const NodeContainer &c):
13 for(typename C::iterator i=this->begin(); i!=this->end(); ++i)
18 Statement::Statement():
28 void Block::visit(NodeVisitor &visitor)
34 void Literal::visit(NodeVisitor &visitor)
40 void ParenthesizedExpression::visit(NodeVisitor &visitor)
46 VariableReference::VariableReference():
50 void VariableReference::visit(NodeVisitor &visitor)
56 void MemberAccess::visit(NodeVisitor &visitor)
62 UnaryExpression::UnaryExpression():
66 void UnaryExpression::visit(NodeVisitor &visitor)
72 void BinaryExpression::visit(NodeVisitor &visitor)
78 Assignment::Assignment():
79 self_referencing(false),
83 void Assignment::visit(NodeVisitor &visitor)
89 FunctionCall::FunctionCall():
94 void FunctionCall::visit(NodeVisitor &visitor)
100 void ExpressionStatement::visit(NodeVisitor &visitor)
102 visitor.visit(*this);
106 void Import::visit(NodeVisitor &visitor)
108 visitor.visit(*this);
112 void Precision::visit(NodeVisitor &visitor)
114 visitor.visit(*this);
118 void Layout::visit(NodeVisitor &visitor)
120 visitor.visit(*this);
124 void InterfaceLayout::visit(NodeVisitor &visitor)
126 visitor.visit(*this);
130 StructDeclaration::StructDeclaration()
132 members.use_braces = true;
135 void StructDeclaration::visit(NodeVisitor &visitor)
137 visitor.visit(*this);
141 VariableDeclaration::VariableDeclaration():
145 linked_declaration(0)
148 void VariableDeclaration::visit(NodeVisitor &visitor)
150 visitor.visit(*this);
154 InterfaceBlock::InterfaceBlock():
157 members.use_braces = true;
160 void InterfaceBlock::visit(NodeVisitor &visitor)
162 visitor.visit(*this);
166 FunctionDeclaration::FunctionDeclaration():
170 FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other):
171 return_type(other.return_type),
173 parameters(other.parameters),
174 definition(other.definition==&other ? this : other.definition),
178 void FunctionDeclaration::visit(NodeVisitor &visitor)
180 visitor.visit(*this);
184 void Conditional::visit(NodeVisitor &visitor)
186 visitor.visit(*this);
190 void Iteration::visit(NodeVisitor &visitor)
192 visitor.visit(*this);
196 void Passthrough::visit(NodeVisitor &visitor)
198 visitor.visit(*this);
202 void Return::visit(NodeVisitor &visitor)
204 visitor.visit(*this);
208 void Jump::visit(NodeVisitor &visitor)
210 visitor.visit(*this);
214 void NodeVisitor::visit(Assignment &assign)
216 visit(static_cast<BinaryExpression &>(assign));
220 void TraversingVisitor::visit(Block &block)
222 for(NodeList<Statement>::iterator i=block.body.begin(); i!=block.body.end(); ++i)
226 void TraversingVisitor::visit(ParenthesizedExpression &parexpr)
228 parexpr.expression->visit(*this);
231 void TraversingVisitor::visit(MemberAccess &memacc)
233 memacc.left->visit(*this);
236 void TraversingVisitor::visit(UnaryExpression &unary)
238 unary.expression->visit(*this);
241 void TraversingVisitor::visit(BinaryExpression &binary)
243 binary.left->visit(*this);
244 binary.right->visit(*this);
247 void TraversingVisitor::visit(FunctionCall &call)
249 for(NodeArray<Expression>::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i)
253 void TraversingVisitor::visit(ExpressionStatement &expr)
255 expr.expression->visit(*this);
258 void TraversingVisitor::visit(InterfaceLayout &layout)
260 layout.layout.visit(*this);
263 void TraversingVisitor::visit(StructDeclaration &strct)
265 strct.members.visit(*this);
268 void TraversingVisitor::visit(VariableDeclaration &var)
271 var.layout->visit(*this);
272 if(var.init_expression)
273 var.init_expression->visit(*this);
275 var.array_size->visit(*this);
278 void TraversingVisitor::visit(InterfaceBlock &iface)
280 iface.members.visit(*this);
283 void TraversingVisitor::visit(FunctionDeclaration &func)
285 for(NodeArray<VariableDeclaration>::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
287 func.body.visit(*this);
290 void TraversingVisitor::visit(Conditional &cond)
292 cond.condition->visit(*this);
293 cond.body.visit(*this);
294 cond.else_body.visit(*this);
297 void TraversingVisitor::visit(Iteration &iter)
299 if(iter.init_statement)
300 iter.init_statement->visit(*this);
302 iter.condition->visit(*this);
303 if(iter.loop_expression)
304 iter.loop_expression->visit(*this);
305 iter.body.visit(*this);
308 void TraversingVisitor::visit(Passthrough &pass)
311 pass.subscript->visit(*this);
314 void TraversingVisitor::visit(Return &ret)
317 ret.expression->visit(*this);
321 Stage::Stage(StageType t):
331 } // namespace ProgramSyntax