00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _QORE_QORENAMESPACE_H
00032
00033 #define _QORE_QORENAMESPACE_H
00034
00035 #include <string.h>
00036 #include <stdlib.h>
00037
00038 #include <string>
00039
00040 class RootQoreNamespace;
00041 class ConstantList;
00042 class QoreNamespaceList;
00043 class QoreClassList;
00044 class NamedScope;
00045
00047 class QoreNamespace {
00048 friend class QoreNamespaceList;
00049 friend class RootQoreNamespace;
00050
00051 private:
00052 struct qore_ns_private *priv;
00053
00054 DLLLOCAL AbstractQoreNode *parseMatchScopedConstantValue(NamedScope *name, int *matched) const;
00055 DLLLOCAL QoreClass *parseMatchScopedClass(NamedScope *name, int *matched) const;
00056 DLLLOCAL QoreClass *parseMatchScopedClassWithMethod(NamedScope *nscope, int *matched) const;
00057 DLLLOCAL QoreNamespace *parseMatchNamespace(NamedScope *nscope, int *matched) const;
00058 DLLLOCAL void assimilate(QoreNamespace *ns);
00059 DLLLOCAL QoreNamespace *findNamespace(const char *name) const;
00060 DLLLOCAL QoreNamespace *resolveNameScope(NamedScope *name) const;
00061 DLLLOCAL AbstractQoreNode *getConstantValue(const char *name) const;
00062 DLLLOCAL QoreNamespace(const char *n, QoreClassList *ocl, ConstantList *cl, QoreNamespaceList *nnsl, QoreClassList *pend_ocl, ConstantList *pend_cl, QoreNamespaceList *pend_nnsl);
00063
00065 DLLLOCAL QoreNamespace(const QoreNamespace&);
00066
00068 DLLLOCAL QoreNamespace& operator=(const QoreNamespace&);
00069
00070 public:
00072
00075 DLLEXPORT QoreNamespace(const char *n);
00076
00078 DLLEXPORT ~QoreNamespace();
00079
00081
00085 DLLEXPORT void addConstant(const char *name, AbstractQoreNode *value);
00086
00088
00091 DLLEXPORT void addSystemClass(QoreClass *oc);
00092
00094
00099 DLLEXPORT void addInitialNamespace(QoreNamespace *ns);
00100
00102
00104 DLLEXPORT QoreNamespace *copy(int po = 0) const;
00105
00106
00108
00113 DLLEXPORT QoreHashNode *getClassInfo() const;
00114
00116
00121 DLLEXPORT QoreHashNode *getConstantInfo() const;
00122
00124
00130 DLLEXPORT QoreHashNode *getInfo() const;
00131
00133
00136 DLLEXPORT const char *getName() const;
00137
00139
00143 DLLEXPORT void addNamespace(QoreNamespace *ns);
00144
00145
00146 DLLLOCAL QoreNamespace();
00147 DLLLOCAL void addClass(NamedScope *n, QoreClass *oc);
00148 DLLLOCAL void addConstant(NamedScope *name, AbstractQoreNode *value);
00149 DLLLOCAL void addClass(QoreClass *oc);
00150 DLLLOCAL void parseInit();
00151 DLLLOCAL void parseInitConstants();
00152 DLLLOCAL void parseRollback();
00153 DLLLOCAL void parseCommit();
00154 DLLLOCAL void setName(const char *nme);
00155
00157 DLLLOCAL void purge();
00158 };
00159
00161
00165 class RootQoreNamespace : public QoreNamespace {
00166 private:
00167 QoreNamespace *qoreNS;
00168
00169
00170
00171 QoreClass *File;
00172
00173 DLLLOCAL QoreNamespace *rootResolveNamespace(NamedScope *nscope);
00174 DLLLOCAL void addQoreNamespace(QoreNamespace *qns);
00175
00176 DLLLOCAL RootQoreNamespace(QoreClassList *ocl, ConstantList *cl, QoreNamespaceList *nnsl, QoreClassList *pend_ocl, ConstantList *pend_cl, QoreNamespaceList *pend_nsl);
00177 DLLLOCAL QoreClass *rootFindScopedClassWithMethod(NamedScope *nscope, int *matched) const;
00178 DLLLOCAL QoreClass *rootFindScopedClass(NamedScope *name, int *matched) const;
00179 DLLLOCAL QoreClass *rootFindChangeClass(const char *name);
00180 DLLLOCAL AbstractQoreNode *rootFindConstantValue(const char *name) const;
00181 DLLLOCAL AbstractQoreNode *rootFindScopedConstantValue(NamedScope *name, int *matched) const;
00182
00183 public:
00185
00188 DLLEXPORT QoreNamespace *rootGetQoreNamespace() const;
00189
00190 DLLLOCAL RootQoreNamespace(QoreNamespace **QoreNS);
00191 DLLLOCAL ~RootQoreNamespace();
00192 DLLLOCAL RootQoreNamespace *copy(int po = 0) const;
00193 DLLLOCAL QoreClass *rootFindClass(const char *name) const;
00194 DLLLOCAL void rootAddClass(NamedScope *name, QoreClass *oc);
00195 DLLLOCAL void rootAddConstant(NamedScope *name, AbstractQoreNode *value);
00196 DLLLOCAL AbstractQoreNode *findConstantValue(NamedScope *name, int level) const;
00197 DLLLOCAL AbstractQoreNode *findConstantValue(const char *name, int level) const;
00198 DLLLOCAL QoreClass *parseFindClass(const char *name) const;
00199 DLLLOCAL QoreClass *parseFindScopedClass(NamedScope *name) const;
00200 DLLLOCAL QoreClass *parseFindScopedClassWithMethod(NamedScope *name) const;
00201
00202 DLLLOCAL int resolveSimpleConstant(AbstractQoreNode **, int level) const;
00203
00204 DLLLOCAL int parseInitConstantValue(AbstractQoreNode **, int level);
00205
00206 DLLLOCAL int resolveScopedConstant(AbstractQoreNode **, int level) const;
00207
00208 DLLLOCAL int addMethodToClass(NamedScope *name, QoreMethod *qcmethod, class BCAList *bcal);
00209 };
00210
00211 #endif // QORE_NAMESPACE_H