2980
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 2000, 2002, 2003, 2004, 2005, 2006, 2007 |
|
4 John W. Eaton |
2980
|
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. |
2980
|
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/>. |
2980
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_tree_colon_h) |
|
25 #define octave_tree_colon 1 |
|
26 |
|
27 #include <string> |
|
28 |
|
29 class tree_walker; |
|
30 |
|
31 class octave_value; |
|
32 class octave_value_list; |
|
33 class octave_lvalue; |
|
34 |
|
35 #include "pt-exp.h" |
7336
|
36 #include "symtab.h" |
2980
|
37 |
|
38 // Colon expressions. |
|
39 |
|
40 class |
|
41 tree_colon_expression : public tree_expression |
|
42 { |
|
43 public: |
|
44 |
|
45 tree_colon_expression (int l = -1, int c = -1) |
2990
|
46 : tree_expression (l, c), op_base (0), op_limit (0), |
|
47 op_increment (0), save_base (false) { } |
2980
|
48 |
|
49 tree_colon_expression (tree_expression *e, int l = -1, int c = -1) |
2990
|
50 : tree_expression (l, c), op_base (e), op_limit (0), |
|
51 op_increment (0), save_base (false) { } |
2980
|
52 |
5861
|
53 tree_colon_expression (tree_expression *bas, tree_expression *lim, |
|
54 tree_expression *inc, int l = -1, int c = -1) |
|
55 : tree_expression (l, c), op_base (bas), op_limit (lim), |
|
56 op_increment (inc), save_base (false) { } |
|
57 |
2980
|
58 ~tree_colon_expression (void) |
|
59 { |
2990
|
60 if (! save_base) |
|
61 delete op_base; |
|
62 |
2980
|
63 delete op_limit; |
|
64 delete op_increment; |
|
65 } |
|
66 |
4267
|
67 bool has_magic_end (void) const |
|
68 { |
|
69 return ((op_base && op_base->has_magic_end ()) |
|
70 || (op_limit && op_limit->has_magic_end ()) |
|
71 || (op_increment && op_increment->has_magic_end ())); |
|
72 } |
|
73 |
2990
|
74 void preserve_base (void) { save_base = true; } |
|
75 |
2980
|
76 tree_colon_expression *append (tree_expression *t); |
|
77 |
3933
|
78 bool rvalue_ok (void) const { return true; } |
2980
|
79 |
|
80 octave_value rvalue (void); |
|
81 |
|
82 octave_value_list rvalue (int nargout); |
|
83 |
5347
|
84 void eval_error (const std::string& s = std::string ()) const; |
2980
|
85 |
|
86 tree_expression *base (void) { return op_base; } |
|
87 |
|
88 tree_expression *limit (void) { return op_limit; } |
|
89 |
|
90 tree_expression *increment (void) { return op_increment; } |
|
91 |
5066
|
92 int line (void) const; |
|
93 int column (void) const; |
|
94 |
7336
|
95 tree_expression *dup (symbol_table::scope_id scope); |
5861
|
96 |
2980
|
97 void accept (tree_walker& tw); |
|
98 |
|
99 private: |
|
100 |
|
101 // The components of the expression. |
|
102 tree_expression *op_base; |
|
103 tree_expression *op_limit; |
|
104 tree_expression *op_increment; |
2988
|
105 |
2990
|
106 bool save_base; |
|
107 |
5347
|
108 octave_value |
|
109 make_range (const Matrix& m_base, const Matrix& m_limit, |
5349
|
110 const Matrix& m_increment, bool result_is_str, |
|
111 bool dq_str) const; |
5347
|
112 |
|
113 octave_value |
|
114 make_range (const octave_value& ov_base, const octave_value& ov_limit, |
|
115 const octave_value& ov_increment) const; |
|
116 |
2988
|
117 // No copying! |
|
118 |
|
119 tree_colon_expression (const tree_colon_expression&); |
|
120 |
|
121 tree_colon_expression& operator = (const tree_colon_expression&); |
2980
|
122 }; |
|
123 |
|
124 #endif |
|
125 |
|
126 /* |
|
127 ;;; Local Variables: *** |
|
128 ;;; mode: C++ *** |
|
129 ;;; End: *** |
|
130 */ |