(obj LValue, key string, value LValue)
| 1155 | } |
| 1156 | |
| 1157 | func (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 |
no test coverage detected