00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SymbolEntry_h
00024 #define SymbolEntry_h
00025
00026 #include <y2util/Ustring.h>
00027 #include <y2util/RepDef.h>
00028
00029 #include "ycp/YCPValue.h"
00030 #include "ycp/Type.h"
00031
00032 #include <stack>
00033
00034 class Y2Namespace;
00035
00036 DEFINE_BASE_POINTER (SymbolEntry);
00037
00041 class SymbolEntry : public Rep
00042 #ifdef D_MEMUSAGE
00043 , public MemUsage
00044 #endif
00045 {
00046 REP_BODY (SymbolEntry);
00047
00048 public:
00049
00050 static UstringHash* _nameHash;
00051 static Ustring emptyUstring;
00052
00053 public:
00054 typedef enum {
00055 c_unspec = 0,
00056 c_global,
00057 c_module,
00058 c_variable,
00059 c_reference,
00060 c_function,
00061 c_builtin,
00062 c_typedef,
00063 c_const,
00064 c_namespace,
00065 c_self,
00066 c_predefined,
00067 c_filename
00068 } category_t;
00069
00070 protected:
00071
00072
00073
00074 bool m_global;
00075
00076
00077
00078
00079 const Y2Namespace *m_namespace;
00080
00081
00082
00083
00084 unsigned int m_position;
00085
00086
00087
00088
00089 Ustring m_name;
00090
00091
00092
00093
00094 category_t m_category;
00095
00096
00097
00098
00099 constTypePtr m_type;
00100
00101
00102 YCPValue m_value;
00103
00104 typedef std::stack<YCPValue> valuestack_t;
00105 valuestack_t* m_recurse_stack;
00106
00107 public:
00108
00109 SymbolEntry (const Y2Namespace* name_space, unsigned int position, const char *name, category_t cat, constTypePtr type);
00110
00111 virtual ~SymbolEntry ();
00112
00113
00114 const Y2Namespace *nameSpace () const;
00115 void setNamespace (const Y2Namespace *name_space);
00116
00117
00118
00119
00120 virtual bool onlyDeclared () const { return false; }
00121
00122
00123
00124 unsigned int position () const;
00125 void setPosition (unsigned int position);
00126
00127 bool isGlobal () const;
00128 void setGlobal (bool global);
00129
00130 bool isModule () const { return m_category == c_module; }
00131 bool isVariable () const { return m_category == c_variable; }
00132 bool isReference () const { return m_category == c_reference; }
00133 bool isFunction () const { return m_category == c_function; }
00134 bool isBuiltin () const { return m_category == c_builtin; }
00135 bool isNamespace () const { return m_category == c_namespace; }
00136 bool isSelf () const { return m_category == c_self; }
00137 bool isFilename () const { return m_category == c_filename; }
00138 bool isPredefined () const { return m_category == c_predefined; }
00139
00140 bool likeNamespace () const { return isModule() || isNamespace() || isSelf(); }
00141
00142 const char *name () const;
00143 category_t category () const;
00144 void setCategory (category_t cat);
00145 constTypePtr type () const;
00146 string catString () const;
00147 void setType (constTypePtr type);
00148 YCPValue setValue (YCPValue value);
00149 YCPValue value () const;
00150
00151 void push ();
00152 void pop ();
00153
00154 virtual string toString (bool with_type = true) const;
00155 };
00156
00157 #endif // SymbolEntry_h