MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / MakeBoolean

Function MakeBoolean

src/Chain/libraries/glua/glua_decompile.cpp:530–742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

528}
529
530LogicExp* MakeBoolean(GluaDecompileContextP ctx, Function* F, int* thenaddr, int* endif) {
531 int i;
532 int firstaddr, elseaddr;
533 BoolOp *first, *realLast, *last, *tmpLast, *curr;
534 int lastCount;
535 LogicExp *currExp = nullptr, *firstExp = nullptr;
536 int dest;
537
538 if (endif) {
539 *endif = 0;
540 }
541
542 if (F->bools.size == 0) {
543 SET_ERROR(ctx, F, "Attempted to build a boolean expression without a pending context");
544 return nullptr;
545 }
546
547 first = (BoolOp*)FirstItem(&(F->bools));
548 realLast = (BoolOp*)LastItem(&(F->bools));
549 last = realLast;
550 firstaddr = first->pc + 2;
551 *thenaddr = last->pc + 2;
552 elseaddr = last->dest;
553
554 for (curr = realLast; curr; curr = lua_cast(BoolOp*, curr->super.prev)) {
555 int dest = curr->dest;
556 if ((elseaddr > *thenaddr) &&
557 (((curr->op == OP_TEST) || (curr->op == OP_TESTSET)) ? (dest > elseaddr + 1) :
558 (dest > elseaddr))) {
559 last = curr;
560 *thenaddr = curr->pc + 2;
561 elseaddr = dest;
562 }
563 }
564
565 tmpLast = last;
566 for (curr = first; curr && curr != tmpLast; curr = lua_cast(BoolOp*, curr->super.next)) {
567 int dest = curr->dest;
568 if (elseaddr > firstaddr) {
569 if (dest < firstaddr) {
570 last = curr;
571 *thenaddr = curr->pc + 2;
572 elseaddr = dest;
573 }
574 }
575 else {
576 if (dest == firstaddr) {
577 last = curr;
578 *thenaddr = curr->pc + 2;
579 elseaddr = dest;
580 }
581 else {
582 break;
583 }
584 }
585 }
586
587 dest = first->dest;

Callers 2

OutputBooleanFunction · 0.85
ProcessCodeFunction · 0.85

Calls 12

FirstItemFunction · 0.85
LastItemFunction · 0.85
MakeExpNodeFunction · 0.85
MakeExpChainFunction · 0.85
TieAsSubExpFunction · 0.85
printfClass · 0.85
TieAsNextFunction · 0.85
DeleteLogicExpTreeFunction · 0.85
UntieFunction · 0.85
DeleteLogicExpSubTreeFunction · 0.85
DeleteBoolOpFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected