Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: src/types.cc

Issue 18587007: Type::GetName() for printing types in debugger (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/types.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698