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

Function CompareProto

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

Source from the content-addressed store, hash-verified

1774}
1775
1776int CompareProto(const Proto* fleft, const Proto* fright, std::stringstream &str) {
1777 int sizesame, pc, minsizecode;
1778 int diff = 0;
1779 clear_sstream(str);
1780 if (fleft->numparams != fright->numparams) {
1781 diff++;
1782 str << " different params size;";
1783 }
1784 if (NUPS(fleft) != NUPS(fright)) {
1785 diff++;
1786 str << " different upvalues size;";
1787 }
1788 if (fleft->is_vararg != fright->is_vararg) {
1789 diff++;
1790 str << " different is_vararg;";
1791 }
1792 if (fleft->sizecode != fright->sizecode) {
1793 diff++;
1794 str << " different code size;";
1795 }
1796 sizesame = 0;
1797 minsizecode = MIN(fleft->sizecode, fright->sizecode);
1798 for (pc = 0; pc < minsizecode; pc++) {
1799 Instruction ileft = fleft->code[pc];
1800 Instruction iright = fright->code[pc];
1801 if (ileft == iright) {
1802 sizesame++;
1803 }
1804 else {
1805 Inst left = extractInstruction(ileft);
1806 Inst right = extractInstruction(iright);
1807 if (left.op == OP_EQ && right.op == OP_EQ) {
1808 if (left.a == right.a && left.b == right.c && left.c == right.b) {
1809 sizesame++;
1810 }
1811 }
1812 else if ((left.op == OP_LT && right.op == OP_LE) ||
1813 (left.op == OP_LE && right.op == OP_LT)) {
1814 if (left.a == !right.a && left.b == right.c && left.c == right.b) {
1815 sizesame++;
1816 }
1817 }
1818 }
1819 }
1820 if (sizesame != fleft->sizecode) {
1821 diff++;
1822 str << " sizecode org: " << fleft->sizecode << ", decompiled: " << fright->sizecode << ", same: " << sizesame << ";";
1823 }
1824 return diff;
1825}
1826
1827std::string PrintFunctionOnlyParamsAndUpvalues(GluaDecompileContextP ctx, const Proto* f, int indent, std::string funcnumstr) {
1828 std::stringstream code;

Callers 1

FunctionCheckFunction · 0.85

Calls 2

extractInstructionFunction · 0.85
clear_sstreamFunction · 0.70

Tested by

no test coverage detected