| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 518 |
| 519 | 519 |
| 520 #ifdef OBJECT_PRINT | 520 #ifdef OBJECT_PRINT |
| 521 void Type::TypePrint() { | 521 void Type::TypePrint() { |
| 522 TypePrint(stdout); | 522 TypePrint(stdout); |
| 523 PrintF(stdout, "\n"); | 523 PrintF(stdout, "\n"); |
| 524 Flush(stdout); | 524 Flush(stdout); |
| 525 } | 525 } |
| 526 | 526 |
| 527 | 527 |
| 528 const char* Type::bitset_name(int bitset) { |
| 529 switch (bitset) { |
| 530 #define PRINT_COMPOSED_TYPE(type, value) case k##type: return #type; |
| 531 BITSET_TYPE_LIST(PRINT_COMPOSED_TYPE) |
| 532 #undef PRINT_COMPOSED_TYPE |
| 533 default: |
| 534 return NULL; |
| 535 } |
| 536 } |
| 537 |
| 538 |
| 528 void Type::TypePrint(FILE* out) { | 539 void Type::TypePrint(FILE* out) { |
| 529 if (is_bitset()) { | 540 if (is_bitset()) { |
| 530 int val = as_bitset(); | 541 int bitset = as_bitset(); |
| 531 const char* composed_name = GetComposedName(val); | 542 const char* name = bitset_name(bitset); |
| 532 if (composed_name != NULL) { | 543 if (name != NULL) { |
| 533 PrintF(out, "%s", composed_name); | 544 PrintF(out, "%s", name); |
| 534 return; | 545 } else { |
| 546 bool is_first = true; |
| 547 PrintF(out, "("); |
| 548 for (int mask = 1; mask != 0; mask = mask << 1) { |
| 549 if ((bitset & mask) != 0) { |
| 550 if (!is_first) PrintF(out, " | "); |
| 551 is_first = false; |
| 552 PrintF(out, "%s", bitset_name(mask)); |
| 553 } |
| 554 } |
| 555 PrintF(out, ")"); |
| 535 } | 556 } |
| 536 bool first_entry = true; | |
| 537 PrintF(out, "{"); | |
| 538 for (unsigned i = 0; i < sizeof(val)*8; ++i) { | |
| 539 int mask = (1 << i); | |
| 540 if ((val & mask) != 0) { | |
| 541 if (!first_entry) PrintF(out, ","); | |
| 542 first_entry = false; | |
| 543 PrintF(out, "%s", GetPrimitiveName(mask)); | |
| 544 } | |
| 545 } | |
| 546 PrintF(out, "}"); | |
| 547 } else if (is_constant()) { | 557 } else if (is_constant()) { |
| 548 PrintF(out, "Constant(%p : ", static_cast<void*>(*as_constant())); | 558 PrintF(out, "Constant(%p : ", static_cast<void*>(*as_constant())); |
| 549 from_bitset(LubBitset())->TypePrint(out); | 559 from_bitset(LubBitset())->TypePrint(out); |
| 550 PrintF(")"); | 560 PrintF(")"); |
| 551 } else if (is_class()) { | 561 } else if (is_class()) { |
| 552 PrintF(out, "Class(%p < ", static_cast<void*>(*as_class())); | 562 PrintF(out, "Class(%p < ", static_cast<void*>(*as_class())); |
| 553 from_bitset(LubBitset())->TypePrint(out); | 563 from_bitset(LubBitset())->TypePrint(out); |
| 554 PrintF(")"); | 564 PrintF(")"); |
| 555 } else if (is_union()) { | 565 } else if (is_union()) { |
| 556 PrintF(out, "{"); | 566 PrintF(out, "("); |
| 557 Handle<Unioned> unioned = as_union(); | 567 Handle<Unioned> unioned = as_union(); |
| 558 for (int i = 0; i < unioned->length(); ++i) { | 568 for (int i = 0; i < unioned->length(); ++i) { |
| 559 Handle<Type> type_i = union_get(unioned, i); | 569 Handle<Type> type_i = union_get(unioned, i); |
| 560 if (i > 0) PrintF(out, ","); | 570 if (i > 0) PrintF(out, " | "); |
| 561 type_i->TypePrint(out); | 571 type_i->TypePrint(out); |
| 562 } | 572 } |
| 563 PrintF(out, "}"); | 573 PrintF(out, ")"); |
| 564 } | 574 } |
| 565 } | 575 } |
| 566 #endif | 576 #endif |
| 567 | 577 |
| 568 | 578 |
| 569 } } // namespace v8::internal | 579 } } // namespace v8::internal |
| OLD | NEW |