| 844 | } |
| 845 | |
| 846 | void FlushBoolean(GluaDecompileContextP ctx, Function* F) { |
| 847 | if (F->bools.size == 0) { |
| 848 | FlushWhile1(F); |
| 849 | } |
| 850 | while (F->bools.size > 0) { |
| 851 | AstStatement* whilestmt = nullptr; |
| 852 | int endif = 0, thenaddr = 0; |
| 853 | std::string test; |
| 854 | std::stringstream str; |
| 855 | LoopItem* walk = nullptr; |
| 856 | |
| 857 | test = OutputBoolean(ctx, F, &thenaddr, &endif, 0); |
| 858 | if (ctx->error.length()>0) goto FlushBoolean_CLEAR_HANDLER1; |
| 859 | |
| 860 | //TODO find another method to determine while loop body to output while do |
| 861 | //search parent |
| 862 | walk = F->loop_ptr; |
| 863 | if (walk->type == WHILE_STMT && walk->out == endif - 1 && walk->body == -1) { |
| 864 | int whileStart = walk->start; |
| 865 | walk->body = thenaddr; |
| 866 | whilestmt = walk->block; |
| 867 | } |
| 868 | |
| 869 | if (whilestmt) { |
| 870 | whilestmt->code = test; |
| 871 | test = ""; |
| 872 | RawAddAstStatement(F, whilestmt); |
| 873 | F->currStmt = whilestmt; |
| 874 | } |
| 875 | else { |
| 876 | AstStatement* ifstmt = nullptr; |
| 877 | FlushWhile1(F); |
| 878 | ifstmt = MakeIfStatement(test); |
| 879 | ThenStart(ifstmt) = thenaddr; |
| 880 | ElseStart(ifstmt) = endif - 1; |
| 881 | test = ""; |
| 882 | RawAddAstStatement(F, ifstmt); |
| 883 | F->currStmt = ThenStmt(ifstmt); |
| 884 | } |
| 885 | |
| 886 | FlushBoolean_CLEAR_HANDLER1: |
| 887 | if (ctx->error.length()>0) return; |
| 888 | } |
| 889 | F->testpending = 0; |
| 890 | } |
| 891 | |
| 892 | void DeclareLocalsAddStatement(GluaDecompileContextP ctx, Function* F, std::stringstream &statement) { |
| 893 | if (F->pc > 0) { |
no test coverage detected