GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-funcall.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2012-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 "ov-fcn.h"
28 #include "pt-funcall.h"
29 #include "pt-walk.h"
30 
31 namespace octave
32 {
33  // Function call objects.
34 
35  void
36  tree_funcall::print (std::ostream& os, bool pr_as_read_syntax,
37  bool pr_orig_text)
38  {
39  print_raw (os, pr_as_read_syntax, pr_orig_text);
40  }
41 
42  void
43  tree_funcall::print_raw (std::ostream& os, bool pr_as_read_syntax,
44  bool pr_orig_text)
45  {
46  if (pr_orig_text)
47  {
48  os << original_text ();
49  }
50  else
51  {
53  std::string nm = (fp ? fp->name () : "<invalid-function>");
54 
55  os << nm << " (";
56 
58  for (octave_idx_type i = 0; i < n; i++)
59  {
60  m_args(i).print_raw (os, pr_as_read_syntax);
61 
62  if (i < n - 1)
63  os << ", ";
64  }
65 
66  os << ')';
67  }
68  }
69 
70  tree_funcall *
72  {
73  tree_funcall *new_fc
74  = new tree_funcall (m_fcn, m_args, line (), column ());
75 
76  new_fc->copy_base (*this);
77 
78  return new_fc;
79  }
80 }
tree_funcall(const octave_value &f, const octave_value_list &a, int l=-1, int c=-1)
Definition: pt-funcall.h:45
void print(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
Definition: pt-funcall.cc:36
virtual int column(void) const
Definition: pt.h:58
virtual std::string original_text(void) const
Definition: pt-exp.cc:47
octave_value_list m_args
Definition: pt-funcall.h:87
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:975
void print_raw(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
Definition: pt-funcall.cc:43
octave_value m_fcn
Definition: pt-funcall.h:84
virtual void copy_base(const tree_expression &e)
Definition: pt-exp.h:130
octave_function * function_value(bool silent=false) const
tree_funcall * dup(symbol_scope &scope) const
Definition: pt-funcall.cc:71
octave_idx_type length(void) const
Definition: ovl.h:96
for i
Definition: data.cc:5264
std::string name(void) const
Definition: ov-fcn.h:182
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
octave::stream os
Definition: file-io.cc:627