Пример #1
0
        protected override void GenerateCode(CodeGenContext context)
        {
            context.SetPrettyPrintProlog(initText);
            Initialization?.GenerateCodeForValueWithPrettyPrint(context, EvaluationIntention.SideEffectsOnly);

            var loopTop = context.CreateLabel();

            context.PlaceLabelHere(loopTop);

            var cl = context.CreateLabel();
            var bl = context.CreateLabel();

            ContinueLabel = cl;
            BreakLabel    = bl;

            context.SetPrettyPrintProlog(condText);
            Condition?.GenerateCodeForConditionalBranchWithPrettyPrint(context, bl, false);

            context.SetPrettyPrintProlog(bodyText);
            Body.GenerateCodeWithPrettyPrint(context);

            context.PlaceLabelHere(cl);

            context.SetPrettyPrintProlog(incrText);
            Increment?.GenerateCodeForValueWithPrettyPrint(context, EvaluationIntention.SideEffectsOnly);

            if (Body.EndsLive())
            {
                context.GenerateUnconditionalBranch(loopTop);
            }

            context.PlaceLabelHere(bl);
        }