]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.cpp
Rewrite type comparisons as a visitor
[libs/gl.git] / source / glsl / syntax.cpp
index 32a7b12c6639aebd69344aa7a2f6408c67de308f..947b310ef5e528e026dd53dcbd642de96f4923b3 100644 (file)
@@ -138,14 +138,16 @@ void InterfaceBlockReference::visit(NodeVisitor &visitor)
 
 
 MemberAccess::MemberAccess():
-       declaration(0)
+       declaration(0),
+       index(-1)
 { }
 
 MemberAccess::MemberAccess(const MemberAccess &other):
        Expression(other),
        left(other.left),
        member(other.member),
-       declaration(0)
+       declaration(0),
+       index(-1)
 { }
 
 void MemberAccess::visit(NodeVisitor &visitor)
@@ -485,6 +487,21 @@ string get_unused_variable_name(const Block &block, const string &base)
        }
 }
 
+int get_layout_value(const Layout &layout, const string &name, int def_value)
+{
+       for(vector<Layout::Qualifier>::const_iterator i=layout.qualifiers.begin(); i!=layout.qualifiers.end(); ++i)
+               if(i->name==name)
+                       return i->value;
+       return def_value;
+}
+
+void add_to_chain(Assignment::Target &target, Assignment::Target::ChainType type, unsigned index)
+{
+       if(target.chain_len<7)
+               target.chain[target.chain_len] = type | min<unsigned>(index, 0x3F);
+       ++target.chain_len;
+}
+
 } // namespace SL
 } // namespace GL
 } // namespace Msp