1//===- Fragment.cpp -------------------------------------------------------===//
2//
3//                     The MCLinker Project
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "mcld/Fragment/Fragment.h"
11#include "mcld/LD/SectionData.h"
12
13#include <llvm/Support/DataTypes.h>
14
15namespace mcld {
16
17//===----------------------------------------------------------------------===//
18// Fragment
19//===----------------------------------------------------------------------===//
20Fragment::Fragment()
21    : m_Kind(Type(~0)), m_pParent(NULL), m_Offset(~uint64_t(0)) {
22}
23
24Fragment::Fragment(Type pKind, SectionData* pParent)
25    : m_Kind(pKind), m_pParent(pParent), m_Offset(~uint64_t(0)) {
26  if (m_pParent != NULL)
27    m_pParent->getFragmentList().push_back(this);
28}
29
30Fragment::~Fragment() {
31}
32
33uint64_t Fragment::getOffset() const {
34  assert(hasOffset() && "Cannot getOffset() before setting it up.");
35  return m_Offset;
36}
37
38bool Fragment::hasOffset() const {
39  return (m_Offset != ~uint64_t(0));
40}
41
42}  // namespace mcld
43