MCPcopy Create free account
hub / github.com/carbonengine/trinity / MarkUsedSymbols

Function MarkUsedSymbols

shadercompiler/ParserUtils.cpp:167–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167void MarkUsedSymbols( ASTNode* entryPoint, SymbolTable& symbols )
168{
169 if( entryPoint == nullptr )
170 {
171 return;
172 }
173
174 const InlineString globalsStructName = MakeInlineString( "GlobalsData" );
175
176 if( entryPoint->GetNodeType() == NT_FUNCTION_ATTRIBUTE &&
177 entryPoint->GetChildOrNull( 0 ) &&
178 entryPoint->GetToken()->stringValue == MakeInlineString( "patchconstantfunc" ) &&
179 entryPoint->GetChildOrNull( 0 )->GetToken()->type == OP_STRING_CONST )
180 {
181 Symbol* symbol = symbols.LookupGlobal( ParseString( entryPoint->GetChildOrNull( 0 )->GetToken()->stringValue ).c_str() );
182 if( symbol && !symbol->used )
183 {
184 MarkUsedSymbols( symbol->definition, symbols );
185 }
186 }
187 // "Globals" struct is a special case and we don't want to mark all of it's members
188 // as "used" automatically.
189 if( !( entryPoint->GetNodeType() == NT_STRUCT && entryPoint->GetSymbol()->name == globalsStructName ) && entryPoint->GetNodeType() != NT_SAMPLER_STATE_LIST )
190 {
191 for( size_t i = 0; i < entryPoint->GetChildrenCount(); ++i )
192 {
193 MarkUsedSymbols( entryPoint->GetChild( i ), symbols );
194 }
195 }
196 if( entryPoint->GetSymbol() && entryPoint->GetSymbol()->used )
197 {
198 return;
199 }
200 if( entryPoint->GetSymbol() )
201 {
202 entryPoint->GetSymbol()->used = true;
203 }
204 if( entryPoint->GetSymbol() )
205 {
206 if( entryPoint->GetSymbol()->definition )
207 {
208 MarkUsedSymbols( entryPoint->GetSymbol()->definition, symbols );
209 }
210 if( entryPoint->GetSymbol()->type.symbol && entryPoint->GetSymbol()->type.symbol->definition )
211 {
212 MarkUsedSymbols( entryPoint->GetSymbol()->type.symbol->definition, symbols );
213 }
214 }
215 if( entryPoint->GetType().symbol )
216 {
217 MarkUsedSymbols( entryPoint->GetType().symbol->definition, symbols );
218 }
219}
220
221static bool HasUsedDeclarations( ASTNode* node )
222{

Callers 3

CompileEffectMethod · 0.85
CompileEffectMethod · 0.85

Calls 12

MakeInlineStringFunction · 0.85
ParseStringFunction · 0.85
GetNodeTypeMethod · 0.80
GetChildOrNullMethod · 0.80
GetTokenMethod · 0.80
LookupGlobalMethod · 0.80
GetSymbolMethod · 0.80
GetChildrenCountMethod · 0.80
GetTreeMethod · 0.80
GetChildMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected