GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pt-const.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2015 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_pt_const_h)
24 #define octave_pt_const_h 1
25 
26 #include <iosfwd>
27 #include <string>
28 
29 
30 class octave_value_list;
31 class tree_walker;
32 
33 #include "ov.h"
34 #include "pt-bp.h"
35 #include "pt-exp.h"
36 #include "symtab.h"
37 
38 class
40 {
41 public:
42 
43  tree_constant (int l = -1, int c = -1)
44  : tree_expression (l, c), val (), orig_text () { }
45 
46  tree_constant (const octave_value& v, int l = -1, int c = -1)
47  : tree_expression (l, c), val (v), orig_text () { }
48 
49  tree_constant (const octave_value& v, const std::string& ot,
50  int l = -1, int c = -1)
51  : tree_expression (l, c), val (v), orig_text (ot) { }
52 
53  ~tree_constant (void) { }
54 
55  bool has_magic_end (void) const { return false; }
56 
57  // Type. It would be nice to eliminate the need for this.
58 
59  bool is_constant (void) const { return true; }
60 
61  void maybe_mutate (void) { val.maybe_mutate (); }
62 
63  void print (std::ostream& os, bool pr_as_read_syntax = false,
64  bool pr_orig_txt = true);
65 
66  void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
67  bool pr_orig_txt = true);
68 
69  bool rvalue_ok (void) const { return true; }
70 
71  octave_value rvalue1 (int = 1) { return val; }
72 
73  octave_value_list rvalue (int nargout);
74 
77 
78  void accept (tree_walker& tw);
79 
80  // Store the original text corresponding to this constant for later
81  // pretty printing.
82 
83  void stash_original_text (const std::string& s) { orig_text = s; }
84 
85  std::string original_text (void) const { return orig_text; }
86 
87 private:
88 
89  // The actual value that this constant refers to.
91 
92  // The original text form of this constant.
93  std::string orig_text;
94 
95  // No copying!
96 
98 
100 
101 };
102 
103 #endif
tree_constant(const octave_value &v, int l=-1, int c=-1)
Definition: pt-const.h:46
void maybe_mutate(void)
Definition: pt-const.h:61
octave_value rvalue1(int=1)
Definition: pt-const.h:71
octave_value val
Definition: pt-const.h:90
tree_constant(int l=-1, int c=-1)
Definition: pt-const.h:43
~tree_constant(void)
Definition: pt-const.h:53
bool rvalue_ok(void) const
Definition: pt-const.h:69
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
std::string orig_text
Definition: pt-const.h:93
void stash_original_text(const std::string &s)
Definition: pt-const.h:83
bool is_constant(void) const
Definition: pt-const.h:59
tree_constant(const octave_value &v, const std::string &ot, int l=-1, int c=-1)
Definition: pt-const.h:49
bool has_magic_end(void) const
Definition: pt-const.h:55
size_t context_id
Definition: symtab.h:51
std::string original_text(void) const
Definition: pt-const.h:85
tree_walker & operator=(const tree_walker &)