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

Function PrintIfStatement

src/Chain/libraries/glua/glua_statement.cpp:185–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183 }
184
185 void PrintIfStatement(GluaDecompileContextP ctx, AstStatement* stmt, std::stringstream &buff, int indent, int elseif) {
186 AstStatement* thenstmt = lua_cast(AstStatement*, stmt->sub->head);
187 List* thensub = thenstmt->sub;
188 AstStatement* elsestmt = lua_cast(AstStatement*, stmt->sub->tail);
189 List* elsesub = elsestmt->sub;
190 int elsesize = elsesub->size;
191 AstStatement* elsefirst = lua_cast(AstStatement*, elsesub->head);
192 if (elseif) {
193 PrintIndent(buff, indent);
194 buff << "elseif " << stmt->code << " then\n";
195 }
196 else {
197 PrintIndent(buff, indent);
198 buff << "if " << stmt->code << " then\n";
199 }
200 if (ctx->debug) {
201 PrintIndent(buff, indent + 1);
202 buff << "-- AstStatement type=IF_THEN_STMT line=" << thenstmt->line << " size=" << thensub->size << "\n";
203 }
204 PrintAstSub(ctx, thenstmt, buff, indent + 1);
205 if (elsesize == 0) {
206 PrintIndent(buff, indent);
207 buff << "end\n";
208 }
209 else if (elsesize == 1 && elsefirst->type == IF_STMT) {
210 PrintIfStatement(ctx, elsefirst, buff, indent, 1);
211 }
212 else {
213 PrintIndent(buff, indent);
214 buff << "else\n";
215 if (ctx->debug) {
216 PrintIndent(buff, indent + 1);
217 buff << "-- AstStatement type=IF_ELSE_STMT line=" << elsestmt->line << " size=" << elsesize << "\n";
218 }
219 PrintAstSub(ctx, elsestmt, buff, indent + 1);
220 PrintIndent(buff, indent);
221 buff << "end\n";
222 }
223 }
224
225 void PrintJmpDestStatement(GluaDecompileContextP ctx, AstStatement* stmt, std::stringstream &buff, int indent) {
226 if (ctx->debug) {

Callers 1

PrintAstStatementFunction · 0.85

Calls 2

PrintIndentFunction · 0.85
PrintAstSubFunction · 0.85

Tested by

no test coverage detected