コード例 #1
0
ファイル: array_data.cpp プロジェクト: GunioRobot/hiphop-php
bool ArrayData::hasInternalReference(PointerSet &vars) const {
  if (supportValueRef()) {
    for (ArrayIter iter(this); iter; ++iter) {
      CVarRef var = iter.secondRef();
      if (var.isReferenced()) {
        Variant *pvar = var.getVariantData();
        if (vars.find(pvar) != vars.end()) {
          return true;
        }
        vars.insert(pvar);
      }
      if (var.isObject()) {
        ObjectData *pobj = var.getObjectData();
        if (vars.find(pobj) != vars.end()) {
          return true;
        }
        vars.insert(pobj);

        if (pobj->o_toArray().get()->hasInternalReference(vars)) {
          return true;
        }
      } else if (var.isArray() &&
                 var.getArrayData()->hasInternalReference(vars)) {
        return true;
      }
    }
  }
  return false;
}
コード例 #2
0
void VariableSerializer::writeArrayValue(const ArrayData *arr, CVarRef value) {
  // Do not count referenced values after the first
  if (m_type == Serialize &&
      !(value.isReferenced() &&
        m_arrayIds.find(value.getVariantData()) != m_arrayIds.end()))
    m_valueCount++;

  write(value);
  switch (m_type) {
  case PrintR:
    *m_out << '\n';
    break;
  case VarExport:
    *m_out << ",\n";
    break;
  default:
    break;
  }

  ArrayInfo &info = m_arrayInfos.back();
  info.first_element = false;
}
コード例 #3
0
ファイル: array_data.cpp プロジェクト: Braunson/hiphop-php
bool ArrayData::hasInternalReference(PointerSet &vars,
                                     bool ds /* = false */) const {
    if (isSharedMap()) return false;
    for (ArrayIter iter(this); iter; ++iter) {
        CVarRef var = iter.secondRef();
        if (var.isReferenced()) {
            Variant *pvar = var.getVariantData();
            if (vars.find(pvar) != vars.end()) {
                return true;
            }
            vars.insert(pvar);
        }
        if (var.isObject()) {
            ObjectData *pobj = var.getObjectData();
            if (vars.find(pobj) != vars.end()) {
                return true;
            }
            vars.insert(pobj);
            if (pobj->o_instanceof("Serializable")) {
                if (ds) {
                    // We want to detect Serializable object as well
                    return true;
                } else {
                    // Serializable object does not have internal reference issue
                    return false;
                }
            }
            if (pobj->o_toArray().get()->hasInternalReference(vars, ds)) {
                return true;
            }
        } else if (var.isArray() &&
                   var.getArrayData()->hasInternalReference(vars, ds)) {
            return true;
        }
    }
    return false;
}
コード例 #4
0
void VariableSerializer::writeArrayValue(const ArrayData *arr, CVarRef value) {
  // Do not count referenced values after the first
  if ((m_type == Serialize || m_type == APCSerialize ||
       m_type == DebuggerSerialize) &&
      !(value.isReferenced() &&
        m_arrayIds->find(value.getVariantData()) != m_arrayIds->end())) {
    m_valueCount++;
  }

  write(value);
  switch (m_type) {
  case PrintR:
    m_buf->append('\n');
    break;
  case VarExport:
    m_buf->append(",\n");
    break;
  default:
    break;
  }

  ArrayInfo &info = m_arrayInfos.back();
  info.first_element = false;
}