Index: src/types.cc |
diff --git a/src/types.cc b/src/types.cc |
index 1275deacb744e7b2f60485e6c0deaa9005f1fc59..b76ca656b6c972dcada31a4d94ad57d07547770b 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,50 @@ Type* Type::Optional(Handle<Type> type) { |
: Union(type, Undefined()->handle_via_isolate_of(*type)); |
} |
+ |
+#ifdef OBJECT_PRINT |
+void Type::TypePrint() { |
+ TypePrint(stdout); |
+ PrintF(stdout, "\n"); |
+ Flush(stdout); |
+} |
+ |
+ |
+void Type::TypePrint(FILE* out) { |
+ if (is_bitset()) { |
+ int val = as_bitset(); |
+ const char* composed_name = GetComposedName(val); |
+ if (composed_name != NULL) { |
+ PrintF(out, "%s", composed_name); |
+ return; |
+ } |
+ bool first_entry = true; |
+ PrintF(out, "{"); |
+ for (unsigned i = 0; i < sizeof(val)*8; ++i) { |
+ int mask = (1<<i); |
+ if ((val & mask) != 0) { |
+ if (!first_entry) PrintF(out, ","); |
+ first_entry = false; |
+ PrintF(out, "%s", GetPrimitiveName(mask)); |
+ } |
+ } |
+ PrintF(out, "}"); |
+ } else if (is_constant()) { |
+ PrintF(out, "Constant(0x%x)", (unsigned)(*as_constant())); |
rossberg
2013/07/10 10:32:08
Is there a specific reason you are not using %p (h
oliv
2013/07/10 11:19:43
none except didn't remember the parameter
|
+ } else if (is_class()) { |
+ PrintF(out, "Class(0x%x)", (unsigned)(*as_class())); |
+ } else if (is_union()) { |
+ PrintF(out, "{"); |
+ Handle<Unioned> unioned = as_union(); |
+ for (int i = 0; i < unioned->length(); ++i) { |
+ Handle<Type> type_i = union_get(unioned, i); |
+ if (i>0) PrintF(out, ","); |
rossberg
2013/07/10 10:32:08
Nit: spaces around >
|
+ type_i->TypePrint(out); |
+ } |
+ PrintF(out, "}"); |
+ } |
+} |
+#endif |
+ |
+ |
} } // namespace v8::internal |