X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogramsyntax.cpp;h=8cb276d9b6dcdef94e2afaccc7ba907ab580f675;hp=f64493eed2a116fae42a88791a6183a084c06e0a;hb=8e14c298d9eaa47b81e27d5c25174bda958b445f;hpb=a36992487d018d8801ead6980b362b00a2f5f5c5 diff --git a/source/programsyntax.cpp b/source/programsyntax.cpp index f64493ee..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; @@ -100,7 +135,8 @@ void StructDeclaration::visit(NodeVisitor &visitor) VariableDeclaration::VariableDeclaration(): constant(false), type_declaration(0), - array(false) + array(false), + linked_declaration(0) { } void VariableDeclaration::visit(NodeVisitor &visitor) @@ -109,7 +145,8 @@ void VariableDeclaration::visit(NodeVisitor &visitor) } -InterfaceBlock::InterfaceBlock() +InterfaceBlock::InterfaceBlock(): + array(false) { members.use_braces = true; } @@ -121,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) @@ -136,21 +181,39 @@ void Conditional::visit(NodeVisitor &visitor) } +void Iteration::visit(NodeVisitor &visitor) +{ + visitor.visit(*this); +} + + +void Passthrough::visit(NodeVisitor &visitor) +{ + visitor.visit(*this); +} + + void Return::visit(NodeVisitor &visitor) { visitor.visit(*this); } -void Iteration::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); } @@ -177,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); } @@ -186,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); @@ -193,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) @@ -206,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); } @@ -228,6 +298,12 @@ void TraversingVisitor::visit(Iteration &iter) iter.body.visit(*this); } +void TraversingVisitor::visit(Passthrough &pass) +{ + if(pass.subscript) + pass.subscript->visit(*this); +} + void TraversingVisitor::visit(Return &ret) { if(ret.expression) @@ -235,17 +311,14 @@ void TraversingVisitor::visit(Return &ret) } -Context::Context(ContextType t): +Stage::Stage(StageType t): type(t), - present(false) + previous(0) { } Module::Module(): - global_context(GLOBAL), - vertex_context(VERTEX), - geometry_context(GEOMETRY), - fragment_context(FRAGMENT) + shared(SHARED) { } } // namespace ProgramSyntax