10 const Operator Operator::operators[] =
12 { "[", 2, BINARY, LEFT_TO_RIGHT },
13 { "(", 2, BINARY, LEFT_TO_RIGHT },
14 { ".", 2, BINARY, LEFT_TO_RIGHT },
15 { "++", 2, POSTFIX, LEFT_TO_RIGHT },
16 { "--", 2, POSTFIX, LEFT_TO_RIGHT },
17 { "++", 3, PREFIX, RIGHT_TO_LEFT },
18 { "--", 3, PREFIX, RIGHT_TO_LEFT },
19 { "+", 3, PREFIX, RIGHT_TO_LEFT },
20 { "-", 3, PREFIX, RIGHT_TO_LEFT },
21 { "~", 3, PREFIX, RIGHT_TO_LEFT },
22 { "!", 3, PREFIX, RIGHT_TO_LEFT },
23 { "*", 4, BINARY, LEFT_TO_RIGHT },
24 { "/", 4, BINARY, LEFT_TO_RIGHT },
25 { "%", 4, BINARY, LEFT_TO_RIGHT },
26 { "+", 5, BINARY, LEFT_TO_RIGHT },
27 { "-", 5, BINARY, LEFT_TO_RIGHT },
28 { "<<", 6, BINARY, LEFT_TO_RIGHT },
29 { ">>", 6, BINARY, LEFT_TO_RIGHT },
30 { "<", 7, BINARY, LEFT_TO_RIGHT },
31 { ">", 7, BINARY, LEFT_TO_RIGHT },
32 { "<=", 7, BINARY, LEFT_TO_RIGHT },
33 { ">=", 7, BINARY, LEFT_TO_RIGHT },
34 { "==", 8, BINARY, LEFT_TO_RIGHT },
35 { "!=", 8, BINARY, LEFT_TO_RIGHT },
36 { "&", 9, BINARY, LEFT_TO_RIGHT },
37 { "^", 10, BINARY, LEFT_TO_RIGHT },
38 { "|", 11, BINARY, LEFT_TO_RIGHT },
39 { "&&", 12, BINARY, LEFT_TO_RIGHT },
40 { "^^", 13, BINARY, LEFT_TO_RIGHT },
41 { "||", 14, BINARY, LEFT_TO_RIGHT },
42 { "?", 15, BINARY, RIGHT_TO_LEFT },
43 { ":", 15, BINARY, RIGHT_TO_LEFT },
44 { "=", 16, BINARY, RIGHT_TO_LEFT },
45 { "+=", 16, BINARY, RIGHT_TO_LEFT },
46 { "-=", 16, BINARY, RIGHT_TO_LEFT },
47 { "*=", 16, BINARY, RIGHT_TO_LEFT },
48 { "/=", 16, BINARY, RIGHT_TO_LEFT },
49 { "%=", 16, BINARY, RIGHT_TO_LEFT },
50 { "<<=", 16, BINARY, RIGHT_TO_LEFT },
51 { ">>=", 16, BINARY, RIGHT_TO_LEFT },
52 { "&=", 16, BINARY, RIGHT_TO_LEFT },
53 { "^=", 16, BINARY, RIGHT_TO_LEFT },
54 { "|=", 16, BINARY, RIGHT_TO_LEFT },
55 { ",", 17, BINARY, LEFT_TO_RIGHT },
56 { { 0 }, 18, NO_OPERATOR, LEFT_TO_RIGHT }
61 NodeContainer<C>::NodeContainer(const NodeContainer &c):
64 for(typename C::iterator i=this->begin(); i!=this->end(); ++i)
69 Statement::Statement():
80 Block::Block(const Block &other):
83 use_braces(other.use_braces),
87 void Block::visit(NodeVisitor &visitor)
93 void Literal::visit(NodeVisitor &visitor)
99 void ParenthesizedExpression::visit(NodeVisitor &visitor)
101 visitor.visit(*this);
105 VariableReference::VariableReference():
109 VariableReference::VariableReference(const VariableReference &other):
114 void VariableReference::visit(NodeVisitor &visitor)
116 visitor.visit(*this);
120 InterfaceBlockReference::InterfaceBlockReference():
124 InterfaceBlockReference::InterfaceBlockReference(const InterfaceBlockReference &other):
129 void InterfaceBlockReference::visit(NodeVisitor &visitor)
131 visitor.visit(*this);
135 MemberAccess::MemberAccess():
139 MemberAccess::MemberAccess(const MemberAccess &other):
141 member(other.member),
145 void MemberAccess::visit(NodeVisitor &visitor)
147 visitor.visit(*this);
151 UnaryExpression::UnaryExpression():
155 void UnaryExpression::visit(NodeVisitor &visitor)
157 visitor.visit(*this);
161 void BinaryExpression::visit(NodeVisitor &visitor)
163 visitor.visit(*this);
167 Assignment::Assignment():
168 self_referencing(false),
169 target_declaration(0)
172 Assignment::Assignment(const Assignment &other):
173 self_referencing(other.self_referencing),
174 target_declaration(0)
177 void Assignment::visit(NodeVisitor &visitor)
179 visitor.visit(*this);
183 FunctionCall::FunctionCall():
188 FunctionCall::FunctionCall(const FunctionCall &other):
191 constructor(other.constructor),
192 arguments(other.arguments)
195 void FunctionCall::visit(NodeVisitor &visitor)
197 visitor.visit(*this);
201 void ExpressionStatement::visit(NodeVisitor &visitor)
203 visitor.visit(*this);
207 void Import::visit(NodeVisitor &visitor)
209 visitor.visit(*this);
213 void Precision::visit(NodeVisitor &visitor)
215 visitor.visit(*this);
219 void Layout::visit(NodeVisitor &visitor)
221 visitor.visit(*this);
225 void InterfaceLayout::visit(NodeVisitor &visitor)
227 visitor.visit(*this);
231 StructDeclaration::StructDeclaration()
233 members.use_braces = true;
236 void StructDeclaration::visit(NodeVisitor &visitor)
238 visitor.visit(*this);
242 VariableDeclaration::VariableDeclaration():
246 linked_declaration(0)
249 VariableDeclaration::VariableDeclaration(const VariableDeclaration &other):
250 constant(other.constant),
251 sampling(other.sampling),
252 interpolation(other.interpolation),
253 interface(other.interface),
254 precision(other.precision),
259 array_size(other.array_size),
260 init_expression(other.init_expression),
261 linked_declaration(0),
265 VariableDeclaration::~VariableDeclaration()
267 if(linked_declaration && linked_declaration->linked_declaration==this)
268 linked_declaration->linked_declaration = 0;
271 void VariableDeclaration::visit(NodeVisitor &visitor)
273 visitor.visit(*this);
277 InterfaceBlock::InterfaceBlock():
281 members.use_braces = true;
284 InterfaceBlock::InterfaceBlock(const InterfaceBlock &other):
285 interface(other.interface),
287 members(other.members),
288 instance_name(other.instance_name),
293 InterfaceBlock::~InterfaceBlock()
295 if(linked_block && linked_block->linked_block==this)
296 linked_block->linked_block = 0;
299 void InterfaceBlock::visit(NodeVisitor &visitor)
301 visitor.visit(*this);
305 FunctionDeclaration::FunctionDeclaration():
309 FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other):
310 return_type(other.return_type),
312 parameters(other.parameters),
313 definition(other.definition==&other ? this : 0),
317 void FunctionDeclaration::visit(NodeVisitor &visitor)
319 visitor.visit(*this);
323 void Conditional::visit(NodeVisitor &visitor)
325 visitor.visit(*this);
329 void Iteration::visit(NodeVisitor &visitor)
331 visitor.visit(*this);
335 void Passthrough::visit(NodeVisitor &visitor)
337 visitor.visit(*this);
341 void Return::visit(NodeVisitor &visitor)
343 visitor.visit(*this);
347 void Jump::visit(NodeVisitor &visitor)
349 visitor.visit(*this);
353 Stage::Stage(Stage::Type t):
358 const char *Stage::get_stage_name(Type type)
360 static const char *names[] = { "shared", "vertex", "geometry", "fragment" };
366 shared(Stage::SHARED)