Mercurial > hg > octave-nkf
annotate src/pt-const.h @ 12556:88558b8eb8a7
Add deprecated entry for cquad() pointing to quadcc().
HG Enter commit message. Lines beginning with 'HG:' are removed.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 31 Mar 2011 09:57:11 -0700 |
parents | fd0a3ac60b0e |
children | 3b5afcec526b |
rev | line source |
---|---|
1 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1993-2011 John W. Eaton |
1 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
383 | 23 #if !defined (octave_tree_const_h) |
24 #define octave_tree_const_h 1 | |
1 | 25 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
26 #include <iosfwd> |
1728 | 27 #include <string> |
28 | |
2475 | 29 #include "oct-alloc.h" |
500 | 30 |
2086 | 31 class octave_value_list; |
2124 | 32 class tree_walker; |
33 | |
2390 | 34 #include "ov.h" |
7336 | 35 #include "pt-bp.h" |
36 #include "pt-exp.h" | |
37 #include "symtab.h" | |
581 | 38 |
1 | 39 class |
2971 | 40 tree_constant : public tree_expression |
1 | 41 { |
42 public: | |
620 | 43 |
2879 | 44 tree_constant (int l = -1, int c = -1) |
2971 | 45 : tree_expression (l, c), val (), orig_text () { } |
620 | 46 |
2390 | 47 tree_constant (const octave_value& v, int l = -1, int c = -1) |
2971 | 48 : tree_expression (l, c), val (v), orig_text () { } |
1 | 49 |
5861 | 50 tree_constant (const octave_value& v, const std::string& ot, |
10313 | 51 int l = -1, int c = -1) |
5861 | 52 : tree_expression (l, c), val (v), orig_text (ot) { } |
53 | |
2390 | 54 ~tree_constant (void) { } |
55 | |
4267 | 56 bool has_magic_end (void) const { return false; } |
57 | |
3933 | 58 void *operator new (size_t size) { return allocator.alloc (size); } |
2475 | 59 |
3933 | 60 void operator delete (void *p, size_t size) { allocator.free (p, size); } |
1 | 61 |
1558 | 62 // Type. It would be nice to eliminate the need for this. |
620 | 63 |
3933 | 64 bool is_constant (void) const { return true; } |
620 | 65 |
3933 | 66 void maybe_mutate (void) { val.maybe_mutate (); } |
2409 | 67 |
3523 | 68 void print (std::ostream& os, bool pr_as_read_syntax = false, |
10313 | 69 bool pr_orig_txt = true); |
1199 | 70 |
3523 | 71 void print_raw (std::ostream& os, bool pr_as_read_syntax = false, |
10313 | 72 bool pr_orig_txt = true); |
2942 | 73 |
3933 | 74 bool rvalue_ok (void) const { return true; } |
1 | 75 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
76 octave_value rvalue1 (int = 1) { return val; } |
2971 | 77 |
78 octave_value_list rvalue (int nargout); | |
79 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
80 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 81 symbol_table::context_id context) const; |
5861 | 82 |
2971 | 83 void accept (tree_walker& tw); |
1 | 84 |
1558 | 85 // Store the original text corresponding to this constant for later |
86 // pretty printing. | |
620 | 87 |
3933 | 88 void stash_original_text (const std::string& s) { orig_text = s; } |
620 | 89 |
3933 | 90 std::string original_text (void) const { return orig_text; } |
2124 | 91 |
747 | 92 private: |
93 | |
2475 | 94 // For custom memory management. |
95 static octave_allocator allocator; | |
96 | |
97 // The actual value that this constant refers to. | |
2390 | 98 octave_value val; |
747 | 99 |
2475 | 100 // The original text form of this constant. |
3523 | 101 std::string orig_text; |
2988 | 102 |
103 // No copying! | |
104 | |
105 tree_constant (const tree_constant&); | |
106 | |
107 tree_constant& operator = (const tree_constant&); | |
2390 | 108 }; |
2179 | 109 |
1 | 110 #endif |