]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/optimize.h
Remove unreachable code after a jump statement
[libs/gl.git] / source / glsl / optimize.h
index b7b39176a06e62490573cee96ec174fbcd276ad4..e21dd98fd0fcbe63e578e3012cd072d108c5437d 100644 (file)
@@ -227,6 +227,26 @@ private:
        virtual void visit(Iteration &);
 };
 
+class UnreachableCodeRemover: private TraversingVisitor
+{
+private:
+       bool reachable;
+       std::set<Node *> unreachable_nodes;
+
+public:
+       UnreachableCodeRemover();
+
+       virtual bool apply(Stage &);
+
+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; }
+};
+
 /** Removes types which are not used anywhere. */
 class UnusedTypeRemover: private TraversingVisitor
 {