KSeExpr 6.0.0.0
TypePrinter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2011-2019 Disney Enterprises, Inc.
2// SPDX-License-Identifier: LicenseRef-Apache-2.0
3// SPDX-FileCopyrightText: 2020 L. E. Segovia <amy@amyspark.me>
4// SPDX-License-Identifier: GPL-3.0-or-later
5
6#pragma once
7
8#include <array>
9#include <cstdio>
10#include <typeinfo>
11
12#include "ExprNode.h"
13#include "ExprWalker.h"
14#include "Expression.h"
15
16namespace KSeExpr
17{
19 public:
20 bool examine(const ExprNode* examinee) override;
21 void reset() override {};
22 void post(const ExprNode *) override {};
23};
24
26 const ExprNode* curr = examinee;
27 int depth = 0;
28 std::array<char, 1024> buf{};
29 while (curr != nullptr) {
30 depth++;
31 curr = curr->parent();
32 }
33 sprintf(buf.data(), "%*s", depth * 2, " ");
34 std::cout << buf.data() << "'" << examinee->toString() << "' " << typeid(*examinee).name()
35 << " type=" << examinee->type().toString() << std::endl;
36
37 return true;
38}
39} // namespace KSeExpr
bool examine(const ExprNode *examinee) override
Definition TypePrinter.h:25
void post(const ExprNode *) override
Definition TypePrinter.h:22
KSeExpr::SPrintFuncX sprintf