SetUpValue sets the value of a closure's upvalue. It assigns the value at the top of the stack to the upvalue and returns its name. It also pops a value from the stack. function and index are as in UpValue. Returns an empty string and false if the index is greater than the number of upvalues. htt
(l *State, function, index int)
| 1276 | // |
| 1277 | // http://www.lua.org/manual/5.2/manual.html#lua_setupvalue |
| 1278 | func SetUpValue(l *State, function, index int) (name string, ok bool) { |
| 1279 | if c, isClosure := l.indexToValue(function).(closure); isClosure { |
| 1280 | if ok = 1 <= index && index <= c.upValueCount(); ok { |
| 1281 | if c, isLua := c.(*luaClosure); isLua { |
| 1282 | name = c.prototype.upValues[index-1].name |
| 1283 | } |
| 1284 | l.top-- |
| 1285 | c.setUpValue(index-1, l.stack[l.top]) |
| 1286 | } |
| 1287 | } |
| 1288 | return |
| 1289 | } |
| 1290 | |
| 1291 | func (l *State) upValue(f, n int) **upValue { |
| 1292 | return &l.indexToValue(f).(*luaClosure).upValues[n-1] |
no test coverage detected