| 153 | } |
| 154 | |
| 155 | Symbol* 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 | |
| 206 | Symbol* ScopeSymbolTable::LookupFunction( const InlineString& name, ASTNode* callNode, std::string& diagnosticMessage ) const |
| 207 | { |
nothing calls this directly
no test coverage detected