| 1743 | Proto* toproto(lua_State* L, int i); |
| 1744 | |
| 1745 | int FunctionCheck(GluaDecompileContextP ctx, Proto* f, std::string funcnumstr, std::stringstream &str) { |
| 1746 | lua_State* newState; |
| 1747 | int check_result; |
| 1748 | auto decompiled = ProcessSubFunction(ctx, f, 1, funcnumstr); |
| 1749 | newState = lua_open(); |
| 1750 | if (luaL_loadstring(newState, decompiled.c_str()) != 0) { |
| 1751 | check_result = -1; |
| 1752 | clear_sstream(str); |
| 1753 | str << "-- function check fail " << funcnumstr << " : cannot compile"; |
| 1754 | } |
| 1755 | else { |
| 1756 | std::stringstream compare_result_str; |
| 1757 | Proto* newProto = toproto(newState, -1);; |
| 1758 | if (!IsMain(ctx, f)) { |
| 1759 | newProto = newProto->p[0]; |
| 1760 | } |
| 1761 | check_result = CompareProto(f, newProto, compare_result_str); |
| 1762 | if (check_result == 0) { |
| 1763 | clear_sstream(str); |
| 1764 | str << "-- function check pass " << funcnumstr; |
| 1765 | } |
| 1766 | else { |
| 1767 | clear_sstream(str); |
| 1768 | str << "-- function check fail " << funcnumstr << " : " << compare_result_str.str(); |
| 1769 | } |
| 1770 | } |
| 1771 | |
| 1772 | lua_close(newState); |
| 1773 | return check_result; |
| 1774 | } |
| 1775 | |
| 1776 | int CompareProto(const Proto* fleft, const Proto* fright, std::stringstream &str) { |
| 1777 | int sizesame, pc, minsizecode; |
no test coverage detected