]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/validate.h
Add a bunch of validation for declarations in GLSL
[libs/gl.git] / source / glsl / validate.h
index 6cd5675a07f691f413c8786f2143fb5d2ebb3708..f1e3f5126eb8422624524979a8768165b5451396 100644 (file)
@@ -24,21 +24,39 @@ protected:
        void add_info(Node &, const std::string &);
 };
 
        void add_info(Node &, const std::string &);
 };
 
-class TypeValidator: private Validator
+class DeclarationValidator: private Validator
 {
 private:
 {
 private:
-       bool in_struct;
+       enum ScopeType
+       {
+               GLOBAL,
+               STRUCT,
+               INTERFACE_BLOCK,
+               FUNCTION_PARAM,
+               FUNCTION
+       };
+
+       ScopeType scope;
+       InterfaceLayout *iface_layout;
+       InterfaceBlock *iface_block;
+       VariableDeclaration *variable;
 
 public:
 
 public:
-       TypeValidator();
+       DeclarationValidator();
 
        void apply(Stage &s) { stage = &s; s.content.visit(*this); }
 
 private:
 
        void apply(Stage &s) { stage = &s; s.content.visit(*this); }
 
 private:
+       static const char *describe_variable(ScopeType);
+
+       virtual void visit(Layout &);
+       virtual void visit(InterfaceLayout &);
        virtual void visit(BasicTypeDeclaration &);
        virtual void visit(ImageTypeDeclaration &);
        virtual void visit(StructDeclaration &);
        virtual void visit(VariableDeclaration &);
        virtual void visit(BasicTypeDeclaration &);
        virtual void visit(ImageTypeDeclaration &);
        virtual void visit(StructDeclaration &);
        virtual void visit(VariableDeclaration &);
+       virtual void visit(InterfaceBlock &);
+       virtual void visit(FunctionDeclaration &);
 };
 
 class IdentifierValidator: private Validator
 };
 
 class IdentifierValidator: private Validator
@@ -90,7 +108,12 @@ private:
 
 class ExpressionValidator: private Validator
 {
 
 class ExpressionValidator: private Validator
 {
+private:
+       FunctionDeclaration *current_function;
+
 public:
 public:
+       ExpressionValidator();
+
        void apply(Stage &s) { stage = &s; s.content.visit(*this); }
 
 private:
        void apply(Stage &s) { stage = &s; s.content.visit(*this); }
 
 private:
@@ -100,6 +123,8 @@ private:
        virtual void visit(Assignment &);
        virtual void visit(TernaryExpression &);
        virtual void visit(VariableDeclaration &);
        virtual void visit(Assignment &);
        virtual void visit(TernaryExpression &);
        virtual void visit(VariableDeclaration &);
+       virtual void visit(FunctionDeclaration &);
+       virtual void visit(Return &);
 };
 
 } // namespace SL
 };
 
 } // namespace SL