]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.cpp
Fix opcode for matrix inverse
[libs/gl.git] / source / glsl / syntax.cpp
index bbd364c0730d7cca157376ad34bbdbd028ec1581..4526bf2bd986075f6bfe50e50dae1eabf2ebd204 100644 (file)
@@ -105,12 +105,6 @@ void Literal::visit(NodeVisitor &visitor)
 }
 
 
-void ParenthesizedExpression::visit(NodeVisitor &visitor)
-{
-       visitor.visit(*this);
-}
-
-
 VariableReference::VariableReference():
        declaration(0)
 { }
@@ -144,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)
@@ -275,6 +271,7 @@ void InterfaceLayout::visit(NodeVisitor &visitor)
 BasicTypeDeclaration::BasicTypeDeclaration():
        kind(ALIAS),
        size(0),
+       sign(true),
        base_type(0)
 { }
 
@@ -282,6 +279,7 @@ BasicTypeDeclaration::BasicTypeDeclaration(const BasicTypeDeclaration &other):
        TypeDeclaration(other),
        kind(other.kind),
        size(other.size),
+       sign(other.sign),
        base(other.base),
        base_type(0)
 { }
@@ -375,7 +373,7 @@ InterfaceBlock::InterfaceBlock():
 InterfaceBlock::InterfaceBlock(const InterfaceBlock &other):
        Statement(other),
        interface(other.interface),
-       name(other.name),
+       block_name(other.block_name),
        members(other.members),
        instance_name(other.instance_name),
        array(other.array),
@@ -470,6 +468,42 @@ Module::Module():
        shared(Stage::SHARED)
 { }
 
+
+string get_unused_variable_name(const Block &block, const string &base)
+{
+       string name = base;
+
+       unsigned number = 1;
+       unsigned base_size = name.size();
+       while(1)
+       {
+               bool unused = true;
+               for(const Block *b=█ (unused && b); b=b->parent)
+                       unused = !b->variables.count(name);
+               if(unused)
+                       return name;
+
+               name.erase(base_size);
+               name += format("_%d", number);
+               ++number;
+       }
+}
+
+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