KSeExpr
6.0.0.0
KSeExpr
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
16
namespace
KSeExpr
17
{
18
class
TypePrintExaminer
:
public
KSeExpr::Examiner
<true> {
19
public
:
20
bool
examine
(
const
ExprNode
*
examinee
)
override
;
21
void
reset
()
override
{};
22
void
post
(
const
ExprNode
*)
override
{};
23
};
24
25
bool
TypePrintExaminer::examine
(
const
ExprNode
*
examinee
) {
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
ExprNode.h
ExprWalker.h
Expression.h
KSeExpr::Examiner
Definition
ExprWalker.h:18
KSeExpr::ExprNode
Definition
ExprNode.h:56
KSeExpr::TypePrintExaminer
Definition
TypePrinter.h:18
KSeExpr::TypePrintExaminer::reset
void reset() override
Definition
TypePrinter.h:21
KSeExpr::TypePrintExaminer::examine
bool examine(const ExprNode *examinee) override
Definition
TypePrinter.h:25
KSeExpr::TypePrintExaminer::post
void post(const ExprNode *) override
Definition
TypePrinter.h:22
KSeExpr::Vec
Definition
Vec.h:31
KSeExpr
Definition
Context.h:13
KSeExpr::sprintf
KSeExpr::SPrintFuncX sprintf
Generated by
1.9.8