Mercurial > hg > octave-nkf
annotate src/pt-const.h @ 10884:cc2bc3f46cd4
fix assignment bug with lazy indices
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 11 Aug 2010 10:55:31 +0200 |
parents | f3b65e1ae355 |
children | fd0a3ac60b0e |
rev | line source |
---|---|
1 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, |
8920 | 4 2004, 2005, 2006, 2007, 2008, 2009 John W. Eaton |
1 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1 | 21 |
22 */ | |
23 | |
383 | 24 #if !defined (octave_tree_const_h) |
25 #define octave_tree_const_h 1 | |
1 | 26 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
27 #include <iosfwd> |
1728 | 28 #include <string> |
29 | |
2475 | 30 #include "oct-alloc.h" |
500 | 31 |
2086 | 32 class octave_value_list; |
2124 | 33 class tree_walker; |
34 | |
2390 | 35 #include "ov.h" |
7336 | 36 #include "pt-bp.h" |
37 #include "pt-exp.h" | |
38 #include "symtab.h" | |
581 | 39 |
1 | 40 class |
2971 | 41 tree_constant : public tree_expression |
1 | 42 { |
43 public: | |
620 | 44 |
2879 | 45 tree_constant (int l = -1, int c = -1) |
2971 | 46 : tree_expression (l, c), val (), orig_text () { } |
620 | 47 |
2390 | 48 tree_constant (const octave_value& v, int l = -1, int c = -1) |
2971 | 49 : tree_expression (l, c), val (v), orig_text () { } |
1 | 50 |
5861 | 51 tree_constant (const octave_value& v, const std::string& ot, |
10313 | 52 int l = -1, int c = -1) |
5861 | 53 : tree_expression (l, c), val (v), orig_text (ot) { } |
54 | |
2390 | 55 ~tree_constant (void) { } |
56 | |
4267 | 57 bool has_magic_end (void) const { return false; } |
58 | |
3933 | 59 void *operator new (size_t size) { return allocator.alloc (size); } |
2475 | 60 |
3933 | 61 void operator delete (void *p, size_t size) { allocator.free (p, size); } |
1 | 62 |
1558 | 63 // Type. It would be nice to eliminate the need for this. |
620 | 64 |
3933 | 65 bool is_constant (void) const { return true; } |
620 | 66 |
3933 | 67 void maybe_mutate (void) { val.maybe_mutate (); } |
2409 | 68 |
3523 | 69 void print (std::ostream& os, bool pr_as_read_syntax = false, |
10313 | 70 bool pr_orig_txt = true); |
1199 | 71 |
3523 | 72 void print_raw (std::ostream& os, bool pr_as_read_syntax = false, |
10313 | 73 bool pr_orig_txt = true); |
2942 | 74 |
3933 | 75 bool rvalue_ok (void) const { return true; } |
1 | 76 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
77 octave_value rvalue1 (int = 1) { return val; } |
2971 | 78 |
79 octave_value_list rvalue (int nargout); | |
80 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
81 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 82 symbol_table::context_id context) const; |
5861 | 83 |
2971 | 84 void accept (tree_walker& tw); |
1 | 85 |
1558 | 86 // Store the original text corresponding to this constant for later |
87 // pretty printing. | |
620 | 88 |
3933 | 89 void stash_original_text (const std::string& s) { orig_text = s; } |
620 | 90 |
3933 | 91 std::string original_text (void) const { return orig_text; } |
2124 | 92 |
747 | 93 private: |
94 | |
2475 | 95 // For custom memory management. |
96 static octave_allocator allocator; | |
97 | |
98 // The actual value that this constant refers to. | |
2390 | 99 octave_value val; |
747 | 100 |
2475 | 101 // The original text form of this constant. |
3523 | 102 std::string orig_text; |
2988 | 103 |
104 // No copying! | |
105 | |
106 tree_constant (const tree_constant&); | |
107 | |
108 tree_constant& operator = (const tree_constant&); | |
2390 | 109 }; |
2179 | 110 |
1 | 111 #endif |