1 #ifndef MSP_GL_SL_VALIDATE_H_
2 #define MSP_GL_SL_VALIDATE_H_
6 #include "glsl_error.h"
13 class Validator: protected TraversingVisitor
20 void diagnose(Node &, Diagnostic::Severity, const std::string &);
21 void error(Node &n, const std::string &m) { diagnose(n, Diagnostic::ERR, m); }
24 class TypeValidator: private Validator
32 void apply(Stage &s) { stage = &s; s.content.visit(*this); }
35 virtual void visit(BasicTypeDeclaration &);
36 virtual void visit(ImageTypeDeclaration &);
37 virtual void visit(StructDeclaration &);
38 virtual void visit(VariableDeclaration &);
41 class DeclarationValidator: private Validator
44 typedef std::map<std::string, Statement *> BlockDeclarationMap;
46 std::map<Block *, BlockDeclarationMap> declarations;
47 std::map<std::string, InterfaceBlock *> interface_blocks;
51 DeclarationValidator();
53 void apply(Stage &s) { stage = &s; s.content.visit(*this); }
56 void multiple_definition(const std::string &, Statement &, Statement &);
57 Statement *find_definition(const std::string &);
58 void check_definition(const std::string &, Statement &);
59 void record_definition(const std::string &, Statement &);
61 virtual void visit(TypeDeclaration &);
62 virtual void visit(BasicTypeDeclaration &t) { visit(static_cast<TypeDeclaration &>(t)); }
63 virtual void visit(ImageTypeDeclaration &t) { visit(static_cast<TypeDeclaration &>(t)); }
64 virtual void visit(StructDeclaration &);
65 virtual void visit(VariableDeclaration &);
66 virtual void visit(InterfaceBlock &);
67 virtual void visit(FunctionDeclaration &);
70 class ReferenceValidator: private Validator
73 void apply(Stage &s) { stage = &s; s.content.visit(*this); }
76 virtual void visit(BasicTypeDeclaration &);
77 virtual void visit(ImageTypeDeclaration &);
78 virtual void visit(VariableReference &);
79 virtual void visit(InterfaceBlockReference &);
80 virtual void visit(VariableDeclaration &);
81 virtual void visit(FunctionDeclaration &);
84 class ExpressionValidator: private Validator
87 void apply(Stage &s) { stage = &s; s.content.visit(*this); }
90 virtual void visit(UnaryExpression &);
91 virtual void visit(BinaryExpression &);
92 virtual void visit(Assignment &);
93 virtual void visit(VariableDeclaration &);