2 Copyright (C) 2001-2005, The Perl Foundation.
3 This program is free software. It is subject to the same license as
9 src/packdump.c - Functions for dumping packfile structures
13 This is only used by the PBC dumper C<pdump>.
23 #include "parrot/parrot.h"
24 #include "parrot/packfile.h"
27 ** FIXME: this should also be segmentized.
28 ** For now just remove some warnings
31 void PackFile_ConstTable_dump(Interp
*,
32 struct PackFile_ConstTable
*);
33 static void PackFile_Constant_dump(Interp
*,
34 struct PackFile_Constant
*);
35 void PackFile_Fixup_dump(Interp
*,
36 struct PackFile_FixupTable
*ft
);
41 PackFile_ConstTable_dump(Interp *interpreter,
42 struct PackFile_ConstTable *self)>
44 Dumps the constant table C<self>.
51 PackFile_ConstTable_dump(Interp
*interpreter
,
52 struct PackFile_ConstTable
*self
)
56 for (i
= 0; i
< self
->const_count
; i
++) {
57 PIO_printf(interpreter
, " # %ld:\n", (long)i
);
58 PackFile_Constant_dump(interpreter
, self
->constants
[i
]);
65 PackFile_Constant_dump(Interp *interpreter,
66 struct PackFile_Constant *self)>
68 Dumps the constant C<self>.
75 PackFile_Constant_dump(Interp
*interpreter
,
76 struct PackFile_Constant
*self
)
81 PIO_printf(interpreter
, " [ 'PFC_NUMBER', %g ],\n", self
->u
.number
);
85 PIO_printf(interpreter
, " [ 'PFC_STRING', {\n");
86 PIO_printf(interpreter
, " FLAGS => 0x%04lx,\n",
87 (long)PObj_get_FLAGS(self
->u
.string
));
88 PIO_printf(interpreter
, " CHARSET => %ld,\n",
89 self
->u
.string
->charset
);
90 PIO_printf(interpreter
, " SIZE => %ld,\n",
91 (long)self
->u
.string
->bufused
);
92 /* TODO: Won't do anything reasonable for most encodings */
93 PIO_printf(interpreter
, " DATA => '%.*s'\n",
94 (int)self
->u
.string
->bufused
,
95 (char *)self
->u
.string
->strstart
);
96 PIO_printf(interpreter
, " } ],\n");
100 PIO_printf(interpreter
, " [ 'PFC_KEY', {\n");
101 PIO_printf(interpreter
, " ??? TODO \n");
102 PIO_printf(interpreter
, " } ],\n");
105 PIO_printf(interpreter
, " [ 'PFC_PMC', {\n");
107 PMC
*pmc
= self
->u
.key
;
109 STRING
*a_key
= const_string(interpreter
, "(keyed)");
110 STRING
*null
= const_string(interpreter
, "(null)");
111 opcode_t
*code_start
=
112 interpreter
->code
->base
.data
;
113 switch (pmc
->vtable
->base_type
) {
115 case enum_class_Coroutine
:
117 PIO_printf(interpreter
,
119 "\tstart_offs => %d,\n"
120 "\tend_offs => %d,\n"
122 "\tnamespace => '%Ss'\n",
128 (sub
->namespace->vtable
->base_type
==
130 PMC_str_val(sub
->namespace) : a_key
) :
135 PIO_printf(interpreter
, "\tunknown PMC\n");
138 PIO_printf(interpreter
, " } ],\n");
141 PIO_printf(interpreter
, " [ 'PFC_\?\?\?', type '0x%x' ],\n",
150 PackFile_Fixup_dump(Interp *interpreter,
151 struct PackFile_FixupTable *ft)>
153 Dumps the fix-up table C<ft>.
160 PackFile_Fixup_dump(Interp
*interpreter
,
161 struct PackFile_FixupTable
*ft
)
165 for (i
= 0; i
< ft
->fixup_count
; i
++) {
166 PIO_printf(interpreter
,"\t#%d\n", (int) i
);
167 switch (ft
->fixups
[i
]->type
) {
168 case enum_fixup_label
:
170 PIO_printf(interpreter
,
171 "\ttype => %d offs => %8d name => '%s',\n",
172 (int)ft
->fixups
[i
]->type
,
173 (int)ft
->fixups
[i
]->offset
,
174 ft
->fixups
[i
]->name
);
177 PIO_printf(interpreter
,"\ttype => %d ???,\n",
178 (int) ft
->fixups
[i
]->type
);
199 * c-file-style: "parrot"
201 * vim: expandtab shiftwidth=4: