GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-cbinop.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2008-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_pt_cbinop_h)
27 #define octave_pt_cbinop_h 1
28 
29 #include "octave-config.h"
30 
31 #include <string>
32 
33 class octave_value;
34 class octave_value_list;
35 
36 #include "ov.h"
37 #include "pt-binop.h"
38 #include "pt-walk.h"
39 
41 
42 // Binary expressions that can be reduced to compound operations
43 
45 {
46 public:
47 
49  int l, int c,
53  : tree_binary_expression (a, b, l, c, t), m_lhs (ca), m_rhs (cb),
54  m_etype (ct)
55  { }
56 
57  OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (tree_compound_binary_expression)
58 
59  // FIXME: who is responsibile for deleting M_LHS and M_RHS?
61 
62  octave_value::compound_binary_op cop_type () const { return m_etype; }
63 
64  bool rvalue_ok () const { return true; }
65 
66  tree_expression * clhs () { return m_lhs; }
67  tree_expression * crhs () { return m_rhs; }
68 
69  octave_value evaluate (tree_evaluator&, int nargout = 1);
70 
72  {
73  return ovl (evaluate (tw, nargout));
74  }
75 
76  void accept (tree_walker& tw)
77  {
79  }
80 
81 private:
82 
83  tree_expression *m_lhs;
84  tree_expression *m_rhs;
85 
87 };
88 
89 // a "virtual constructor"
90 
93  int l = -1, int c = -1,
96 
97 OCTAVE_END_NAMESPACE(octave)
98 
99 #endif
compound_binary_op
Definition: ov.h:117
binary_op
Definition: ov.h:92
@ unknown_binary_op
Definition: ov.h:113
octave_value::compound_binary_op cop_type() const
Definition: pt-cbinop.h:62
tree_compound_binary_expression(tree_expression *a, tree_expression *b, int l, int c, octave_value::binary_op t, tree_expression *ca, tree_expression *cb, octave_value::compound_binary_op ct)
Definition: pt-cbinop.h:48
tree_expression * clhs()
Definition: pt-cbinop.h:66
tree_expression * crhs()
Definition: pt-cbinop.h:67
octave_value_list evaluate_n(tree_evaluator &tw, int nargout=1)
Definition: pt-cbinop.h:71
void accept(tree_walker &tw)
Definition: pt-cbinop.h:76
virtual void visit_compound_binary_expression(tree_compound_binary_expression &)
Definition: pt-walk.cc:162
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:219
tree_binary_expression * maybe_compound_binary_expression(tree_expression *a, tree_expression *b, int l=-1, int c=-1, octave_value::binary_op t=octave_value::unknown_binary_op)
Definition: pt-cbinop.cc:143