• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
15 namespace mcld {
16 
17 //===----------------------------------------------------------------------===//
18 // Fragment
19 //===----------------------------------------------------------------------===//
Fragment()20 Fragment::Fragment()
21     : m_Kind(Type(~0)), m_pParent(NULL), m_Offset(~uint64_t(0)) {
22 }
23 
Fragment(Type pKind,SectionData * pParent)24 Fragment::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 
~Fragment()30 Fragment::~Fragment() {
31 }
32 
getOffset() const33 uint64_t Fragment::getOffset() const {
34   assert(hasOffset() && "Cannot getOffset() before setting it up.");
35   return m_Offset;
36 }
37 
hasOffset() const38 bool Fragment::hasOffset() const {
39   return (m_Offset != ~uint64_t(0));
40 }
41 
42 }  // namespace mcld
43