Esempio n. 1
0
void SharedVariant::loadElems(ArrayData *&elems,
                              const SharedMap &sharedMap,
                              bool keepRef /* = false */) {
    ASSERT(is(KindOfArray));
    uint count = arrSize();
    bool isVector = getIsVector();
    ArrayInit ai = isVector ?
                   ArrayInit(count, ArrayInit::vectorInit) : ArrayInit(count, keepRef);
    if (isVector) {
        for (uint i = 0; i < count; i++) {
            ai.set(sharedMap.getValueRef(i));
        }
    } else {
        for (uint i = 0; i < count; i++) {
            ai.add(m_data.map->getKeyIndex(i)->toLocal(), sharedMap.getValueRef(i),
                   true);
        }
    }
    elems = ai.create();
    if (elems->isStatic()) elems = elems->copy();
}
ArrayData* SharedVariant::loadElems(const SharedMap &sharedMap,
                                    bool mapInit /* = false */) {
  assert(is(KindOfArray));
  uint count = arrSize();
  bool isVector = getIsVector();
  ArrayInit ai = mapInit ? ArrayInit(count, ArrayInit::mapInit) :
                 isVector ? ArrayInit(count, ArrayInit::vectorInit) :
                 ArrayInit(count);
  if (isVector) {
    for (uint i = 0; i < count; i++) {
      ai.set(sharedMap.getValueRef(i));
    }
  } else {
    for (uint i = 0; i < count; i++) {
      ai.add(m_data.map->getKeyIndex(i)->toLocal(), sharedMap.getValueRef(i),
             true);
    }
  }
  ArrayData* elems = ai.create();
  if (elems->isStatic()) elems = elems->copy();
  return elems;
}