1 // Debugging support for dynamic typing.
7 #include "cln/object.h"
16 // The default printer function.
17 void cl_dprint_unknown (cl_heap* pointer)
19 fprint(cl_debugout, "<unknown @0x");
20 fprinthexadecimal(cl_debugout, (unsigned long) pointer);
21 fprint(cl_debugout, " refcount=");
22 fprintdecimal(cl_debugout, pointer->refcount);
23 fprint(cl_debugout, " type=");
24 fprinthexadecimal(cl_debugout, (unsigned long) pointer->type);
25 fprint(cl_debugout, ">");
28 static void cl_dprint_unknown_immediate (cl_heap* pointer)
30 fprint(cl_debugout, "<unknown @0x");
31 fprinthexadecimal(cl_debugout, (unsigned long) pointer);
32 fprint(cl_debugout, ">");
35 // Print an object. This function is callable from the debugger.
36 extern "C" void* cl_print (cl_uint word);
37 void* cl_print (cl_uint word)
39 var cl_heap* pointer = (cl_heap*)word;
40 if (cl_pointer_p(word)) {
41 var const cl_class* type = pointer->type;
43 type->dprint(pointer);
45 cl_dprint_unknown(pointer);
47 var const cl_class* type = cl_immediate_classes[cl_tag(word)];
48 if (type && type->dprint)
49 type->dprint(pointer);
51 cl_dprint_unknown_immediate(pointer);
53 cl_debugout << std::endl; // newline and flush output
57 void cl_gcobject::debug_print () const
62 void cl_gcpointer::debug_print () const
67 void cl_rcobject::debug_print () const
72 void cl_rcpointer::debug_print () const