| 4496 | } |
| 4497 | |
| 4498 | void PrintWhileDo(WhileInstruction * instr) |
| 4499 | { |
| 4500 | int HeaderBlockLabel = ++ctx.CurrentID; |
| 4501 | int ConditionBlockLabel = ++ctx.CurrentID; |
| 4502 | int BodyBlockLabel = ++ctx.CurrentID; |
| 4503 | int UpdateBlockLabel = ++ctx.CurrentID; |
| 4504 | int MergeBlockLabel = ++ctx.CurrentID; |
| 4505 | |
| 4506 | ctx.AddInstrBranch(HeaderBlockLabel); |
| 4507 | |
| 4508 | // header block |
| 4509 | ctx.AddInstrLabel_AtFunctionBody(HeaderBlockLabel); |
| 4510 | ctx.AddInstrLoopMerge(MergeBlockLabel, UpdateBlockLabel); |
| 4511 | ctx.AddInstrBranch(ConditionBlockLabel); |
| 4512 | |
| 4513 | // condition block |
| 4514 | ctx.PushScope(); |
| 4515 | ctx.AddInstrLabel_AtFunctionBody(ConditionBlockLabel); |
| 4516 | GenerateCode(instr->ConditionCode.Ptr(), ConditionBlockLabel, true); |
| 4517 | int conditionID = GetOperandValue(instr->ConditionCode->GetLastInstruction()->As<ReturnInstruction>()->Operand.Ptr()); |
| 4518 | conditionID = ctx.ConvertBasicType( |
| 4519 | conditionID, |
| 4520 | ctx.IDInfos[conditionID]().GetILType(), |
| 4521 | GetTypeFromString("bool") |
| 4522 | ); |
| 4523 | ctx.AddInstrBranchConditional(conditionID, BodyBlockLabel, MergeBlockLabel); |
| 4524 | ctx.PopScope(); |
| 4525 | |
| 4526 | // body block |
| 4527 | ctx.PushScope(); |
| 4528 | ctx.AddInstrLabel_AtFunctionBody(BodyBlockLabel); |
| 4529 | ctx.StackMergeBlock.Add(MergeBlockLabel); |
| 4530 | ctx.StackContinueBlock.Add(UpdateBlockLabel); |
| 4531 | GenerateCode(instr->BodyCode.Ptr(), BodyBlockLabel); |
| 4532 | ctx.StackMergeBlock.RemoveAt(ctx.StackMergeBlock.Count() - 1); |
| 4533 | ctx.StackContinueBlock.RemoveAt(ctx.StackContinueBlock.Count() - 1); |
| 4534 | ctx.AddInstrBranch(UpdateBlockLabel); |
| 4535 | ctx.PopScope(); |
| 4536 | |
| 4537 | // update block (empty) |
| 4538 | ctx.AddInstrLabel_AtFunctionBody(UpdateBlockLabel); |
| 4539 | ctx.AddInstrBranch(HeaderBlockLabel); |
| 4540 | |
| 4541 | // merge block |
| 4542 | ctx.AddInstrLabel_AtFunctionBody(MergeBlockLabel); |
| 4543 | } |
| 4544 | |
| 4545 | void PrintDoWhile(DoInstruction * instr) |
| 4546 | { |
nothing calls this directly
no test coverage detected