diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-08 07:27:57 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-03-08 07:28:28 -0700 |
commit | 5019124b1ddc3839bd8ccba08819b11c0151e8a9 (patch) | |
tree | e83820e9ee3c77bdff1892dfbc7b2664c26d0df6 /gdb/ax-gdb.c | |
parent | 2bc9b40ce16a109a22320589d2cfb9fced5fb769 (diff) | |
download | fsf-binutils-gdb-5019124b1ddc3839bd8ccba08819b11c0151e8a9.zip fsf-binutils-gdb-5019124b1ddc3839bd8ccba08819b11c0151e8a9.tar.gz fsf-binutils-gdb-5019124b1ddc3839bd8ccba08819b11c0151e8a9.tar.bz2 |
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/ax-gdb.c')
-rw-r--r-- | gdb/ax-gdb.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index bdf4a6d..8ec3dd7 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -2693,6 +2693,62 @@ var_value_operation::do_generate_ax (struct expression *exp, } } +void +logical_and_operation::do_generate_ax (struct expression *exp, + struct agent_expr *ax, + struct axs_value *value, + struct type *cast_type) +{ + struct axs_value value1, value2; + int if1, go1, if2, go2, end; + + /* Generate the obvious sequence of tests and jumps. */ + std::get<0> (m_storage)->generate_ax (exp, ax, &value1); + gen_usual_unary (ax, &value1); + if1 = ax_goto (ax, aop_if_goto); + go1 = ax_goto (ax, aop_goto); + ax_label (ax, if1, ax->len); + std::get<1> (m_storage)->generate_ax (exp, ax, &value2); + gen_usual_unary (ax, &value2); + if2 = ax_goto (ax, aop_if_goto); + go2 = ax_goto (ax, aop_goto); + ax_label (ax, if2, ax->len); + ax_const_l (ax, 1); + end = ax_goto (ax, aop_goto); + ax_label (ax, go1, ax->len); + ax_label (ax, go2, ax->len); + ax_const_l (ax, 0); + ax_label (ax, end, ax->len); + value->kind = axs_rvalue; + value->type = builtin_type (ax->gdbarch)->builtin_int; +} + +void +logical_or_operation::do_generate_ax (struct expression *exp, + struct agent_expr *ax, + struct axs_value *value, + struct type *cast_type) +{ + struct axs_value value1, value2; + int if1, if2, end; + + /* Generate the obvious sequence of tests and jumps. */ + std::get<0> (m_storage)->generate_ax (exp, ax, &value1); + gen_usual_unary (ax, &value1); + if1 = ax_goto (ax, aop_if_goto); + std::get<1> (m_storage)->generate_ax (exp, ax, &value2); + gen_usual_unary (ax, &value2); + if2 = ax_goto (ax, aop_if_goto); + ax_const_l (ax, 0); + end = ax_goto (ax, aop_goto); + ax_label (ax, if1, ax->len); + ax_label (ax, if2, ax->len); + ax_const_l (ax, 1); + ax_label (ax, end, ax->len); + value->kind = axs_rvalue; + value->type = builtin_type (ax->gdbarch)->builtin_int; +} + } /* This handles the middle-to-right-side of code generation for binary |