MCPcopy Index your code
hub / github.com/Shopify/go-lua / indexToValue

Method indexToValue

lua.go:491–516  ·  view source on GitHub ↗
(index int)

Source from the content-addressed store, hash-verified

489var none value = &struct{}{}
490
491func (l *State) indexToValue(index int) value {
492 switch {
493 case index > 0:
494 // TODO apiCheck(index <= callInfo.top_-(callInfo.function+1), "unacceptable index")
495 // if i := callInfo.function + index; i < l.top {
496 // return l.stack[i]
497 // }
498 // return none
499 if l.callInfo.function+index >= l.top {
500 return none
501 }
502 return l.stack[l.callInfo.function:l.top][index]
503 case index > RegistryIndex: // negative index
504 // TODO apiCheck(index != 0 && -index <= l.top-(callInfo.function+1), "invalid index")
505 return l.stack[l.top+index]
506 case index == RegistryIndex:
507 return l.global.registry
508 default: // upvalues
509 i := RegistryIndex - index
510 return l.stack[l.callInfo.function].(*goClosure).upValues[i-1]
511 // if closure := l.stack[callInfo.function].(*goClosure); i <= len(closure.upValues) {
512 // return closure.upValues[i-1]
513 // }
514 // return none
515 }
516}
517
518func (l *State) setIndexToValue(index int, v value) {
519 switch {

Callers 15

SetFieldMethod · 0.95
RemoveMethod · 0.95
InsertMethod · 0.95
TypeOfMethod · 0.95
IsGoFunctionMethod · 0.95
IsNumberMethod · 0.95
IsStringMethod · 0.95
IsUserDataMethod · 0.95
RawEqualMethod · 0.95
CompareMethod · 0.95
ToIntegerMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected