00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef StaticDeclaration_h
00022 #define StaticDeclaration_h
00023
00024 #include <string>
00025 #include <list>
00026 using namespace std;
00027
00028 #include "ycp/YCPValue.h"
00029 #include "ycp/YCPList.h"
00030 #include "ycp/Type.h"
00031 #include "y2/Y2Namespace.h"
00032
00033 class SymbolEntry;
00034 class SymbolTable;
00035
00036
00037
00038
00039
00040
00041
00042
00043 enum DeclFlags
00044 {
00045 DECL_NIL = 0x00000001,
00046 DECL_WILD = 0x00000002,
00047 DECL_SYMBOL = 0x00000004,
00048 DECL_CODE = 0x00000008,
00049 DECL_LOOP = 0x00000010,
00050 DECL_TYPEDEF = 0x00000020,
00051 DECL_CONSTANT = 0x00000040,
00052 DECL_NAMESPACE = 0x00000080,
00053 DECL_FLEX = 0x00000100,
00054 DECL_NOEVAL = 0x00000200,
00055 DECL_CALL_HANDLER = 0x00000400,
00056 DECL_DEPRECATED = 0x00000800
00057 };
00058
00059
00060
00061 typedef YCPValue (*call_handler_t)(void * function, int argc, YCPValue args[] );
00062
00067 struct declaration {
00068 const char *name;
00069 const char *signature;
00070 void *ptr;
00071 int flags;
00072 struct declaration *next;
00073 struct declaration *name_space;
00074 constTypePtr type;
00075 };
00076 typedef struct declaration declaration_t;
00077
00078 class StaticDeclaration {
00079 private:
00080
00081 SymbolTable *m_declTable;
00082
00083 std::list<std::pair<std::string, Y2Namespace *> > m_active_predefined;
00084 public:
00085
00086 StaticDeclaration ();
00087 ~StaticDeclaration ();
00088
00089 SymbolTable *symbolTable() { return m_declTable; };
00090
00091
00092 const std::list<std::pair<std::string, Y2Namespace *> > & active_predefined() const { return m_active_predefined; };
00093
00094
00095 void registerDeclarations (const char *filename, declaration_t *declarations);
00096
00097
00098 declaration_t *findDeclaration (const char *name) const;
00099 declaration_t *findDeclaration (const char *name, constTypePtr type, bool partial = false) const;
00100 declaration_t *findDeclaration (declaration_t *decl, constTypePtr type, bool partial = false) const;
00101
00102
00103 void dumpDeclarations () const;
00104
00105
00106 std::ostream & writeDeclaration (std::ostream & str, const declaration_t *decl) const;
00107
00108
00109 declaration_t *readDeclaration (std::istream & str) const;
00110
00111
00112
00113 static string Decl2String (const declaration_t *declaration, bool full = false);
00114 };
00115
00116 #endif // StaticDeclaration_h