MCPcopy Index your code
hub / github.com/yuin/gopher-lua / GetInfo

Method GetInfo

state.go:1746–1801  ·  view source on GitHub ↗
(what string, dbg *Debug, fn LValue)

Source from the content-addressed store, hash-verified

1744}
1745
1746func (ls *LState) GetInfo(what string, dbg *Debug, fn LValue) (LValue, error) {
1747 if !strings.HasPrefix(what, ">") {
1748 fn = dbg.frame.Fn
1749 } else {
1750 what = what[1:]
1751 }
1752 f, ok := fn.(*LFunction)
1753 if !ok {
1754 return LNil, newApiErrorS(ApiErrorRun, "can not get debug info(an object in not a function)")
1755 }
1756
1757 retfn := false
1758 for _, c := range what {
1759 switch c {
1760 case 'f':
1761 retfn = true
1762 case 'S':
1763 if dbg.frame != nil && dbg.frame.Parent == nil {
1764 dbg.What = "main"
1765 } else if f.IsG {
1766 dbg.What = "G"
1767 } else if dbg.frame != nil && dbg.frame.TailCall > 0 {
1768 dbg.What = "tail"
1769 } else {
1770 dbg.What = "Lua"
1771 }
1772 if !f.IsG {
1773 dbg.Source = f.Proto.SourceName
1774 dbg.LineDefined = f.Proto.LineDefined
1775 dbg.LastLineDefined = f.Proto.LastLineDefined
1776 }
1777 case 'l':
1778 if !f.IsG && dbg.frame != nil {
1779 if dbg.frame.Pc > 0 {
1780 dbg.CurrentLine = f.Proto.DbgSourcePositions[dbg.frame.Pc-1]
1781 }
1782 } else {
1783 dbg.CurrentLine = -1
1784 }
1785 case 'u':
1786 dbg.NUpvalues = len(f.Upvalues)
1787 case 'n':
1788 if dbg.frame != nil {
1789 dbg.Name = ls.rawFrameFuncName(dbg.frame)
1790 }
1791 default:
1792 return LNil, newApiErrorS(ApiErrorRun, "invalid what: "+string(c))
1793 }
1794 }
1795
1796 if retfn {
1797 return f, nil
1798 }
1799 return LNil, nil
1800
1801}
1802
1803func (ls *LState) GetStack(level int) (*Debug, bool) {

Callers 1

debugGetInfoFunction · 0.45

Calls 2

rawFrameFuncNameMethod · 0.95
newApiErrorSFunction · 0.70

Tested by

no test coverage detected