Пример #1
0
        public override void Print(Output output)
        {
            output.Print("for ");
            this.m_r.GetTarget(this.m_register + 3, this.Begin - 1).Print(output);
            var n = this.m_register + 2 + this.m_length;

            for (var r1 = this.m_register + 4; r1 <= n; r1++)
            {
                output.Print(", ");
                this.m_r.GetTarget(r1, this.Begin - 1).Print(output);
            }

            output.Print(" in ");

            // TODO: Optimize code
            this.PrintRecurse(this.m_r.GetValue(this.m_register, this.Begin - 1), output, 1);
            output.Print(" do");
            output.PrintLine();
            output.IncreaseIndent();
            PrintSequence(output, this.m_statements);
            output.DecreaseIndent();
            output.Print("end");
        }
Пример #2
0
        public override void Print(Output output)
        {
            output.Print("for ");
            this.m_r.GetTarget(this.m_register + 3, this.Begin - 1).Print(output);
            output.Print(" = ");
            this.m_r.GetValue(this.m_register, this.Begin - 1).Print(output);
            output.Print(", ");
            this.m_r.GetValue(this.m_register + 1, this.Begin - 1).Print(output);
            var step = this.m_r.GetValue(this.m_register + 2, this.Begin - 1);

            if (!step.IsInteger || step.AsInteger() != 1)
            {
                output.Print(", ");
                step.Print(output);
            }

            output.Print(" do");
            output.PrintLine();
            output.IncreaseIndent();
            PrintSequence(output, this.m_statements);
            output.DecreaseIndent();
            output.Print("end");
        }
Пример #3
0
        public override void Print(Output output)
        {
            this.m_entries.Sort();
            this.m_listLength = 1;
            if (this.m_entries.Count == 0)
            {
                output.Print("{}");
            }
            else
            {
                var lineBreak = (this.m_isList && this.m_entries.Count > 5) ||
                                (this.m_isObject && this.m_entries.Count > 2) ||
                                (!this.m_isObject);
                if (!lineBreak)
                {
                    foreach (var entry in this.m_entries)
                    {
                        var value = entry.Value;
                        if (!value.IsBrief)
                        {
                            lineBreak = true;
                            break;
                        }
                    }
                }

                output.Print("{");
                if (lineBreak)
                {
                    output.PrintLine();
                    output.IncreaseIndent();
                }

                this.PrintEntry(0, output);
                if (!this.m_entries[0].Value.IsMultiple)
                {
                    for (var i = 1; i < this.m_entries.Count; i++)
                    {
                        output.Print(",");
                        if (lineBreak)
                        {
                            output.PrintLine();
                        }
                        else
                        {
                            output.Print(" ");
                        }

                        this.PrintEntry(i, output);
                        if (this.m_entries[i].Value.IsMultiple)
                        {
                            break;
                        }
                    }
                }

                if (lineBreak)
                {
                    output.PrintLine();
                    output.DecreaseIndent();
                }

                output.Print("}");
            }
        }