1 // Debugging support for dynamic typing.
7 #include "cln/object.h"
13 #include "cln/abort.h"
17 // The default printer function.
18 void cl_dprint_unknown (cl_heap* pointer)
20 fprint(cl_debugout, "<unknown @0x");
21 fprinthexadecimal(cl_debugout, (unsigned long) pointer);
22 fprint(cl_debugout, " refcount=");
23 fprintdecimal(cl_debugout, pointer->refcount);
24 fprint(cl_debugout, " type=");
25 fprinthexadecimal(cl_debugout, (unsigned long) pointer->type);
26 fprint(cl_debugout, ">");
29 static void cl_dprint_unknown_immediate (cl_heap* pointer)
31 fprint(cl_debugout, "<unknown @0x");
32 fprinthexadecimal(cl_debugout, (unsigned long) pointer);
33 fprint(cl_debugout, ">");
36 // Print an object. This function is callable from the debugger.
37 extern "C" void* cl_print (cl_uint word);
38 void* cl_print (cl_uint word)
40 var cl_heap* pointer = (cl_heap*)word;
41 if (cl_pointer_p(word)) {
42 var const cl_class* type = pointer->type;
44 type->dprint(pointer);
46 cl_dprint_unknown(pointer);
48 var const cl_class* type = cl_immediate_classes[cl_tag(word)];
49 if (type && type->dprint)
50 type->dprint(pointer);
52 cl_dprint_unknown_immediate(pointer);
54 cl_debugout << std::endl; // newline and flush output
58 void cl_gcobject::debug_print () const
63 void cl_gcpointer::debug_print () const
68 void cl_rcobject::debug_print () const
73 void cl_rcpointer::debug_print () const