|
yast2-core
|
00001 /*----------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \-----------------------------------------------------------------------/ 00012 00013 File: SymbolEntry.h 00014 symbol entry class 00015 00016 Author: Stanislav Visnovsky <visnov@suse.cz> 00017 Maintainer: Stanislav Visnovsky <visnov@suse.cz> 00018 00019 /-*/ 00020 // -*- c++ -*- 00021 00022 #ifndef YSymbolEntry_h 00023 #define YSymbolEntry_h 00024 00025 #include <y2util/Ustring.h> 00026 #include <y2util/RepDef.h> 00027 00028 #include <y2/SymbolEntry.h> 00029 00030 #include "ycp/YCPValue.h" 00031 #include "ycp/Type.h" 00032 #include "ycp/StaticDeclaration.h" 00033 #include "ycp/YCode.h" 00034 00035 #include <stack> 00036 00037 class Y2Namespace; 00038 00039 DEFINE_DERIVED_POINTER (YSymbolEntry, SymbolEntry); 00040 00041 class YSymbolEntry : public SymbolEntry { 00042 REP_BODY (YSymbolEntry); 00043 00056 union payload { 00057 Y2Namespace *m_namespace; 00058 declaration_t *m_decl; 00059 SymbolTable *m_table; 00060 } m_payload; 00061 00062 /* 00063 * Valid for 00064 * c_variable: YCode* (any value) 00065 * c_reference: YCode* (YEReference*) 00066 * c_function: YCode* (YFunction* to be precise) 00067 */ 00068 YCodePtr m_code; 00069 00070 public: 00071 // create symbol beloging to namespace (at position) - overloaded 00072 YSymbolEntry (const Y2Namespace* name_space, unsigned int position, const char *name, category_t cat, constTypePtr type, YCodePtr payload = 0); 00073 00074 // create builtin symbol (category == c_builtin), name_space != 0 for symbols inside namespace 00075 YSymbolEntry (const char *name, constTypePtr type, declaration_t *payload, const Y2Namespace *name_space = 0); 00076 00077 // create namespace symbol (category == c_namespace) 00078 YSymbolEntry (const char *name, constTypePtr type, SymbolTable *payload); 00079 00080 // create declaration point symbol (category == c_filename) 00081 YSymbolEntry (const char *filename); 00082 00083 YSymbolEntry (bytecodeistream & str, const Y2Namespace *name_space = 0); 00084 00085 // payload access for variables and functions 00086 void setCode (YCodePtr code); 00087 YCodePtr code () const; 00088 00089 // returns true for a declared symbol which isn't defined yet. 00090 virtual bool onlyDeclared () const; 00091 00092 // payload access for builtins 00093 void setDeclaration (declaration_t *decl); 00094 declaration_t *declaration () const; 00095 00096 // payload access for namespace symbols 00097 void setTable (SymbolTable *table); 00098 SymbolTable *table() const; 00099 00100 // symbols' link to the defining namespace 00101 Y2Namespace *payloadNamespace () const; 00102 void setPayloadNamespace (Y2Namespace *name_space); 00103 00104 virtual string toString (bool with_type = true) const; 00105 std::ostream & toStream (std::ostream & str) const; 00106 std::ostream & toXml (std::ostream & str, int indent ) const; 00107 }; 00108 00109 #endif // YSymbolEntry_h
1.7.3