hqlir.hpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*##############################################################################
  2. 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 HQLIR_INCL
  14. #define HQLIR_INCL
  15. #include "hqlexpr.hpp"
  16. /*
  17. * This header declares the Intermediate Representation (IR)
  18. * for ECL graphs (Directed Acyclic Graphs - DAG), for debug
  19. * dumps, test checks and optimisation analysis.
  20. *
  21. * It needs to be included from a top-level header, to make sure
  22. * it'll be available throughout the compiler code, but it's best
  23. * to keep it inside _DEBUG areas, since it's where it'll be used
  24. * most.
  25. *
  26. * The IR is meant to be a simple, non-redundant and complete
  27. * description of ECL graphs. The aim is to produce a textual
  28. * description of the DAG in a way that is easy to read it again
  29. * and produce correct graphs from it.
  30. *
  31. * When things get more complicated, and the IR gets used for
  32. * internal processes, it might be good to expose some simple
  33. * interfaces for importing/exporting expressions to IR.
  34. *
  35. * See the C++ file for better description of the IR.
  36. */
  37. namespace EclIR
  38. {
  39. extern HQL_API const char * getOperatorIRText(node_operator op);
  40. extern HQL_API const char * getTypeIRText(type_t type);
  41. extern HQL_API void dump_ir(IHqlExpression * expr);
  42. extern HQL_API void dump_ir(ITypeInfo * type);
  43. extern HQL_API void dump_ir(const HqlExprArray & exprs);
  44. //The following are useful for finding the differences between two types or expressions - the output between the two returns
  45. extern HQL_API void dump_ir(ITypeInfo * type1, ITypeInfo * type2);
  46. extern HQL_API void dump_ir(IHqlExpression * expr1, IHqlExpression * expr2);
  47. extern HQL_API void dump_irn(unsigned n, ...);
  48. extern HQL_API void dbglogIR(IHqlExpression * expr);
  49. extern HQL_API void dbglogIR(ITypeInfo * type);
  50. extern HQL_API void dbglogIR(const HqlExprArray & exprs);
  51. extern HQL_API void dbglogIR(unsigned n, ...);
  52. extern HQL_API void getIRText(StringBuffer & target, unsigned options, IHqlExpression * expr);
  53. extern HQL_API void getIRText(StringArray & target, unsigned options, IHqlExpression * expr);
  54. //These functions are not thread safe, they are only designed to be called from within a debugger
  55. extern HQL_API const char * getIRText(IHqlExpression * expr);
  56. extern HQL_API const char * getIRText(ITypeInfo * type);
  57. } // namespace EclIR
  58. #endif /* HQLIR_INCL */