]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.h
Record location information in all syntax nodes
[libs/gl.git] / source / glsl / syntax.h
index 682a0f5aeeaa2246b01226df25536a23a91d9c7a..f275eab8c4ae454ee369ac10e40d3c0e4499190a 100644 (file)
@@ -8,6 +8,7 @@
 #include <vector>
 #include <msp/core/refptr.h>
 #include "features.h"
+#include "glsl_error.h"
 #include "sourcemap.h"
 
 #pragma push_macro("interface")
@@ -30,7 +31,8 @@ struct Operator
        enum Associativity
        {
                LEFT_TO_RIGHT,
-               RIGHT_TO_LEFT
+               RIGHT_TO_LEFT,
+               ASSOCIATIVE
        };
 
        char token[4];
@@ -53,9 +55,11 @@ struct NodeVisitor;
 
 struct Node
 {
-protected:
-       Node() { }
-       Node(const Node &) { }
+       int source;
+       unsigned line;
+
+       Node(): source(GENERATED_SOURCE), line(1) { }
+       Node(const Node &n): source(n.source), line(n.line) { }
 private:
        Node &operator=(const Node &);
 public:
@@ -104,11 +108,6 @@ struct FunctionDeclaration;
 
 struct Statement: Node
 {
-       int source;
-       unsigned line;
-
-       Statement();
-
        virtual Statement *clone() const = 0;
 };
 
@@ -368,7 +367,7 @@ struct Conditional: Statement
 
 struct Iteration: Statement
 {
-       NodePtr<Node> init_statement;
+       NodePtr<Statement> init_statement;
        NodePtr<Expression> condition;
        NodePtr<Expression> loop_expression;
        Block body;
@@ -419,6 +418,7 @@ struct Stage
        std::map<std::string, FunctionDeclaration *> functions;
        std::map<std::string, unsigned> locations;
        Features required_features;
+       std::vector<Diagnostic> diagnostics;
 
        Stage(Type);