MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / GetDef

Method GetDef

neo/game/script/Script_Program.cpp:1395–1429  ·  view source on GitHub ↗

============ idProgram::GetDef If type is NULL, it will match any type ============ */

Source from the content-addressed store, hash-verified

1393============
1394*/
1395idVarDef *idProgram::GetDef( const idTypeDef *type, const char *name, const idVarDef *scope ) const {
1396 idVarDef *def;
1397 idVarDef *bestDef;
1398 int bestDepth;
1399 int depth;
1400
1401 bestDepth = 0;
1402 bestDef = NULL;
1403 for( def = GetDefList( name ); def != NULL; def = def->Next() ) {
1404 if ( def->scope->Type() == ev_namespace ) {
1405 depth = def->DepthOfScope( scope );
1406 if ( !depth ) {
1407 // not in the same namespace
1408 continue;
1409 }
1410 } else if ( def->scope != scope ) {
1411 // in a different function
1412 continue;
1413 } else {
1414 depth = 1;
1415 }
1416
1417 if ( !bestDef || ( depth < bestDepth ) ) {
1418 bestDepth = depth;
1419 bestDef = def;
1420 }
1421 }
1422
1423 // see if the name is already in use for another type
1424 if ( bestDef && type && ( bestDef->TypeDef() != type ) ) {
1425 throw idCompileError( va( "Type mismatch on redeclaration of %s", name ) );
1426 }
1427
1428 return bestDef;
1429}
1430
1431/*
1432============

Callers 7

ParseFunctionCallMethod · 0.45
LookupDefMethod · 0.45
ParseValueMethod · 0.45
ParseFunctionDefMethod · 0.45
ParseVariableDefMethod · 0.45
ParseDefsMethod · 0.45
GetRegisterValueMethod · 0.45

Calls 6

vaFunction · 0.85
idCompileErrorClass · 0.70
NextMethod · 0.45
TypeMethod · 0.45
DepthOfScopeMethod · 0.45
TypeDefMethod · 0.45

Tested by

no test coverage detected