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

Function ProcessSubFunction

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

Source from the content-addressed store, hash-verified

3411 }
3412
3413 std::string ProcessSubFunction(GluaDecompileContextP ctx, Proto* cf, int func_checking, std::string funcnumstr) {
3414 int i;
3415 int uvn = NUPS(cf);
3416 std::stringstream buff;
3417 std::string tmpname;
3418
3419 /* determining upvalues */
3420 if (!cf->upvalues) {
3421 // Lua 5.1 only
3422 cf->sizeupvalues = uvn;
3423 cf->upvalues = luaM_newvector(ctx->glstate, uvn, UPVAL_TYPE);
3424 for (i = 0; i < uvn; i++) {
3425 tmpname = std::string("upval_") + funcnumstr + "_" + std::to_string(i);
3426 UPVAL_NAME(cf, i) = luaS_new(ctx->glstate, tmpname.c_str());
3427 }
3428 }
3429 else {
3430 // FixUpvalNames
3431 for (i = 0; i < uvn; i++) {
3432 TString* name = UPVAL_NAME(cf, i);
3433 if (name == nullptr || LUA_STRLEN(name) == 0 ||
3434 strlen(getstr(name)) == 0 || !isIdentifier(getstr(name))) {
3435 // TODO 5.2 Maybe we should trace up to get _ENV ?
3436 // Also wen can get the location where upval defined
3437 tmpname = std::string("upval_") + funcnumstr + "_" + std::to_string(i);
3438 UPVAL_NAME(cf, i) = luaS_new(ctx->glstate, tmpname.c_str());
3439 }
3440 }
3441 }
3442
3443 clear_sstream(buff);
3444 if (!IsMain(ctx, cf)) {
3445 if (NUPS(cf) > 0) {
3446 buff << "local ";
3447 listUpvalues(ctx, cf, buff);
3448 buff << "\n";
3449 }
3450 buff << "DecompiledFunction_" << funcnumstr << " = ";
3451 }
3452 std::string code = ProcessCode(ctx, cf, 0, func_checking, funcnumstr);
3453
3454 buff << code << "\n";
3455 code = buff.str();
3456 return code;
3457 }
3458
3459 void luaU_decompileSubFunction(GluaDecompileContextP ctx, Proto* f, int dflag, std::string funcnumstr) {
3460 std::string realfuncnumstr;;

Callers 2

FunctionCheckFunction · 0.85

Calls 9

luaS_newFunction · 0.85
isIdentifierFunction · 0.85
listUpvaluesFunction · 0.85
ProcessCodeFunction · 0.85
clear_sstreamFunction · 0.70
stringClass · 0.50
to_stringFunction · 0.50
c_strMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected