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
00032 #ifndef _QORE_QORENAMESPACE_H
00033
00034 #define _QORE_QORENAMESPACE_H
00035
00036 #include <string.h>
00037 #include <stdlib.h>
00038
00039 #include <string>
00040
00041 class RootQoreNamespace;
00042 class ConstantList;
00043 class QoreNamespaceList;
00044 class QoreClassList;
00045 class NamedScope;
00046 class MethodVariantBase;
00047
00049 class QoreNamespace {
00050 friend class QoreNamespaceList;
00051 friend class RootQoreNamespace;
00052
00053 protected:
00054 struct qore_ns_private *priv;
00055
00056 DLLLOCAL AbstractQoreNode *parseMatchScopedConstantValue(NamedScope *name, int *matched, const QoreTypeInfo *&typeInfo) const;
00057 DLLLOCAL QoreClass *parseMatchScopedClass(NamedScope *name, int *matched) const;
00058 DLLLOCAL QoreClass *parseMatchScopedClassWithMethod(NamedScope *nscope, int *matched) const;
00059 DLLLOCAL QoreNamespace *parseMatchNamespace(NamedScope *nscope, int *matched) const;
00060 DLLLOCAL void assimilate(QoreNamespace *ns);
00061 DLLLOCAL QoreNamespace *findNamespace(const char *name) const;
00062 DLLLOCAL QoreNamespace *resolveNameScope(NamedScope *name) const;
00063 DLLLOCAL AbstractQoreNode *getConstantValue(const char *name, const QoreTypeInfo *&typeInfo) const;
00064 DLLLOCAL QoreNamespace(const char *n, QoreClassList *ocl, ConstantList *cl, QoreNamespaceList *nnsl);
00065
00067 DLLLOCAL QoreNamespace(const QoreNamespace&);
00068
00070 DLLLOCAL QoreNamespace& operator=(const QoreNamespace&);
00071
00072 public:
00074
00077 DLLEXPORT QoreNamespace(const char *n);
00078
00080 DLLEXPORT ~QoreNamespace();
00081
00083
00089 DLLEXPORT void addConstant(const char *name, AbstractQoreNode *value);
00090
00092
00098 DLLEXPORT void addConstant(const char *name, AbstractQoreNode *value, const QoreTypeInfo *typeInfo);
00099
00101
00104 DLLEXPORT void addSystemClass(QoreClass *oc);
00105
00107
00112 DLLEXPORT void addInitialNamespace(QoreNamespace *ns);
00113
00115
00118 DLLEXPORT QoreNamespace *copy(int po) const;
00119
00121
00124 DLLEXPORT QoreNamespace *copy(int64 po = PO_DEFAULT) const;
00125
00126
00128
00133 DLLEXPORT QoreHashNode *getClassInfo() const;
00134
00136
00141 DLLEXPORT QoreHashNode *getConstantInfo() const;
00142
00144
00150 DLLEXPORT QoreHashNode *getInfo() const;
00151
00153
00156 DLLEXPORT const char *getName() const;
00157
00159
00162 DLLEXPORT void addNamespace(QoreNamespace *ns);
00163
00164
00165 DLLLOCAL QoreNamespace();
00166 DLLLOCAL void addClass(NamedScope *n, QoreClass *oc);
00167
00168 DLLLOCAL void parseAddConstant(NamedScope *name, AbstractQoreNode *value);
00169
00170 DLLLOCAL void addClass(QoreClass *oc);
00171 DLLLOCAL void parseAddNamespace(QoreNamespace *ns);
00172 DLLLOCAL void parseInit();
00173 DLLLOCAL void parseInitConstants();
00174 DLLLOCAL void parseRollback();
00175 DLLLOCAL void parseCommit();
00176 DLLLOCAL void setName(const char *nme);
00177
00179 DLLLOCAL void purge();
00180 };
00181
00183
00187 class RootQoreNamespace : public QoreNamespace {
00188 protected:
00189 QoreNamespace *qoreNS;
00190
00191 DLLLOCAL QoreNamespace *rootResolveNamespace(NamedScope *nscope);
00192 DLLLOCAL void addQoreNamespace(QoreNamespace *qns);
00193
00194 DLLLOCAL RootQoreNamespace(QoreClassList *ocl, ConstantList *cl, QoreNamespaceList *nnsl);
00195
00196 DLLLOCAL RootQoreNamespace();
00197 DLLLOCAL QoreClass *rootFindScopedClassWithMethod(NamedScope *nscope, int *matched) const;
00198 DLLLOCAL QoreClass *rootFindScopedClass(NamedScope *name, int *matched) const;
00199 DLLLOCAL QoreClass *rootFindChangeClass(const char *name);
00200 DLLLOCAL AbstractQoreNode *rootFindConstantValue(const char *name, const QoreTypeInfo *&typeInfo) const;
00201 DLLLOCAL AbstractQoreNode *rootFindScopedConstantValue(NamedScope *name, int *matched, const QoreTypeInfo *&typeInfo) const;
00202
00203 public:
00205
00208 DLLEXPORT QoreNamespace *rootGetQoreNamespace() const;
00209
00210 DLLLOCAL RootQoreNamespace(QoreNamespace *&QoreNS, int64 po = PO_DEFAULT);
00211 DLLLOCAL ~RootQoreNamespace();
00212 DLLLOCAL RootQoreNamespace *copy(int64 po = PO_DEFAULT) const;
00213 DLLLOCAL QoreClass *rootFindClass(const char *name) const;
00214 DLLLOCAL void rootAddClass(NamedScope *name, QoreClass *oc);
00215 DLLLOCAL void rootAddConstant(NamedScope *name, AbstractQoreNode *value);
00216 DLLLOCAL AbstractQoreNode *findConstantValue(NamedScope *name, int level, const QoreTypeInfo *&typeInfo) const;
00217 DLLLOCAL AbstractQoreNode *findConstantValue(const char *name, int level, const QoreTypeInfo *&typeInfo) const;
00218 DLLLOCAL QoreClass *parseFindClass(const char *name) const;
00219 DLLLOCAL QoreClass *parseFindScopedClass(NamedScope *name) const;
00220 DLLLOCAL QoreClass *parseFindScopedClassWithMethod(NamedScope *name) const;
00221
00222 DLLLOCAL int resolveSimpleConstant(AbstractQoreNode **, int level, const QoreTypeInfo *&) const;
00223
00224 DLLLOCAL int resolveScopedConstant(AbstractQoreNode **, int level, const QoreTypeInfo *&) const;
00225
00226 DLLLOCAL int addMethodToClass(NamedScope *name, MethodVariantBase *qcmethod, bool static_flag);
00227 };
00228
00229 #endif // QORE_NAMESPACE_H