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

Function Compile

compile.go:1849–1870  ·  view source on GitHub ↗

}}}

(chunk []ast.Stmt, name string)

Source from the content-addressed store, hash-verified

1847} // }}}
1848
1849func Compile(chunk []ast.Stmt, name string) (proto *FunctionProto, err error) { // {{{
1850 defer func() {
1851 if rcv := recover(); rcv != nil {
1852 if _, ok := rcv.(*CompileError); ok {
1853 err = rcv.(error)
1854 } else {
1855 panic(rcv)
1856 }
1857 }
1858 }()
1859 err = nil
1860 parlist := &ast.ParList{HasVargs: true, Names: []string{}}
1861 funcexpr := &ast.FunctionExpr{ParList: parlist, Stmts: chunk}
1862 if len(chunk) > 0 {
1863 funcexpr.SetLastLine(sline(chunk[0]))
1864 funcexpr.SetLastLine(eline(chunk[len(chunk)-1]) + 1)
1865 }
1866 context := newFuncContext(name, nil)
1867 compileFunctionExpr(context, funcexpr, ecnone(0))
1868 proto = context.Proto
1869 return
1870} // }}}

Callers 3

LoadMethod · 0.85
LoadMethod · 0.85
testScriptCompileFunction · 0.85

Calls 6

slineFunction · 0.85
elineFunction · 0.85
newFuncContextFunction · 0.85
compileFunctionExprFunction · 0.85
ecnoneFunction · 0.85
SetLastLineMethod · 0.65

Tested by 1

testScriptCompileFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…