1 #ifndef MSP_GL_SL_VALIDATE_H_
2 #define MSP_GL_SL_VALIDATE_H_
6 #include "glsl_error.h"
13 class Validator: protected TraversingVisitor
21 void diagnose(Node &, Node &, Diagnostic::Severity, const std::string &);
22 void diagnose(Node &n, Diagnostic::Severity s, const std::string &m) { diagnose(n, n, s, m); }
23 void error(Node &n, const std::string &m) { diagnose(n, Diagnostic::ERR, m); }
24 void add_info(Node &, const std::string &);
27 class TypeValidator: private Validator
35 void apply(Stage &s) { stage = &s; s.content.visit(*this); }
38 virtual void visit(BasicTypeDeclaration &);
39 virtual void visit(ImageTypeDeclaration &);
40 virtual void visit(StructDeclaration &);
41 virtual void visit(VariableDeclaration &);
44 class DeclarationValidator: private Validator
47 typedef std::map<std::string, Statement *> BlockDeclarationMap;
49 std::map<Block *, BlockDeclarationMap> declarations;
50 std::map<std::string, InterfaceBlock *> interface_blocks;
51 std::map<std::string, FunctionDeclaration *> overloaded_functions;
55 DeclarationValidator();
57 void apply(Stage &s) { stage = &s; s.content.visit(*this); }
60 void multiple_definition(const std::string &, Statement &, Statement &);
61 Statement *find_definition(const std::string &);
62 void check_definition(const std::string &, Statement &);
63 void record_definition(const std::string &, Statement &);
65 virtual void visit(TypeDeclaration &);
66 virtual void visit(BasicTypeDeclaration &t) { visit(static_cast<TypeDeclaration &>(t)); }
67 virtual void visit(ImageTypeDeclaration &t) { visit(static_cast<TypeDeclaration &>(t)); }
68 virtual void visit(StructDeclaration &);
69 virtual void visit(VariableDeclaration &);
70 virtual void visit(InterfaceBlock &);
71 virtual void visit(FunctionDeclaration &);
74 class ReferenceValidator: private Validator
77 void apply(Stage &s) { stage = &s; s.content.visit(*this); }
80 virtual void visit(BasicTypeDeclaration &);
81 virtual void visit(ImageTypeDeclaration &);
82 virtual void visit(VariableReference &);
83 virtual void visit(MemberAccess &);
84 virtual void visit(InterfaceBlockReference &);
85 virtual void visit(FunctionCall &);
86 virtual void visit(VariableDeclaration &);
87 virtual void visit(InterfaceBlock &);
88 virtual void visit(FunctionDeclaration &);
91 class ExpressionValidator: private Validator
94 void apply(Stage &s) { stage = &s; s.content.visit(*this); }
97 virtual void visit(Swizzle &);
98 virtual void visit(UnaryExpression &);
99 virtual void visit(BinaryExpression &);
100 virtual void visit(Assignment &);
101 virtual void visit(TernaryExpression &);
102 virtual void visit(VariableDeclaration &);