]> git.tdb.fi Git - libs/gl.git/commitdiff
Consistently use the NodeList and NodeArray types
authorMikko Rasa <tdb@tdb.fi>
Fri, 21 Jun 2019 10:24:01 +0000 (13:24 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 21 Jun 2019 11:54:28 +0000 (14:54 +0300)
source/programcompiler.cpp
source/programcompiler.h
source/programsyntax.cpp

index ca3913cde1358656d307dc85cbcb170121b246be..5027dc9b79788783c0e2cc5860fa91c39b232ef2 100644 (file)
@@ -241,8 +241,8 @@ void ProgramCompiler::finalize(Stage &stage)
 
 void ProgramCompiler::inject_block(Block &target, const Block &source)
 {
-       list<RefPtr<Statement> >::iterator insert_point = target.body.begin();
-       for(list<RefPtr<Statement> >::const_iterator i=source.body.begin(); i!=source.body.end(); ++i)
+       NodeList<Statement>::iterator insert_point = target.body.begin();
+       for(NodeList<Statement>::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<RefPtr<Statement> >::iterator &i)
+void ProgramCompiler::BlockModifier::apply_and_increment(Block &block, NodeList<Statement>::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<RefP
 
 void ProgramCompiler::BlockModifier::visit(Block &block)
 {
-       for(list<RefPtr<Statement> >::iterator i=block.body.begin(); i!=block.body.end(); )
+       for(NodeList<Statement>::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<RefPtr<Expression> >::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i)
+       for(NodeArray<Expression>::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<unsigned> set(indent, indent+(indent>0 || use_braces));
        string spaces(indent*2, ' ');
-       for(list<RefPtr<Statement> >::iterator i=block.body.begin(); i!=block.body.end(); ++i)
+       for(NodeList<Statement>::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<RefPtr<VariableDeclaration> >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
+       for(NodeArray<VariableDeclaration>::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<unsigned> set(scope_level, scope_level+1);
-       for(list<RefPtr<Statement> >::iterator i=block.body.begin(); i!=block.body.end(); )
+       for(NodeList<Statement>::iterator i=block.body.begin(); i!=block.body.end(); )
        {
                (*i)->visit(*this);
 
@@ -873,7 +873,7 @@ void ProgramCompiler::InterfaceGenerator::visit(Block &block)
                {
                        for(map<string, RefPtr<VariableDeclaration> >::iterator j=iface_declarations.begin(); j!=iface_declarations.end(); ++j)
                        {
-                               list<RefPtr<Statement> >::iterator k = block.body.insert(i, j->second);
+                               NodeList<Statement>::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<RefPtr<Statement> >::iterator struct_insert_point = block.body.end();
-       list<RefPtr<Statement> >::iterator variable_insert_point = block.body.end();
-       list<RefPtr<Statement> >::iterator function_insert_point = block.body.end();
+       NodeList<Statement>::iterator struct_insert_point = block.body.end();
+       NodeList<Statement>::iterator variable_insert_point = block.body.end();
+       NodeList<Statement>::iterator function_insert_point = block.body.end();
        unsigned unordered_func_count = 0;
        bool ordered_any_funcs = false;
 
-       for(list<RefPtr<Statement> >::iterator i=block.body.begin(); i!=block.body.end(); )
+       for(NodeList<Statement>::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<RefPtr<Statement> >::iterator i=block.body.begin(); i!=block.body.end(); ++i)
+       for(NodeList<Statement>::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<RefPtr<Expression> >::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i)
+       for(NodeArray<Expression>::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<bool> set(global_scope, false);
-               for(vector<RefPtr<VariableDeclaration> >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
+               for(NodeArray<VariableDeclaration>::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<RefPtr<VariableDeclaration> >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
+       for(NodeArray<VariableDeclaration>::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<Node *> &r):
 
 void ProgramCompiler::NodeRemover::visit(Block &block)
 {
-       for(list<RefPtr<Statement> >::iterator i=block.body.begin(); i!=block.body.end(); )
+       for(NodeList<Statement>::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<RefPtr<Expression> >::iterator i = call.arguments.begin();
+               NodeArray<Expression>::iterator i = call.arguments.begin();
                if(i!=call.arguments.end())
                {
                        (*i)->visit(*this);
index 5a2f42401620505c5801cf0326a5311e16a58f37..8c4f54537c7bc0da9f70ce9a744acf154157bb5d 100644 (file)
@@ -34,7 +34,7 @@ private:
                BlockModifier();
 
                void flatten_block(ProgramSyntax::Block &);
-               void apply_and_increment(ProgramSyntax::Block &, std::list<RefPtr<ProgramSyntax::Statement> >::iterator &);
+               void apply_and_increment(ProgramSyntax::Block &, ProgramSyntax::NodeList<ProgramSyntax::Statement>::iterator &);
                using Visitor::visit;
                virtual void visit(ProgramSyntax::Block &);
        };
index 46f51c2cb699f26c10b57a59c17a152d26a61425..edd38eaa84285c5924699d9671bc8fb3178a287b 100644 (file)
@@ -213,7 +213,7 @@ void NodeVisitor::visit(Assignment &assign)
 
 void TraversingVisitor::visit(Block &block)
 {
-       for(list<RefPtr<Statement> >::iterator i=block.body.begin(); i!=block.body.end(); ++i)
+       for(NodeList<Statement>::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<RefPtr<Expression> >::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i)
+       for(NodeArray<Expression>::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<RefPtr<VariableDeclaration> >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
+       for(NodeArray<VariableDeclaration>::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
                (*i)->visit(*this);
        func.body.visit(*this);
 }