| 2002 | } |
| 2003 | |
| 2004 | std::string ProcessCode(GluaDecompileContextP ctx, Proto* f, int indent, int func_checking, std::string funcnumstr) |
| 2005 | { |
| 2006 | int i = 0; |
| 2007 | |
| 2008 | int ignoreNext = 0; |
| 2009 | |
| 2010 | InitOperators(); |
| 2011 | |
| 2012 | Function* F; |
| 2013 | std::stringstream str; |
| 2014 | |
| 2015 | const Instruction* code = f->code; |
| 2016 | int pc, n = f->sizecode; |
| 2017 | int baseIndent = indent; |
| 2018 | |
| 2019 | std::string output; |
| 2020 | |
| 2021 | int currLocVar = 0; |
| 2022 | int RvarTop = 0; |
| 2023 | int Rvar[MAXARG_A]; |
| 2024 | |
| 2025 | LoopItem* next_child; |
| 2026 | |
| 2027 | F = NewFunction(f); |
| 2028 | F->funcnumstr = funcnumstr; |
| 2029 | F->indent = indent; |
| 2030 | F->pc = 0; |
| 2031 | ctx->error = ""; |
| 2032 | |
| 2033 | FixLocalNames(ctx, f, funcnumstr); |
| 2034 | |
| 2035 | /* |
| 2036 | * Function parameters are stored in registers from 0 on. |
| 2037 | */ |
| 2038 | for (i = 0; i < f->numparams; i++) { |
| 2039 | TRY(ctx, DeclareVariable(ctx, F, getLocalName(ctx, F->f, i), i)); |
| 2040 | IS_VARIABLE(i) = 1; |
| 2041 | } |
| 2042 | F->freeLocal = f->numparams; |
| 2043 | |
| 2044 | listParams(ctx, f, str); |
| 2045 | F->funcBlock->code = str.str(); |
| 2046 | if (!IsMain(ctx, f)) { |
| 2047 | F->indent++; |
| 2048 | } |
| 2049 | |
| 2050 | // make function comment |
| 2051 | clear_sstream(str); |
| 2052 | str << "-- function num : " << funcnumstr; |
| 2053 | if (NUPS(f) > 0) { |
| 2054 | str << " , upvalues : "; |
| 2055 | listUpvalues(ctx, f, str); |
| 2056 | } |
| 2057 | TRY(ctx, RawAddStatement(F, str)); |
| 2058 | clear_sstream(str); |
| 2059 | |
| 2060 | if (ctx->func_check == 1 && func_checking == 0) { |
| 2061 | int func_check_result = FunctionCheck(ctx, f, funcnumstr, str); |
no test coverage detected