github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/lib/base/dofile.go (about) 1 package base 2 3 import ( 4 rt "github.com/arnodel/golua/runtime" 5 ) 6 7 func dofile(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { 8 chunk, chunkName, err := loadChunk(t, c.Args()) 9 defer t.ReleaseBytes(len(chunk)) 10 if err != nil { 11 return nil, err 12 } 13 clos, err := t.LoadFromSourceOrCode(chunkName, chunk, "bt", rt.TableValue(t.GlobalEnv()), true) 14 if err != nil { 15 return nil, err 16 } 17 return clos.Continuation(t, c.Next()), nil 18 }