]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.h
Implement the ternary operator in GLSL
[libs/gl.git] / source / glsl / syntax.h
index 3976af56aa77c97b2a8f430daa89514004209628..86972869f2fe03ed2ebdce4bf47efe4e98d1aa5b 100644 (file)
@@ -27,7 +27,8 @@ struct Operator
                NO_OPERATOR,
                BINARY,
                PREFIX,
-               POSTFIX
+               POSTFIX,
+               TERNARY
        };
 
        enum Associativity
@@ -259,6 +260,16 @@ struct Assignment: BinaryExpression
        virtual void visit(NodeVisitor &);
 };
 
+struct TernaryExpression: Expression
+{
+       NodePtr<Expression> condition;
+       NodePtr<Expression> true_expr;
+       NodePtr<Expression> false_expr;
+
+       virtual TernaryExpression *clone() const { return new TernaryExpression(*this); }
+       virtual void visit(NodeVisitor &);
+};
+
 struct FunctionCall: Expression
 {
        std::string name;
@@ -449,6 +460,7 @@ struct FunctionDeclaration: Statement
        NodeArray<VariableDeclaration> parameters;
        Block body;
 
+       std::string signature;
        FunctionDeclaration *definition;
        TypeDeclaration *return_type_declaration;