(index int)
| 489 | var none value = &struct{}{} |
| 490 | |
| 491 | func (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 | |
| 518 | func (l *State) setIndexToValue(index int, v value) { |
| 519 | switch { |
no outgoing calls
no test coverage detected