Mercurial > octave
annotate src/pt-exp.h @ 7767:71f068b22fcc
scope and context fixes for function handles
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 07 May 2008 13:45:30 -0400 |
parents | 745a8299c2b5 |
children | 5861b95e9879 |
rev | line source |
---|---|
1739 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2002, 2003, 2004, 2005, 2006, 2007 |
4 John W. Eaton | |
1739 | 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. | |
1739 | 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/>. | |
1739 | 21 |
22 */ | |
23 | |
2980 | 24 #if !defined (octave_tree_expr_h) |
25 #define octave_tree_expr_h 1 | |
1739 | 26 |
2980 | 27 #include <string> |
2124 | 28 |
2879 | 29 class octave_value; |
2979 | 30 class octave_lvalue; |
2879 | 31 |
2988 | 32 #include "pt.h" |
7336 | 33 #include "symtab.h" |
2124 | 34 |
2980 | 35 // A base class for expressions. |
1739 | 36 |
37 class | |
2980 | 38 tree_expression : public tree |
2388 | 39 { |
40 public: | |
41 | |
2980 | 42 tree_expression (int l = -1, int c = -1) |
43 : tree (l, c), num_parens (0), postfix_indexed (false), | |
44 print_flag (false) { } | |
2388 | 45 |
2980 | 46 virtual ~tree_expression (void) { } |
2388 | 47 |
4267 | 48 virtual bool has_magic_end (void) const = 0; |
49 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
50 virtual tree_expression *dup (symbol_table::scope_id, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
51 symbol_table::context_id context) = 0; |
5861 | 52 |
3933 | 53 virtual bool is_constant (void) const { return false; } |
2388 | 54 |
3933 | 55 virtual bool is_matrix_constant (void) const { return false; } |
2388 | 56 |
3933 | 57 virtual bool is_identifier (void) const { return false; } |
1739 | 58 |
3933 | 59 virtual bool is_index_expression (void) const { return false; } |
1739 | 60 |
3933 | 61 virtual bool is_assignment_expression (void) const { return false; } |
1739 | 62 |
3933 | 63 virtual bool is_prefix_expression (void) const { return false; } |
1739 | 64 |
4023 | 65 virtual bool is_binary_expression (void) const { return false; } |
66 | |
67 virtual bool is_boolean_expression (void) const { return false; } | |
68 | |
2980 | 69 virtual bool is_logically_true (const char *); |
1739 | 70 |
3933 | 71 virtual bool lvalue_ok (void) const { return false; } |
1739 | 72 |
3933 | 73 virtual bool rvalue_ok (void) const { return false; } |
2124 | 74 |
2980 | 75 virtual octave_value rvalue (void); |
1739 | 76 |
2980 | 77 virtual octave_value_list rvalue (int nargout); |
2879 | 78 |
2980 | 79 virtual octave_lvalue lvalue (void); |
2879 | 80 |
3933 | 81 int paren_count (void) const { return num_parens; } |
2124 | 82 |
3933 | 83 bool is_postfix_indexed (void) const { return postfix_indexed; } |
2124 | 84 |
3933 | 85 bool print_result (void) const { return print_flag; } |
1739 | 86 |
3933 | 87 virtual std::string oper (void) const { return "<unknown>"; } |
1739 | 88 |
3933 | 89 virtual std::string name (void) const { return "<unknown>"; } |
2124 | 90 |
3523 | 91 virtual std::string original_text (void) const; |
1739 | 92 |
2980 | 93 tree_expression *mark_in_parens (void) |
1739 | 94 { |
2980 | 95 num_parens++; |
96 return this; | |
1739 | 97 } |
98 | |
2980 | 99 tree_expression *mark_postfix_indexed (void) |
100 { | |
101 postfix_indexed = true; | |
102 return this; | |
103 } | |
2971 | 104 |
2980 | 105 tree_expression *set_print_flag (bool print) |
106 { | |
107 print_flag = print; | |
108 return this; | |
109 } | |
2971 | 110 |
5861 | 111 virtual void copy_base (tree_expression& e) |
112 { | |
113 num_parens = e.num_parens; | |
114 postfix_indexed = e.postfix_indexed; | |
115 print_flag = e.print_flag; | |
116 } | |
117 | |
2980 | 118 protected: |
2971 | 119 |
2980 | 120 // A count of the number of times this expression appears directly |
121 // inside a set of parentheses. | |
122 // | |
123 // (((e1)) + e2) ==> 2 for expression e1 | |
124 // ==> 1 for expression ((e1)) + e2 | |
125 // ==> 0 for expression e2 | |
126 int num_parens; | |
2971 | 127 |
2980 | 128 // A flag that says whether this expression has an index associated |
129 // with it. See the code in tree_identifier::rvalue for the rationale. | |
130 bool postfix_indexed; | |
2971 | 131 |
2980 | 132 // Print result of rvalue for this expression? |
133 bool print_flag; | |
2988 | 134 |
135 private: | |
136 | |
137 // No copying! | |
138 | |
139 tree_expression (const tree_expression&); | |
140 | |
141 tree_expression& operator = (const tree_expression&); | |
2971 | 142 }; |
143 | |
1739 | 144 #endif |
145 | |
146 /* | |
147 ;;; Local Variables: *** | |
148 ;;; mode: C++ *** | |
149 ;;; End: *** | |
150 */ |