public override void Decode()
 {
     tryBlock = DecodeLineInfo();
     int length = DecodeLength();
     var finallyBlock = DecodeNode();
     StringBuilder b = new StringBuilder();
     string label = tryBlock.CreateLabelStmt();
     string body = tryBlock.CreateBody();
     b.AppendLine(label + "try {");
     b.AppendLine(body);
     int i = length;
     while (i > 0)
     {
         var arg = DecodeId();
         var exceptionFilter = DecodeNode();
         var catchBlock = DecodeNode();
         b.Append("} catch (" + arg);
         if (exceptionFilter != null)
         {
             b.Append(" if " + exceptionFilter.PrettyPrint());
         }
         b.AppendLine(") {");
         b.Append(catchBlock == null ? string.Empty : catchBlock.PrettyPrint());
         b.AppendLine("");
         i--;
     }
     if (finallyBlock != null)
     {
         b.AppendLine("} finally {");
         b.Append(finallyBlock.PrettyPrint());
         b.AppendLine("");
     }
     b.Append("}");
     expr = b.ToString();
 }
Esempio n. 2
0
        public override string PrettyPrint()
        {
            string label = lineInfo.CreateLabelStmt();
            string name  = "debugger";

            return(label + name);
        }
Esempio n. 3
0
        public override string PrettyPrint()
        {
            string returnExpr = exprInfo == null ? "" : " " + exprInfo.PrettyPrint();
            string label      = lineInfo.CreateLabelStmt();
            string stmt       = label + "return" + returnExpr;

            stmt += ";";
            return(stmt);
        }
Esempio n. 4
0
        void BuildIf(StringBuilder output)
        {
            string label    = body.CreateLabelStmt();
            string bodyExpr = body.CreateBody();
            string testExpr = test.PrettyPrint();

            output.AppendLine(string.Format("{0}if ({1}) {{", label, testExpr));
            output.AppendLine(bodyExpr);
            output.Append("}");
        }
Esempio n. 5
0
        public override string PrettyPrint()
        {
            string        label = bodyInfo.CreateLabelStmt();
            string        body  = bodyInfo.CreateBody();
            StringBuilder b     = new StringBuilder();

            b.AppendLine(string.Format("{0}with ({1}) {{", label, objName));
            b.AppendLine(body);
            b.Append("}");
            return(b.ToString());
        }
Esempio n. 6
0
        public override string PrettyPrint()
        {
            string        label = bodyInfo.CreateLabelStmt();
            string        body  = bodyInfo.CreateBody();
            StringBuilder b     = new StringBuilder();

            b.AppendLine(string.Format("{0}for (var {1} in {2}) {{", label, loopVarName, objExpr));
            b.AppendLine(body);
            b.Append("}");
            return(b.ToString());
        }
Esempio n. 7
0
        public override string PrettyPrint()
        {
            var           label    = body.CreateLabelStmt();
            var           bodyExpr = body.CreateBody();
            StringBuilder b        = new StringBuilder();

            b.AppendLine(label + "do {");
            b.AppendLine("  " + bodyExpr);
            b.Append("} while (" + test + ")");
            return(b.ToString());
        }
        public override string PrettyPrint()
        {
            string        label    = bodyInfo.CreateLabelStmt();
            string        body     = bodyInfo.CreateBody();
            string        loopName = isForEachLoop ? "for each" : "for";
            StringBuilder b        = new StringBuilder();

            b.AppendLine(string.Format("{0}{1} (var {2} in {3}) {{", label, loopName, loopVarName, objExpr));
            b.AppendLine(body);
            b.Append("}");
            return(b.ToString());
        }
Esempio n. 9
0
        public override string PrettyPrint()
        {
            var           cond  = condInfo == null ? "true" : condInfo.PrettyPrint();
            string        label = bodyInfo.CreateLabelStmt();
            var           body  = bodyInfo.CreateBody();
            StringBuilder b     = new StringBuilder();

            b.AppendLine(string.Format("{0}while ({1}) {{", label, cond));
            b.AppendLine(body);
            b.Append("}");
            return(b.ToString());
        }
Esempio n. 10
0
        public override string PrettyPrint()
        {
            string        label       = bodyInfo.CreateLabelStmt();
            string        body        = bodyInfo.CreateBody();
            string        loopVarName = loopVarInfo == null ? null : loopVarInfo.PrettyPrint();
            string        upperBound  = upperBoundInfo == null ? null : upperBoundInfo.PrettyPrint();
            StringBuilder b           = new StringBuilder();

            b.AppendLine(string.Format("{0}for (var {1} = {2};{1} {3} {4}; {1} += {5}) {{", label, loopVarName, initExpr, compOp, upperBound, stepSize));
            b.AppendLine(body);
            b.Append("}");
            return(b.ToString());
        }
Esempio n. 11
0
        public override string PrettyPrint()
        {
            var           label = bodyInfo.CreateLabelStmt();
            string        body  = bodyInfo.CreateBody();
            StringBuilder b     = new StringBuilder();

            b.AppendLine(string.Format("{0}for ({1}; {2}; {3}) {{",
                                       label,
                                       initInfo == null ? "" : initInfo.PrettyPrint(),
                                       testInfo == null ? "" : testInfo.PrettyPrint(),
                                       updateInfo == null ? "" : updateInfo.PrettyPrint()));
            b.AppendLine(body);
            b.Append("}");
            return(b.ToString());
        }
Esempio n. 12
0
        public override string PrettyPrint()
        {
            string jmp = labelInfo.CreateLabelStmt();

            if (isBreakStatement)
            {
                jmp += "break " + jmpLocation;
            }
            else
            {
                jmp += "continue " + jmpLocation;
            }
            jmp += ";";
            return(jmp);
        }
Esempio n. 13
0
        public override string PrettyPrint()
        {
            string labels            = lineInfo.CreateLabelStmt();
            var    statementsOrdered = statements.OrderBy(s => ((IStatement)s).LineNumber);
            var    statementsPretty  = statementsOrdered.Select(f =>
            {
                bool requiresSemicolon = f.NodeType == NodeType.ExprNode;
                string expr            = f.PrettyPrint();
                if (requiresSemicolon)
                {
                    expr = expr + ";";
                }
                return(expr);
            }).ToList();
            string block = string.Join(Environment.NewLine, statementsPretty);

            return(labels + block);
        }
Esempio n. 14
0
        public override void Decode()
        {
            tryBlock = DecodeLineInfo();
            int           length       = DecodeLength();
            var           finallyBlock = DecodeNode();
            StringBuilder b            = new StringBuilder();
            string        label        = tryBlock.CreateLabelStmt();
            string        body         = tryBlock.CreateBody();

            b.AppendLine(label + "try {");
            b.AppendLine(body);
            int i = length;

            while (i > 0)
            {
                var arg             = DecodeId();
                var exceptionFilter = DecodeNode();
                var catchBlock      = DecodeNode();
                b.Append("} catch (" + arg);
                if (exceptionFilter != null)
                {
                    b.Append(" if " + exceptionFilter.PrettyPrint());
                }
                b.AppendLine(") {");
                b.Append(catchBlock == null ? string.Empty : catchBlock.PrettyPrint());
                b.AppendLine("");
                i--;
            }
            if (finallyBlock != null)
            {
                b.AppendLine("} finally {");
                b.Append(finallyBlock.PrettyPrint());
                b.AppendLine("");
            }
            b.Append("}");
            expr = b.ToString();
        }
Esempio n. 15
0
        public override string PrettyPrint()
        {
            string labels = lineInfo.CreateLabelStmt();

            return(labels + expr.PrettyPrint());
        }