]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.cpp
Add GLSL keywords for overriding functions
[libs/gl.git] / source / glsl / syntax.cpp
index cb77419763645be5987842b9bd7d654eb30e13c5..025af2710bb55da807fb686b6876eaef41d4ce22 100644 (file)
@@ -40,8 +40,8 @@ const Operator Operator::operators[] =
        { "&&", 12, BINARY, ASSOCIATIVE },
        { "^^", 13, BINARY, ASSOCIATIVE },
        { "||", 14, BINARY, ASSOCIATIVE },
-       { "?", 15, BINARY, RIGHT_TO_LEFT },
-       { ":", 15, BINARY, RIGHT_TO_LEFT },
+       { "?", 15, TERNARY, RIGHT_TO_LEFT },
+       { ":", 15, TERNARY, RIGHT_TO_LEFT },
        { "=", 16, BINARY, RIGHT_TO_LEFT },
        { "+=", 16, BINARY, RIGHT_TO_LEFT },
        { "-=", 16, BINARY, RIGHT_TO_LEFT },
@@ -161,6 +161,18 @@ void MemberAccess::visit(NodeVisitor &visitor)
 }
 
 
+Swizzle::Swizzle():
+       count(0)
+{
+       fill(components, components+4, 0);
+}
+
+void Swizzle::visit(NodeVisitor &visitor)
+{
+       visitor.visit(*this);
+}
+
+
 void UnaryExpression::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);
@@ -174,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)
@@ -190,6 +200,30 @@ 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;
+}
+
+
+void TernaryExpression::visit(NodeVisitor &visitor)
+{
+       visitor.visit(*this);
+}
+
+
 FunctionCall::FunctionCall():
        constructor(false),
        declaration(0)
@@ -366,6 +400,8 @@ void InterfaceBlock::visit(NodeVisitor &visitor)
 
 
 FunctionDeclaration::FunctionDeclaration():
+       virtua(false),
+       overrd(false),
        definition(0),
        return_type_declaration(0)
 { }
@@ -375,7 +411,10 @@ FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other):
        return_type(other.return_type),
        name(other.name),
        parameters(other.parameters),
+       virtua(other.virtua),
+       overrd(other.overrd),
        body(other.body),
+       signature(other.signature),
        definition(other.definition==&other ? this : 0),
        return_type_declaration(0)
 { }