| 516 | } |
| 517 | |
| 518 | func (l *State) setIndexToValue(index int, v value) { |
| 519 | switch { |
| 520 | case index > 0: |
| 521 | l.stack[l.callInfo.function:l.top][index] = v |
| 522 | // if i := callInfo.function + index; i < l.top { |
| 523 | // l.stack[i] = v |
| 524 | // } else { |
| 525 | // panic("unacceptable index") |
| 526 | // } |
| 527 | case index > RegistryIndex: // negative index |
| 528 | l.stack[l.top+index] = v |
| 529 | case index == RegistryIndex: |
| 530 | l.global.registry = v.(*table) |
| 531 | default: // upvalues |
| 532 | i := RegistryIndex - index |
| 533 | l.stack[l.callInfo.function].(*goClosure).upValues[i-1] = v |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | // AbsIndex converts the acceptable index index to an absolute index (that |
| 538 | // is, one that does not depend on the stack top). |