]> git.tdb.fi Git - libs/gl.git/commitdiff
Tweaks to visitor classes in the GLSL compiler
authorMikko Rasa <tdb@tdb.fi>
Sat, 20 Feb 2021 18:10:30 +0000 (20:10 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 20 Feb 2021 18:22:14 +0000 (20:22 +0200)
source/glsl/compatibility.cpp
source/glsl/generate.cpp
source/glsl/optimize.cpp
source/glsl/output.cpp
source/glsl/visitor.cpp
source/glsl/visitor.h

index f12a46e384cf6c451b05125048ba89ffd38fe733..692db972b56491eca5de797ae0f79bec61995754 100644 (file)
@@ -20,7 +20,7 @@ DefaultPrecisionGenerator::DefaultPrecisionGenerator():
 
 void DefaultPrecisionGenerator::apply(Stage &stage)
 {
-       SetForScope<Stage::Type> set_stage(stage_type, stage.type);
+       stage_type = stage.type;
        visit(stage.content);
 }
 
@@ -87,7 +87,7 @@ LegacyConverter::LegacyConverter():
 
 void LegacyConverter::apply(Stage &s)
 {
-       SetForScope<Stage *> set_stage(stage, &s);
+       stage = &s;
        visit(s.content);
 }
 
index f3c57a2f0f9190352860bc5f7bc22ff634433123..379a6871ae754aef88ec7b589997493e025733e1 100644 (file)
@@ -255,7 +255,7 @@ string InterfaceGenerator::get_out_prefix(Stage::Type type)
 
 void InterfaceGenerator::apply(Stage &s)
 {
-       SetForScope<Stage *> set(stage, &s);
+       stage = &s;
        if(stage->previous)
                in_prefix = get_out_prefix(stage->previous->type);
        out_prefix = get_out_prefix(stage->type);
index 5813e2d9a2a196a6fe759b730641dea562f6bdfa..dfb17b26799bc2845d063ad9618356f2f80be8d9 100644 (file)
@@ -213,14 +213,14 @@ UnusedVariableLocator::UnusedVariableLocator():
        global_scope(true)
 { }
 
-const set<Node *> &UnusedVariableLocator::apply(Stage &s)
+const set<Node *> &UnusedVariableRemover::apply(Stage &stage)
 {
        variables.push_back(BlockVariableMap());
-       visit(s.content);
+       visit(stage.content);
        BlockVariableMap &global_variables = variables.back();
        for(BlockVariableMap::iterator i=global_variables.begin(); i!=global_variables.end(); ++i)
        {
-               if(i->first->interface=="out" && (s.type==Stage::FRAGMENT || i->first->linked_declaration || !i->first->name.compare(0, 3, "gl_")))
+               if(i->first->interface=="out" && (stage.type==Stage::FRAGMENT || i->first->linked_declaration || !i->first->name.compare(0, 3, "gl_")))
                        continue;
                if(!i->second.referenced)
                {
index 6e88fd1f870e6ba554a0fbfa0ddaba93d6347720..973ff8324ac927bdb0d282ff23edf6f7259565c5 100644 (file)
@@ -18,7 +18,7 @@ Formatter::Formatter():
 
 const string &Formatter::apply(Stage &s)
 {
-       SetForScope<Stage *> set_stage(stage, &s);
+       stage = &s;
 
        GLApi api = get_gl_api();
        const Version &ver = s.required_version;
index 717acad1fdf6dbbd0f03e4e4a9a64ce3f2a4bcd2..91e75b7006b40cf0d621e0a3498c5cf2e5431fe1 100644 (file)
@@ -153,7 +153,7 @@ NodeRemover::NodeRemover(const set<Node *> &r):
 
 void NodeRemover::apply(Stage &s)
 {
-       SetForScope<Stage *> set_stage(stage, &s);
+       stage = &s;
        visit(s.content);
 }
 
index e1c45b5c89de152976cfd94549c018f8e7607116..756584c2e262289783a6f58ec75cbfc2c6ec5a46 100644 (file)
@@ -83,7 +83,7 @@ public:
 };
 
 template<typename T>
-class NodeGatherer: public TraversingVisitor
+class NodeGatherer: private TraversingVisitor
 {
 private:
        std::vector<T *> nodes;
@@ -91,11 +91,12 @@ private:
 public:
        const std::vector<T *> &apply(Stage &s) { visit(s.content); return nodes; }
 
+private:
        using TraversingVisitor::visit;
        virtual void visit(T &n) { nodes.push_back(&n); }
 };
 
-class NodeRemover: public TraversingVisitor
+class NodeRemover: private TraversingVisitor
 {
 private:
        Stage *stage;
@@ -106,6 +107,7 @@ public:
 
        void apply(Stage &);
 
+private:
        using TraversingVisitor::visit;
        virtual void visit(Block &);
        virtual void visit(VariableDeclaration &);