@@ -1594,7 +1594,7 @@ eval_op_subscript (struct type *expect_type, struct expression *exp,
/* A helper function for BINOP_EQUAL. */
-static struct value *
+struct value *
eval_op_equal (struct type *expect_type, struct expression *exp,
enum noside noside, enum exp_opcode op,
struct value *arg1, struct value *arg2)
@@ -1617,7 +1617,7 @@ eval_op_equal (struct type *expect_type, struct expression *exp,
/* A helper function for BINOP_NOTEQUAL. */
-static struct value *
+struct value *
eval_op_notequal (struct type *expect_type, struct expression *exp,
enum noside noside, enum exp_opcode op,
struct value *arg1, struct value *arg2)
@@ -1640,7 +1640,7 @@ eval_op_notequal (struct type *expect_type, struct expression *exp,
/* A helper function for BINOP_LESS. */
-static struct value *
+struct value *
eval_op_less (struct type *expect_type, struct expression *exp,
enum noside noside, enum exp_opcode op,
struct value *arg1, struct value *arg2)
@@ -1663,7 +1663,7 @@ eval_op_less (struct type *expect_type, struct expression *exp,
/* A helper function for BINOP_GTR. */
-static struct value *
+struct value *
eval_op_gtr (struct type *expect_type, struct expression *exp,
enum noside noside, enum exp_opcode op,
struct value *arg1, struct value *arg2)
@@ -1686,7 +1686,7 @@ eval_op_gtr (struct type *expect_type, struct expression *exp,
/* A helper function for BINOP_GEQ. */
-static struct value *
+struct value *
eval_op_geq (struct type *expect_type, struct expression *exp,
enum noside noside, enum exp_opcode op,
struct value *arg1, struct value *arg2)
@@ -1709,7 +1709,7 @@ eval_op_geq (struct type *expect_type, struct expression *exp,
/* A helper function for BINOP_LEQ. */
-static struct value *
+struct value *
eval_op_leq (struct type *expect_type, struct expression *exp,
enum noside noside, enum exp_opcode op,
struct value *arg1, struct value *arg2)
@@ -105,6 +105,36 @@ extern struct value *eval_op_subscript (struct type *expect_type,
enum noside noside, enum exp_opcode op,
struct value *arg1,
struct value *arg2);
+extern struct value *eval_op_equal (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1,
+ struct value *arg2);
+extern struct value *eval_op_notequal (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1,
+ struct value *arg2);
+extern struct value *eval_op_less (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1,
+ struct value *arg2);
+extern struct value *eval_op_gtr (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1,
+ struct value *arg2);
+extern struct value *eval_op_geq (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1,
+ struct value *arg2);
+extern struct value *eval_op_leq (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1,
+ struct value *arg2);
namespace expr
{
@@ -1128,6 +1158,36 @@ class subscript_operation
enum noside noside) override;
};
+/* Implementation of comparison operations. */
+template<enum exp_opcode OP, binary_ftype FUNC>
+class comparison_operation
+ : public usual_ax_binop_operation<OP, FUNC>
+{
+public:
+
+ using usual_ax_binop_operation<OP, FUNC>::usual_ax_binop_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ value *lhs
+ = std::get<0> (this->m_storage)->evaluate (nullptr, exp, noside);
+ value *rhs
+ = std::get<1> (this->m_storage)->evaluate (value_type (lhs), exp,
+ noside);
+ return FUNC (expect_type, exp, noside, OP, lhs, rhs);
+ }
+};
+
+using equal_operation = comparison_operation<BINOP_EQUAL, eval_op_equal>;
+using notequal_operation
+ = comparison_operation<BINOP_NOTEQUAL, eval_op_notequal>;
+using less_operation = comparison_operation<BINOP_LESS, eval_op_less>;
+using gtr_operation = comparison_operation<BINOP_GTR, eval_op_gtr>;
+using geq_operation = comparison_operation<BINOP_GEQ, eval_op_geq>;
+using leq_operation = comparison_operation<BINOP_LEQ, eval_op_leq>;
+
} /* namespace expr */
#endif /* EXPOP_H */