]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.cpp
Record assignment targets more precisely
[libs/gl.git] / source / glsl / syntax.cpp
index 85d805d1b67aeea72ee41bcec1855222732dc5ef..71e5c39a948aabc7db12e701a80bcca32cfef3dc 100644 (file)
@@ -186,14 +186,12 @@ void BinaryExpression::visit(NodeVisitor &visitor)
 
 
 Assignment::Assignment():
-       self_referencing(false),
-       target_declaration(0)
+       self_referencing(false)
 { }
 
 Assignment::Assignment(const Assignment &other):
        BinaryExpression(other),
-       self_referencing(other.self_referencing),
-       target_declaration(0)
+       self_referencing(other.self_referencing)
 { }
 
 void Assignment::visit(NodeVisitor &visitor)
@@ -202,6 +200,24 @@ void Assignment::visit(NodeVisitor &visitor)
 }
 
 
+Assignment::Target::Target(Statement *d):
+       declaration(d),
+       chain_len(0)
+{
+       fill(chain, chain+7, 0);
+}
+
+bool Assignment::Target::operator<(const Target &other) const
+{
+       if(declaration!=other.declaration)
+               return declaration<other.declaration;
+       for(unsigned i=0; (i<7 && i<chain_len && i<other.chain_len); ++i)
+               if(chain[i]!=other.chain[i])
+                       return chain[i]<other.chain[i];
+       return chain_len<other.chain_len;
+}
+
+
 FunctionCall::FunctionCall():
        constructor(false),
        declaration(0)