GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-const.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-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 <iostream>
28 
29 #include "error.h"
30 #include "ovl.h"
31 #include "pager.h"
32 #include "pt-const.h"
33 #include "pt-walk.h"
34 
35 namespace octave
36 {
37  // We are likely to have a lot of tree_constant objects to allocate,
38  // so make the grow_size large.
39 
40  void
41  tree_constant::print (std::ostream& os, bool pr_as_read_syntax,
42  bool pr_orig_text)
43  {
44  if (pr_orig_text && ! m_orig_text.empty ())
45  os << m_orig_text;
46  else
47  m_value.print (os, pr_as_read_syntax);
48  }
49 
50  void
51  tree_constant::print_raw (std::ostream& os, bool pr_as_read_syntax,
52  bool pr_orig_text)
53  {
54  if (pr_orig_text && ! m_orig_text.empty ())
55  os << m_orig_text;
56  else
57  m_value.print_raw (os, pr_as_read_syntax);
58  }
59 
62  {
63  tree_constant *new_tc
64  = new tree_constant (m_value, m_orig_text, line (), column ());
65 
66  new_tc->copy_base (*this);
67 
68  return new_tc;
69  }
70 }
virtual int column(void) const
Definition: pt.h:58
octave_value m_value
Definition: pt-const.h:102
std::string m_orig_text
Definition: pt-const.h:105
tree_constant(int l=-1, int c=-1)
Definition: pt-const.h:46
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov.h:1268
void print(std::ostream &os, bool pr_as_read_syntax=false)
Definition: ov.h:1265
virtual void copy_base(const tree_expression &e)
Definition: pt-exp.h:130
tree_expression * dup(symbol_scope &scope) const
Definition: pt-const.cc:61
void print(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
Definition: pt-const.cc:41
octave::stream os
Definition: file-io.cc:627
void print_raw(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
Definition: pt-const.cc:51