X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fvalidate.h;h=d38849012e26fd4569919eaff31588fb144c3559;hb=c4aeeced7b397d46772577775bd3a0d6c4706cba;hp=1a05817069282873e27328f03683921b5945499e;hpb=6377f8efc81ffe84b7ffe44380f1caa2059f437f;p=libs%2Fgl.git diff --git a/source/glsl/validate.h b/source/glsl/validate.h index 1a058170..d3884901 100644 --- a/source/glsl/validate.h +++ b/source/glsl/validate.h @@ -118,6 +118,7 @@ class ExpressionValidator: private Validator { private: FunctionDeclaration *current_function; + bool constant_expression; public: ExpressionValidator(); @@ -125,6 +126,8 @@ public: void apply(Stage &s) { stage = &s; s.content.visit(*this); } private: + virtual void visit(VariableReference &); + virtual void visit(InterfaceBlockReference &); virtual void visit(Swizzle &); virtual void visit(UnaryExpression &); virtual void visit(BinaryExpression &); @@ -137,6 +140,27 @@ private: virtual void visit(Return &); }; +/** Verifies flow control constructs. Functions returning non-void must have +return statements. Warnings are given about dead code. */ +class FlowControlValidator: private Validator +{ +private: + bool reachable; + +public: + FlowControlValidator(); + + void apply(Stage &s) { stage = &s; s.content.visit(*this); } + +private: + virtual void visit(Block &); + virtual void visit(FunctionDeclaration &); + virtual void visit(Conditional &); + virtual void visit(Iteration &); + virtual void visit(Return &) { reachable = false; } + virtual void visit(Jump &) { reachable = false; } +}; + /** Verifies that stage input and output interfaces are valid. Linked variables must have matching types and locations and there must not be any overlap in locations. */