Пример #1
0
        // private static void WriteDoWhileStatement(BoundDoWhileStatement node, IndentedTextWriter writer)
        // {
        //     writer.WriteKeyword("do");
        //     writer.WriteLine();
        //     writer.WriteNestedStatement(node.Body);
        //     writer.WriteKeyword("while ");
        //     node.Condition.WriteTo(writer);
        //     writer.WriteLine();
        // }

        private static void WriteForStatement(BoundForStatement node, IndentedTextWriter writer)
        {
            writer.WriteKeyword("for ");
            writer.WriteIdentifier(node.Variable.Name);
            writer.WritePunctuation(" = ");
            node.LowerBound.WriteTo(writer);
            writer.WriteKeyword(" to ");
            node.UpperBound.WriteTo(writer);
            writer.WriteLine();
            writer.WriteNestedStatement(node.Body);
        }
Пример #2
0
        protected virtual BoundStatement RewriteForStatement(BoundForStatement node)
        {
            var lowerBound = RewriteExpression(node.LowerBound);
            var upperBound = RewriteExpression(node.UpperBound);
            var body       = RewriteStatement(node.Body);

            if (lowerBound == node.LowerBound && upperBound == node.LowerBound && body == node.Body)
            {
                return(node);
            }

            return(new BoundForStatement(node.Variable, lowerBound, upperBound, body));
        }
Пример #3
0
        protected virtual BoundStatement RewriteForStatement(BoundForStatement node)
        {
            var lowerBound = RewriteExpression(node.LowerBound);
            var upperBound = RewriteExpression(node.UpperBound);
            var Itterator  = RewriteExpression(node.Itterator);
            var body       = RewriteStatement(node.Body);

            if (lowerBound == node.LowerBound && upperBound == node.LowerBound && body == node.Body)
            {
                return(node);
            }

            return(new BoundForStatement(node.Variable, lowerBound, upperBound, Itterator, body, node.BodyLabel, node.BreakLabel, node.ContinueLabel));
        }