summaryrefslogtreecommitdiff
path: root/gdb/expop.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:28 -0700
commit5019124b1ddc3839bd8ccba08819b11c0151e8a9 (patch)
treee83820e9ee3c77bdff1892dfbc7b2664c26d0df6 /gdb/expop.h
parent2bc9b40ce16a109a22320589d2cfb9fced5fb769 (diff)
downloadbinutils-gdb-5019124b1ddc3839bd8ccba08819b11c0151e8a9.tar.gz
Implement the "&&" and "||" operators
This implements the "&&" and "||" operators. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class logical_and_operation) (class logical_or_operation): New. * eval.c (logical_and_operation::evaluate) (logical_or_operation::evaluate): New methods. * ax-gdb.c (logical_and_operation::do_generate_ax) (logical_or_operation::do_generate_ax): New methods.
Diffstat (limited to 'gdb/expop.h')
-rw-r--r--gdb/expop.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/gdb/expop.h b/gdb/expop.h
index 6b1a8753b97..7850c457adb 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -1982,6 +1982,54 @@ public:
{ return MULTI_SUBSCRIPT; }
};
+/* The "&&" operator. */
+class logical_and_operation
+ : public maybe_constant_operation<operation_up, operation_up>
+{
+public:
+
+ using maybe_constant_operation::maybe_constant_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override;
+
+ enum exp_opcode opcode () const override
+ { return BINOP_LOGICAL_AND; }
+
+protected:
+
+ void do_generate_ax (struct expression *exp,
+ struct agent_expr *ax,
+ struct axs_value *value,
+ struct type *cast_type)
+ override;
+};
+
+/* The "||" operator. */
+class logical_or_operation
+ : public maybe_constant_operation<operation_up, operation_up>
+{
+public:
+
+ using maybe_constant_operation::maybe_constant_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override;
+
+ enum exp_opcode opcode () const override
+ { return BINOP_LOGICAL_OR; }
+
+protected:
+
+ void do_generate_ax (struct expression *exp,
+ struct agent_expr *ax,
+ struct axs_value *value,
+ struct type *cast_type)
+ override;
+};
+
} /* namespace expr */
#endif /* EXPOP_H */