+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
+ };
+
+ NodeList<Statement>::iterator insert_point;
+ std::set<Node *> nodes_to_remove;
+ RefPtr<Expression> r_ternary_result;
+ bool r_external_side_effects = false;
+
+public:
+ void apply(Stage &);