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

Method FindImmediate

neo/d3xp/script/Script_Compiler.cpp:384–455  ·  view source on GitHub ↗

============ idCompiler::FindImmediate tries to find an existing immediate with the same value ============ */

Source from the content-addressed store, hash-verified

382============
383*/
384idVarDef *idCompiler::FindImmediate( const idTypeDef *type, const eval_t *eval, const char *string ) const {
385 idVarDef *def;
386 etype_t etype;
387
388 etype = type->Type();
389
390 // check for a constant with the same value
391 for( def = gameLocal.program.GetDefList( "<IMMEDIATE>" ); def != NULL; def = def->Next() ) {
392 if ( def->TypeDef() != type ) {
393 continue;
394 }
395
396 switch( etype ) {
397 case ev_field :
398 if ( *def->value.intPtr == eval->_int ) {
399 return def;
400 }
401 break;
402
403 case ev_argsize :
404 if ( def->value.argSize == eval->_int ) {
405 return def;
406 }
407 break;
408
409 case ev_jumpoffset :
410 if ( def->value.jumpOffset == eval->_int ) {
411 return def;
412 }
413 break;
414
415 case ev_entity :
416 if ( *def->value.intPtr == eval->entity ) {
417 return def;
418 }
419 break;
420
421 case ev_string :
422 if ( idStr::Cmp( def->value.stringPtr, string ) == 0 ) {
423 return def;
424 }
425 break;
426
427 case ev_float :
428 if ( *def->value.floatPtr == eval->_float ) {
429 return def;
430 }
431 break;
432
433 case ev_virtualfunction :
434 if ( def->value.virtualFunction == eval->_int ) {
435 return def;
436 }
437 break;
438
439
440 case ev_vector :
441 if ( ( def->value.vectorPtr->x == eval->vector[ 0 ] ) &&

Callers

nothing calls this directly

Calls 5

ErrorFunction · 0.50
TypeMethod · 0.45
GetDefListMethod · 0.45
NextMethod · 0.45
TypeDefMethod · 0.45

Tested by

no test coverage detected