MCPcopy Index your code
hub / github.com/yuin/gopher-lua / setFieldString

Method setFieldString

state.go:1370–1400  ·  view source on GitHub ↗
(obj LValue, key string, value LValue)

Source from the content-addressed store, hash-verified

1368}
1369
1370func (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

Callers 3

SetFieldMethod · 0.95
initFunction · 0.45
initFunction · 0.45

Calls 9

metaOp1Method · 0.95
RaiseErrorMethod · 0.95
CallMethod · 0.95
LStringTypeAlias · 0.85
RawGetStringMethod · 0.80
RawSetStringMethod · 0.80
StringMethod · 0.65
TypeMethod · 0.65
PushMethod · 0.65

Tested by

no test coverage detected