From 8468279a03d906f79fb6158162c7970d4d7fff60 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 21 Jun 2019 13:24:01 +0300 Subject: [PATCH] Consistently use the NodeList and NodeArray types --- source/programcompiler.cpp | 38 +++++++++++++++++++------------------- source/programcompiler.h | 2 +- source/programsyntax.cpp | 6 +++--- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index ca3913cd..5027dc9b 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -241,8 +241,8 @@ void ProgramCompiler::finalize(Stage &stage) void ProgramCompiler::inject_block(Block &target, const Block &source) { - list >::iterator insert_point = target.body.begin(); - for(list >::const_iterator i=source.body.begin(); i!=source.body.end(); ++i) + NodeList::iterator insert_point = target.body.begin(); + for(NodeList::const_iterator i=source.body.begin(); i!=source.body.end(); ++i) target.body.insert(insert_point, (*i)->clone()); } @@ -284,7 +284,7 @@ void ProgramCompiler::BlockModifier::flatten_block(Block &block) remove_node = true; } -void ProgramCompiler::BlockModifier::apply_and_increment(Block &block, list >::iterator &i) +void ProgramCompiler::BlockModifier::apply_and_increment(Block &block, NodeList::iterator &i) { block.body.insert(i, insert_nodes.begin(), insert_nodes.end()); insert_nodes.clear(); @@ -298,7 +298,7 @@ void ProgramCompiler::BlockModifier::apply_and_increment(Block &block, list >::iterator i=block.body.begin(); i!=block.body.end(); ) + for(NodeList::iterator i=block.body.begin(); i!=block.body.end(); ) { (*i)->visit(*this); apply_and_increment(block, i); @@ -383,7 +383,7 @@ void ProgramCompiler::Formatter::visit(Assignment &assign) void ProgramCompiler::Formatter::visit(FunctionCall &call) { formatted += format("%s(", call.name); - for(vector >::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i) + for(NodeArray::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i) { if(i!=call.arguments.begin()) formatted += ", "; @@ -410,7 +410,7 @@ void ProgramCompiler::Formatter::visit(Block &block) SetForScope set(indent, indent+(indent>0 || use_braces)); string spaces(indent*2, ' '); - for(list >::iterator i=block.body.begin(); i!=block.body.end(); ++i) + for(NodeList::iterator i=block.body.begin(); i!=block.body.end(); ++i) { if(i!=block.body.begin()) formatted += '\n'; @@ -515,7 +515,7 @@ void ProgramCompiler::Formatter::visit(InterfaceBlock &iface) void ProgramCompiler::Formatter::visit(FunctionDeclaration &func) { formatted += format("%s %s(", func.return_type, func.name); - for(vector >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) + for(NodeArray::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) { if(i!=func.parameters.begin()) formatted += ", "; @@ -865,7 +865,7 @@ void ProgramCompiler::InterfaceGenerator::apply(Stage &s) void ProgramCompiler::InterfaceGenerator::visit(Block &block) { SetForScope set(scope_level, scope_level+1); - for(list >::iterator i=block.body.begin(); i!=block.body.end(); ) + for(NodeList::iterator i=block.body.begin(); i!=block.body.end(); ) { (*i)->visit(*this); @@ -873,7 +873,7 @@ void ProgramCompiler::InterfaceGenerator::visit(Block &block) { for(map >::iterator j=iface_declarations.begin(); j!=iface_declarations.end(); ++j) { - list >::iterator k = block.body.insert(i, j->second); + NodeList::iterator k = block.body.insert(i, j->second); (*k)->visit(*this); } iface_declarations.clear(); @@ -1069,13 +1069,13 @@ void ProgramCompiler::DeclarationReorderer::visit(Block &block) if(scope_level>1) return Visitor::visit(block); - list >::iterator struct_insert_point = block.body.end(); - list >::iterator variable_insert_point = block.body.end(); - list >::iterator function_insert_point = block.body.end(); + NodeList::iterator struct_insert_point = block.body.end(); + NodeList::iterator variable_insert_point = block.body.end(); + NodeList::iterator function_insert_point = block.body.end(); unsigned unordered_func_count = 0; bool ordered_any_funcs = false; - for(list >::iterator i=block.body.begin(); i!=block.body.end(); ) + for(NodeList::iterator i=block.body.begin(); i!=block.body.end(); ) { kind = NO_DECLARATION; (*i)->visit(*this); @@ -1210,7 +1210,7 @@ void ProgramCompiler::FunctionInliner::visit(Block &block) if(extract_result) --extract_result; - for(list >::iterator i=block.body.begin(); i!=block.body.end(); ++i) + for(NodeList::iterator i=block.body.begin(); i!=block.body.end(); ++i) { (*i)->visit(*this); if(extract_result) @@ -1239,7 +1239,7 @@ void ProgramCompiler::FunctionInliner::visit(MemberAccess &memacc) void ProgramCompiler::FunctionInliner::visit(FunctionCall &call) { - for(vector >::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i) + for(NodeArray::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i) visit_and_inline(*i); FunctionDeclaration *def = call.declaration; @@ -1573,7 +1573,7 @@ void ProgramCompiler::UnusedVariableLocator::visit(FunctionDeclaration &func) { SetForScope set(global_scope, false); - for(vector >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) + for(NodeArray::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) (*i)->visit(*this); func.body.visit(*this); } @@ -1581,7 +1581,7 @@ void ProgramCompiler::UnusedVariableLocator::visit(FunctionDeclaration &func) BlockVariableMap &block_variables = variables.back(); for(BlockVariableMap::iterator i=block_variables.begin(); i!=block_variables.end(); ++i) i->second.conditionally_assigned = true; - for(vector >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) + for(NodeArray::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) block_variables[i->get()].referenced = true; merge_down_variables(); } @@ -1693,7 +1693,7 @@ ProgramCompiler::NodeRemover::NodeRemover(const set &r): void ProgramCompiler::NodeRemover::visit(Block &block) { - for(list >::iterator i=block.body.begin(); i!=block.body.end(); ) + for(NodeList::iterator i=block.body.begin(); i!=block.body.end(); ) { (*i)->visit(*this); if(to_remove.count(i->get())) @@ -1859,7 +1859,7 @@ void ProgramCompiler::LegacyConverter::visit(FunctionCall &call) { if(call.name=="texture" && !call.declaration && !supports_unified_sampling_functions()) { - vector >::iterator i = call.arguments.begin(); + NodeArray::iterator i = call.arguments.begin(); if(i!=call.arguments.end()) { (*i)->visit(*this); diff --git a/source/programcompiler.h b/source/programcompiler.h index 5a2f4240..8c4f5453 100644 --- a/source/programcompiler.h +++ b/source/programcompiler.h @@ -34,7 +34,7 @@ private: BlockModifier(); void flatten_block(ProgramSyntax::Block &); - void apply_and_increment(ProgramSyntax::Block &, std::list >::iterator &); + void apply_and_increment(ProgramSyntax::Block &, ProgramSyntax::NodeList::iterator &); using Visitor::visit; virtual void visit(ProgramSyntax::Block &); }; diff --git a/source/programsyntax.cpp b/source/programsyntax.cpp index 46f51c2c..edd38eaa 100644 --- a/source/programsyntax.cpp +++ b/source/programsyntax.cpp @@ -213,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(NodeList::iterator i=block.body.begin(); i!=block.body.end(); ++i) (*i)->visit(*this); } @@ -240,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(NodeArray::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i) (*i)->visit(*this); } @@ -276,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(NodeArray::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) (*i)->visit(*this); func.body.visit(*this); } -- 2.45.2