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 class TableEntry;
00036 class bytecodeistream;
00037 class Logger;
00038
00039
00040
00041
00042
00043
00044
00045
00046 enum DeclFlags
00047 {
00048 DECL_NIL = 0x00000001,
00049 DECL_WILD = 0x00000002,
00050 DECL_SYMBOL = 0x00000004,
00051 DECL_CODE = 0x00000008,
00052 DECL_LOOP = 0x00000010,
00053 DECL_TYPEDEF = 0x00000020,
00054 DECL_CONSTANT = 0x00000040,
00055 DECL_NAMESPACE = 0x00000080,
00056 DECL_FLEX = 0x00000100,
00057 DECL_NOEVAL = 0x00000200,
00058 DECL_CALL_HANDLER = 0x00000400,
00059 DECL_DEPRECATED = 0x00000800,
00060 DECL_FORMATTED = 0x00001000
00061 };
00062
00063
00064
00065 typedef YCPValue (*call_handler_t)(void * function, int argc, YCPValue args[] );
00066
00071 struct declaration {
00072 const char *name;
00073 const char *signature;
00074 void *ptr;
00075 int flags;
00076 struct declaration *name_space;
00077 constTypePtr type;
00078 TableEntry* tentry;
00079 };
00080 typedef struct declaration declaration_t;
00081
00082 class StaticDeclaration {
00083 private:
00084
00085 SymbolTable *m_declTable;
00086
00087 std::list<std::pair<std::string, Y2Namespace *> > m_active_predefined;
00088 public:
00089
00090 StaticDeclaration ();
00091 ~StaticDeclaration ();
00092
00093 SymbolTable *symbolTable() { return m_declTable; };
00094
00095
00096 const std::list<std::pair<std::string, Y2Namespace *> > & active_predefined() const { return m_active_predefined; };
00097
00098
00099 void registerDeclarations (const char *filename, declaration_t *declarations);
00100
00101
00102 declaration_t *findDeclaration (const char *name) const;
00103 declaration_t *findDeclaration (const char *name, constTypePtr type, bool partial = false) const;
00104 declaration_t *findDeclaration (declaration_t *decl, constTypePtr type, bool partial = false) const;
00105
00106
00107 void dumpDeclarations () const;
00108
00109
00110 std::ostream & writeDeclaration (std::ostream & str, const declaration_t *decl) const;
00111 std::ostream & writeXmlDeclaration (std::ostream & str, const declaration_t *decl) const;
00112
00113
00114 declaration_t *readDeclaration (bytecodeistream & str) const;
00115
00116
00117
00118 static string Decl2String (const declaration_t *declaration, bool full = false);
00119
00120 static void errorNoMatch (Logger* problem_logger, constFunctionTypePtr orig, declaration_t* first_decl);
00121 };
00122
00123 #endif // StaticDeclaration_h