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

Method Get

state.go:1513–1550  ·  view source on GitHub ↗
(idx int)

Source from the content-addressed store, hash-verified

1511}
1512
1513func (ls *LState) Get(idx int) LValue {
1514 base := ls.currentLocalBase()
1515 if idx > 0 {
1516 reg := base + idx - 1
1517 if reg < ls.reg.Top() {
1518 return ls.reg.Get(reg)
1519 }
1520 return LNil
1521 } else if idx == 0 {
1522 return LNil
1523 } else if idx > RegistryIndex {
1524 tidx := ls.reg.Top() + idx
1525 if tidx < base {
1526 return LNil
1527 }
1528 return ls.reg.Get(tidx)
1529 } else {
1530 switch idx {
1531 case RegistryIndex:
1532 return ls.G.Registry
1533 case EnvironIndex:
1534 if ls.currentFrame == nil {
1535 return ls.Env
1536 }
1537 return ls.currentFrame.Fn.Env
1538 case GlobalsIndex:
1539 return ls.G.Global
1540 default:
1541 fn := ls.currentFrame.Fn
1542 index := GlobalsIndex - idx - 1
1543 if index < len(fn.Upvalues) {
1544 return fn.Upvalues[index].Value()
1545 }
1546 return LNil
1547 }
1548 }
1549 return LNil
1550}
1551
1552func (ls *LState) Push(value LValue) {
1553 ls.reg.Push(value)

Callers 15

CheckAnyMethod · 0.95
CheckIntMethod · 0.95
CheckInt64Method · 0.95
CheckNumberMethod · 0.95
CheckStringMethod · 0.95
CheckBoolMethod · 0.95
CheckTableMethod · 0.95
CheckFunctionMethod · 0.95
CheckUserDataMethod · 0.95
CheckThreadMethod · 0.95
CheckTypeMethod · 0.95
CheckTypesMethod · 0.95

Calls 3

currentLocalBaseMethod · 0.95
ValueMethod · 0.80
TopMethod · 0.45

Tested by 5

TestGetAndReplaceFunction · 0.36
TestRemoveFunction · 0.36
TestToTableFunction · 0.36
TestToFunctionFunction · 0.36
TestToUserDataFunction · 0.36