(obj LValue, key string, value LValue)
| 1368 | } |
| 1369 | |
| 1370 | func (ls *LState) setFieldString(obj LValue, key string, value LValue) { |
| 1371 | curobj := obj |
| 1372 | for i := 0; i < MaxTableGetLoop; i++ { |
| 1373 | tb, istable := curobj.(*LTable) |
| 1374 | if istable { |
| 1375 | if tb.RawGetString(key) != LNil { |
| 1376 | tb.RawSetString(key, value) |
| 1377 | return |
| 1378 | } |
| 1379 | } |
| 1380 | metaindex := ls.metaOp1(curobj, "__newindex") |
| 1381 | if metaindex == LNil { |
| 1382 | if !istable { |
| 1383 | ls.RaiseError("attempt to index a non-table object(%v) with key '%s'", curobj.Type().String(), key) |
| 1384 | } |
| 1385 | tb.RawSetString(key, value) |
| 1386 | return |
| 1387 | } |
| 1388 | if metaindex.Type() == LTFunction { |
| 1389 | ls.reg.Push(metaindex) |
| 1390 | ls.reg.Push(curobj) |
| 1391 | ls.reg.Push(LString(key)) |
| 1392 | ls.reg.Push(value) |
| 1393 | ls.Call(3, 0) |
| 1394 | return |
| 1395 | } else { |
| 1396 | curobj = metaindex |
| 1397 | } |
| 1398 | } |
| 1399 | ls.RaiseError("too many recursions in settable") |
| 1400 | } |
| 1401 | |
| 1402 | /* }}} */ |
| 1403 |
no test coverage detected