00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_tree_identifier_h)
00025 #define octave_tree_identifier_h 1
00026
00027 #include <iosfwd>
00028 #include <string>
00029
00030 class octave_value;
00031 class octave_value_list;
00032 class octave_function;
00033
00034 class tree_walker;
00035
00036 #include "pt-bp.h"
00037 #include "pt-exp.h"
00038 #include "symtab.h"
00039
00040
00041
00042 class
00043 tree_identifier : public tree_expression
00044 {
00045 friend class tree_index_expression;
00046
00047 public:
00048
00049 tree_identifier (int l = -1, int c = -1)
00050 : tree_expression (l, c), sym (), scope (-1) { }
00051
00052 tree_identifier (const symbol_table::symbol_record& s,
00053 int l = -1, int c = -1,
00054 symbol_table::scope_id sc = symbol_table::current_scope ())
00055 : tree_expression (l, c), sym (s), scope (sc) { }
00056
00057 ~tree_identifier (void) { }
00058
00059 bool has_magic_end (void) const { return (name () == "__end__"); }
00060
00061 bool is_identifier (void) const { return true; }
00062
00063
00064
00065 std::string name (void) const { return sym.name (); }
00066
00067 bool is_defined (void) { return xsym().is_defined (); }
00068
00069 bool is_variable (void) { return xsym().is_variable (); }
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 octave_value
00087 do_lookup (const octave_value_list& args = octave_value_list ())
00088 {
00089 return xsym().find (args);
00090 }
00091
00092 void mark_global (void) { xsym().mark_global (); }
00093
00094 void mark_as_static (void) { xsym().init_persistent (); }
00095
00096 void mark_as_formal_parameter (void) { xsym().mark_formal (); }
00097
00098
00099
00100
00101 bool lvalue_ok (void) const { return true; }
00102
00103 octave_value rvalue1 (int nargout = 1);
00104
00105 octave_value_list rvalue (int nargout);
00106
00107 octave_lvalue lvalue (void);
00108
00109 void eval_undefined_error (void);
00110
00111 tree_identifier *dup (symbol_table::scope_id scope,
00112 symbol_table::context_id context) const;
00113
00114 void accept (tree_walker& tw);
00115
00116 private:
00117
00118
00119 symbol_table::symbol_record sym;
00120
00121 symbol_table::scope_id scope;
00122
00123
00124
00125
00126 symbol_table::symbol_record& xsym (void)
00127 {
00128 symbol_table::scope_id curr_scope = symbol_table::current_scope ();
00129
00130 if (scope != curr_scope)
00131 {
00132 scope = curr_scope;
00133 sym = symbol_table::insert (sym.name ());
00134 }
00135
00136 return sym;
00137 }
00138
00139
00140
00141 tree_identifier (const tree_identifier&);
00142
00143 tree_identifier& operator = (const tree_identifier&);
00144 };
00145
00146 #endif
00147
00148
00149
00150
00151
00152