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

Function OutputAssignments

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

Source from the content-addressed store, hash-verified

1311}
1312
1313void OutputAssignments(GluaDecompileContextP ctx, Function* F) {
1314 int i, srcs;
1315 ListItem *walk, *tail;
1316 std::stringstream vars;
1317 std::string exps;
1318 if (!SET_IS_EMPTY(F->tpend)) {
1319 goto OutputAssignments_ERROR_HANDLER;
1320 }
1321 srcs = 0;
1322 walk = F->vpend.head;
1323 tail = F->vpend.tail;
1324 i = 0;
1325 while (walk) {
1326 int r = lua_cast(VarListItem*, walk)->reg;
1327 auto src = lua_cast(VarListItem*, walk)->src;
1328 auto dest = lua_cast(VarListItem*, walk)->dest;
1329 if (!(r == -1 || PENDING(r))) {
1330 ctx->errortmp = std::string("Confused about usage of register: R") + std::to_string(r) + " in 'OutputAssignments'";
1331 SET_ERROR(ctx, F, ctx->errortmp);
1332 goto OutputAssignments_ERROR_HANDLER;
1333 }
1334
1335 if (i > 0) {
1336 auto replaced = std::string(", ") + vars.str();
1337 clear_sstream(vars);
1338 vars << replaced;
1339 }
1340 auto replaced2 = std::string(dest) + vars.str();
1341 clear_sstream(vars);
1342 vars << replaced2;
1343
1344 if (src.length()>0 && (srcs > 0 || (srcs == 0 && strcmp(src.c_str(), "nil") != 0) || walk == tail)) {
1345 if (srcs > 0) {
1346 exps = ", " + exps;
1347 }
1348 exps = src + exps;
1349 srcs++;
1350 }
1351 if (r != -1) {
1352 PENDING(r) = 0;
1353 }
1354 walk = walk->next;
1355 i++;
1356 }
1357
1358 if (i > 0) {
1359 vars << " = ";
1360 vars << exps;
1361 AddStatement(ctx, F, vars);
1362 if (ctx->error.length()>0) {
1363 goto OutputAssignments_ERROR_HANDLER;
1364 }
1365 }
1366OutputAssignments_ERROR_HANDLER:
1367 ClearList(&(F->vpend), (ListItemFn)ClearVarListItem);
1368}
1369
1370void ReleaseLocals(GluaDecompileContextP ctx, Function* F) {

Callers 1

ProcessCodeFunction · 0.85

Calls 8

AddStatementFunction · 0.85
ClearListFunction · 0.85
clear_sstreamFunction · 0.70
stringClass · 0.50
to_stringFunction · 0.50
strMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected