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

Function baseLoad

baselib.go:170–196  ·  view source on GitHub ↗
(L *LState)

Source from the content-addressed store, hash-verified

168}
169
170func baseLoad(L *LState) int {
171 fn := L.CheckFunction(1)
172 chunkname := L.OptString(2, "?")
173 top := L.GetTop()
174 buf := []string{}
175 for {
176 L.SetTop(top)
177 L.Push(fn)
178 L.Call(0, 1)
179 ret := L.reg.Pop()
180 if ret == LNil {
181 break
182 } else if LVCanConvToString(ret) {
183 str := ret.String()
184 if len(str) > 0 {
185 buf = append(buf, string(str))
186 } else {
187 break
188 }
189 } else {
190 L.Push(LNil)
191 L.Push(LString("reader function must return a string"))
192 return 2
193 }
194 }
195 return loadaux(L, strings.NewReader(strings.Join(buf, "")), chunkname)
196}
197
198func baseLoadFile(L *LState) int {
199 var reader io.Reader

Callers

nothing calls this directly

Calls 11

LVCanConvToStringFunction · 0.85
LStringTypeAlias · 0.85
loadauxFunction · 0.85
CheckFunctionMethod · 0.80
OptStringMethod · 0.80
PushMethod · 0.65
PopMethod · 0.65
StringMethod · 0.65
GetTopMethod · 0.45
SetTopMethod · 0.45
CallMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…