示例#1
0
        public override void Format(PositionedWriter writer, bool semi)
        {
            writer.Write("[");
            var first    = true;
            var indented = false;

            foreach (var elem in this.Elements)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    writer.Write(", ");
                }
                if (writer.ReachLineEnd())
                {
                    if (!indented)
                    {
                        indented = true;
                        writer.IndentForward();
                    }
                    writer.NewLine();
                    writer.Indent();
                }
                elem.Format(writer, semi);
            }
            if (indented)
            {
                writer.IndentBack();
            }
            writer.Write("]");
        }
示例#2
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.Write("catch(");
     this.Param.Format(writer, semi);
     writer.Write(")");
     this.Body.Format(writer, semi);
 }
示例#3
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     if (semi)
     {
         writer.Write(";");
     }
 }
示例#4
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.Write("{");
     if (this.Properties.Length > 0)
     {
         writer.IndentForward();
         var first = true;
         foreach (var p in this.Properties)
         {
             if (first)
             {
                 first = false;
             }
             else
             {
                 writer.Write(", ");
             }
             writer.NewLine();
             writer.Indent();
             p.Format(writer, semi);
         }
         writer.NewLine();
         writer.IndentBack();
         writer.Indent();
     }
     writer.Write("}");
 }
示例#5
0
        public override void Format(PositionedWriter writer, bool semi)
        {
            writer.Write("<");
            this.Name.Format(writer, semi);
            var indented = false;

            foreach (var attr in this.Attributes)
            {
                writer.Write(" ");
                if (writer.ReachLineEnd())
                {
                    if (!indented)
                    {
                        indented = true;
                        writer.IndentForward();
                    }
                    writer.NewLine();
                    writer.Indent();
                }
                attr.Format(writer, semi);
            }
            if (indented)
            {
                writer.IndentBack();
            }
            if (this.SelfClosing)
            {
                writer.Write("/>");
            }
            else
            {
                writer.Write(">");
            }
        }
示例#6
0
        public override void Format(PositionedWriter writer, bool semi)
        {
            if (this.Callee is FunctionExpression)
            {
                writer.Write("(");
                this.Callee.Format(writer, semi);
                writer.Write(")");
            }
            else
            {
                this.Callee.Format(writer, semi);
            }
            writer.Write("(");
            var first = true;

            foreach (var a  in this.Arguments)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    writer.Write(", ");
                }
                a.Format(writer, semi);
            }
            writer.Write(")");
        }
示例#7
0
        public override void Format(PositionedWriter writer, bool semi)
        {
            writer.Write("function ");
            if (this.Id != null)
            {
                this.Id.Format(writer, semi);
            }
            writer.Write("(");
            var first = true;

            foreach (var p in this.Params)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    writer.Write(", ");
                }
                p.Format(writer, semi);
            }
            writer.Write(")");
            this.Body.Format(writer, semi);
        }
示例#8
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     foreach (var statement in Body)
     {
         statement.Format(writer, semi);
         writer.NewLine();
     }
 }
示例#9
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.Write("for(");
     this.Left.Format(writer, semi);
     writer.Write("in");
     this.Right.Format(writer, semi);
     this.Body.Format(writer, semi);
 }
示例#10
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     this.Test.Format(writer, semi);
     writer.Write(" ? ");
     this.Consequent.Format(writer, semi);
     writer.Write(" : ");
     this.Alternate.Format(writer, semi);
 }
示例#11
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     this.Expression.Format(writer, semi);
     if (semi)
     {
         writer.Write(";");
     }
 }
示例#12
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     this.Left.Format(writer, semi);
     writer.Write(" ");
     writer.Write(this.Op);
     writer.Write(" ");
     this.Right.Format(writer, semi);
 }
示例#13
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.Write("throw ");
     this.Argument.Format(writer, semi);
     if (semi)
     {
         writer.Write(";");
     }
 }
示例#14
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     this.Label.Format(writer, semi);
     writer.WriteLine(": ");
     writer.IndentForward();
     writer.Indent();
     this.Body.Format(writer, semi);
     writer.IndentBack();
 }
示例#15
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     this.Id.Format(writer, semi);
     if (this.Init != null)
     {
         writer.Write(" = ");
         this.Init.Format(writer, semi);
     }
 }
