]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.h
Make the iteration init statement a Statement instead of Node
[libs/gl.git] / source / glsl / syntax.h
index 70ea50d106f774c2c8be8974cb3140fbf0421d39..384bd60f603dc04cef77d41a67f5f190d5414851 100644 (file)
@@ -30,7 +30,8 @@ struct Operator
        enum Associativity
        {
                LEFT_TO_RIGHT,
-               RIGHT_TO_LEFT
+               RIGHT_TO_LEFT,
+               ASSOCIATIVE
        };
 
        char token[4];
@@ -39,6 +40,14 @@ struct Operator
        Associativity assoc;
 
        static const Operator operators[];
+
+       static const Operator &get_operator(const std::string &, Type);
+};
+
+enum
+{
+       BUILTIN_SOURCE = -1,
+       GENERATED_SOURCE = 0
 };
 
 struct NodeVisitor;
@@ -96,7 +105,7 @@ struct FunctionDeclaration;
 
 struct Statement: Node
 {
-       unsigned source;
+       int source;
        unsigned line;
 
        Statement();
@@ -121,6 +130,10 @@ struct Block: Node
 
 struct Expression: Node
 {
+       const Operator *oper;
+
+       Expression();
+
        virtual Expression *clone() const = 0;
 };
 
@@ -182,11 +195,7 @@ struct MemberAccess: Expression
 
 struct UnaryExpression: Expression
 {
-       std::string oper;
        NodePtr<Expression> expression;
-       bool prefix;
-
-       UnaryExpression();
 
        virtual UnaryExpression *clone() const { return new UnaryExpression(*this); }
        virtual void visit(NodeVisitor &);
@@ -195,9 +204,7 @@ struct UnaryExpression: Expression
 struct BinaryExpression: Expression
 {
        NodePtr<Expression> left;
-       std::string oper;
        NodePtr<Expression> right;
-       std::string after;
 
        virtual BinaryExpression *clone() const { return new BinaryExpression(*this); }
        virtual void visit(NodeVisitor &);
@@ -362,7 +369,7 @@ struct Conditional: Statement
 
 struct Iteration: Statement
 {
-       NodePtr<Node> init_statement;
+       NodePtr<Statement> init_statement;
        NodePtr<Expression> condition;
        NodePtr<Expression> loop_expression;
        Block body;