mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-02 07:17:36 +00:00
Add getHeader helper and move ToHeader to the cpp file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185933 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -36,10 +36,6 @@ struct ArchiveMemberHeader {
|
|||||||
uint64_t getSize() const;
|
uint64_t getSize() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const ArchiveMemberHeader *ToHeader(const char *base) {
|
|
||||||
return reinterpret_cast<const ArchiveMemberHeader *>(base);
|
|
||||||
}
|
|
||||||
|
|
||||||
class Archive : public Binary {
|
class Archive : public Binary {
|
||||||
virtual void anchor();
|
virtual void anchor();
|
||||||
public:
|
public:
|
||||||
@@ -50,6 +46,10 @@ public:
|
|||||||
/// \brief Offset from Data to the start of the file.
|
/// \brief Offset from Data to the start of the file.
|
||||||
uint16_t StartOfFile;
|
uint16_t StartOfFile;
|
||||||
|
|
||||||
|
const ArchiveMemberHeader *getHeader() const {
|
||||||
|
return reinterpret_cast<const ArchiveMemberHeader *>(Data.data());
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Child(const Archive *Parent, const char *Start);
|
Child(const Archive *Parent, const char *Start);
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
Child getNext() const;
|
Child getNext() const;
|
||||||
|
|
||||||
error_code getName(StringRef &Result) const;
|
error_code getName(StringRef &Result) const;
|
||||||
StringRef getRawName() const { return ToHeader(Data.data())->getName(); }
|
StringRef getRawName() const { return getHeader()->getName(); }
|
||||||
/// \return the size of the archive member without the header or padding.
|
/// \return the size of the archive member without the header or padding.
|
||||||
uint64_t getSize() const { return Data.size() - StartOfFile; }
|
uint64_t getSize() const { return Data.size() - StartOfFile; }
|
||||||
|
|
||||||
|
|||||||
@@ -61,12 +61,16 @@ uint64_t ArchiveMemberHeader::getSize() const {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const ArchiveMemberHeader *toHeader(const char *base) {
|
||||||
|
return reinterpret_cast<const ArchiveMemberHeader *>(base);
|
||||||
|
}
|
||||||
|
|
||||||
Archive::Child::Child(const Archive *Parent, const char *Start)
|
Archive::Child::Child(const Archive *Parent, const char *Start)
|
||||||
: Parent(Parent) {
|
: Parent(Parent) {
|
||||||
if (!Start)
|
if (!Start)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const ArchiveMemberHeader *Header = ToHeader(Start);
|
const ArchiveMemberHeader *Header = toHeader(Start);
|
||||||
Data = StringRef(Start, sizeof(ArchiveMemberHeader) + Header->getSize());
|
Data = StringRef(Start, sizeof(ArchiveMemberHeader) + Header->getSize());
|
||||||
|
|
||||||
// Setup StartOfFile and PaddingBytes.
|
// Setup StartOfFile and PaddingBytes.
|
||||||
@@ -270,7 +274,7 @@ Archive::child_iterator Archive::begin_children(bool skip_internal) const {
|
|||||||
const char *Loc = Data->getBufferStart() + strlen(Magic);
|
const char *Loc = Data->getBufferStart() + strlen(Magic);
|
||||||
Child c(this, Loc);
|
Child c(this, Loc);
|
||||||
// Skip internals at the beginning of an archive.
|
// Skip internals at the beginning of an archive.
|
||||||
if (skip_internal && isInternalMember(*ToHeader(Loc)))
|
if (skip_internal && isInternalMember(*toHeader(Loc)))
|
||||||
return c.getNext();
|
return c.getNext();
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user