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

Method LookupFunctionDeclaration

shadercompiler/SymbolTable.cpp:155–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155Symbol* ScopeSymbolTable::LookupFunctionDeclaration( const InlineString& name, ASTNode* header ) const
156{
157 std::vector<std::pair<Symbol*, int>> overrides;
158 const ScopeSymbolTable* scope = this;
159 while( scope )
160 {
161 for( auto it = scope->m_symbols.begin(); it != scope->m_symbols.end(); ++it )
162 {
163 if( ( *it )->name == name && ( *it )->definition && ( *it )->definition->GetNodeType() == NT_FUNCTION_HEADER )
164 {
165 overrides.push_back( std::make_pair( *it, 100000 ) );
166 }
167 }
168 scope = scope->m_parent;
169 }
170 if( overrides.empty() )
171 {
172 return nullptr;
173 }
174
175 for( auto it = overrides.begin(); it != overrides.end(); ++it )
176 {
177 ASTNode* node = it->first->definition;
178 auto parameterCount = node->GetChildrenCount();
179 auto argumentCount = header->GetChildrenCount();
180
181 if( argumentCount != parameterCount )
182 {
183 continue;
184 }
185 if( node->GetType() != header->GetType() )
186 {
187 continue;
188 }
189 bool match = true;
190 for( size_t i = 0; i < argumentCount; ++i )
191 {
192 if( node->GetChild( i )->GetType() != header->GetChild( i )->GetType() )
193 {
194 match = false;
195 break;
196 }
197 }
198 if( match )
199 {
200 return it->first;
201 }
202 }
203 return nullptr;
204}
205
206Symbol* ScopeSymbolTable::LookupFunction( const InlineString& name, ASTNode* callNode, std::string& diagnosticMessage ) const
207{

Callers

nothing calls this directly

Calls 7

GetNodeTypeMethod · 0.80
emptyMethod · 0.80
GetChildrenCountMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
GetTypeMethod · 0.45
GetChildMethod · 0.45

Tested by

no test coverage detected