+ bool apply(Stage &s) { s.content.visit(*this); return r_any_folded; }
+
+private:
+ template<typename T>
+ static T evaluate_logical(char, T, T);
+ template<typename T>
+ static bool evaluate_relation(const char *, T, T);
+ template<typename T>
+ static T evaluate_arithmetic(char, T, T);
+ template<typename T>
+ static T evaluate_int_special_op(char, T, T);
+ template<typename T>
+ void convert_to_result(const Variant &);
+ void set_result(const Variant &, bool = false);
+
+ virtual void visit(RefPtr<Expression> &);
+ virtual void visit(Literal &);
+ virtual void visit(VariableReference &);
+ virtual void visit(MemberAccess &);
+ virtual void visit(Swizzle &);
+ virtual void visit(UnaryExpression &);
+ virtual void visit(BinaryExpression &);
+ virtual void visit(Assignment &);
+ virtual void visit(TernaryExpression &);
+ virtual void visit(FunctionCall &);
+ virtual void visit(VariableDeclaration &);
+ virtual void visit(Iteration &);
+};
+
+/** Removes conditional statements and loops where the condition can be
+determined as constant at compile time. Also removes such statements where
+the body is empty and the condition has no side effects. */
+class ConstantConditionEliminator: private TraversingVisitor
+{
+private:
+ enum ConstantStatus
+ {
+ CONSTANT_FALSE,
+ CONSTANT_TRUE,
+ NOT_CONSTANT
+ };