Chromium Code Reviews| 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 (unsigned i = 0; i < sizeof(bitset)*8; ++i) { | |
|
Toon Verwaest
2013/11/18 17:05:46
8 -> kBitsPerByte
Could also just do >>1 until th
rossberg
2013/11/18 17:37:03
Good idea (I don't even see why I still need i the
| |
| 549 int mask = (1 << i); | |
| 550 if ((bitset & mask) != 0) { | |
| 551 if (!is_first) PrintF(out, " | "); | |
| 552 is_first = false; | |
| 553 PrintF(out, "%s", bitset_name(mask)); | |
| 554 } | |
| 555 } | |
| 556 PrintF(out, ")"); | |
| 535 } | 557 } |
| 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()) { | 558 } else if (is_constant()) { |
| 548 PrintF(out, "Constant(%p : ", static_cast<void*>(*as_constant())); | 559 PrintF(out, "Constant(%p : ", static_cast<void*>(*as_constant())); |
| 549 from_bitset(LubBitset())->TypePrint(out); | 560 from_bitset(LubBitset())->TypePrint(out); |
| 550 PrintF(")"); | 561 PrintF(")"); |
| 551 } else if (is_class()) { | 562 } else if (is_class()) { |
| 552 PrintF(out, "Class(%p < ", static_cast<void*>(*as_class())); | 563 PrintF(out, "Class(%p < ", static_cast<void*>(*as_class())); |
| 553 from_bitset(LubBitset())->TypePrint(out); | 564 from_bitset(LubBitset())->TypePrint(out); |
| 554 PrintF(")"); | 565 PrintF(")"); |
| 555 } else if (is_union()) { | 566 } else if (is_union()) { |
| 556 PrintF(out, "{"); | 567 PrintF(out, "("); |
| 557 Handle<Unioned> unioned = as_union(); | 568 Handle<Unioned> unioned = as_union(); |
| 558 for (int i = 0; i < unioned->length(); ++i) { | 569 for (int i = 0; i < unioned->length(); ++i) { |
| 559 Handle<Type> type_i = union_get(unioned, i); | 570 Handle<Type> type_i = union_get(unioned, i); |
| 560 if (i > 0) PrintF(out, ","); | 571 if (i > 0) PrintF(out, " | "); |
| 561 type_i->TypePrint(out); | 572 type_i->TypePrint(out); |
| 562 } | 573 } |
| 563 PrintF(out, "}"); | 574 PrintF(out, ")"); |
| 564 } | 575 } |
| 565 } | 576 } |
| 566 #endif | 577 #endif |
| 567 | 578 |
| 568 | 579 |
| 569 } } // namespace v8::internal | 580 } } // namespace v8::internal |
| OLD | NEW |