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 |