hql.hpp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef _HQL_INCL
  14. #define _HQL_INCL
  15. #ifdef HQL_EXPORTS
  16. #define HQL_API DECL_EXPORT
  17. #else
  18. #define HQL_API DECL_IMPORT
  19. #endif
  20. #include "hqlatoms.hpp"
  21. #include "build-config.h"
  22. #ifdef _DEBUG
  23. //#define TEST_INDEX_PROJECT // Force index translation (to default specified record) on all indexes - for testing!
  24. #endif
  25. #define stringify(x) # x
  26. #define estringify(x) stringify(x)
  27. /*
  28. ECL Language version number. Use to provide a version for the ECL language that is processed.
  29. * Major goes up when we break everything so badly nothing is likely to compile
  30. * Minor goes up when we add new functionality, or increase sub on a new branch
  31. * Sub goes up when we change anything else.
  32. We should always aim to preserve backward compatibility as much as possible.
  33. Relevant changes include
  34. * Changes to the ECL syntax
  35. * Changes to the standard library
  36. * Changes to archive formats etc.
  37. * Changes to the system plugins
  38. */
  39. #define LANGUAGE_VERSION_MAJOR BUILD_VERSION_MAJOR
  40. #define LANGUAGE_VERSION_MINOR BUILD_VERSION_MINOR
  41. #define LANGUAGE_VERSION_SUB BUILD_VERSION_POINT
  42. #define LANGUAGE_VERSION estringify(LANGUAGE_VERSION_MAJOR) "." estringify(LANGUAGE_VERSION_MINOR) "." estringify(LANGUAGE_VERSION_SUB)
  43. #define DEFAULT_INT_SIZE 8
  44. #define DEFAULT_REAL_SIZE 8
  45. #undef interface
  46. #ifdef _MSC_VER
  47. #define interface struct __declspec(novtable)
  48. #else
  49. #define interface struct
  50. #endif
  51. typedef const char * user_t;
  52. enum object_type
  53. {
  54. //Flags set on symbols
  55. ob_private = 0x0000,
  56. ob_exported = 0x0001,
  57. ob_shared = 0x0002,
  58. ob_import = 0x0004,
  59. ob_member = 0x0008, // is a member of a module
  60. ob_virtual = 0x0010,
  61. //attributes returned from the repository to show the vcs status
  62. ob_sandbox = 0x00010000,
  63. ob_orphaned = 0x00020000,
  64. ob_refsandbox = 0x00040000,
  65. ob_showtext = 0x00080000,
  66. ob_olderver = 0x00100000,
  67. ob_refolderver = 0x00200000,
  68. ob_locked = 0x00400000,
  69. ob_lockedself = 0x00800000,
  70. ob_registryflags= 0xffff0000,
  71. };
  72. enum cs_access
  73. {
  74. cs_none = 0,
  75. cs_access = 1,
  76. cs_read = 2,
  77. cs_write = 4,
  78. cs_full = 0x7fffffff
  79. };
  80. interface IHqlScope;
  81. interface IHqlRemoteScope;
  82. interface IHqlExpression;
  83. interface IErrorReceiver;
  84. interface IAtom;
  85. interface IPropertyTree;
  86. typedef IArrayOf<IHqlScope> HqlScopeArray;
  87. typedef IArrayOf<IHqlRemoteScope> HqlRemoteScopeArray;
  88. class HqlLookupContext;
  89. //This is held in a kept hash table, but normally linked so that could be changed (see note in hqlexpr.cpp for details)
  90. typedef IAtom ISourcePath;
  91. struct HQL_API ECLlocation
  92. {
  93. public:
  94. inline ECLlocation() : lineno(0), column(0), position(0), sourcePath(NULL) {}
  95. ECLlocation(const IHqlExpression * _expr) { if (!extractLocationAttr(_expr)) clear(); }
  96. ECLlocation(int _line, int _column, int _position, ISourcePath * _sourcePath) { set(_line, _column, _position, _sourcePath); }
  97. inline void clear()
  98. {
  99. lineno = 0;
  100. column = 0;
  101. position = 0;
  102. sourcePath = NULL;
  103. }
  104. inline void release()
  105. {
  106. }
  107. inline void set(const ECLlocation & _other)
  108. {
  109. lineno = _other.lineno;
  110. column = _other.column;
  111. position = _other.position;
  112. sourcePath = _other.sourcePath;
  113. }
  114. inline void set(int _line, int _column, int _position, ISourcePath * _sourcePath)
  115. {
  116. lineno = _line;
  117. column = _column;
  118. position = _position;
  119. sourcePath = _sourcePath;
  120. }
  121. inline bool equals(const ECLlocation & _other) const
  122. {
  123. return (lineno == _other.lineno) &&
  124. (column == _other.column) &&
  125. (position == _other.position) &&
  126. (sourcePath == _other.sourcePath);
  127. }
  128. IHqlExpression * createLocationAttr() const;
  129. bool extractLocationAttr(const IHqlExpression * location);
  130. StringBuffer & getText(StringBuffer & text) const;
  131. inline ECLlocation & operator = (const ECLlocation & other)
  132. {
  133. position = other.position;
  134. lineno = other.lineno;
  135. column = other.column;
  136. sourcePath = other.sourcePath;
  137. return *this;
  138. }
  139. public:
  140. // Linked<ISourcePath> sourcePath;
  141. ISourcePath * sourcePath;
  142. int position;
  143. int lineno;
  144. int column;
  145. };
  146. interface IFileContents;
  147. interface IEclSource;
  148. interface IEclRepository: public IInterface
  149. {
  150. virtual IHqlScope * queryRootScope() = 0;
  151. };
  152. //MORE: Make this more private
  153. interface IEclRepositoryCallback : public IEclRepository
  154. {
  155. //Should only be called and implemented for concrete repositories
  156. virtual bool loadModule(IHqlRemoteScope * rScope, IErrorReceiver * errs, bool forceAll) = 0;
  157. virtual IHqlExpression * loadSymbol(IHqlRemoteScope *scope, IIdAtom * searchName) = 0;
  158. virtual IEclSource * getSource(IHqlRemoteScope *scope, IIdAtom * searchName) = 0;
  159. };
  160. interface ICodegenContextCallback : public IInterface
  161. {
  162. virtual void noteCluster(const char *clusterName) = 0;
  163. virtual void pushCluster(const char *clusterName) = 0;
  164. virtual void popCluster() = 0;
  165. virtual bool allowAccess(const char * category, bool isSigned) = 0;
  166. /**
  167. * Lookup a file in DFS and return the record definition
  168. *
  169. * @param filename The logical filename. Scope expansion/~ removal should not have been done
  170. * @param errs Where to report errors
  171. * @param location Location to use when reporting errors
  172. */
  173. virtual IHqlExpression *lookupDFSlayout(const char *filename, IErrorReceiver &errs, const ECLlocation &location, bool isOpt) const = 0;
  174. /**
  175. * Return number of nodes for the current cluster, via Dali lookup, or 0 if cannot be determined.
  176. *
  177. */
  178. virtual unsigned lookupClusterSize() const = 0;
  179. };
  180. #if defined(_DEBUG) && defined(_WIN32) && !defined(USING_MPATROL)
  181. #undef new
  182. #define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
  183. #endif
  184. extern bool HQL_API extractVersion(unsigned & major, unsigned & minor, unsigned & sub, const char * version);
  185. #endif