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

Function FunctionCheck

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

Source from the content-addressed store, hash-verified

1743Proto* toproto(lua_State* L, int i);
1744
1745int 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
1776int CompareProto(const Proto* fleft, const Proto* fright, std::stringstream &str) {
1777 int sizesame, pc, minsizecode;

Callers 1

ProcessCodeFunction · 0.85

Calls 8

ProcessSubFunctionFunction · 0.85
luaL_loadstringFunction · 0.85
toprotoFunction · 0.85
CompareProtoFunction · 0.85
lua_closeFunction · 0.85
clear_sstreamFunction · 0.70
c_strMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected