]> git.tdb.fi Git - libs/gl.git/commitdiff
Allow using SL::Formatter on single nodes
authorMikko Rasa <tdb@tdb.fi>
Sun, 21 Feb 2021 10:19:52 +0000 (12:19 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 21 Feb 2021 10:22:30 +0000 (12:22 +0200)
This is occasionally useful for debugging.

source/glsl/output.cpp
source/glsl/output.h

index 973ff8324ac927bdb0d282ff23edf6f7259565c5..f97b8cdb2e2958aeb7bee1d979bb9b0ecbbffeae 100644 (file)
@@ -65,7 +65,7 @@ void Formatter::set_source(unsigned index, unsigned line)
                else
                {
                        unsigned l = line;
-                       if(stage->required_version<Version(3, 30))
+                       if(stage && stage->required_version<Version(3, 30))
                                --l;
                        formatted += format("#line %d %d\n", l, index);
                }
@@ -214,7 +214,7 @@ void Formatter::visit(VariableDeclaration &var)
        if(!var.interface.empty() && var.interface!=block_interface)
        {
                string interface = var.interface;
-               if(stage->required_version<Version(1, 30))
+               if(stage && stage->required_version<Version(1, 30))
                {
                        if(stage->type==Stage::VERTEX && var.interface=="in")
                                interface = "attribute";
index 5b03420223c3f70fb57f7f900f6708e2da5efe39..5f741909062f2f9ada8fce46ae0fc7fe3502e02c 100644 (file)
@@ -23,6 +23,7 @@ public:
        Formatter();
 
        const std::string &apply(Stage &);
+       const std::string &apply(Node &n) { n.visit(*this); return formatted; }
 
 private:
        void append(const std::string &);