Exemple #1
0
        public static string traceback()
        {
            var builder = new StringBuilder();

            var stackFrame = LuaExceptionData.GetStackTrace(new StackTrace()).Where(x =>
                                                                                    x.Type == LuaStackFrameType.Lua);

            Script script = null;

            foreach (var item in stackFrame)
            {
                if (script == null)
                {
                    script = ScriptService.Scripts[item.FileName];
                }

                builder.Append($"Script '{script.GetFullName()}', Line {item.LineNumber}");

                if (item.MethodName != item.FileName)
                {
                    var methodname = item.MethodName.Substring(item.FileName.Length + 1);
                    builder.Append(" " + methodname);
                }

                builder.AppendLine();
            }

            builder.Append("Stack End");

            return(builder.ToString());
        }
Exemple #2
0
        public static object debugger()
        {
            var id =
                LuaExceptionData.GetStackTrace(new StackTrace())
                .First(x => x.Type == LuaStackFrameType.Lua)
                .FileName;

            var script = ScriptService.Scripts[id];

            return(script.Debugger);
        }
Exemple #3
0
 private object TestAssert(object test, string sMessage)
 {
     if (!(bool)Lua.RtConvertValue(test, typeof(bool)))
     {
         LuaStackFrame frame = LuaExceptionData.GetStackTrace(new StackTrace(0, true)).FirstOrDefault(c => c.Type == LuaStackFrameType.Lua);
         if (frame == null)
         {
             Assert.IsTrue(false, "Test failed (unknown position) " + sMessage);
         }
         else
         {
             Assert.IsTrue(false, "Test failed at line {0}, column {1}, file {2} {3}", frame.LineNumber, frame.ColumnNumber, frame.FileName, sMessage);
         }
     }
     return(test);
 }