| 183 | |
| 184 | |
| 185 | Retained<HeapCollection> HeapCollection::mutableCopy(const Value *v, tags ifType) { |
| 186 | if (!v || v->tag() != ifType) |
| 187 | return nullptr; |
| 188 | if (v->isMutable()) |
| 189 | return (HeapCollection*)asHeapValue(v); |
| 190 | switch (ifType) { |
| 191 | case kArrayTag: return new HeapArray((const Array*)v); |
| 192 | case kDictTag: return new HeapDict((const Dict*)v); |
| 193 | default: return nullptr; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | } } } |