1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "glslastdump_p.h"
5#include <QTextStream>
6
7#include <typeinfo>
8
9#ifdef Q_CC_GNU
10# include <cxxabi.h>
11#endif
12
13QT_BEGIN_NAMESPACE
14
15using namespace GLSL;
16
17ASTDump::ASTDump(QTextStream &out)
18 : out(out), _depth(0)
19{
20}
21
22void ASTDump::operator()(AST *ast)
23{
24 _depth = 0;
25 accept(ast);
26}
27
28bool ASTDump::preVisit(AST *ast)
29{
30 const char *id = typeid(*ast).name();
31#ifdef Q_CC_GNU
32 char *cppId = abi::__cxa_demangle(mangled_name: id, output_buffer: nullptr, length: nullptr, status: nullptr);
33 id = cppId;
34#endif
35 out << QByteArray(_depth, ' ') << id << '\n';
36#ifdef Q_CC_GNU
37 free(ptr: cppId);
38#endif
39 ++_depth;
40 return true;
41}
42
43void ASTDump::postVisit(AST *)
44{
45 --_depth;
46}
47
48QT_END_NAMESPACE
49

source code of qtquick3d/src/glslparser/glslastdump.cpp