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

Method setFieldString

_state.go:1157–1187  ·  view source on GitHub ↗
(obj LValue, key string, value LValue)

Source from the content-addressed store, hash-verified

1155}
1156
1157func (ls *LState) setFieldString(obj LValue, key string, value LValue) {
1158 curobj := obj
1159 for i := 0; i < MaxTableGetLoop; i++ {
1160 tb, istable := curobj.(*LTable)
1161 if istable {
1162 if tb.RawGetString(key) != LNil {
1163 tb.RawSetString(key, value)
1164 return
1165 }
1166 }
1167 metaindex := ls.metaOp1(curobj, "__newindex")
1168 if metaindex == LNil {
1169 if !istable {
1170 ls.RaiseError("attempt to index a non-table object(%v) with key '%s'", curobj.Type().String(), key)
1171 }
1172 tb.RawSetString(key, value)
1173 return
1174 }
1175 if metaindex.Type() == LTFunction {
1176 ls.reg.Push(metaindex)
1177 ls.reg.Push(curobj)
1178 ls.reg.Push(LString(key))
1179 ls.reg.Push(value)
1180 ls.Call(3, 0)
1181 return
1182 } else {
1183 curobj = metaindex
1184 }
1185 }
1186 ls.RaiseError("too many recursions in settable")
1187}
1188
1189/* }}} */
1190

Callers 1

SetFieldMethod · 0.95

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