| 1 | // prebuilt/asdl/runtime.mycpp.h: GENERATED by mycpp
|
| 2 |
|
| 3 | #ifndef ASDL_RUNTIME_MYCPP_H
|
| 4 | #define ASDL_RUNTIME_MYCPP_H
|
| 5 |
|
| 6 | #include "_gen/asdl/hnode.asdl.h"
|
| 7 | #include "cpp/data_lang.h"
|
| 8 | #include "mycpp/runtime.h"
|
| 9 |
|
| 10 | namespace runtime { // forward declare
|
| 11 |
|
| 12 | class TraversalState;
|
| 13 |
|
| 14 | } // forward declare namespace runtime
|
| 15 |
|
| 16 | namespace format { // forward declare
|
| 17 |
|
| 18 | class ColorOutput;
|
| 19 | class TextOutput;
|
| 20 | class HtmlOutput;
|
| 21 | class AnsiOutput;
|
| 22 | class _PrettyPrinter;
|
| 23 |
|
| 24 | } // forward declare namespace format
|
| 25 |
|
| 26 | namespace runtime { // declare
|
| 27 |
|
| 28 | using hnode_asdl::hnode;
|
| 29 | extern int NO_SPID;
|
| 30 | hnode::Record* NewRecord(BigStr* node_type);
|
| 31 | hnode::Leaf* NewLeaf(BigStr* s, hnode_asdl::color_t e_color);
|
| 32 | class TraversalState {
|
| 33 | public:
|
| 34 | TraversalState();
|
| 35 | Dict<int, bool>* seen;
|
| 36 | Dict<int, int>* ref_count;
|
| 37 |
|
| 38 | static constexpr ObjHeader obj_header() {
|
| 39 | return ObjHeader::ClassScanned(2, sizeof(TraversalState));
|
| 40 | }
|
| 41 |
|
| 42 | DISALLOW_COPY_AND_ASSIGN(TraversalState)
|
| 43 | };
|
| 44 |
|
| 45 | extern BigStr* TRUE_STR;
|
| 46 | extern BigStr* FALSE_STR;
|
| 47 |
|
| 48 | } // declare namespace runtime
|
| 49 |
|
| 50 | namespace format { // declare
|
| 51 |
|
| 52 | using hnode_asdl::hnode;
|
| 53 | format::ColorOutput* DetectConsoleOutput(mylib::Writer* f);
|
| 54 | class ColorOutput {
|
| 55 | public:
|
| 56 | ColorOutput(mylib::Writer* f);
|
| 57 | virtual format::ColorOutput* NewTempBuffer();
|
| 58 | virtual void FileHeader();
|
| 59 | virtual void FileFooter();
|
| 60 | virtual void PushColor(hnode_asdl::color_t e_color);
|
| 61 | virtual void PopColor();
|
| 62 | virtual void write(BigStr* s);
|
| 63 | void WriteRaw(Tuple2<BigStr*, int>* raw);
|
| 64 | int NumChars();
|
| 65 | Tuple2<BigStr*, int> GetRaw();
|
| 66 | mylib::Writer* f;
|
| 67 | int num_chars;
|
| 68 |
|
| 69 | static constexpr uint32_t field_mask() {
|
| 70 | return maskbit(offsetof(ColorOutput, f));
|
| 71 | }
|
| 72 |
|
| 73 | static constexpr ObjHeader obj_header() {
|
| 74 | return ObjHeader::ClassFixed(field_mask(), sizeof(ColorOutput));
|
| 75 | }
|
| 76 |
|
| 77 | DISALLOW_COPY_AND_ASSIGN(ColorOutput)
|
| 78 | };
|
| 79 |
|
| 80 | class TextOutput : public ::format::ColorOutput {
|
| 81 | public:
|
| 82 | TextOutput(mylib::Writer* f);
|
| 83 | virtual format::TextOutput* NewTempBuffer();
|
| 84 | virtual void PushColor(hnode_asdl::color_t e_color);
|
| 85 | virtual void PopColor();
|
| 86 |
|
| 87 | static constexpr uint32_t field_mask() {
|
| 88 | return ::format::ColorOutput::field_mask();
|
| 89 | }
|
| 90 |
|
| 91 | static constexpr ObjHeader obj_header() {
|
| 92 | return ObjHeader::ClassFixed(field_mask(), sizeof(TextOutput));
|
| 93 | }
|
| 94 |
|
| 95 | DISALLOW_COPY_AND_ASSIGN(TextOutput)
|
| 96 | };
|
| 97 |
|
| 98 | class HtmlOutput : public ::format::ColorOutput {
|
| 99 | public:
|
| 100 | HtmlOutput(mylib::Writer* f);
|
| 101 | virtual format::HtmlOutput* NewTempBuffer();
|
| 102 | virtual void FileHeader();
|
| 103 | virtual void FileFooter();
|
| 104 | virtual void PushColor(hnode_asdl::color_t e_color);
|
| 105 | virtual void PopColor();
|
| 106 | virtual void write(BigStr* s);
|
| 107 |
|
| 108 | static constexpr uint32_t field_mask() {
|
| 109 | return ::format::ColorOutput::field_mask();
|
| 110 | }
|
| 111 |
|
| 112 | static constexpr ObjHeader obj_header() {
|
| 113 | return ObjHeader::ClassFixed(field_mask(), sizeof(HtmlOutput));
|
| 114 | }
|
| 115 |
|
| 116 | DISALLOW_COPY_AND_ASSIGN(HtmlOutput)
|
| 117 | };
|
| 118 |
|
| 119 | class AnsiOutput : public ::format::ColorOutput {
|
| 120 | public:
|
| 121 | AnsiOutput(mylib::Writer* f);
|
| 122 | virtual format::AnsiOutput* NewTempBuffer();
|
| 123 | virtual void PushColor(hnode_asdl::color_t e_color);
|
| 124 | virtual void PopColor();
|
| 125 |
|
| 126 | static constexpr uint32_t field_mask() {
|
| 127 | return ::format::ColorOutput::field_mask();
|
| 128 | }
|
| 129 |
|
| 130 | static constexpr ObjHeader obj_header() {
|
| 131 | return ObjHeader::ClassFixed(field_mask(), sizeof(AnsiOutput));
|
| 132 | }
|
| 133 |
|
| 134 | DISALLOW_COPY_AND_ASSIGN(AnsiOutput)
|
| 135 | };
|
| 136 |
|
| 137 | extern int INDENT;
|
| 138 | class _PrettyPrinter {
|
| 139 | public:
|
| 140 | _PrettyPrinter(int max_col);
|
| 141 | bool _PrintWrappedArray(List<hnode_asdl::hnode_t*>* array, int prefix_len, format::ColorOutput* f, int indent);
|
| 142 | bool _PrintWholeArray(List<hnode_asdl::hnode_t*>* array, int prefix_len, format::ColorOutput* f, int indent);
|
| 143 | void _PrintRecord(hnode::Record* node, format::ColorOutput* f, int indent);
|
| 144 | void PrintNode(hnode_asdl::hnode_t* node, format::ColorOutput* f, int indent);
|
| 145 | int max_col;
|
| 146 |
|
| 147 | static constexpr ObjHeader obj_header() {
|
| 148 | return ObjHeader::ClassScanned(0, sizeof(_PrettyPrinter));
|
| 149 | }
|
| 150 |
|
| 151 | DISALLOW_COPY_AND_ASSIGN(_PrettyPrinter)
|
| 152 | };
|
| 153 |
|
| 154 | bool _TrySingleLineObj(hnode::Record* node, format::ColorOutput* f, int max_chars);
|
| 155 | bool _TrySingleLine(hnode_asdl::hnode_t* node, format::ColorOutput* f, int max_chars);
|
| 156 | void PrintTree(hnode_asdl::hnode_t* node, format::ColorOutput* f);
|
| 157 |
|
| 158 | } // declare namespace format
|
| 159 |
|
| 160 | #endif // ASDL_RUNTIME_MYCPP_H
|