mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Make all raw_ostreams support the tell() function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69583 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -54,6 +54,9 @@ public:
|
|||||||
delete [] OutBufStart;
|
delete [] OutBufStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// tell - Return the current offset with the file.
|
||||||
|
uint64_t tell() { return current_pos() + GetNumBytesInBuffer(); }
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Configuration Interface
|
// Configuration Interface
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
@@ -179,6 +182,10 @@ private:
|
|||||||
// An out of line virtual method to provide a home for the class vtable.
|
// An out of line virtual method to provide a home for the class vtable.
|
||||||
virtual void handle();
|
virtual void handle();
|
||||||
|
|
||||||
|
/// current_pos - Return the current position within the stream, not
|
||||||
|
/// counting the bytes currently in the buffer.
|
||||||
|
virtual uint64_t current_pos() = 0;
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Private Interface
|
// Private Interface
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
@@ -202,6 +209,11 @@ class raw_fd_ostream : public raw_ostream {
|
|||||||
|
|
||||||
/// write_impl - See raw_ostream::write_impl.
|
/// write_impl - See raw_ostream::write_impl.
|
||||||
virtual void write_impl(const char *Ptr, unsigned Size);
|
virtual void write_impl(const char *Ptr, unsigned Size);
|
||||||
|
|
||||||
|
/// current_pos - Return the current position within the stream, not
|
||||||
|
/// counting the bytes currently in the buffer.
|
||||||
|
virtual uint64_t current_pos() { return pos; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// raw_fd_ostream - Open the specified file for writing. If an
|
/// raw_fd_ostream - Open the specified file for writing. If an
|
||||||
/// error occurs, information about the error is put into ErrorInfo,
|
/// error occurs, information about the error is put into ErrorInfo,
|
||||||
@@ -271,9 +283,17 @@ class raw_os_ostream : public raw_ostream {
|
|||||||
|
|
||||||
/// write_impl - See raw_ostream::write_impl.
|
/// write_impl - See raw_ostream::write_impl.
|
||||||
virtual void write_impl(const char *Ptr, unsigned Size);
|
virtual void write_impl(const char *Ptr, unsigned Size);
|
||||||
|
|
||||||
|
/// current_pos - Return the current position within the stream, not
|
||||||
|
/// counting the bytes currently in the buffer.
|
||||||
|
virtual uint64_t current_pos();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
raw_os_ostream(std::ostream &O) : OS(O) {}
|
raw_os_ostream(std::ostream &O) : OS(O) {}
|
||||||
~raw_os_ostream();
|
~raw_os_ostream();
|
||||||
|
|
||||||
|
/// tell - Return the current offset with the stream.
|
||||||
|
uint64_t tell();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// raw_string_ostream - A raw_ostream that writes to an std::string. This is a
|
/// raw_string_ostream - A raw_ostream that writes to an std::string. This is a
|
||||||
@@ -283,10 +303,17 @@ class raw_string_ostream : public raw_ostream {
|
|||||||
|
|
||||||
/// write_impl - See raw_ostream::write_impl.
|
/// write_impl - See raw_ostream::write_impl.
|
||||||
virtual void write_impl(const char *Ptr, unsigned Size);
|
virtual void write_impl(const char *Ptr, unsigned Size);
|
||||||
|
|
||||||
|
/// current_pos - Return the current position within the stream, not
|
||||||
|
/// counting the bytes currently in the buffer.
|
||||||
|
virtual uint64_t current_pos() { return OS.size(); }
|
||||||
public:
|
public:
|
||||||
raw_string_ostream(std::string &O) : OS(O) {}
|
raw_string_ostream(std::string &O) : OS(O) {}
|
||||||
~raw_string_ostream();
|
~raw_string_ostream();
|
||||||
|
|
||||||
|
/// tell - Return the current offset with the stream.
|
||||||
|
uint64_t tell() { return OS.size() + GetNumBytesInBuffer(); }
|
||||||
|
|
||||||
/// str - Flushes the stream contents to the target string and returns
|
/// str - Flushes the stream contents to the target string and returns
|
||||||
/// the string's reference.
|
/// the string's reference.
|
||||||
std::string& str() {
|
std::string& str() {
|
||||||
@@ -302,9 +329,16 @@ class raw_svector_ostream : public raw_ostream {
|
|||||||
|
|
||||||
/// write_impl - See raw_ostream::write_impl.
|
/// write_impl - See raw_ostream::write_impl.
|
||||||
virtual void write_impl(const char *Ptr, unsigned Size);
|
virtual void write_impl(const char *Ptr, unsigned Size);
|
||||||
|
|
||||||
|
/// current_pos - Return the current position within the stream, not
|
||||||
|
/// counting the bytes currently in the buffer.
|
||||||
|
virtual uint64_t current_pos();
|
||||||
public:
|
public:
|
||||||
raw_svector_ostream(SmallVectorImpl<char> &O) : OS(O) {}
|
raw_svector_ostream(SmallVectorImpl<char> &O) : OS(O) {}
|
||||||
~raw_svector_ostream();
|
~raw_svector_ostream();
|
||||||
|
|
||||||
|
/// tell - Return the current offset with the stream.
|
||||||
|
uint64_t tell();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end llvm namespace
|
} // end llvm namespace
|
||||||
|
@@ -339,6 +339,12 @@ void raw_os_ostream::write_impl(const char *Ptr, unsigned Size) {
|
|||||||
OS.write(Ptr, Size);
|
OS.write(Ptr, Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t raw_os_ostream::current_pos() { return OS.tellp(); }
|
||||||
|
|
||||||
|
uint64_t raw_os_ostream::tell() {
|
||||||
|
return (uint64_t)OS.tellp() + GetNumBytesInBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// raw_string_ostream
|
// raw_string_ostream
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@@ -363,3 +369,8 @@ void raw_svector_ostream::write_impl(const char *Ptr, unsigned Size) {
|
|||||||
OS.append(Ptr, Ptr + Size);
|
OS.append(Ptr, Ptr + Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t raw_svector_ostream::current_pos() { return OS.size(); }
|
||||||
|
|
||||||
|
uint64_t raw_svector_ostream::tell() {
|
||||||
|
return OS.size() + GetNumBytesInBuffer();
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user