Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: src/types.cc

Issue 18587007: Type::GetName() for printing types in debugger (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/types.h ('K') | « src/types.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.cc
diff --git a/src/types.cc b/src/types.cc
index 1275deacb744e7b2f60485e6c0deaa9005f1fc59..0de8427b7fb21a902af5bf64fb11b3b5a0189e19 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -26,6 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "types.h"
+#include "string-stream.h"
namespace v8 {
namespace internal {
@@ -476,4 +477,33 @@ Type* Type::Optional(Handle<Type> type) {
: Union(type, Undefined()->handle_via_isolate_of(*type));
}
+
+SmartArrayPointer<const char> Type::GetName(Type* type) {
+ char buffer[100];
+ NoAllocationStringAllocator allocator(buffer,
+ static_cast<unsigned>(sizeof(buffer)));
+ StringStream stream(&allocator);
+ PrintName(&stream, type);
+ return stream.ToCString();
+}
+
+
+void Type::PrintName(StringStream* stream, Type* type) {
+ if (type->is_bitset()) {
+ stream->Add(type->GetPrimitiveName());
+ } else if (type->is_constant()) {
+ stream->Add("Constant");
+ } else if (type->is_class()) {
+ stream->Add("Class");
+ } else if (type->is_union()) {
+ Handle<Unioned> unioned = type->as_union();
+ SimpleListPrinter printer(stream);
+ for (int i = 0; i < unioned->length(); ++i) {
rossberg 2013/07/03 14:52:54 Note that for a union, at most one part is not a c
oliv 2013/07/05 12:29:06 As discussed offline, i now print the addresses of
+ Handle<Type> type_i = union_get(unioned, i);
+ printer.Add(*GetName(*type_i));
+ }
+ }
+}
+
+
} } // namespace v8::internal
« src/types.h ('K') | « src/types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698