| 1044 | } |
| 1045 | |
| 1046 | std::string PrintTable(GluaDecompileContextP ctx, Function* F, int r, int returnCopy) { |
| 1047 | std::string result; |
| 1048 | int numerics = 0; |
| 1049 | DecTableItem* item; |
| 1050 | std::stringstream str; |
| 1051 | DecTable* tbl = (DecTable*)FindFromListTail(&(F->tables), (ListItemCmpFn)MatchTable, &r); |
| 1052 | if (tbl == nullptr) { |
| 1053 | IS_TABLE(r) = 0; |
| 1054 | return F->R[r]; |
| 1055 | } |
| 1056 | item = lua_cast(DecTableItem*, tbl->array.head); |
| 1057 | if (item) { |
| 1058 | numerics = 1; |
| 1059 | PrintTableItemNumeric(str, item); |
| 1060 | item = lua_cast(DecTableItem*, item->super.next); |
| 1061 | while (item) { |
| 1062 | str << ", "; |
| 1063 | PrintTableItemNumeric(str, item); |
| 1064 | item = lua_cast(DecTableItem*, item->super.next); |
| 1065 | } |
| 1066 | } |
| 1067 | item = lua_cast(DecTableItem*, tbl->keyed.head); |
| 1068 | if (item) { |
| 1069 | if (numerics) { |
| 1070 | str << "; "; |
| 1071 | } |
| 1072 | PrintTableItemKeyed(ctx, F, str, item); |
| 1073 | item = lua_cast(DecTableItem*, item->super.next); |
| 1074 | while (item) { |
| 1075 | str << ", "; |
| 1076 | PrintTableItemKeyed(ctx, F, str, item); |
| 1077 | item = lua_cast(DecTableItem*, item->super.next); |
| 1078 | } |
| 1079 | } |
| 1080 | str << "}"; |
| 1081 | PENDING(r) = 0; |
| 1082 | AssignReg(ctx, F, r, str.str().c_str(), 0, 0); |
| 1083 | if (ctx->error.length()>0) { |
| 1084 | result = ""; |
| 1085 | } |
| 1086 | else if (returnCopy) { |
| 1087 | result = str.str(); |
| 1088 | } |
| 1089 | CloseTable(F, r); |
| 1090 | return result; |
| 1091 | } |
| 1092 | |
| 1093 | DecTable* NewTable(int r, int b, int c, int pc) { |
| 1094 | auto self = new DecTable(); |
no test coverage detected