GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-binop.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include "error.h"
28 #include "ov.h"
29 #include "pt-binop.h"
30 #include "variables.h"
31 
32 namespace octave
33 {
34  // Binary expressions.
35 
36  void
38  {
39  warning_with_id ("Octave:possible-matlab-short-circuit-operator",
40  "Matlab-style short-circuit operation performed for operator %s",
41  op);
42 
44  }
45 
48  {
50  }
51 
54  {
56  = new tree_binary_expression (m_lhs ? m_lhs->dup (scope) : nullptr,
57  m_rhs ? m_rhs->dup (scope) : nullptr,
58  line (), column (), m_etype);
59 
60  new_be->copy_base (*this);
61 
62  return new_be;
63  }
64 
65  // Boolean expressions.
66 
69  {
70  std::string retval = "<unknown>";
71 
72  switch (m_etype)
73  {
74  case bool_and:
75  retval = "&&";
76  break;
77 
78  case bool_or:
79  retval = "||";
80  break;
81 
82  default:
83  break;
84  }
85 
86  return retval;
87  }
88 
91  {
93  = new tree_boolean_expression (m_lhs ? m_lhs->dup (scope) : nullptr,
94  m_rhs ? m_rhs->dup (scope) : nullptr,
95  line (), column (), m_etype);
96 
97  new_be->copy_base (*this);
98 
99  return new_be;
100  }
101 }
virtual int line(void) const
Definition: pt.h:56
void warning_with_id(const char *id, const char *fmt,...)
Definition: error.cc:816
virtual int column(void) const
Definition: pt.h:58
static std::string binary_op_as_string(binary_op)
Definition: ov.cc:177
std::string oper(void) const
Definition: pt-binop.cc:47
tree_expression * m_rhs
Definition: pt-binop.h:122
tree_boolean_expression(int l=-1, int c=-1, type t=unknown)
Definition: pt-binop.h:151
void matlab_style_short_circuit_warning(const char *op)
Definition: pt-binop.cc:37
tree_expression * dup(symbol_scope &scope) const
Definition: pt-binop.cc:53
virtual void copy_base(const tree_expression &e)
Definition: pt-exp.h:130
std::string oper(void) const
Definition: pt-binop.cc:68
octave_value retval
Definition: data.cc:6246
tree_binary_expression(int l=-1, int c=-1, octave_value::binary_op t=octave_value::unknown_binary_op)
Definition: pt-binop.h:47
tree_expression * dup(symbol_scope &scope) const
Definition: pt-binop.cc:90
octave_value::binary_op m_etype
Definition: pt-binop.h:127
tree_expression * m_lhs
Definition: pt-binop.h:121
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
virtual tree_expression * dup(symbol_scope &scope) const =0