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