GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-const.h
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 (octave_pt_const_h)
24 #define octave_pt_const_h 1
25 
26 #include "octave-config.h"
27 
28 #include <iosfwd>
29 #include <string>
30 
31 class octave_value_list;
32 
33 #include "ov.h"
34 #include "pt-bp.h"
35 #include "pt-exp.h"
36 #include "pt-walk.h"
37 
38 namespace octave
39 {
40  class symbol_scope;
41 
43  {
44  public:
45 
46  tree_constant (int l = -1, int c = -1)
47  : tree_expression (l, c), m_value (), m_orig_text ()
48  { }
49 
50  tree_constant (const octave_value& v, int l = -1, int c = -1)
51  : tree_expression (l, c), m_value (v), m_orig_text ()
52  { }
53 
54  tree_constant (const octave_value& v, const std::string& ot,
55  int l = -1, int c = -1)
56  : tree_expression (l, c), m_value (v), m_orig_text (ot)
57  { }
58 
59  // No copying!
60 
61  tree_constant (const tree_constant&) = delete;
62 
63  tree_constant& operator = (const tree_constant&) = delete;
64 
65  ~tree_constant (void) = default;
66 
67  bool has_magic_end (void) const { return false; }
68 
69  // Type. It would be nice to eliminate the need for this.
70 
71  bool is_constant (void) const { return true; }
72 
73  void maybe_mutate (void) { m_value.maybe_mutate (); }
74 
75  void print (std::ostream& os, bool pr_as_read_syntax = false,
76  bool pr_orig_txt = true);
77 
78  void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
79  bool pr_orig_txt = true);
80 
81  bool rvalue_ok (void) const { return true; }
82 
83  octave_value value (void) { return m_value; }
84 
85  tree_expression * dup (symbol_scope& scope) const;
86 
87  void accept (tree_walker& tw)
88  {
89  tw.visit_constant (*this);
90  }
91 
92  // Store the original text corresponding to this constant for later
93  // pretty printing.
94 
96 
97  std::string original_text (void) const { return m_orig_text; }
98 
99  private:
100 
101  // The actual value that this constant refers to.
103 
104  // The original text form of this constant.
106  };
107 }
108 
109 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
110 
111 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_constant' instead")
112 typedef octave::tree_constant tree_constant;
113 
114 #endif
115 
116 #endif
octave_value m_value
Definition: pt-const.h:102
virtual void visit_constant(tree_constant &)=0
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
s
Definition: file-io.cc:2729
void accept(tree_walker &tw)
Definition: pt-const.h:87
tree_constant & operator=(const tree_constant &)=delete
std::string m_orig_text
Definition: pt-const.h:105
tree_constant(int l=-1, int c=-1)
Definition: pt-const.h:46
tree_expression * dup(symbol_scope &scope) const
Definition: pt-const.cc:61
~tree_constant(void)=default
bool has_magic_end(void) const
Definition: pt-const.h:67
bool rvalue_ok(void) const
Definition: pt-const.h:81
std::string original_text(void) const
Definition: pt-const.h:97
tree_constant(const octave_value &v, const std::string &ot, int l=-1, int c=-1)
Definition: pt-const.h:54
void maybe_mutate(void)
Definition: pt-const.h:73
bool is_constant(void) const
Definition: pt-const.h:71
void maybe_mutate(void)
tree_constant(const octave_value &v, int l=-1, int c=-1)
Definition: pt-const.h:50
void print(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
Definition: pt-const.cc:41
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
void stash_original_text(const std::string &s)
Definition: pt-const.h:95
octave_value value(void)
Definition: pt-const.h:83
void print_raw(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
Definition: pt-const.cc:51