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

Method Get

_state.go:1300–1337  ·  view source on GitHub ↗
(idx int)

Source from the content-addressed store, hash-verified

1298}
1299
1300func (ls *LState) Get(idx int) LValue {
1301 base := ls.currentLocalBase()
1302 if idx > 0 {
1303 reg := base + idx - 1
1304 if reg < ls.reg.Top() {
1305 return ls.reg.Get(reg)
1306 }
1307 return LNil
1308 } else if idx == 0 {
1309 return LNil
1310 } else if idx > RegistryIndex {
1311 tidx := ls.reg.Top() + idx
1312 if tidx < base {
1313 return LNil
1314 }
1315 return ls.reg.Get(tidx)
1316 } else {
1317 switch idx {
1318 case RegistryIndex:
1319 return ls.G.Registry
1320 case EnvironIndex:
1321 if ls.currentFrame == nil {
1322 return ls.Env
1323 }
1324 return ls.currentFrame.Fn.Env
1325 case GlobalsIndex:
1326 return ls.G.Global
1327 default:
1328 fn := ls.currentFrame.Fn
1329 index := GlobalsIndex - idx - 1
1330 if index < len(fn.Upvalues) {
1331 return fn.Upvalues[index].Value()
1332 }
1333 return LNil
1334 }
1335 }
1336 return LNil
1337}
1338
1339func (ls *LState) Push(value LValue) {
1340 ls.reg.Push(value)

Callers 15

ToBoolMethod · 0.95
ToIntMethod · 0.95
ToInt64Method · 0.95
ToNumberMethod · 0.95
ToStringMethod · 0.95
ToTableMethod · 0.95
ToFunctionMethod · 0.95
ToUserDataMethod · 0.95
ToThreadMethod · 0.95
GetGlobalMethod · 0.95
SetGlobalMethod · 0.95
PCallMethod · 0.95

Calls 3

currentLocalBaseMethod · 0.95
ValueMethod · 0.80
TopMethod · 0.45

Tested by

no test coverage detected