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();
 }
Example #2
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("}");
        }
Example #3
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());
        }
Example #4
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());
        }
Example #5
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());
        }
Example #7
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());
        }
Example #8
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());
        }
Example #9
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());
        }
Example #10
0
        public override string PrettyPrint()
        {
            bool   isHeader = signature.Header5 == 1;
            string body     = bodyInfo.CreateBody();

            // Header seems to imply an automatically added "wrapper" function which is not really needed.
            if (isHeader)
            {
                return(body);
            }
            // Filter out parameters that are actually local variables which for some reason count as parameters.
            var           paramList  = signature.Parameter.OrderBy(p => p.Item2).Where(p => p.Item2 > 536870000 && p.Item2 < 540000000).Select(p => p.Item1).ToList();
            var           paramNames = string.Join(", ", paramList);
            StringBuilder b          = new StringBuilder();

            b.AppendLine(string.Format("function {0}({1}) {{", signature.Name, paramNames));
            b.AppendLine(body);
            b.Append("}");
            return(b.ToString());
        }
Example #11
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();
        }