(idx uint32, val Value, throw bool)
| 212 | } |
| 213 | |
| 214 | func (a *arrayObject) _setOwnIdx(idx uint32, val Value, throw bool) bool { |
| 215 | var prop Value |
| 216 | if idx < uint32(len(a.values)) { |
| 217 | prop = a.values[idx] |
| 218 | } |
| 219 | |
| 220 | if prop == nil { |
| 221 | if proto := a.prototype; proto != nil { |
| 222 | // we know it's foreign because prototype loops are not allowed |
| 223 | if res, ok := proto.self.setForeignIdx(valueInt(idx), val, a.val, throw); ok { |
| 224 | return res |
| 225 | } |
| 226 | } |
| 227 | // new property |
| 228 | if !a.extensible { |
| 229 | a.val.runtime.typeErrorResult(throw, "Cannot add property %d, object is not extensible", idx) |
| 230 | return false |
| 231 | } else { |
| 232 | if idx >= a.length { |
| 233 | if !a.setLengthInt(idx+1, throw) { |
| 234 | return false |
| 235 | } |
| 236 | } |
| 237 | if idx >= uint32(len(a.values)) { |
| 238 | if !a.expand(idx) { |
| 239 | a.val.self.(*sparseArrayObject).add(idx, val) |
| 240 | return true |
| 241 | } |
| 242 | } |
| 243 | a.objCount++ |
| 244 | } |
| 245 | } else { |
| 246 | if prop, ok := prop.(*valueProperty); ok { |
| 247 | if !prop.isWritable() { |
| 248 | a.val.runtime.typeErrorResult(throw) |
| 249 | return false |
| 250 | } |
| 251 | prop.set(a.val, val) |
| 252 | return true |
| 253 | } |
| 254 | } |
| 255 | a.values[idx] = val |
| 256 | return true |
| 257 | } |
| 258 | |
| 259 | func (a *arrayObject) setOwnStr(name unistring.String, val Value, throw bool) bool { |
| 260 | if idx := strToArrayIdx(name); idx != math.MaxUint32 { |
no test coverage detected