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)
22 void Block::visit(NodeVisitor &visitor)
28 void Literal::visit(NodeVisitor &visitor)
34 void ParenthesizedExpression::visit(NodeVisitor &visitor)
40 VariableReference::VariableReference():
44 void VariableReference::visit(NodeVisitor &visitor)
50 void MemberAccess::visit(NodeVisitor &visitor)
56 UnaryExpression::UnaryExpression():
60 void UnaryExpression::visit(NodeVisitor &visitor)
66 void BinaryExpression::visit(NodeVisitor &visitor)
72 Assignment::Assignment():
73 self_referencing(false),
77 void Assignment::visit(NodeVisitor &visitor)
83 FunctionCall::FunctionCall():
88 void FunctionCall::visit(NodeVisitor &visitor)
94 void ExpressionStatement::visit(NodeVisitor &visitor)
100 void Import::visit(NodeVisitor &visitor)
102 visitor.visit(*this);
106 void Layout::visit(NodeVisitor &visitor)
108 visitor.visit(*this);
112 void InterfaceLayout::visit(NodeVisitor &visitor)
114 visitor.visit(*this);
118 StructDeclaration::StructDeclaration()
120 members.use_braces = true;
123 void StructDeclaration::visit(NodeVisitor &visitor)
125 visitor.visit(*this);
129 VariableDeclaration::VariableDeclaration():
133 linked_declaration(0)
136 void VariableDeclaration::visit(NodeVisitor &visitor)
138 visitor.visit(*this);
142 InterfaceBlock::InterfaceBlock():
145 members.use_braces = true;
148 void InterfaceBlock::visit(NodeVisitor &visitor)
150 visitor.visit(*this);
154 FunctionDeclaration::FunctionDeclaration():
158 FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other):
159 return_type(other.return_type),
161 parameters(other.parameters),
162 definition(other.definition==&other ? this : other.definition),
166 void FunctionDeclaration::visit(NodeVisitor &visitor)
168 visitor.visit(*this);
172 void Conditional::visit(NodeVisitor &visitor)
174 visitor.visit(*this);
178 void Iteration::visit(NodeVisitor &visitor)
180 visitor.visit(*this);
184 void Passthrough::visit(NodeVisitor &visitor)
186 visitor.visit(*this);
190 void Return::visit(NodeVisitor &visitor)
192 visitor.visit(*this);
196 void Jump::visit(NodeVisitor &visitor)
198 visitor.visit(*this);
202 void NodeVisitor::visit(Assignment &assign)
204 visit(static_cast<BinaryExpression &>(assign));
208 void TraversingVisitor::visit(Block &block)
210 for(list<RefPtr<Node> >::iterator i=block.body.begin(); i!=block.body.end(); ++i)
214 void TraversingVisitor::visit(ParenthesizedExpression &parexpr)
216 parexpr.expression->visit(*this);
219 void TraversingVisitor::visit(MemberAccess &memacc)
221 memacc.left->visit(*this);
224 void TraversingVisitor::visit(UnaryExpression &unary)
226 unary.expression->visit(*this);
229 void TraversingVisitor::visit(BinaryExpression &binary)
231 binary.left->visit(*this);
232 binary.right->visit(*this);
235 void TraversingVisitor::visit(FunctionCall &call)
237 for(vector<RefPtr<Expression> >::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i)
241 void TraversingVisitor::visit(ExpressionStatement &expr)
243 expr.expression->visit(*this);
246 void TraversingVisitor::visit(InterfaceLayout &layout)
248 layout.layout.visit(*this);
251 void TraversingVisitor::visit(StructDeclaration &strct)
253 strct.members.visit(*this);
256 void TraversingVisitor::visit(VariableDeclaration &var)
259 var.layout->visit(*this);
260 if(var.init_expression)
261 var.init_expression->visit(*this);
263 var.array_size->visit(*this);
266 void TraversingVisitor::visit(InterfaceBlock &iface)
268 iface.members.visit(*this);
271 void TraversingVisitor::visit(FunctionDeclaration &func)
273 for(vector<RefPtr<VariableDeclaration> >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
275 func.body.visit(*this);
278 void TraversingVisitor::visit(Conditional &cond)
280 cond.condition->visit(*this);
281 cond.body.visit(*this);
282 cond.else_body.visit(*this);
285 void TraversingVisitor::visit(Iteration &iter)
287 iter.init_statement->visit(*this);
289 iter.condition->visit(*this);
290 if(iter.loop_expression)
291 iter.loop_expression->visit(*this);
292 iter.body.visit(*this);
295 void TraversingVisitor::visit(Passthrough &pass)
298 pass.subscript->visit(*this);
301 void TraversingVisitor::visit(Return &ret)
304 ret.expression->visit(*this);
308 Stage::Stage(StageType t):
318 } // namespace ProgramSyntax