public void WriteTo(TranslationWriter writer)
 {
     writer.WriteControlStatementToTranslation("while ");
     writer.WriteToTranslation('(');
     writer.WriteKeywordToTranslation("true");
     writer.WriteToTranslation(')');
     _loopBodyTranslation.WriteTo(writer);
 }
Beispiel #2
0
        public void WriteTo(TranslationWriter writer)
        {
            writer.WriteControlStatementToTranslation(_switch);
            _valueTranslation.WriteInParentheses(writer);
            writer.WriteOpeningBraceToTranslation();

            for (var i = 0; ;)
            {
                var caseTestValueTranslations = _caseTestValueTranslations[i];

                for (int j = 0, l = caseTestValueTranslations.Length; ;)
                {
                    writer.WriteControlStatementToTranslation(_case);
                    caseTestValueTranslations[j].WriteTo(writer);
                    writer.WriteToTranslation(':');
                    writer.WriteNewLineToTranslation();

                    ++j;

                    if (j == l)
                    {
                        break;
                    }
                }

                WriteCaseBody(_caseTranslations[i], writer);

                ++i;

                if (i == _casesCount)
                {
                    break;
                }

                writer.WriteNewLineToTranslation();
                writer.WriteNewLineToTranslation();
            }

            WriteDefaultIfPresent(writer);

            writer.WriteClosingBraceToTranslation();
        }
Beispiel #3
0
            public override void WriteTo(TranslationWriter writer)
            {
                WriteIfStatement(writer);
                writer.WriteNewLineToTranslation();
                writer.WriteControlStatementToTranslation("else");

                if (_isElseIf)
                {
                    writer.WriteSpaceToTranslation();
                }

                IfFalseTranslation.WriteTo(writer);
            }
Beispiel #4
0
        private void WriteDefaultIfPresent(TranslationWriter writer)
        {
            if (_defaultCaseTranslation == null)
            {
                return;
            }

            writer.WriteNewLineToTranslation();
            writer.WriteNewLineToTranslation();
            writer.WriteControlStatementToTranslation("default:");
            writer.WriteNewLineToTranslation();

            WriteCaseBody(_defaultCaseTranslation, writer);
        }
Beispiel #5
0
        private static void WriteCaseBody(ITranslation bodyTranslation, TranslationWriter writer)
        {
            writer.Indent();

            bodyTranslation.WriteTo(writer);

            if (WriteBreak(bodyTranslation))
            {
                writer.WriteNewLineToTranslation();
                writer.WriteControlStatementToTranslation("break;");
            }

            writer.Unindent();
        }
Beispiel #6
0
 public static void WriteReturnToTranslation(this TranslationWriter writer)
 => writer.WriteControlStatementToTranslation("return ");
Beispiel #7
0
 protected void WriteIfStatement(TranslationWriter writer)
 {
     writer.WriteControlStatementToTranslation("if ");
     TestTranslation.WriteInParentheses(writer);
     IfTrueTranslation.WriteTo(writer);
 }
 public void WriteTo(TranslationWriter writer)
 {
     writer.WriteControlStatementToTranslation(_statement);
     writer.WriteToTranslation(';');
 }
 public void WriteTo(TranslationWriter writer)
 {
     writer.WriteControlStatementToTranslation("goto ");
     writer.WriteToTranslation(_labelName);
     writer.WriteToTranslation(';');
 }