zhangjinkun 9 سال پیش
والد
کامیت
2c0cc071e7
1فایلهای تغییر یافته به همراه26 افزوده شده و 23 حذف شده
  1. 26 23
      common/src/github.com/yuin/gopher-lua/state.go

+ 26 - 23
common/src/github.com/yuin/gopher-lua/state.go

@@ -442,32 +442,35 @@ func (ls *LState) where(level int, skipg bool) string {
 }
 
 func (ls *LState) stackTrace(level int) string {
-	buf := []string{}
-	header := "stack traceback:"
-	if ls.currentFrame != nil {
-		i := 0
-		for dbg, ok := ls.GetStack(i); ok; dbg, ok = ls.GetStack(i) {
-			cf := dbg.frame
-			buf = append(buf, fmt.Sprintf("\t%v in %v", ls.Where(i), ls.formattedFrameFuncName(cf)))
-			if !cf.Fn.IsG && cf.TailCall > 0 {
-				for tc := cf.TailCall; tc > 0; tc-- {
-					buf = append(buf, "\t(tailcall): ?")
-					i++
+	return ls.ScriptFileName + "出错!"
+	/*
+		buf := []string{}
+		header := "stack traceback:"
+		if ls.currentFrame != nil {
+			i := 0
+			for dbg, ok := ls.GetStack(i); ok; dbg, ok = ls.GetStack(i) {
+				cf := dbg.frame
+				buf = append(buf, fmt.Sprintf("\t%v in %v", ls.Where(i), ls.formattedFrameFuncName(cf)))
+				if !cf.Fn.IsG && cf.TailCall > 0 {
+					for tc := cf.TailCall; tc > 0; tc-- {
+						buf = append(buf, "\t(tailcall): ?")
+						i++
+					}
 				}
+				i++
 			}
-			i++
 		}
-	}
-	buf = append(buf, fmt.Sprintf("\t%v: %v", "[G]", "?"))
-	buf = buf[intMax(0, intMin(level, len(buf))):len(buf)]
-	if len(buf) > 20 {
-		newbuf := make([]string, 0, 20)
-		newbuf = append(newbuf, buf[0:7]...)
-		newbuf = append(newbuf, "\t...")
-		newbuf = append(newbuf, buf[len(buf)-7:len(buf)]...)
-		buf = newbuf
-	}
-	return fmt.Sprintf("%s\n%s", header, strings.Join(buf, "\n"))
+		buf = append(buf, fmt.Sprintf("\t%v: %v", "[G]", "?"))
+		buf = buf[intMax(0, intMin(level, len(buf))):len(buf)]
+		if len(buf) > 20 {
+			newbuf := make([]string, 0, 20)
+			newbuf = append(newbuf, buf[0:7]...)
+			newbuf = append(newbuf, "\t...")
+			newbuf = append(newbuf, buf[len(buf)-7:len(buf)]...)
+			buf = newbuf
+		}
+		return fmt.Sprintf("%s\n%s", header, strings.Join(buf, "\n"))
+	*/
 }
 
 func (ls *LState) formattedFrameFuncName(fr *callFrame) string {