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

Function AssignReg

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

Source from the content-addressed store, hash-verified

923}
924
925void AssignReg(GluaDecompileContextP ctx, Function* F, int reg, std::string src, int prio, int mayTest) {
926 std::string dest = REGISTER(reg);
927 std::string nsrc;
928
929 if (PENDING(reg)) {
930 if (ctx->guess_locals) {
931 ctx->errortmp = std::string("Overwrote pending register: R") + std::to_string(reg) + " in 'AssignReg'";
932 SET_ERROR(ctx, F, ctx->errortmp);
933 }
934 else {
935 ctx->errortmp = std::string("Overwrote pending register: R") + std::to_string(reg) + " in 'AssignReg'. Creating missing local";
936 SET_ERROR(ctx, F, ctx->errortmp);
937 DeclareLocal(ctx, F, reg, dest);
938 }
939 return;
940 }
941
942 PENDING(reg) = 1;
943 CALL(reg) = 0;
944 F->Rprio[reg] = prio;
945
946 if (ctx->debug) {
947 printf("SET_SIZE(tpend) = %d \n", SET_SIZE(F->tpend));
948 }
949
950 nsrc = std::string(src);
951 if (F->testpending == reg + 1 && mayTest && F->testjump == F->pc + 2) {
952 int thenaddr, endif;
953 std::string test = OutputBoolean(ctx, F, &thenaddr, &endif, 1);
954 if (ctx->error.length()>0) {
955 return;
956 }
957 if (endif >= F->pc) {
958 std::stringstream str;
959 str << test << " or " << src;
960 nsrc = str.str();
961 F->testpending = 0;
962 F->Rprio[reg] = 8;
963 }
964 }
965 F->testjump = 0;
966
967 if (!IS_VARIABLE(reg)) {
968 REGISTER(reg) = nsrc;
969 AddToSet(F->tpend, reg);
970 }
971 else {
972 AddToVarList(&(F->vpend), dest, nsrc, reg);
973 }
974}
975
976/*
977** Table Functions

Callers 2

PrintTableFunction · 0.85
ProcessCodeFunction · 0.85

Calls 9

DeclareLocalFunction · 0.85
printfClass · 0.85
OutputBooleanFunction · 0.85
AddToSetFunction · 0.85
AddToVarListFunction · 0.85
stringClass · 0.50
to_stringFunction · 0.50
lengthMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected