Commit 3ed8ba0c by Ben Clayton

Reactor: Support printing pointers

Change-Id: Ibc630c1b37ecaad87f9c015d8fecc38a6d6b6392 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28396 Presubmit-Ready: Ben Clayton <bclayton@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent 42761d27
......@@ -2977,6 +2977,13 @@ namespace rr
return out + "]";
}
static std::string addr(const void* ptr)
{
char buf[32];
snprintf(buf, sizeof(buf), "%p", ptr);
return buf;
}
public:
const std::string format;
const std::vector<Value*> values;
......@@ -2994,7 +3001,6 @@ namespace rr
template <typename T>
PrintValue(const T* arr, int len) : format(fmt(Ty<T>::fmt, len)), values(val(arr, len)) {}
// PrintValue constructors for plain-old-data values.
PrintValue(bool v) : format(v ? "true" : "false") {}
PrintValue(int8_t v) : format(std::to_string(v)) {}
......@@ -3005,11 +3011,16 @@ namespace rr
PrintValue(uint32_t v) : format(std::to_string(v)) {}
PrintValue(int64_t v) : format(std::to_string(v)) {}
PrintValue(uint64_t v) : format(std::to_string(v)) {}
PrintValue(long v) : format(std::to_string(v)) {}
PrintValue(unsigned long v) : format(std::to_string(v)) {}
PrintValue(float v) : format(std::to_string(v)) {}
PrintValue(double v) : format(std::to_string(v)) {}
PrintValue(const char* v) : format(v) {}
PrintValue(const std::string& v) : format(v) {}
template <typename T>
PrintValue(const T* v) : format(addr(v)) {}
// vals is a helper to build composite value lists.
// vals returns the full, sequential list of printf argument values used
// to print all the provided variadic values.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment