Пример #1
0
 public CodeConditionStatement(CodeExpression condition,
                               CodeStatement[] trueStatements,
                               CodeStatement[] falseStatements)
 {
     this.condition = condition;
     TrueStatements.AddRange(trueStatements);
     FalseStatements.AddRange(falseStatements);
 }
Пример #2
0
        protected override void GenerateInner(CodeGenerator generator, CodeStatementEmitOptions emitOptions)
        {
            generator.WriteBlankLineBeforeEnteringBlock();
            generator.Write(TokenType.Keyword, "if");
            generator.Write(TokenType.Space, ' ');
            generator.Write(TokenType.Punctuation, '(');
            Condition.Generate(generator);
            generator.Write(TokenType.Punctuation, ')');
            if (TrueStatements.Count == 0 && FalseStatements.Count == 0)
            {
                generator.WriteEmptyBlock();
            }
            else
            {
                generator.WriteOpeningBrace();
                generator.Indent++;
                generator.EnterLocalScope();
                TrueStatements.ReserveLocals(generator, default(CodeStatementEmitOptions));
                TrueStatements.Generate(generator, default(CodeStatementEmitOptions));
                generator.ExitLocalScope();
                generator.Indent--;

                if (FalseStatements.Count > 0)
                {
                    generator.WriteMiddleClosingBrace();
                    generator.Write(TokenType.Keyword, "else");
                    generator.WriteOpeningBrace();
                    generator.Indent++;
                    generator.EnterLocalScope();
                    FalseStatements.ReserveLocals(generator, default(CodeStatementEmitOptions));
                    FalseStatements.Generate(generator, default(CodeStatementEmitOptions));
                    generator.ExitLocalScope();
                    generator.Indent--;
                }
                generator.WriteClosingBrace();
            }
        }
 public CodeConditionStatement(ILInstruction inline, CodeExpression condition, CodeStatement[] trueStatements, CodeStatement[] falseStatements) : base(inline)
 {
     Condition = condition;
     TrueStatements.AddRange(trueStatements);
     FalseStatements.AddRange(falseStatements);
 }
Пример #4
0
 public CodeIfStatement(CodeExpression condition, IEnumerable <CodeStatement> trueStatements, IEnumerable <CodeStatement> falseStatements)
 {
     Condition = condition;
     TrueStatements.AddRange(trueStatements);
     FalseStatements.AddRange(falseStatements);
 }