示例#16
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.Write("do");
     this.Body.Format(writer, semi);
     writer.NewLine();
     writer.Indent();
     writer.Write("while(");
     this.Test.Format(writer, semi);
     writer.Write(")");
 }
示例#17
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     if (semi)
     {
         writer.Write("debugger;");
     }
     else
     {
         writer.Write("debugger");
     }
 }
示例#18
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.Write("for(");
     this.Init.Format(writer, false);
     writer.Write(";");
     this.Test.Format(writer, false);
     writer.Write(";");
     this.Update.Format(writer, false);
     writer.Write(";)");
     this.Body.Format(writer, semi);
 }
示例#19
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     if (semi)
     {
         writer.Write("continue;");
     }
     else
     {
         writer.Write("continue");
     }
 }
示例#20
0
        public string Format(bool semi)
        {
            var writer = new PositionedWriter();

            foreach (var statement in Body)
            {
                statement.Format(writer, semi);
                writer.NewLine();
            }
            return(writer.ToString());
        }
示例#21
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     if (this.Prefix)
     {
         writer.Write(this.Op);
         this.Argument.Format(writer, semi);
     }
     else
     {
         this.Argument.Format(writer, semi);
         writer.Write(this.Op);
     }
 }
示例#22
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.Write("return");
     if (this.Argument != null)
     {
         writer.Write(" ");
         this.Argument.Format(writer, semi);
     }
     if (semi)
     {
         writer.Write(";");
     }
 }
示例#23
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.WriteLine("{");
     writer.IndentForward();
     foreach (var statement in this.Body)
     {
         writer.Indent();
         statement.Format(writer, semi);
         writer.NewLine();
     }
     writer.IndentBack();
     writer.Indent();
     writer.Write("}");
 }
示例#24
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.Write("if(");
     this.Test.Format(writer, semi);
     writer.Write(")");
     this.Consequent.Format(writer, semi);
     if (this.Alternate != null)
     {
         writer.NewLine();
         writer.Indent();
         writer.Write("else ");
         this.Alternate.Format(writer, semi);
     }
 }
示例#25
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     this.Object.Format(writer, semi);
     if (this.Computed)
     {
         writer.Write("[");
         this.Property.Format(writer, semi);
         writer.Write("]");
     }
     else
     {
         writer.Write(".");
         this.Property.Format(writer, semi);
     }
 }
示例#26
0
        protected static void SpacePad(PositionedWriter writer, int length)
        {
            while (length >= 32)
            {
                writer.Write(SPACES[5]);
                length -= 32;
            }

            for (int i = 4; i >= 0; i--)
            {
                if ((length & (1 << i)) != 0)
                {
                    writer.Write(SPACES[i]);
                }
            }
        }
示例#27
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.Write("switch(");
     this.Discriminant.Format(writer, semi);
     writer.Write("){");
     writer.NewLine();
     writer.IndentForward();
     foreach (var c in this.Cases)
     {
         writer.Indent();
         c.Format(writer, semi);
         writer.NewLine();
     }
     writer.IndentBack();
     writer.Indent();
     writer.Write("}");
 }
示例#28
0
        public override void Format(PositionedWriter writer, bool semi)
        {
            var first = true;

            foreach (var expr in this.Expressions)
            {
                if (first)
                {
                    first = false;
                    expr.Format(writer, semi);
                }
                else
                {
                    writer.Write(", ");
                    expr.Format(writer, semi);
                }
            }
        }
示例#29
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     writer.Write("try ");
     this.Block.Format(writer, semi);
     if (this.Handler != null)
     {
         writer.NewLine();
         writer.Indent();
         this.Handler.Format(writer, semi);
         writer.NewLine();
     }
     if (this.Finalizer != null)
     {
         writer.Indent();
         writer.Write("finally");
         this.Finalizer.Format(writer, semi);
     }
 }
示例#30
0
 public override void Format(PositionedWriter writer, bool semi)
 {
     this.OpeningElement.Format(writer, semi);
     if (this.Children.Length > 0)
     {
         writer.IndentForward();
         foreach (var child in this.Children)
         {
             writer.NewLine();
             writer.Indent();
             child.Format(writer, semi);
         }
         writer.IndentBack();
     }
     if (this.ClosingElement != null)
     {
         writer.NewLine();
         writer.Indent();
         this.ClosingElement.Format(writer, semi);
     }
 }