]> git.tdb.fi Git - libs/gl.git/commitdiff
Have generate_interface return the generated statement
authorMikko Rasa <tdb@tdb.fi>
Thu, 4 Mar 2021 11:16:04 +0000 (13:16 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 4 Mar 2021 15:32:04 +0000 (17:32 +0200)
source/glsl/generate.cpp
source/glsl/generate.h

index 02021a4c39993c999f544c8718ea40292a4b0806..7c619830c1733f43160323172ff19605a69632e4 100644 (file)
@@ -417,10 +417,10 @@ string InterfaceGenerator::change_prefix(const string &name, const string &prefi
        return prefix+name.substr(offset);
 }
 
-bool InterfaceGenerator::generate_interface(VariableDeclaration &var, const string &iface, const string &name)
+VariableDeclaration *InterfaceGenerator::generate_interface(VariableDeclaration &var, const string &iface, const string &name)
 {
        if(stage->content.variables.count(name))
-               return false;
+               return 0;
 
        VariableDeclaration* iface_var = new VariableDeclaration;
        iface_var->sampling = var.sampling;
@@ -445,13 +445,13 @@ bool InterfaceGenerator::generate_interface(VariableDeclaration &var, const stri
        iface_target_block->body.insert(iface_insert_point, iface_var);
        iface_target_block->variables[name] = iface_var;
 
-       return true;
+       return iface_var;
 }
 
-bool InterfaceGenerator::generate_interface(InterfaceBlock &out_block)
+InterfaceBlock *InterfaceGenerator::generate_interface(InterfaceBlock &out_block)
 {
        if(stage->interface_blocks.count(out_block.name))
-               return false;
+               return 0;
 
        InterfaceBlock *in_block = new InterfaceBlock;
        in_block->interface = "in";
@@ -480,7 +480,7 @@ bool InterfaceGenerator::generate_interface(InterfaceBlock &out_block)
        SetForScope<Block *> set_block(current_block, &stage->content);
        in_block->visit(*this);
 
-       return true;
+       return in_block;
 }
 
 ExpressionStatement &InterfaceGenerator::insert_assignment(const string &left, Expression *right)
index 2cf5c54a3735a611070f1314762a165de7a24b6d..951a672d89eb3d90bcc38aecdc3fd78b0febebbc 100644 (file)
@@ -133,8 +133,8 @@ private:
        static std::string get_out_prefix(Stage::Type);
        std::string change_prefix(const std::string &, const std::string &) const;
        virtual void visit(Block &);
-       bool generate_interface(VariableDeclaration &, const std::string &, const std::string &);
-       bool generate_interface(InterfaceBlock &);
+       VariableDeclaration *generate_interface(VariableDeclaration &, const std::string &, const std::string &);
+       InterfaceBlock *generate_interface(InterfaceBlock &);
        ExpressionStatement &insert_assignment(const std::string &, Expression *);
        virtual void visit(VariableReference &);
        virtual void visit(VariableDeclaration &);