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

Function DeclareLocals

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

Source from the content-addressed store, hash-verified

1404}
1405
1406void DeclareLocals(GluaDecompileContextP ctx, Function* F) {
1407 int i;
1408 int locals;
1409 int internalLocals = 0;
1410 //int loopstart;
1411 //int loopvars;
1412 int loopconvert;
1413 std::stringstream str;
1414 std::stringstream rhs;
1415 std::string names[MAXARG_A];
1416 int startparams = 0;
1417 /*
1418 * Those are declaration of parameters.
1419 */
1420 if (F->pc == 0) {
1421 startparams = F->f->numparams;
1422 if (NEED_ARG(F->f)) {
1423 startparams++;
1424 }
1425 }
1426 str << "local ";
1427 rhs << " = ";
1428 locals = 0;
1429 if (F->pc != 0) {
1430 for (i = startparams; i < F->f->maxstacksize; i++) {
1431 if (ctx->functionnum >= 0 && ctx->functionnum < 255 && ctx->localdeclare[ctx->functionnum][i] == F->pc) {
1432 int r = i;
1433 char name[12];
1434 memset(name, 0x0, sizeof(name));
1435 sprintf(name, "l_%d_%d", ctx->functionnum, i);
1436 name[11] = '\0';
1437 if (F->Rinternal[r]) {
1438 names[r] = std::string(name);
1439 F->Rinternal[r] = 0;
1440 internalLocals++;
1441 continue;
1442 }
1443 if (PENDING(r)) {
1444 if (locals > 0) {
1445 str << ", ";
1446 rhs << ", ";
1447 }
1448 str << name;
1449 rhs << GetR(ctx, F, r);
1450 }
1451 else {
1452 str << ", " << name;
1453 }
1454 CALL(r) = 0;
1455 IS_VARIABLE(r) = 1;
1456 names[r] = std::string(name);
1457 locals++;
1458 }
1459 }
1460 }
1461 loopconvert = 0;
1462 for (i = startparams; i < F->f->sizelocvars; i++) {
1463 if (F->f->locvars[i].startpc == F->pc) {

Callers 1

ProcessCodeFunction · 0.85

Calls 7

GetRFunction · 0.85
DeclareVariableFunction · 0.85
stringClass · 0.50
lengthMethod · 0.45
strMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected