Traceback creates and pushes a traceback of the stack l1. If message is not nil it is appended at the beginning of the traceback. The level parameter tells at which level to start the traceback.
(l, l1 *State, message string, level int)
| 46 | // nil it is appended at the beginning of the traceback. The level parameter |
| 47 | // tells at which level to start the traceback. |
| 48 | func Traceback(l, l1 *State, message string, level int) { |
| 49 | const levels1, levels2 = 12, 10 |
| 50 | levels := countLevels(l1) |
| 51 | mark := 0 |
| 52 | if levels > levels1+levels2 { |
| 53 | mark = levels1 |
| 54 | } |
| 55 | buf := message |
| 56 | if buf != "" { |
| 57 | buf += "\n" |
| 58 | } |
| 59 | buf += "stack traceback:" |
| 60 | for f, ok := Stack(l1, level); ok; f, ok = Stack(l1, level) { |
| 61 | if level++; level == mark { |
| 62 | buf += "\n\t..." |
| 63 | level = levels - levels2 |
| 64 | } else { |
| 65 | d, _ := Info(l1, "Slnt", f) |
| 66 | buf += "\n\t" + d.ShortSource + ":" |
| 67 | if d.CurrentLine > 0 { |
| 68 | buf += fmt.Sprintf("%d:", d.CurrentLine) |
| 69 | } |
| 70 | buf += " in " + functionName(l, d) |
| 71 | if d.IsTailCall { |
| 72 | buf += "\n\t(...tail calls...)" |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | l.PushString(buf) |
| 77 | } |
| 78 | |
| 79 | // MetaField pushes onto the stack the field event from the metatable of the |
| 80 | // object at index. If the object does not have a metatable, or if the |
no test coverage detected
searching dependent graphs…