X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogramsyntax.cpp;h=8cb276d9b6dcdef94e2afaccc7ba907ab580f675;hp=4341f06b72c4542393c052d62c39acccb80fe53e;hb=f14516331a9b98b1d9d6c9c4e44787167f87a813;hpb=7cd066816f7faab6f8f0eba1fca4dee67ee5dc3b diff --git a/source/programsyntax.cpp b/source/programsyntax.cpp index 4341f06b..8cb276d9 100644 --- a/source/programsyntax.cpp +++ b/source/programsyntax.cpp @@ -6,6 +6,15 @@ namespace Msp { namespace GL { namespace ProgramSyntax { +template +NodeContainer::NodeContainer(const NodeContainer &c): + C(c) +{ + for(typename C::iterator i=this->begin(); i!=this->end(); ++i) + *i = (*i)->clone(); +} + + Block::Block(): use_braces(false) { } @@ -54,17 +63,25 @@ void UnaryExpression::visit(NodeVisitor &visitor) } -BinaryExpression::BinaryExpression(): - assignment(false) +void BinaryExpression::visit(NodeVisitor &visitor) +{ + visitor.visit(*this); +} + + +Assignment::Assignment(): + self_referencing(false), + target_declaration(0) { } -void BinaryExpression::visit(NodeVisitor &visitor) +void Assignment::visit(NodeVisitor &visitor) { visitor.visit(*this); } FunctionCall::FunctionCall(): + declaration(0), constructor(false) { } @@ -80,12 +97,30 @@ void ExpressionStatement::visit(NodeVisitor &visitor) } +void Import::visit(NodeVisitor &visitor) +{ + visitor.visit(*this); +} + + +void Precision::visit(NodeVisitor &visitor) +{ + visitor.visit(*this); +} + + void Layout::visit(NodeVisitor &visitor) { visitor.visit(*this); } +void InterfaceLayout::visit(NodeVisitor &visitor) +{ + visitor.visit(*this); +} + + StructDeclaration::StructDeclaration() { members.use_braces = true; @@ -110,7 +145,8 @@ void VariableDeclaration::visit(NodeVisitor &visitor) } -InterfaceBlock::InterfaceBlock() +InterfaceBlock::InterfaceBlock(): + array(false) { members.use_braces = true; } @@ -122,7 +158,15 @@ void InterfaceBlock::visit(NodeVisitor &visitor) FunctionDeclaration::FunctionDeclaration(): - definition(false) + definition(0) +{ } + +FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other): + return_type(other.return_type), + name(other.name), + parameters(other.parameters), + definition(other.definition==&other ? this : other.definition), + body(other.body) { } void FunctionDeclaration::visit(NodeVisitor &visitor) @@ -155,9 +199,21 @@ void Return::visit(NodeVisitor &visitor) } +void Jump::visit(NodeVisitor &visitor) +{ + visitor.visit(*this); +} + + +void NodeVisitor::visit(Assignment &assign) +{ + visit(static_cast(assign)); +} + + void TraversingVisitor::visit(Block &block) { - for(list >::iterator i=block.body.begin(); i!=block.body.end(); ++i) + for(list >::iterator i=block.body.begin(); i!=block.body.end(); ++i) (*i)->visit(*this); } @@ -184,7 +240,7 @@ void TraversingVisitor::visit(BinaryExpression &binary) void TraversingVisitor::visit(FunctionCall &call) { - for(vector >::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i) + for(vector >::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i) (*i)->visit(*this); } @@ -193,6 +249,11 @@ void TraversingVisitor::visit(ExpressionStatement &expr) expr.expression->visit(*this); } +void TraversingVisitor::visit(InterfaceLayout &layout) +{ + layout.layout.visit(*this); +} + void TraversingVisitor::visit(StructDeclaration &strct) { strct.members.visit(*this); @@ -200,6 +261,8 @@ void TraversingVisitor::visit(StructDeclaration &strct) void TraversingVisitor::visit(VariableDeclaration &var) { + if(var.layout) + var.layout->visit(*this); if(var.init_expression) var.init_expression->visit(*this); if(var.array_size) @@ -213,7 +276,7 @@ void TraversingVisitor::visit(InterfaceBlock &iface) void TraversingVisitor::visit(FunctionDeclaration &func) { - for(vector >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) + for(vector >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) (*i)->visit(*this); func.body.visit(*this); }