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_identifier_h) |
|
24 #define octave_tree_identifier_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 class ostream; |
|
31 |
|
32 #include <string> |
|
33 |
|
34 class octave_symbol; |
|
35 class octave_function; |
|
36 class symbol_record; |
|
37 |
|
38 class tree_walker; |
|
39 |
|
40 #include "pt-mvr-base.h" |
|
41 |
|
42 // Symbols from the symbol table. |
|
43 |
|
44 class |
|
45 tree_identifier : public tree_multi_val_ret |
|
46 { |
|
47 friend class tree_index_expression; |
|
48 |
|
49 public: |
|
50 |
|
51 tree_identifier (int l = -1, int c = -1) |
|
52 : tree_multi_val_ret (l, c), sym (0), maybe_do_ans_assign (false) { } |
|
53 |
|
54 tree_identifier (symbol_record *s, int l = -1, int c = -1) |
|
55 : tree_multi_val_ret (l, c), sym (s), maybe_do_ans_assign (false) { } |
|
56 |
|
57 ~tree_identifier (void) { } |
|
58 |
|
59 bool is_identifier (void) const |
|
60 { return true; } |
|
61 |
|
62 string name (void) const; |
|
63 |
|
64 tree_identifier *define (octave_symbol *s, unsigned int sym_type); |
|
65 |
|
66 tree_identifier *define (octave_function *f, unsigned int sym_type); |
|
67 |
|
68 tree_identifier *define (const octave_value& v); |
|
69 |
|
70 void document (const string& s); |
|
71 |
|
72 octave_value assign (octave_value::assign_op op, |
|
73 const octave_value& t); |
|
74 |
|
75 octave_value assign (octave_value::assign_op op, |
|
76 const octave_value_list& args, |
|
77 const octave_value& t); |
|
78 |
|
79 bool is_defined (void); |
|
80 |
|
81 void increment (void); |
|
82 |
|
83 void decrement (void); |
|
84 |
|
85 octave_symbol *do_lookup (bool& script_file_executed, bool |
|
86 exec_script = true); |
|
87 |
|
88 void link_to_global (void); |
|
89 |
|
90 void mark_as_static (void); |
|
91 |
|
92 void mark_as_formal_parameter (void); |
|
93 |
|
94 void mark_for_possible_ans_assign (void) |
|
95 { maybe_do_ans_assign = true; } |
|
96 |
|
97 octave_value eval (bool print = false); |
|
98 |
|
99 octave_value_list eval (bool print, int nargout, |
|
100 const octave_value_list& args); |
|
101 |
|
102 void eval_undefined_error (void); |
|
103 |
|
104 void accept (tree_walker& tw); |
|
105 |
|
106 octave_value value (void) const; |
|
107 |
|
108 octave_value& reference (void); |
|
109 |
|
110 private: |
|
111 |
|
112 // The symbol record that this identifier references. |
|
113 symbol_record *sym; |
|
114 |
|
115 // True if we should consider assigning the result of evaluating |
|
116 // this identifier to the built-in variable ans. |
|
117 bool maybe_do_ans_assign; |
|
118 }; |
|
119 |
|
120 #endif |
|
121 |
|
122 /* |
|
123 ;;; Local Variables: *** |
|
124 ;;; mode: C++ *** |
|
125 ;;; End: *** |
|
126 */ |