X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogramsyntax.cpp;h=8cb276d9b6dcdef94e2afaccc7ba907ab580f675;hp=83cfbb089b4d5d3278722b384c82a91a382aa4d1;hb=8e14c298d9eaa47b81e27d5c25174bda958b445f;hpb=2b073e0a3808f8ece4b93669395e4b812214cf5d diff --git a/source/programsyntax.cpp b/source/programsyntax.cpp index 83cfbb08..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) { } @@ -72,6 +81,7 @@ void Assignment::visit(NodeVisitor &visitor) FunctionCall::FunctionCall(): + declaration(0), constructor(false) { } @@ -87,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; @@ -130,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) @@ -163,6 +199,12 @@ void Return::visit(NodeVisitor &visitor) } +void Jump::visit(NodeVisitor &visitor) +{ + visitor.visit(*this); +} + + void NodeVisitor::visit(Assignment &assign) { visit(static_cast(assign)); @@ -171,7 +213,7 @@ void NodeVisitor::visit(Assignment &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); } @@ -198,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); } @@ -207,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); @@ -214,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) @@ -227,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); }