CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
VisitorTracker.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Visitor.hpp"
11
14
16
17 // Extended visitor class with AST tracking functions.
18 class VisitorTracker : public Visitor {
19 protected: // Global scope tracker
21
22 protected: // Function declaration tracker
25
26 // Returns true if the visitor is currently inside a function declaration.
28
29 // Returns true if the visitor is currently inside the main entry point.
30 [[nodiscard]] bool isInsideEntryPoint() const;
31
32 // Returns true if the visitor is currently inside the secondary entry point.
34
35 // Returns the active (inner most) function declaration or null if the analyzer is currently not inside a function declaration.
37
38 // Returns the structure the active (inner most) member function declaration belongs to or null if no such structure exists.
40
41 protected: // Call expression tracker
44
45 // Returns the active (inner most) call expression or null if the visitor is currently not inside a function call.
47
48 protected: // L-value expression tracker
51
52 // Returns the active (inner most) l-value expression or null (can be AssignExpression, UnaryExpression, or PostUnaryExpression).
54
55 protected: // Structure declaration tracker
56 void pushStructDeclaration(StructDeclaration* structDeclaration);
58
59 // Returns true if the analyzer is currently inside a structure declaration.
61
62 // Returns the active (inner most) structure declaration or null if the visitor is currently not inside a structure declaration.
64
65 // Returns the stack (or rather the list) of all current, nested structure declarations.
67
68 protected: // Uniform buffer declaration tracker
71
72 // Returns true if the analyzer is currently inside a uniform buffer declaration.
74
75 // Returns the stack (or rather the list) of all current, nested structure declarations.
77
78 protected: // Variable declaration statement tracker
81
82 // Returns true if the visitor is currently inside a variable declaration statement.
84
85 // Returns the active (inner most) variable declaration statement.
87
88 private:
89 // Function declaration stack.
91
92 // Call expression stack to join arguments with its function call.
94
95 // L-value expression stack
97
98 // Structure stack to collect all members with system value semantic (SV_...), and detect all nested structures.
100
101 // Uniform buffer declaration stack.
103
104 // Variable declaration stack.
106
107 // Function declaration level of the main entry point.
108 std::size_t mStackLevelOfEntryPoint = std::size_t(~0);
109
110 // Function declaration level of the secondary entry point.
111 std::size_t mStackLevelOf2ndEntryPoint = std::size_t(~0);
112 };
113
114#undef VISITOR_VISIT_PROC
115
116} // namespace CeresEngine::ShaderCompiler
Definition Visitor.hpp:92
Definition VisitorTracker.hpp:18
std::size_t mStackLevelOf2ndEntryPoint
Definition VisitorTracker.hpp:111
Vector< UniformBufferDeclaration * > mUniformBufferDeclarationStack
Definition VisitorTracker.hpp:102
const Vector< StructDeclaration * > & getStructDeclarationStack() const
Definition VisitorTracker.hpp:66
StructDeclaration * getActiveStructDeclaration() const
void pushLValueExpression(Expression *expression)
StructDeclaration * getActiveFunctionStructDeclaration() const
FunctionDeclaration * getActiveFunctionDeclaration() const
CallExpression * getActiveCallExpression() const
void pushCallExpression(CallExpression *callExpression)
void pushFunctionDeclaration(FunctionDeclaration *funcDeclaration)
std::size_t mStackLevelOfEntryPoint
Definition VisitorTracker.hpp:108
void pushVarDeclarationStatement(VarDeclarationStatement *varDeclarationStatement)
void pushStructDeclaration(StructDeclaration *structDeclaration)
void pushUniformBufferDeclaration(UniformBufferDeclaration *uniformBufferDeclaration)
Stack< CallExpression * > mCallExpressionStack
Definition VisitorTracker.hpp:93
Vector< StructDeclaration * > mStructDeclarationStack
Definition VisitorTracker.hpp:99
Stack< VarDeclarationStatement * > mVarDeclarationStatementStack
Definition VisitorTracker.hpp:105
const Vector< UniformBufferDeclaration * > & getUniformBufferDeclarationStack() const
Definition VisitorTracker.hpp:76
VarDeclarationStatement * getActiveVarDeclarationStatement() const
Stack< FunctionDeclaration * > mFuncDeclarationStack
Definition VisitorTracker.hpp:90
Stack< Expression * > mLvalueExpressionStack
Definition VisitorTracker.hpp:96
Definition AST.hpp:33
std::stack< T, Container > Stack
The Stack class is a container adapter that gives the programmer the functionality of a stack - speci...
Definition Stack.hpp:18
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25