Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
glslastdump.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
7#include <QTextStream>
8
9#include <typeinfo>
10
11#ifdef Q_CC_GNU
12# include <cxxabi.h>
13#endif
14
15QT_BEGIN_NAMESPACE
16
17using namespace GLSL;
18
19ASTDump::ASTDump(QTextStream &out)
20 : out(out), _depth(0)
21{
22}
23
24void ASTDump::operator()(AST *ast)
25{
26 _depth = 0;
27 accept(ast);
28}
29
30bool ASTDump::preVisit(AST *ast)
31{
32 const char *id = typeid(*ast).name();
33#ifdef Q_CC_GNU
34 char *cppId = abi::__cxa_demangle(id, nullptr, nullptr, nullptr);
35 id = cppId;
36#endif
37 out << QByteArray(_depth, ' ') << id << '\n';
38#ifdef Q_CC_GNU
39 free(cppId);
40#endif
41 ++_depth;
42 return true;
43}
44
45void ASTDump::postVisit(AST *)
46{
47 --_depth;
48}
49
50QT_END_NAMESPACE