C++程序  |  46行  |  1.12 KB

//===- Fragment.cpp -------------------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include <mcld/Fragment/Fragment.h>

#include <llvm/Support/DataTypes.h>

#include <mcld/LD/SectionData.h>

using namespace mcld;

//===----------------------------------------------------------------------===//
// Fragment
//===----------------------------------------------------------------------===//
Fragment::Fragment()
  : m_Kind(Type(~0)), m_pParent(NULL), m_Offset(~uint64_t(0)) {
}

Fragment::Fragment(Type pKind, SectionData *pParent)
  : m_Kind(pKind), m_pParent(pParent), m_Offset(~uint64_t(0)) {
  if (NULL != m_pParent)
    m_pParent->getFragmentList().push_back(this);
}

Fragment::~Fragment()
{
}

uint64_t Fragment::getOffset() const
{
  assert(hasOffset() && "Cannot getOffset() before setting it up.");
  return m_Offset;
}

bool Fragment::hasOffset() const
{
  return (m_Offset != ~uint64_t(0));
}