]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.h
Add basic validation to the GLSL compiler
[libs/gl.git] / source / glsl / syntax.h
index 55f47402f514538b959a459a07b3532e2a0d5efd..da7b0907e37460d5b7041d32e2c921dee9473563 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];
@@ -39,6 +41,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 +106,7 @@ struct FunctionDeclaration;
 
 struct Statement: Node
 {
-       unsigned source;
+       int source;
        unsigned line;
 
        Statement();
@@ -121,6 +131,10 @@ struct Block: Node
 
 struct Expression: Node
 {
+       const Operator *oper;
+
+       Expression();
+
        virtual Expression *clone() const = 0;
 };
 
@@ -182,11 +196,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 +205,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 +370,7 @@ struct Conditional: Statement
 
 struct Iteration: Statement
 {
-       NodePtr<Node> init_statement;
+       NodePtr<Statement> init_statement;
        NodePtr<Expression> condition;
        NodePtr<Expression> loop_expression;
        Block body;
@@ -410,8 +418,10 @@ struct Stage
        Block content;
        std::map<std::string, StructDeclaration *> types;
        std::map<std::string, InterfaceBlock *> interface_blocks;
+       std::map<std::string, FunctionDeclaration *> functions;
        std::map<std::string, unsigned> locations;
        Features required_features;
+       std::vector<Diagnostic> diagnostics;
 
        Stage(Type);