Chromium Code Reviews| Index: src/types.cc |
| diff --git a/src/types.cc b/src/types.cc |
| index ed98480b8a06e10b4dfcb5630216e56a32cbb05c..2f856cf9d1c19193c9b980a883c8fbfa9099fd58 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 { |
| @@ -486,4 +487,49 @@ Representation Representation::FromType(Handle<Type> 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(%p)", reinterpret_cast<void*>(*as_constant())); |
|
rossberg
2013/07/10 12:01:52
This should be a static_cast ;)
|
| + } else if (is_class()) { |
| + PrintF(out, "Class(%p)", reinterpret_cast<void*>(*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, ","); |
| + type_i->TypePrint(out); |
| + } |
| + PrintF(out, "}"); |
| + } |
| +} |
| +#endif |
| + |
| + |
| } } // namespace v8::internal |