| 4543 | } |
| 4544 | |
| 4545 | void PrintDoWhile(DoInstruction * instr) |
| 4546 | { |
| 4547 | int HeaderBlockLabel = ++ctx.CurrentID; |
| 4548 | int BodyBlockLabel = ++ctx.CurrentID; |
| 4549 | int ConditionBlockLabel = ++ctx.CurrentID; |
| 4550 | int MergeBlockLabel = ++ctx.CurrentID; |
| 4551 | |
| 4552 | //ctx.FunctionBody << LR"(OpBranch %)" << HeaderBlockLabel << EndLine; |
| 4553 | ctx.AddInstrBranch(HeaderBlockLabel); |
| 4554 | |
| 4555 | // header block |
| 4556 | ctx.AddInstrLabel_AtFunctionBody(HeaderBlockLabel); |
| 4557 | ctx.AddInstrLoopMerge(MergeBlockLabel, ConditionBlockLabel); |
| 4558 | ctx.AddInstrBranch(BodyBlockLabel); |
| 4559 | |
| 4560 | // body block |
| 4561 | ctx.PushScope(); |
| 4562 | ctx.AddInstrLabel_AtFunctionBody(BodyBlockLabel); |
| 4563 | ctx.StackMergeBlock.Add(MergeBlockLabel); |
| 4564 | ctx.StackContinueBlock.Add(ConditionBlockLabel); |
| 4565 | GenerateCode(instr->BodyCode.Ptr(), BodyBlockLabel); |
| 4566 | ctx.StackMergeBlock.RemoveAt(ctx.StackMergeBlock.Count() - 1); |
| 4567 | ctx.StackContinueBlock.RemoveAt(ctx.StackContinueBlock.Count() - 1); |
| 4568 | ctx.AddInstrBranch(ConditionBlockLabel); |
| 4569 | ctx.PopScope(); |
| 4570 | |
| 4571 | // condition block |
| 4572 | ctx.PushScope(); |
| 4573 | ctx.AddInstrLabel_AtFunctionBody(ConditionBlockLabel); |
| 4574 | GenerateCode(instr->ConditionCode.Ptr(), ConditionBlockLabel, true); |
| 4575 | int conditionID = GetOperandValue(instr->ConditionCode->GetLastInstruction()->As<ReturnInstruction>()->Operand.Ptr()); |
| 4576 | conditionID = ctx.ConvertBasicType( |
| 4577 | conditionID, |
| 4578 | ctx.IDInfos[conditionID]().GetILType(), |
| 4579 | GetTypeFromString("bool") |
| 4580 | ); |
| 4581 | ctx.AddInstrBranchConditional(conditionID, HeaderBlockLabel, MergeBlockLabel); |
| 4582 | ctx.PopScope(); |
| 4583 | |
| 4584 | // merge block |
| 4585 | ctx.AddInstrLabel_AtFunctionBody(MergeBlockLabel); |
| 4586 | } |
| 4587 | |
| 4588 | void GenerateCode(CFGNode * code, int givenLabel = -1, bool LoopReturn = false) |
| 4589 | { |
nothing calls this directly
no test coverage detected