2887
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 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 2, or (at your option) any |
|
10 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, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_indirect_ref_h) |
|
24 #define octave_tree_indirect_ref_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 class ostream; |
|
31 |
|
32 #include <string> |
|
33 |
2942
|
34 class octave_value; |
|
35 class octave_value_list; |
2887
|
36 class tree_identifier; |
|
37 class tree_walker; |
|
38 |
|
39 #include "pt-mvr-base.h" |
|
40 |
|
41 // Indirect references to values (structure references). |
|
42 |
|
43 class |
|
44 tree_indirect_ref : public tree_multi_val_ret |
|
45 { |
|
46 public: |
|
47 |
|
48 tree_indirect_ref (int l = -1, int c = -1) |
|
49 : tree_multi_val_ret (l, c), id (0), indir (0), nm (), |
|
50 preserve_ident (false), preserve_indir (false), |
|
51 maybe_do_ans_assign (false) { } |
|
52 |
|
53 tree_indirect_ref (tree_identifier *i, int l = -1, int c = -1) |
|
54 : tree_multi_val_ret (l, c), id (i), indir (0), nm (), |
|
55 preserve_ident (false), preserve_indir (false), |
|
56 maybe_do_ans_assign (false) { } |
|
57 |
|
58 tree_indirect_ref (tree_indirect_ref *i, const string& n, |
|
59 int l = -1, int c = -1) |
|
60 : tree_multi_val_ret (l, c), id (0), indir (i), nm (n), |
|
61 preserve_ident (false), preserve_indir (false), |
|
62 maybe_do_ans_assign (false) { } |
|
63 |
|
64 ~tree_indirect_ref (void); |
|
65 |
|
66 bool is_indirect_ref (void) const |
|
67 { return true; } |
|
68 |
|
69 bool is_identifier_only (void) const |
|
70 { return (id && nm.empty ()); } |
|
71 |
|
72 tree_identifier *ident (void) |
|
73 { return id; } |
|
74 |
|
75 tree_indirect_ref *indirect (void) |
|
76 { return indir; } |
|
77 |
|
78 void preserve_identifier (void) |
|
79 { preserve_ident = true; } |
|
80 |
|
81 void preserve_indirect (void) |
|
82 { preserve_indir = true; } |
|
83 |
|
84 void mark_for_possible_ans_assign (void); |
|
85 |
|
86 string name (void) const; |
|
87 |
|
88 octave_value eval (bool print = false); |
|
89 |
2942
|
90 octave_value_list |
|
91 eval (bool print, int nargout, const octave_value_list& args); |
2887
|
92 |
2948
|
93 octave_variable_reference reference (void); |
2887
|
94 |
|
95 string elt_name (void) |
|
96 { return nm; } |
|
97 |
|
98 void accept (tree_walker& tw); |
|
99 |
|
100 private: |
|
101 |
|
102 // The identifier for this structure reference. For example, in |
|
103 // a.b.c, a is the id. |
|
104 tree_identifier *id; |
|
105 |
|
106 // This element just points to another indirect reference. |
|
107 tree_indirect_ref *indir; |
|
108 |
|
109 // The sub-element name. |
|
110 string nm; |
|
111 |
|
112 // True if we should not delete the identifier. |
|
113 bool preserve_ident; |
|
114 |
|
115 // True if we should not delete the indirect reference. |
|
116 bool preserve_indir; |
|
117 |
|
118 // True if we should consider assigning the result of evaluating |
|
119 // this identifier to the built-in variable ans. |
|
120 bool maybe_do_ans_assign; |
|
121 }; |
|
122 |
|
123 #endif |
|
124 |
|
125 /* |
|
126 ;;; Local Variables: *** |
|
127 ;;; mode: C++ *** |
|
128 ;;; End: *** |
|
129 */ |