MCPcopy Create free account
hub / github.com/dborth/fceugx / evaluate

Function evaluate

source/fceultra/debug.cpp:417–491  ·  view source on GitHub ↗

Evaluates a condition

Source from the content-addressed store, hash-verified

415
416// Evaluates a condition
417int evaluate(Condition* c)
418{
419 int f = 0;
420
421 int value1, value2;
422
423 if (c->lhs)
424 {
425 value1 = evaluate(c->lhs);
426 }
427 else
428 {
429 switch(c->type1)
430 {
431 case TYPE_ADDR: // This is intended to not break, and use the TYPE_NUM code
432 case TYPE_NUM: value1 = c->value1; break;
433 default: value1 = getValue(c->value1); break;
434 }
435 }
436
437 switch(c->type1)
438 {
439 case TYPE_ADDR: value1 = GetMem(value1); break;
440 case TYPE_PC_BANK: value1 = getBank(_PC); break;
441 case TYPE_DATA_BANK: value1 = getBank(debugLastAddress); break;
442 case TYPE_VALUE_READ: value1 = GetMem(debugLastAddress); break;
443 case TYPE_VALUE_WRITE: value1 = evaluateWrite(debugLastOpcode, debugLastAddress); break;
444 }
445
446 f = value1;
447
448 if (c->op)
449 {
450 if (c->rhs)
451 {
452 value2 = evaluate(c->rhs);
453 }
454 else
455 {
456 switch(c->type2)
457 {
458 case TYPE_ADDR: // This is intended to not break, and use the TYPE_NUM code
459 case TYPE_NUM: value2 = c->value2; break;
460 default: value2 = getValue(c->type2); break;
461 }
462 }
463
464 switch(c->type2)
465 {
466 case TYPE_ADDR: value2 = GetMem(value2); break;
467 case TYPE_PC_BANK: value2 = getBank(_PC); break;
468 case TYPE_DATA_BANK: value2 = getBank(debugLastAddress); break;
469 case TYPE_VALUE_READ: value2 = GetMem(debugLastAddress); break;
470 case TYPE_VALUE_WRITE: value2 = evaluateWrite(debugLastOpcode, debugLastAddress); break;
471 }
472
473 switch (c->op)
474 {

Callers 1

conditionFunction · 0.85

Calls 4

getValueFunction · 0.85
GetMemFunction · 0.85
getBankFunction · 0.85
evaluateWriteFunction · 0.85

Tested by

no test coverage detected