Mercurial > octave
changeset 23522:d2e300f7700c
fix compound binary op error introduced in c452180ab672
Access correct operator and operands when evaluating compound binary
expressions.
* pt-binop.h (tree_binary_expression::lhs,
tree_binary_expression::rhs): Now virtual.
* pt-cbinop.h (tree_compound_binary_expression::cop_lhs,
tree_compound_binary_expression::cop_rhs): Rename from op_lhs and
op_rhs.
(tree_compound_binary_expression::lhs,
tree_compound_binary_expression::rhs): New functions.
* pt-eval.cc ((tree_evaluator::visit_compound_binary_op): Use
compound_binary_op expression type instead of binary_op expression
type in call to do_binary_op.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 23 May 2017 13:55:43 -0400 |
parents | 551fa3879615 |
children | d2748870db4e |
files | libinterp/parse-tree/pt-binop.h libinterp/parse-tree/pt-cbinop.h libinterp/parse-tree/pt-eval.cc |
diffstat | 3 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-binop.h Tue May 23 12:24:44 2017 -0400 +++ b/libinterp/parse-tree/pt-binop.h Tue May 23 13:55:43 2017 -0400 @@ -95,8 +95,8 @@ octave_value::binary_op op_type (void) const { return etype; } - tree_expression * lhs (void) { return op_lhs; } - tree_expression * rhs (void) { return op_rhs; } + virtual tree_expression * lhs (void) { return op_lhs; } + virtual tree_expression * rhs (void) { return op_rhs; } bool is_eligible_for_braindead_shortcircuit (void) const {
--- a/libinterp/parse-tree/pt-cbinop.h Tue May 23 12:24:44 2017 -0400 +++ b/libinterp/parse-tree/pt-cbinop.h Tue May 23 13:55:43 2017 -0400 @@ -48,13 +48,16 @@ octave_value::binary_op t, tree_expression *ca, tree_expression *cb, octave_value::compound_binary_op ct) - : tree_binary_expression (a, b, l, c, t), op_lhs (ca), op_rhs (cb), + : tree_binary_expression (a, b, l, c, t), cop_lhs (ca), cop_rhs (cb), etype (ct) { } octave_value::compound_binary_op cop_type (void) const { return etype; } bool rvalue_ok (void) const { return true; } + tree_expression * lhs (void) { return cop_lhs; } + tree_expression * rhs (void) { return cop_rhs; } + void accept (tree_walker& tw) { tw.visit_compound_binary_expression (*this); @@ -62,8 +65,9 @@ private: - tree_expression *op_lhs; - tree_expression *op_rhs; + tree_expression *cop_lhs; + tree_expression *cop_rhs; + octave_value::compound_binary_op etype; // No copying!
--- a/libinterp/parse-tree/pt-eval.cc Tue May 23 12:24:44 2017 -0400 +++ b/libinterp/parse-tree/pt-eval.cc Tue May 23 13:55:43 2017 -0400 @@ -300,7 +300,7 @@ if (b.is_defined ()) { - octave_value::binary_op etype = expr.op_type (); + octave_value::compound_binary_op etype = expr.cop_type (); val = ::do_binary_op (etype, a, b); }