dds_emit.c

filter: Statementstmt 90.2% 1051 / 1164 Branchbran 78.8% 774 / 982 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 85.0% 1825 / 2146 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« dds_api.c ↑ Summary dds_format.c »
1 #include "dds_engine.h"
2  
3 /* Emission continuations live on the heap, independently of the C stack. */
4 typedef enum {
5 DDS_FRAME_SV,
6 DDS_FRAME_REF,
7 DDS_FRAME_ARRAY,
8 DDS_FRAME_HASH
9 } dds_frame_kind;
10  
11 typedef enum {
12 DDS_STAGE_INITIAL = 0,
13 DDS_STAGE_CHILD,
14 DDS_STAGE_SCALAR_REF
15 } dds_frame_stage;
16  
17 /* Frames borrow graph SVs and catalogue roles. name, class_name, keys,
18 * hidden and temporary_sv own references released by
19 * dds_release_frame. The embedded temporary node lives only as long as
20 * this frame and must never be stored in a deferred fixup. */
21 struct dds_frame {
22 struct dds_frame *parent;
23 dds_frame_kind kind;
24 dds_frame_stage stage;
25 SV *sv, *name, *temporary_sv;
26 UV depth;
27 IV indent;
28 dds_mark *mark;
29 bool is_ref;
30 dds_result result;
31 dds_active active;
32 dds_node *node, temporary;
33 dds_role *role;
34 bool add_do;
35 SV *class_name, *thaw;
36 AV *hidden, *keys;
37 bool overloaded, add_bless, add_lock, fix_lock, inline_thaw, function_thaw;
38 SSize_t k, last, run;
39 UV width;
40 IV last_n;
41 };
42  
43 /*
44 * Traversal continuations
45 *
46 * Each heap frame owns only the values needed across a child visit. Its stage
47 * selects where execution resumes when that child completes.
48 */
49  
50 /* Push a heap continuation for one traversal step, borrowing graph data and
51 * retaining its name and any fetched temporary.
52 */
53 41752 static void dds_push_frame(pTHX_ dds_ctx *ctx, dds_frame_kind kind, SV *sv, UV depth,
54 dds_mark *mark, SV *name, IV indent, bool is_ref)
55 {
56 struct dds_frame *frame;
57  
58 41752 ▶ if (depth > 16384)
Branch: 1 branch
BranchTrueFalseTotal
if (depth > 16384) 0 41752 41752
59 0 croak("DDS maximum traversal depth (16384) exceeded");
60  
61 41752 ▶ if ((frame = ctx->free_frames))
Branch: 1 branch
BranchTrueFalseTotal
if ((frame = ctx->free_frames)) 30283 11469 41752
62 30283 ctx->free_frames = frame->parent;
63 else
64 11469 Newx(frame, 1, struct dds_frame);
65  
66 41752 Zero(frame, 1, struct dds_frame);
67 41752 frame->parent = ctx->frames;
68 41752 ctx->frames = frame;
69 41752 frame->kind = kind;
70 41752 frame->sv = sv;
71 41752 frame->depth = depth;
72  
73 /* Tied fetches may return mortals created by the parent step. Ordinary
74 * graph SVs are borrowed without changing their reference counts. */
75 41752 ▶ if (SvTEMP(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (SvTEMP(sv)) 1094 40658 41752
76 1094 frame->temporary_sv = SvREFCNT_inc(sv);
77  
78 41752 frame->mark = mark;
79 41752 frame->name = SvREFCNT_inc(name);
80 41752 frame->indent = indent;
81 41752 frame->is_ref = is_ref;
82  
83 41752 frame->active.parent = ctx->active;
84 41752 frame->active.sv = sv;
85 41752 ctx->active = &frame->active;
86 41752 }
87  
88 /* Release and clear the SV references owned by a frame without releasing its
89 * borrowed graph values or catalogue records.
90 */
91 53220 static void dds_release_frame(pTHX_ struct dds_frame *frame)
92 {
93 /* Only these fields own SV references. Graph values remain borrowed
94 * from the live graph or callback keepalive. Clear before release
95 * so exception cleanup cannot release the same ownership twice. */
96 #define RELEASE(field) \
97 STMT_START \
98 { \
99 SV *owned = (SV *)frame->field; \
100 frame->field = NULL; \
101 SvREFCNT_dec(owned); \
102 } \
103 STMT_END
104 53220 RELEASE(name);
105 53220 RELEASE(class_name);
106 53220 RELEASE(temporary_sv);
107 53220 RELEASE(hidden);
108 53220 RELEASE(keys);
109 #undef RELEASE
110 53220 }
111  
112 /* Destroy active and reusable continuation frames, including any owned values
113 * left by an interrupted traversal.
114 */
115 5750 void dds_clear_frames(pTHX_ dds_ctx *ctx)
116 {
117 struct dds_frame *frame;
118  
119 5751 ▶ while ((frame = ctx->frames)) {
Branch: 1 branch
BranchTrueFalseTotal
while ((frame = ctx->frames)) { 1 5750 5751
120 1 dds_release_frame(aTHX_ frame);
121 1 ctx->frames = frame->parent;
122 1 Safefree(frame);
123 }
124 17218 ▶ while ((frame = ctx->free_frames)) {
Branch: 1 branch
BranchTrueFalseTotal
while ((frame = ctx->free_frames)) { 11468 5750 17218
125 11468 dds_release_frame(aTHX_ frame);
126 11468 ctx->free_frames = frame->parent;
127 11468 Safefree(frame);
128 }
129 5750 }
130  
131 /* Build a mortal string from a C prefix, an optional SV value and a C suffix. */
132 5160 static SV *dds_concat(pTHX_ const char *prefix, SV *value, const char *suffix)
133 {
134 5160 SV *out = DDS_TEMP(newSVpv(prefix, 0));
135  
136 5160 ▶ if (value)
Branch: 1 branch
BranchTrueFalseTotal
if (value) 5160 0 5160
137 5160 DDS_CAT(out, value);
138 5160 sv_catpv(out, suffix);
139 5160 return out;
140 }
141  
142 /*
143 * Deferred graph construction
144 *
145 * Completion marks describe available destinations. Typed fixups wait for
146 * those marks before assigning aliases, restoring class fields or running
147 * thaws.
148 */
149  
150 /* Allocate a not-yet-ready completion mark owned by the current emission. */
151 2141 dds_mark *dds_new_mark(pTHX_ dds_ctx *ctx)
152 {
153 dds_mark *mark;
154  
155 2141 Newxz(mark, 1, dds_mark);
156 2141 mark->next = ctx->marks;
157 2141 ctx->marks = mark;
158 2141 return mark;
159 }
160  
161 /* Allocate a deferred action, copying its destination expression and borrowing
162 * its stable catalogue node.
163 */
164 5689 dds_fix *dds_new_fix(pTHX_ dds_fix_kind kind, SV *lhs, dds_node *node)
165 {
166 dds_fix *fix;
167  
168 5689 Newxz(fix, 1, dds_fix);
169 5689 fix->kind = kind;
170 5689 ▶ fix->lhs = lhs ? newSVsv(lhs) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
fix->lhs = lhs ? newSVsv(lhs) : NULL; 5650 39 5689
171 5689 fix->node = node;
172 5689 return fix;
173 }
174  
175 /* Queue a deferred action and count pending alias dependencies, placing
176 * variable introductions ahead of actions that may use them.
177 */
178 5689 void dds_add_fix(pTHX_ dds_ctx *ctx, dds_fix *fix)
179 {
180 /* Introduce named variables before fixups that may refer to them. */
181 5689 ▶ if (fix->kind == DDS_FIX_VAR) {
Branch: 1 branch
BranchTrueFalseTotal
if (fix->kind == DDS_FIX_VAR) { 0 5689 5689
182 0 fix->next = ctx->fix_head;
183 0 ctx->fix_head = fix;
184 0 ▶ if (!ctx->fix_tail)
Branch: 1 branch
BranchTrueFalseTotal
if (!ctx->fix_tail) 0 0 0
185 0 ctx->fix_tail = fix;
186 } else {
187 5689 ▶ if (ctx->fix_tail)
Branch: 1 branch
BranchTrueFalseTotal
if (ctx->fix_tail) 5258 431 5689
188 5258 ctx->fix_tail->next = fix;
189 else
190 431 ctx->fix_head = fix;
191 5689 ctx->fix_tail = fix;
192 }
193  
194 5689 ctx->fixes++;
195 5689 ▶ if (fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF || fix->path)
Branch: 3 branches
BranchTrueFalseTotal
if (fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF || fix->path) 5578 111 5689
if (fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF || fix->path) 1245 4333 5578
if (fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF || fix->path) 0 1245 1245
196 4444 ctx->pending_aliases++;
197 5689 }
198  
199 /* Queue a generated helper call, recording its alias destination when class
200 * hydration needs dependency tracking.
201 */
202 1065 static void dds_call_fix(pTHX_ dds_ctx *ctx, const char *function, SV *args, dds_node *source,
203 SV *path)
204 {
205 1065 dds_fix *fix = dds_new_fix(aTHX_ DDS_FIX_CALL, args, source);
206  
207 1065 fix->text = newSVpv(function, 0);
208 1065 ▶ if (ctx->class_head && path)
Branch: 2 branches
BranchTrueFalseTotal
if (ctx->class_head && path) 0 1065 1065
if (ctx->class_head && path) 0 0 0
209 0 fix->path = newSVsv(path);
210 1065 dds_add_fix(aTHX_ ctx, fix);
211 1065 }
212  
213 /* Release a completed deferred action and every output value or glob reference
214 * it owns.
215 */
216 5688 static void dds_free_fix(pTHX_ dds_fix *fix)
217 {
218 5688 SvREFCNT_dec(fix->lhs);
219 5688 SvREFCNT_dec(fix->text);
220 5688 SvREFCNT_dec(fix->class_name);
221 5688 SvREFCNT_dec(fix->args);
222 5688 SvREFCNT_dec(fix->glob);
223 5688 SvREFCNT_dec(fix->path);
224 5688 Safefree(fix);
225 5688 }
226  
227 /* Build a mortal reference expression for a canonical name, adding a reference
228 * operator or blessing when required.
229 */
230 132 static SV *dds_ref_expression(pTHX_ dds_ctx *ctx, SV *name, SV *class_name)
231 {
232 132 const char *p = DDS_PV(name);
233 132 SV *out = DDS_TEMP(newSVpvs(""));
234  
235 132 ▶ if (SvOK(class_name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(class_name)) { 44 88 132
236 44 sv_catpvs(out, "bless(");
237 44 DDS_CAT(out, ctx->style.space);
238 }
239 132 ▶ if (strchr("@%&", p[0]))
Branch: 1 branch
BranchTrueFalseTotal
if (strchr("@%&", p[0])) 132 0 132
240 132 sv_catpvs(out, "\\");
241 132 DDS_CAT(out, name);
242 132 ▶ if (SvOK(class_name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(class_name)) { 44 88 132
243 44 sv_catpvs(out, ",");
244 44 DDS_CAT(out, ctx->style.space);
245 44 DDS_CAT(out, dds_quote(aTHX_ class_name, FALSE));
246 44 DDS_CAT(out, ctx->style.space);
247 44 sv_catpvs(out, ")");
248 }
249 132 return out;
250 }
251  
252 /* Emit a deferred restricted-hash lock, including placeholder keys that must
253 * remain legal.
254 */
255 8 static void dds_lock_fix_output(pTHX_ dds_ctx *ctx, dds_fix *fix)
256 {
257 SSize_t i;
258 8 SV *name = fix->node->ref.name;
259 8 ▶ bool hidden = fix->args && av_len(fix->args) >= 0;
Branch: 2 branches
BranchTrueFalseTotal
bool hidden = fix->args && av_len(fix->args) >= 0; 8 0 8
bool hidden = fix->args && av_len(fix->args) >= 0; 4 4 8
260  
261 8 ▶ dds_put(aTHX_ ctx, hidden ? "lock_keys_plus( " : "lock_keys( ");
Branch: 1 branch
BranchTrueFalseTotal
dds_put(aTHX_ ctx, hidden ? "lock_keys_plus( " : "lock_keys( "); 4 4 8
262 8 dds_write(aTHX_ ctx, name);
263 8 ▶ if (hidden) {
Branch: 1 branch
BranchTrueFalseTotal
if (hidden) { 4 4 8
264 4 dds_put(aTHX_ ctx, ", ");
265 12 ▶ for (i = 0; i <= av_len(fix->args); i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= av_len(fix->args); i++) { 8 4 12
266 8 ▶ if (i)
Branch: 1 branch
BranchTrueFalseTotal
if (i) 4 4 8
267 4 dds_put(aTHX_ ctx, ", ");
268 8 dds_write(aTHX_ ctx, dds_quote(aTHX_ * av_fetch(fix->args, i, 0), FALSE));
269 }
270 4 dds_put(aTHX_ ctx, ");\n");
271 } else
272 4 dds_put(aTHX_ ctx, " );\n");
273 8 }
274  
275 /* Emit a deferred thaw as a method, function or arbitrary code block, making
276 * its referent available to dependent fixups.
277 */
278 3 static void dds_thaw_output(pTHX_ dds_ctx *ctx, dds_fix *fix)
279 {
280 3 SV *name = fix->node->ref.name;
281 3 const char *p = DDS_PV(fix->text), *method = p;
282 3 STRLEN len = strlen(p), i;
283 3 ▶ bool simple = TRUE, function = len >= 2 && strEQ(p + len - 2, "()");
Branch: 2 branches
BranchTrueFalseTotal
bool simple = TRUE, function = len >= 2 && strEQ(p + len - 2, "()"); 3 0 3
bool simple = TRUE, function = len >= 2 && strEQ(p + len - 2, "()"); 1 2 3
284  
285 3 ▶ if (method[0] == '-' && method[1] == '>') {
Branch: 2 branches
BranchTrueFalseTotal
if (method[0] == '-' && method[1] == '>') { 0 3 3
if (method[0] == '-' && method[1] == '>') { 0 0 0
286 0 method += 2;
287 0 len -= 2;
288 }
289 27 ▶ for (i = 0; i < len - (function ? 2 : 0); i++)
Branch: 2 branches
BranchTrueFalseTotal
for (i = 0; i < len - (function ? 2 : 0); i++) 9 18 27
for (i = 0; i < len - (function ? 2 : 0); i++) 24 3 27
290 24 ▶ if (!isALNUMC_A(method[i]) && method[i] != '_' && method[i] != ':')
Branch: 3 branches
BranchTrueFalseTotal
if (!isALNUMC_A(method[i]) && method[i] != '_' && method[i] != ':') 2 22 24
if (!isALNUMC_A(method[i]) && method[i] != '_' && method[i] != ':') 0 2 2
if (!isALNUMC_A(method[i]) && method[i] != '_' && method[i] != ':') 0 0 0
291 0 simple = FALSE;
292 3 ▶ if (fix->node->ref.done)
Branch: 1 branch
BranchTrueFalseTotal
if (fix->node->ref.done) 3 0 3
293 3 fix->node->ref.done->ready = TRUE;
294 3 ▶ if (!simple) {
Branch: 1 branch
BranchTrueFalseTotal
if (!simple) { 0 3 3
295 0 SV *text = DDS_TEMP(newSVsv(fix->text));
296 STRLEN n, at;
297 0 const char *s = SvPV(text, n);
298  
299 0 dds_put(aTHX_ ctx, "for (");
300 0 dds_write(aTHX_ ctx, name);
301 0 dds_put(aTHX_ ctx, ") {\n");
302 0 ▶ for (at = 0; at < n; at++) {
Branch: 1 branch
BranchTrueFalseTotal
for (at = 0; at < n; at++) { 0 0 0
303 0 ▶ if (s[at] == '\t' && (!at || s[at - 1] == '\n'))
Branch: 3 branches
BranchTrueFalseTotal
if (s[at] == '\t' && (!at || s[at - 1] == '\n')) 0 0 0
if (s[at] == '\t' && (!at || s[at - 1] == '\n')) 0 0 0
if (s[at] == '\t' && (!at || s[at - 1] == '\n')) 0 0 0
304 0 continue;
305 0 dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(s + at, 1)));
306 }
307 0 dds_put(aTHX_ ctx, "\n}\n");
308 3 ▶ } else if (function) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (function) { 1 2 3
309 1 dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(method, len - 2)));
310 1 dds_put(aTHX_ ctx, "( ");
311 1 dds_write(aTHX_ ctx, name);
312 1 dds_put(aTHX_ ctx, " );\n");
313 } else {
314 2 dds_write(aTHX_ ctx, name);
315 2 dds_put(aTHX_ ctx, "->");
316 2 dds_put(aTHX_ ctx, method);
317 2 dds_put(aTHX_ ctx, "();\n");
318 }
319 3 }
320  
321 /* Match whole expressions or descendants, not similarly prefixed names. */
322 0 static bool dds_path_contains(pTHX_ SV *parent, SV *path)
323 {
324 STRLEN plen, len;
325 0 ▶ const char *p = SvPV(parent, plen), *s = SvPV(path, len);
Branch: 1 branch
BranchTrueFalseTotal
const char *p = SvPV(parent, plen), *s = SvPV(path, len); 0 0 0
326  
327 0 ▶ return len >= plen && memEQ(p, s, plen) &&
Branch: 2 branches
BranchTrueFalseTotal
return len >= plen && memEQ(p, s, plen) && 0 0 0
return len >= plen && memEQ(p, s, plen) && 0 0 0
328 0 ▶ (len == plen || s[plen] == '-' || s[plen] == '{' || s[plen] == '[');
Branch: 4 branches
BranchTrueFalseTotal
(len == plen || s[plen] == '-' || s[plen] == '{' || s[plen] == '['); 0 0 0
(len == plen || s[plen] == '-' || s[plen] == '{' || s[plen] == '['); 0 0 0
(len == plen || s[plen] == '-' || s[plen] == '{' || s[plen] == '['); 0 0 0
(len == plen || s[plen] == '-' || s[plen] == '{' || s[plen] == '['); 0 0 0
329 }
330  
331 /* Check that no pending alias can replace a field snapshot slot or the object
332 * destination before class hydration.
333 */
334 0 static bool dds_class_fields_ready(pTHX_ dds_ctx *ctx, dds_node *node)
335 {
336 dds_fix *fix;
337 /* Slot replacement must precede hydration, which shares the final
338 * field SVs. Ordinary thaws can make those replacements ready. */
339 0 ▶ if (!ctx->pending_aliases)
Branch: 1 branch
BranchTrueFalseTotal
if (!ctx->pending_aliases) 0 0 0
340 0 return TRUE;
341 0 ▶ for (fix = ctx->fix_head; fix; fix = fix->next) {
Branch: 1 branch
BranchTrueFalseTotal
for (fix = ctx->fix_head; fix; fix = fix->next) { 0 0 0
342 0 ▶ SV *path = fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF ? fix->lhs : fix->path;
Branch: 2 branches
BranchTrueFalseTotal
SV *path = fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF ? fix->lhs : fix->path; 0 0 0
SV *path = fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF ? fix->lhs : fix->path; 0 0 0
343  
344 0 ▶ if (path && (dds_path_contains(aTHX_ node->class_fields_name, path) ||
Branch: 1 branch
BranchTrueFalseTotal
if (path && (dds_path_contains(aTHX_ node->class_fields_name, path) || 0 0 0
345 0 dds_path_contains(aTHX_ path, node->ref.name)))
346 0 return FALSE;
347 }
348 0 return TRUE;
349 }
350  
351 /* Emit XPerl field hydration using the reconstructed object as $self, then
352 * mark its class storage restored.
353 */
354 0 static void dds_restore_class(pTHX_ dds_ctx *ctx, dds_node *node)
355 {
356 0 dds_write(aTHX_ ctx, node->class_fields_name);
357 0 dds_put(aTHX_ ctx, "->{'$self'} = ");
358 0 dds_write(aTHX_ ctx,
359 dds_ref_expression(aTHX_ ctx, node->ref.name,
360 0 ▶ node->class_package ? node->class_package : &PL_sv_undef));
Branch: 1 branch
BranchTrueFalseTotal
node->class_package ? node->class_package : &PL_sv_undef)); 0 0 0
361 0 dds_put(aTHX_ ctx, ";\nbuiltin::class_object_from_hash(");
362 0 dds_write(aTHX_ ctx, node->class_fields_name);
363 0 dds_put(aTHX_ ctx, ");\n");
364 0 node->class_restored = TRUE;
365 0 }
366  
367 /* Emit ready deferred actions until no more progress is possible; final mode
368 * also permits blessing, thaws and class hydration.
369 */
370 4946 void dds_apply_fixes(pTHX_ dds_ctx *ctx, bool final)
371 {
372 bool glob_work, progress;
373  
374 /* A completed fixup can unlock another. Drain to a fixed point;
375 * glob emission may itself queue more ordinary fixups. */
376 do {
377 5520 dds_fix **link = &ctx->fix_head;
378 5520 dds_fix **glob_tail = &ctx->glob_head;
379  
380 5520 glob_work = FALSE;
381 5520 progress = FALSE;
382  
383 14153 ▶ while (*link) {
Branch: 1 branch
BranchTrueFalseTotal
while (*link) { 8633 5520 14153
384 8633 dds_fix *fix = *link;
385 8633 bool ready = FALSE;
386 5134 ▶ dds_role *role = fix->node ? (fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_CALL
Branch: 1 branch
BranchTrueFalseTotal
dds_role *role = fix->node ? (fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_CALL 395 4739 5134
387 698 ? &fix->node->slot
388 10571 ▶ : &fix->node->ref)
Branch: 1 branch
BranchTrueFalseTotal
: &fix->node->ref) 5134 303 5437
389 14070 ▶ : NULL;
Branch: 1 branch
BranchTrueFalseTotal
: NULL; 5437 3196 8633
390  
391 8633 switch (fix->kind) {
392 4930 case DDS_FIX_SLOT:
393 case DDS_FIX_REF:
394 4930 ▶ ready = role && role->done && role->done->ready;
Branch: 3 branches
BranchTrueFalseTotal
ready = role && role->done && role->done->ready; 4930 0 4930
ready = role && role->done && role->done->ready; 4542 388 4930
ready = role && role->done && role->done->ready; 4444 98 4542
395 4930 ▶ if (ready) {
Branch: 1 branch
BranchTrueFalseTotal
if (ready) { 4444 486 4930
396 4444 SV *lhs = fix->lhs, *rhs = role->name, *underef;
397  
398 4444 ▶ if (fix->kind == DDS_FIX_SLOT && (underef = dds_underef(aTHX_ lhs))) {
Branch: 2 branches
BranchTrueFalseTotal
if (fix->kind == DDS_FIX_SLOT && (underef = dds_underef(aTHX_ lhs))) { 111 4333 4444
if (fix->kind == DDS_FIX_SLOT && (underef = dds_underef(aTHX_ lhs))) { 111 0 111
399 111 lhs = underef;
400 111 rhs = dds_concat(aTHX_ "\\", rhs, "");
401 8666 ▶ } else if (fix->kind == DDS_FIX_REF && strchr("@%&", DDS_PV(rhs)[0]))
Branch: 2 branches
BranchTrueFalseTotal
} else if (fix->kind == DDS_FIX_REF && strchr("@%&", DDS_PV(rhs)[0])) 4333 0 4333
} else if (fix->kind == DDS_FIX_REF && strchr("@%&", DDS_PV(rhs)[0])) 36 4297 4333
402 36 rhs = dds_ref_expression(aTHX_ ctx, rhs,
403 36 ▶ fix->class_name ? fix->class_name : &PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
fix->class_name ? fix->class_name : &PL_sv_undef); 12 24 36
404 4444 dds_write(aTHX_ ctx, lhs);
405 4444 dds_put(aTHX_ ctx, " = ");
406 4444 dds_write(aTHX_ ctx, rhs);
407 4444 dds_put(aTHX_ ctx, ";\n");
408 4444 ▶ if (fix->mark)
Branch: 1 branch
BranchTrueFalseTotal
if (fix->mark) 111 4333 4444
409 111 fix->mark->ready = TRUE;
410 }
411 4930 break;
412 3450 case DDS_FIX_CALL:
413 6816 ▶ ready = (!role || (role->done && role->done->ready)) &&
Branch: 3 branches
BranchTrueFalseTotal
ready = (!role || (role->done && role->done->ready)) && 395 3055 3450
ready = (!role || (role->done && role->done->ready)) && 311 84 395
ready = (!role || (role->done && role->done->ready)) && 311 0 311
414 6732 ▶ (!strEQ(DDS_PV(fix->text), "weaken") || (final && ctx->final_weakening));
Branch: 3 branches
BranchTrueFalseTotal
(!strEQ(DDS_PV(fix->text), "weaken") || (final && ctx->final_weakening)); 3046 320 3366
(!strEQ(DDS_PV(fix->text), "weaken") || (final && ctx->final_weakening)); 1490 1556 3046
(!strEQ(DDS_PV(fix->text), "weaken") || (final && ctx->final_weakening)); 745 745 1490
415 3450 ▶ if (ready) {
Branch: 1 branch
BranchTrueFalseTotal
if (ready) { 1065 2385 3450
416 1065 dds_write(aTHX_ ctx, fix->text);
417 1065 dds_put(aTHX_ ctx, "(");
418 1065 dds_write(aTHX_ ctx, fix->lhs);
419 1065 ▶ if (role) {
Branch: 1 branch
BranchTrueFalseTotal
if (role) { 311 754 1065
420 311 dds_put(aTHX_ ctx, ", ");
421 311 dds_write(aTHX_ ctx, role->name);
422 }
423 1065 dds_put(aTHX_ ctx, ");\n");
424 }
425 3450 break;
426 96 case DDS_FIX_BLESS:
427 96 ready = final;
428 96 ▶ if (ready) {
Branch: 1 branch
BranchTrueFalseTotal
if (ready) { 28 68 96
429 STRLEN len;
430 28 const char *p = SvPV(ctx->style.bless, len);
431  
432 28 ▶ dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(p, len ? len - 1 : 0)));
Branch: 1 branch
BranchTrueFalseTotal
dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(p, len ? len - 1 : 0))); 28 0 28
433 28 dds_put(aTHX_ ctx, " ");
434 28 dds_write(aTHX_ ctx, role->name);
435 28 dds_put(aTHX_ ctx, ", ");
436 28 dds_write(aTHX_ ctx, dds_quote(aTHX_ fix->text, FALSE));
437 28 dds_put(aTHX_ ctx, " ");
438 28 ▶ if (len)
Branch: 1 branch
BranchTrueFalseTotal
if (len) 28 0 28
439 28 dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(p + len - 1, 1)));
440 28 dds_put(aTHX_ ctx, ";\n");
441 }
442 96 break;
443 8 case DDS_FIX_LOCK:
444 8 ▶ ready = role && role->done && role->done->ready;
Branch: 3 branches
BranchTrueFalseTotal
ready = role && role->done && role->done->ready; 8 0 8
ready = role && role->done && role->done->ready; 8 0 8
ready = role && role->done && role->done->ready; 8 0 8
445 8 ▶ if (ready)
Branch: 1 branch
BranchTrueFalseTotal
if (ready) 8 0 8
446 8 dds_lock_fix_output(aTHX_ ctx, fix);
447 8 break;
448 8 case DDS_FIX_THAW:
449 8 ▶ ready = final && (!fix->node->class_fields || fix->node->class_restored);
Branch: 3 branches
BranchTrueFalseTotal
ready = final && (!fix->node->class_fields || fix->node->class_restored); 3 5 8
ready = final && (!fix->node->class_fields || fix->node->class_restored); 0 3 3
ready = final && (!fix->node->class_fields || fix->node->class_restored); 0 0 0
450 8 ▶ if (ready)
Branch: 1 branch
BranchTrueFalseTotal
if (ready) 3 5 8
451 3 dds_thaw_output(aTHX_ ctx, fix);
452 8 break;
453 0 case DDS_FIX_CLASS:
454 0 ▶ ready = final && dds_class_fields_ready(aTHX_ ctx, fix->node);
Branch: 2 branches
BranchTrueFalseTotal
ready = final && dds_class_fields_ready(aTHX_ ctx, fix->node); 0 0 0
ready = final && dds_class_fields_ready(aTHX_ ctx, fix->node); 0 0 0
455 0 ▶ if (ready)
Branch: 1 branch
BranchTrueFalseTotal
if (ready) 0 0 0
456 0 dds_restore_class(aTHX_ ctx, fix->node);
457 0 break;
458 141 case DDS_FIX_GLOB:
459 141 ready = TRUE;
460 141 break;
461 0 case DDS_FIX_VAR:
462 0 ready = TRUE;
463 0 ▶ if (ctx->style.declare)
Branch: 1 branch
BranchTrueFalseTotal
if (ctx->style.declare) 0 0 0
464 0 dds_put(aTHX_ ctx, "my ");
465 0 dds_write(aTHX_ ctx, fix->lhs);
466 0 dds_put(aTHX_ ctx, " = ");
467 0 dds_write(aTHX_ ctx,
468 dds_ref_expression(aTHX_ ctx, fix->text,
469 0 ▶ fix->class_name ? fix->class_name : &PL_sv_undef));
Branch: 1 branch
BranchTrueFalseTotal
fix->class_name ? fix->class_name : &PL_sv_undef)); 0 0 0
470 0 dds_put(aTHX_ ctx, ";\n");
471 0 break;
472 }
473  
474 8633 ▶ if (!ready) {
Branch: 1 branch
BranchTrueFalseTotal
if (!ready) { 2944 5689 8633
475 2944 link = &fix->next;
476 2944 continue;
477 }
478  
479 5689 progress = TRUE;
480 5689 ▶ if (fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF || fix->path)
Branch: 3 branches
BranchTrueFalseTotal
if (fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF || fix->path) 5578 111 5689
if (fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF || fix->path) 1245 4333 5578
if (fix->kind == DDS_FIX_SLOT || fix->kind == DDS_FIX_REF || fix->path) 0 1245 1245
481 4444 ctx->pending_aliases--;
482 5689 *link = fix->next;
483 5689 ▶ if (fix == ctx->fix_tail)
Branch: 1 branch
BranchTrueFalseTotal
if (fix == ctx->fix_tail) 504 5185 5689
484 504 ctx->fix_tail = NULL;
485 5689 ▶ if (fix->kind == DDS_FIX_GLOB) {
Branch: 1 branch
BranchTrueFalseTotal
if (fix->kind == DDS_FIX_GLOB) { 141 5548 5689
486 141 fix->next = NULL;
487 141 *glob_tail = fix;
488 141 glob_tail = &fix->next;
489 } else
490 5548 dds_free_fix(aTHX_ fix);
491 }
492  
493 5520 ▶ if (ctx->fix_head) {
Branch: 1 branch
BranchTrueFalseTotal
if (ctx->fix_head) { 477 5043 5520
494 477 ctx->fix_tail = ctx->fix_head;
495 2944 ▶ while (ctx->fix_tail->next)
Branch: 1 branch
BranchTrueFalseTotal
while (ctx->fix_tail->next) 2467 477 2944
496 2467 ctx->fix_tail = ctx->fix_tail->next;
497 }
498  
499 5660 ▶ while (ctx->glob_head) {
Branch: 1 branch
BranchTrueFalseTotal
while (ctx->glob_head) { 141 5519 5660
500 141 dds_fix *fix = ctx->glob_head;
501  
502 141 dds_emit_glob(aTHX_ ctx, fix->glob, fix->lhs, fix->depth);
503 140 ctx->glob_head = fix->next;
504 140 dds_free_fix(aTHX_ fix);
505 140 glob_work = TRUE;
506 }
507 5519 ▶ } while (glob_work || progress);
Branch: 2 branches
BranchTrueFalseTotal
} while (glob_work || progress); 121 5398 5519
} while (glob_work || progress); 453 4945 5398
508 4945 }
509  
510 /* Emit an opening or closing container delimiter with the selected spacing,
511 * returning the indentation for its contents or parent.
512 */
513 9510 static IV dds_brace(pTHX_ dds_ctx *ctx, SV *name, char type, bool multiline, IV indent, UV children)
514 {
515 9510 bool open = strchr("{[(", type) != NULL;
516 9510 const char *p = DDS_PV(name);
517 9510 ▶ char brace = p[0] == '%' || p[0] == '@' ? (open ? '(' : ')') : type;
Branch: 3 branches
BranchTrueFalseTotal
char brace = p[0] == '%' || p[0] == '@' ? (open ? '(' : ')') : type; 9398 112 9510
char brace = p[0] == '%' || p[0] == '@' ? (open ? '(' : ')') : type; 164 9234 9398
char brace = p[0] == '%' || p[0] == '@' ? (open ? '(' : ')') : type; 138 138 276
518  
519 9510 ▶ if (multiline) {
Branch: 1 branch
BranchTrueFalseTotal
if (multiline) { 4534 4976 9510
520 4534 ▶ indent += open ? ctx->style.indentcols : -ctx->style.indentcols;
Branch: 1 branch
BranchTrueFalseTotal
indent += open ? ctx->style.indentcols : -ctx->style.indentcols; 2267 2267 4534
521 4534 ▶ if (!open) {
Branch: 1 branch
BranchTrueFalseTotal
if (!open) { 2267 2267 4534
522 2267 dds_put(aTHX_ ctx, "\n");
523 2267 dds_spaces(aTHX_ ctx, indent);
524 }
525 4534 dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(&brace, 1)));
526 4534 ▶ if (open) {
Branch: 1 branch
BranchTrueFalseTotal
if (open) { 2267 2267 4534
527 2267 dds_put(aTHX_ ctx, "\n");
528 2267 dds_spaces(aTHX_ ctx, indent);
529 }
530 } else {
531 4976 ▶ if (!open && children)
Branch: 2 branches
BranchTrueFalseTotal
if (!open && children) 2488 2488 4976
if (!open && children) 2442 46 2488
532 2442 dds_write(aTHX_ ctx, ctx->style.space);
533 4976 dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(&brace, 1)));
534 4976 ▶ if (open && children)
Branch: 2 branches
BranchTrueFalseTotal
if (open && children) 2488 2488 4976
if (open && children) 2442 46 2488
535 2442 dds_write(aTHX_ ctx, ctx->style.space);
536 }
537 9510 return indent;
538 }
539  
540 /* Decide whether repeating a scalar literal is safe for RLE, excluding
541 * references, magic, readonly values and known aliases.
542 */
543 7451 static bool dds_rle_eligible(pTHX_ dds_ctx *ctx, SV *sv)
544 {
545 dds_node *node;
546  
547 7451 ▶ if (SvROK(sv) || SvREADONLY(sv) || SvGMAGICAL(sv))
Branch: 3 branches
BranchTrueFalseTotal
if (SvROK(sv) || SvREADONLY(sv) || SvGMAGICAL(sv)) 2413 5038 7451
if (SvROK(sv) || SvREADONLY(sv) || SvGMAGICAL(sv)) 2404 9 2413
if (SvROK(sv) || SvREADONLY(sv) || SvGMAGICAL(sv)) 3 2401 2404
548 5050 return FALSE;
549  
550 2401 ▶ node = dds_candidate(aTHX_ sv) ? dds_find(aTHX_ ctx, sv, FALSE) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
node = dds_candidate(aTHX_ sv) ? dds_find(aTHX_ ctx, sv, FALSE) : NULL; 226 2175 2401
551 2401 ▶ return !node || !node->slot.present || node->slot.encounters == 1;
Branch: 3 branches
BranchTrueFalseTotal
return !node || !node->slot.present || node->slot.encounters == 1; 226 2175 2401
return !node || !node->slot.present || node->slot.encounters == 1; 226 0 226
return !node || !node->slot.present || node->slot.encounters == 1; 6 220 226
552 }
553  
554 /*
555 * Container traversal
556 *
557 * Array and hash continuations emit one child at a time, retaining layout
558 * state and recording aliases after the child returns.
559 */
560  
561 /* Advance an array continuation through one child or completion, preserving
562 * layout, RLE state and deferred element aliases.
563 */
564 10691 static bool dds_step_array(pTHX_ dds_ctx *ctx, struct dds_frame *f)
565 {
566 10691 AV *av = (AV *)f->sv;
567 10691 UV depth = f->depth;
568 10691 dds_mark *mark = f->mark;
569 10691 SV *name = f->name;
570 10691 IV indent = f->indent;
571 10691 SSize_t k = 0, last;
572  
573 10691 ▶ if (f->stage != DDS_STAGE_INITIAL)
Branch: 1 branch
BranchTrueFalseTotal
if (f->stage != DDS_STAGE_INITIAL) 7601 3090 10691
574 7601 last = f->last;
575 else {
576 3090 ▶ if (SvTIED_mg((SV *)av, PERL_MAGIC_tied))
Branch: 2 branches
BranchTrueFalseTotal
if (SvTIED_mg((SV *)av, PERL_MAGIC_tied)) 283 2807 3090
if (SvTIED_mg((SV *)av, PERL_MAGIC_tied)) 1 282 283
577 1 dds_callback_guard(aTHX_ ctx);
578 3090 last = av_len(av);
579 }
580 10691 ▶ bool multiline = ctx->style.indent && last > 0;
Branch: 2 branches
BranchTrueFalseTotal
bool multiline = ctx->style.indent && last > 0; 7661 3030 10691
bool multiline = ctx->style.indent && last > 0; 7177 484 7661
581 10691 bool full = ctx->style.indent > 1;
582 10691 IV last_n = 0;
583  
584 10691 ▶ if (f->stage == DDS_STAGE_INITIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if (f->stage == DDS_STAGE_INITIAL) { 3090 7601 10691
585 3090 indent = dds_brace(aTHX_ ctx, name, '[', multiline, indent, last + 1);
586 3090 f->indent = indent;
587 3090 f->last = last;
588 }
589 10691 k = f->k;
590 10691 last_n = f->last_n;
591  
592 18292 ▶ while (k <= last) {
Branch: 1 branch
BranchTrueFalseTotal
while (k <= last) { 15202 3090 18292
593 15202 ▶ SV **entry = f->stage != DDS_STAGE_INITIAL ? NULL : av_fetch(av, k, 0);
Branch: 1 branch
BranchTrueFalseTotal
SV **entry = f->stage != DDS_STAGE_INITIAL ? NULL : av_fetch(av, k, 0); 7601 7601 15202
594 15202 ▶ SV *value = entry ? *entry : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
SV *value = entry ? *entry : &PL_sv_undef; 7601 7601 15202
595 15202 SSize_t count = 1;
596 bool newline;
597 dds_result result;
598  
599 15202 ▶ if (f->stage != DDS_STAGE_INITIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if (f->stage != DDS_STAGE_INITIAL) { 7601 7601 15202
600 7601 count = f->run;
601 7601 goto child_done;
602 }
603  
604 /* Count a run before yielding to its first element. RLE must
605 * preserve value flags as well as the printable string value. */
606 7601 f->active.sv = value;
607 7601 ▶ if (ctx->style.rle && dds_rle_eligible(aTHX_ ctx, value)) {
Branch: 2 branches
BranchTrueFalseTotal
if (ctx->style.rle && dds_rle_eligible(aTHX_ ctx, value)) { 6381 1220 7601
if (ctx->style.rle && dds_rle_eligible(aTHX_ ctx, value)) { 1469 4912 6381
608 1524 ▶ while (k + count <= last) {
Branch: 1 branch
BranchTrueFalseTotal
while (k + count <= last) { 1070 454 1524
609 1070 SV **next = av_fetch(av, k + count, 0);
610 1070 ▶ SV *v = next ? *next : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
SV *v = next ? *next : &PL_sv_undef; 1070 0 1070
611  
612 1782 ▶ if (!dds_rle_eligible(aTHX_ ctx, v) || cBOOL(SvOK(value)) != cBOOL(SvOK(v)) ||
Branch: 1 branch
BranchTrueFalseTotal
if (!dds_rle_eligible(aTHX_ ctx, v) || cBOOL(SvOK(value)) != cBOOL(SvOK(v)) || 712 358 1070
613 712 cBOOL(SvTRUE(value)) != cBOOL(SvTRUE(v)))
614 break;
615 692 ▶ if (cBOOL(SvUTF8(value)) != cBOOL(SvUTF8(v)))
Branch: 1 branch
BranchTrueFalseTotal
if (cBOOL(SvUTF8(value)) != cBOOL(SvUTF8(v))) 1 691 692
616 1 break;
617 691 ▶ if (ctx->style.dualvars) {
Branch: 1 branch
BranchTrueFalseTotal
if (ctx->style.dualvars) { 691 0 691
618 691 ▶ if (cBOOL(SvNIOK(value)) != cBOOL(SvNIOK(v)))
Branch: 1 branch
BranchTrueFalseTotal
if (cBOOL(SvNIOK(value)) != cBOOL(SvNIOK(v))) 7 684 691
619 7 break;
620 684 ▶ if (SvNIOK(value) && SvNIOK(v)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvNIOK(value) && SvNIOK(v)) { 554 130 684
if (SvNIOK(value) && SvNIOK(v)) { 554 0 554
621 554 ▶ if (cBOOL(SvIOK(value)) != cBOOL(SvIOK(v)))
Branch: 1 branch
BranchTrueFalseTotal
if (cBOOL(SvIOK(value)) != cBOOL(SvIOK(v))) 1 553 554
622 1 break;
623 553 ▶ if (SvIOK(value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvIOK(value)) { 552 1 553
624 552 ▶ if (cBOOL(SvIsUV(value)) != cBOOL(SvIsUV(v)))
Branch: 1 branch
BranchTrueFalseTotal
if (cBOOL(SvIsUV(value)) != cBOOL(SvIsUV(v))) 0 552 552
625 0 break;
626 552 ▶ if (SvIsUV(value) ? SvUV(value) != SvUV(v) : SvIV(value) != SvIV(v))
Branch: 2 branches
BranchTrueFalseTotal
if (SvIsUV(value) ? SvUV(value) != SvUV(v) : SvIV(value) != SvIV(v)) 1 551 552
if (SvIsUV(value) ? SvUV(value) != SvUV(v) : SvIV(value) != SvIV(v)) 502 50 552
627 502 break;
628 1 ▶ } else if (SvNV(value) != SvNV(v))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvNV(value) != SvNV(v)) 1 0 1
629 1 break;
630 }
631 }
632 180 ▶ if (SvOK(value) && sv_cmp(value, v))
Branch: 2 branches
BranchTrueFalseTotal
if (SvOK(value) && sv_cmp(value, v)) 180 0 180
if (SvOK(value) && sv_cmp(value, v)) 125 55 180
633 125 break;
634 55 count++;
635 }
636 }
637  
638 7601 ▶ newline = multiline && (!last_n || SvROK(value));
Branch: 3 branches
BranchTrueFalseTotal
newline = multiline && (!last_n || SvROK(value)); 5851 1750 7601
newline = multiline && (!last_n || SvROK(value)); 0 5851 5851
newline = multiline && (!last_n || SvROK(value)); 0 0 0
639 7601 ▶ if (k) {
Branch: 1 branch
BranchTrueFalseTotal
if (k) { 4541 3060 7601
640 4541 dds_write(aTHX_ ctx, ctx->style.arysep);
641 4541 ▶ if (newline) {
Branch: 1 branch
BranchTrueFalseTotal
if (newline) { 4525 16 4541
642 4525 dds_put(aTHX_ ctx, "\n");
643 4525 dds_spaces(aTHX_ ctx, indent);
644 4525 ctx->column = 0;
645 } else {
646 16 dds_write(aTHX_ ctx, ctx->style.space);
647 16 ▶ if (!ctx->style.rle && !SvTRUE(ctx->style.space) && ctx->column > 1024) {
Branch: 3 branches
BranchTrueFalseTotal
if (!ctx->style.rle && !SvTRUE(ctx->style.space) && ctx->column > 1024) { 1 15 16
if (!ctx->style.rle && !SvTRUE(ctx->style.space) && ctx->column > 1024) { 1 0 1
if (!ctx->style.rle && !SvTRUE(ctx->style.space) && ctx->column > 1024) { 1 0 1
648 1 dds_put(aTHX_ ctx, "\n");
649 1 ctx->column = 0;
650 }
651 }
652 }
653  
654 7601 ▶ if (count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (count > 1) { 19 7582 7601
655 19 dds_put(aTHX_ ctx, "(");
656 19 dds_write(aTHX_ ctx, ctx->style.space);
657 19 ctx->column += 2;
658 }
659  
660 /* Save the continuation before a child frame becomes active. */
661 7601 f->stage = DDS_STAGE_CHILD;
662 7601 f->k = k;
663 7601 f->run = count;
664 7601 f->last_n = last_n;
665 7601 dds_push_frame(aTHX_ ctx, DDS_FRAME_SV, value, depth + 1, mark,
666 dds_child_name(aTHX_ name, '[', NULL, k), indent, FALSE);
667 7601 return FALSE;
668  
669 7601 child_done:
670 7601 result = f->result;
671 7601 f->stage = DDS_STAGE_INITIAL;
672 7601 ▶ last_n = !full && !ctx->do_nl && ctx->column < 60 ? last_n + 1 : 0;
Branch: 3 branches
BranchTrueFalseTotal
last_n = !full && !ctx->do_nl && ctx->column < 60 ? last_n + 1 : 0; 1522 6079 7601
last_n = !full && !ctx->do_nl && ctx->column < 60 ? last_n + 1 : 0; 23 1499 1522
last_n = !full && !ctx->do_nl && ctx->column < 60 ? last_n + 1 : 0; 20 3 23
673  
674 7601 ▶ if (result.alias) {
Branch: 1 branch
BranchTrueFalseTotal
if (result.alias) { 301 7300 7601
675 301 SV *args = DDS_TEMP(newSVsv(dds_child_name(aTHX_ name, '@', NULL, 0)));
676  
677 301 sv_catpvf(args, ", %" IVdf, (IV)k);
678 301 dds_call_fix(aTHX_ ctx, "alias_av", args, result.alias,
679 301 ▶ ctx->class_head ? dds_child_name(aTHX_ name, '[', NULL, k) : NULL);
Branch: 1 branch
BranchTrueFalseTotal
ctx->class_head ? dds_child_name(aTHX_ name, '[', NULL, k) : NULL); 0 301 301
680 }
681 7601 ▶ if (count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (count > 1) { 19 7582 7601
682 19 SV *text = DDS_TEMP(newSVsv(ctx->style.space));
683  
684 19 sv_catpvs(text, ")");
685 19 DDS_CAT(text, ctx->style.space);
686 19 sv_catpvs(text, "x");
687 19 DDS_CAT(text, ctx->style.space);
688 19 sv_catpvf(text, "%" IVdf, (IV)count);
689 19 ctx->column += sv_len_utf8(text);
690 19 dds_write(aTHX_ ctx, text);
691 }
692  
693 7601 k += count;
694 7601 f->active.sv = (SV *)av;
695 }
696  
697 3090 dds_brace(aTHX_ ctx, name, ']', multiline, indent, last + 1);
698 3090 Zero(&f->result, 1, dds_result);
699 3090 return TRUE;
700 }
701  
702 /* Advance a hash continuation through one value or completion, preserving key
703 * order, alignment and deferred value aliases.
704 */
705 18365 static bool dds_step_hash(pTHX_ dds_ctx *ctx, struct dds_frame *f)
706 {
707 18365 HV *hv = (HV *)f->sv;
708 18365 UV depth = f->depth;
709 18365 dds_mark *mark = f->mark;
710 18365 SV *name = f->name;
711 18365 IV indent = f->indent;
712 18365 dds_node *node = f->node;
713 18365 AV *keys = f->keys;
714  
715 18365 ▶ if (!keys) {
Branch: 1 branch
BranchTrueFalseTotal
if (!keys) { 1665 16700 18365
716 1665 keys = dds_keys(aTHX_ ctx, hv, 1, NULL);
717 1665 f->keys = (AV *)SvREFCNT_inc((SV *)keys);
718 }
719 18365 UV count = av_len(keys) + 1, width = 0, sum = 0, max = 0;
720 SSize_t k;
721 18365 IV child_indent, last_n = 0;
722 18365 bool full = ctx->style.indent > 1;
723 18365 ▶ bool multiline = ctx->style.indent && count > 1;
Branch: 2 branches
BranchTrueFalseTotal
bool multiline = ctx->style.indent && count > 1; 17444 921 18365
bool multiline = ctx->style.indent && count > 1; 16622 822 17444
724  
725 18365 ▶ if (node && node->key_count)
Branch: 2 branches
BranchTrueFalseTotal
if (node && node->key_count) 17212 1153 18365
if (node && node->key_count) 16222 990 17212
726 16222 ▶ multiline = ctx->style.indent && node->key_count > 1;
Branch: 2 branches
BranchTrueFalseTotal
multiline = ctx->style.indent && node->key_count > 1; 16222 0 16222
multiline = ctx->style.indent && node->key_count > 1; 15992 230 16222
727  
728 /* Reuse analysis widths when available; otherwise measure this hash. */
729 18365 ▶ if (f->stage == DDS_STAGE_INITIAL && ctx->style.indentkeys && multiline) {
Branch: 3 branches
BranchTrueFalseTotal
if (f->stage == DDS_STAGE_INITIAL && ctx->style.indentkeys && multiline) { 1665 16700 18365
if (f->stage == DDS_STAGE_INITIAL && ctx->style.indentkeys && multiline) { 1665 0 1665
if (f->stage == DDS_STAGE_INITIAL && ctx->style.indentkeys && multiline) { 941 724 1665
730 941 ▶ if (node && node->key_count)
Branch: 2 branches
BranchTrueFalseTotal
if (node && node->key_count) 878 63 941
if (node && node->key_count) 873 5 878
731 873 width = node->key_width;
732 else {
733 630 ▶ for (k = 0; k <= av_len(keys); k++) {
Branch: 1 branch
BranchTrueFalseTotal
for (k = 0; k <= av_len(keys); k++) { 562 68 630
734 562 UV len = sv_len_utf8(dds_quote(aTHX_ * av_fetch(keys, k, 0), TRUE));
735  
736 562 sum += len;
737 562 ▶ if (max < len)
Branch: 1 branch
BranchTrueFalseTotal
if (max < len) 114 448 562
738 114 max = len;
739 }
740 72 ▶ width = max > 8 && (2.0 / 3.0 * max) > ((NV)sum / count) ? (UV)(0.5 + (NV)sum / count)
Branch: 1 branch
BranchTrueFalseTotal
width = max > 8 && (2.0 / 3.0 * max) > ((NV)sum / count) ? (UV)(0.5 + (NV)sum / count) 2 2 4
741 72 ▶ : max;
Branch: 1 branch
BranchTrueFalseTotal
: max; 4 64 68
742 }
743 }
744  
745 18365 ▶ if (f->stage == DDS_STAGE_INITIAL)
Branch: 1 branch
BranchTrueFalseTotal
if (f->stage == DDS_STAGE_INITIAL) 1665 16700 18365
746 1665 indent = dds_brace(aTHX_ ctx, name, '{', multiline, indent, count);
747 else
748 16700 width = f->width;
749  
750 18365 child_indent =
751 18365 indent +
752 18365 ▶ (width ? width + 2 * sv_len_utf8(ctx->style.space) + sv_len_utf8(ctx->style.hashsep) : 0);
Branch: 1 branch
BranchTrueFalseTotal
(width ? width + 2 * sv_len_utf8(ctx->style.space) + sv_len_utf8(ctx->style.hashsep) : 0); 16622 1743 18365
753 18365 last_n = f->last_n;
754  
755 35065 ▶ for (k = f->k; k <= av_len(keys); k++) {
Branch: 1 branch
BranchTrueFalseTotal
for (k = f->k; k <= av_len(keys); k++) { 33400 1665 35065
756 33400 SV *key = *av_fetch(keys, k, 0), *quoted;
757 HE *he;
758 SV *value;
759 dds_result result;
760  
761 33400 ▶ if (f->stage != DDS_STAGE_INITIAL)
Branch: 1 branch
BranchTrueFalseTotal
if (f->stage != DDS_STAGE_INITIAL) 16700 16700 33400
762 16700 goto child_done;
763 16700 ▶ if (!SvOK(key))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(key)) 0 16700 16700
764 0 break;
765 16700 he = hv_fetch_ent(hv, key, 0, 0);
766 16700 ▶ value = he ? HeVAL(he) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
value = he ? HeVAL(he) : &PL_sv_undef; 16700 0 16700
767 16700 f->active.sv = value;
768 16700 ▶ if (SvROK(value))
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(value)) 2861 13839 16700
769 2861 last_n = 0;
770 16700 ▶ if (k) {
Branch: 1 branch
BranchTrueFalseTotal
if (k) { 15051 1649 16700
771 15051 ▶ bool newline = multiline && !last_n;
Branch: 2 branches
BranchTrueFalseTotal
bool newline = multiline && !last_n; 14740 311 15051
bool newline = multiline && !last_n; 14740 0 14740
772  
773 15051 dds_write(aTHX_ ctx, ctx->style.pairsep);
774 15051 ctx->column++;
775 15051 ▶ if (newline) {
Branch: 1 branch
BranchTrueFalseTotal
if (newline) { 14740 311 15051
776 14740 dds_put(aTHX_ ctx, "\n");
777 14740 dds_spaces(aTHX_ ctx, indent);
778 14740 ctx->column = 0;
779 } else {
780 311 dds_write(aTHX_ ctx, ctx->style.space);
781 311 ▶ if (!SvTRUE(ctx->style.space) && ctx->column > 1024) {
Branch: 2 branches
BranchTrueFalseTotal
if (!SvTRUE(ctx->style.space) && ctx->column > 1024) { 311 0 311
if (!SvTRUE(ctx->style.space) && ctx->column > 1024) { 2 309 311
782 2 dds_put(aTHX_ ctx, "\n");
783 2 ctx->column = 0;
784 }
785 }
786 }
787  
788 16700 quoted = dds_quote(aTHX_ key, TRUE);
789 16700 dds_write(aTHX_ ctx, quoted);
790 16700 ▶ if (width) {
Branch: 1 branch
BranchTrueFalseTotal
if (width) { 15681 1019 16700
791 15681 UV len = sv_len_utf8(quoted);
792  
793 15681 ▶ if (len <= width)
Branch: 1 branch
BranchTrueFalseTotal
if (len <= width) 15673 8 15681
794 15673 dds_spaces(aTHX_ ctx, width - len);
795 else {
796 8 dds_put(aTHX_ ctx, "\n");
797 8 dds_spaces(aTHX_ ctx, indent + width);
798 }
799 }
800 16700 dds_write(aTHX_ ctx, ctx->style.space);
801 16700 dds_write(aTHX_ ctx, ctx->style.hashsep);
802 16700 dds_write(aTHX_ ctx, ctx->style.space);
803 16700 ▶ ctx->column += (width ? width : sv_len_utf8(quoted)) + 2 * sv_len_utf8(ctx->style.space) +
Branch: 1 branch
BranchTrueFalseTotal
ctx->column += (width ? width : sv_len_utf8(quoted)) + 2 * sv_len_utf8(ctx->style.space) + 1019 15681 16700
804 16700 sv_len_utf8(ctx->style.hashsep);
805  
806 /* The resumed frame finishes alias handling for this same key. */
807 16700 f->stage = DDS_STAGE_CHILD;
808 16700 f->keys = keys;
809 16700 f->k = k;
810 16700 f->last_n = last_n;
811 16700 f->width = width;
812 16700 f->indent = indent;
813 16700 dds_push_frame(aTHX_ ctx, DDS_FRAME_SV, value, depth + 1, mark,
814 dds_child_name(aTHX_ name, '{', key, 0), child_indent, FALSE);
815 16700 return FALSE;
816  
817 16700 child_done:
818 16700 result = f->result;
819 16700 f->stage = DDS_STAGE_INITIAL;
820 16700 ▶ last_n = !full && !ctx->do_nl && ctx->column < 60 ? last_n + 1 : 0;
Branch: 3 branches
BranchTrueFalseTotal
last_n = !full && !ctx->do_nl && ctx->column < 60 ? last_n + 1 : 0; 616 16084 16700
last_n = !full && !ctx->do_nl && ctx->column < 60 ? last_n + 1 : 0; 308 308 616
last_n = !full && !ctx->do_nl && ctx->column < 60 ? last_n + 1 : 0; 28 280 308
821  
822 16700 ▶ if (result.alias) {
Branch: 1 branch
BranchTrueFalseTotal
if (result.alias) { 10 16690 16700
823 10 SV *args = DDS_TEMP(newSVsv(dds_child_name(aTHX_ name, '%', NULL, 0)));
824  
825 10 sv_catpvs(args, ", ");
826 10 DDS_CAT(args, dds_quote(aTHX_ key, FALSE));
827 10 dds_call_fix(aTHX_ ctx, "alias_hv", args, result.alias,
828 10 ▶ ctx->class_head ? dds_child_name(aTHX_ name, '{', key, 0) : NULL);
Branch: 1 branch
BranchTrueFalseTotal
ctx->class_head ? dds_child_name(aTHX_ name, '{', key, 0) : NULL); 0 10 10
829 }
830 16700 f->active.sv = (SV *)hv;
831 }
832  
833 1665 dds_brace(aTHX_ ctx, name, '}', multiline, indent, count);
834 1665 Zero(&f->result, 1, dds_result);
835 1665 return TRUE;
836 }
837  
838 /* Test whether an object reference has active overload behavior that requires
839 * deferred blessing.
840 */
841 5592 static bool dds_overloaded(pTHX_ SV *rv)
842 {
843 5592 ▶ return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv)));
Branch: 13 branches
BranchTrueFalseTotal
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 5592 0 5592
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 264 5328 5592
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 264 0 264
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 264 0 264
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 31 233 264
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 31 0 31
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 31 0 31
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 0 31 31
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 0 0 0
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 31 0 31
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 0 31 31
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 31 0 31
return SvROK(rv) && SvOBJECT(SvRV(rv)) && SvAMAGIC(rv) && Gv_AMG(SvSTASH(SvRV(rv))); 3 28 31
844 }
845  
846 /* Check ignore policies and emit an ignored-object description when selected,
847 * returning whether the referent was handled.
848 */
849 10096 static bool dds_emit_ignored(pTHX_ dds_ctx *ctx, SV *rv, SV *target, bool forced)
850 {
851 10096 HV *style = dds_hash(aTHX_ ctx->object, "style", FALSE);
852 10096 HV *ignore = dds_hash(aTHX_ style, "ignore", FALSE);
853 10096 SV *key = DDS_TEMP(newSVpvf("#%" UVuf, PTR2UV(target)));
854 10096 SV *class_name = dds_class(aTHX_ target);
855 10096 ▶ bool ignored = forced || SvTRUE(dds_hget_sv(aTHX_ ignore, key));
Branch: 2 branches
BranchTrueFalseTotal
bool ignored = forced || SvTRUE(dds_hget_sv(aTHX_ ignore, key)); 10087 9 10096
bool ignored = forced || SvTRUE(dds_hget_sv(aTHX_ ignore, key)); 0 10087 10087
856  
857 10096 ▶ if (SvOK(class_name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(class_name)) { 357 9739 10096
858 357 key = dds_concat(aTHX_ ".", class_name, "");
859 357 ▶ ignored = ignored || SvTRUE(dds_hget_sv(aTHX_ ignore, key));
Branch: 2 branches
BranchTrueFalseTotal
ignored = ignored || SvTRUE(dds_hget_sv(aTHX_ ignore, key)); 348 9 357
ignored = ignored || SvTRUE(dds_hget_sv(aTHX_ ignore, key)); 3 345 348
860 }
861  
862 10096 ▶ if (ignored) {
Branch: 1 branch
BranchTrueFalseTotal
if (ignored) { 12 10084 10096
863 12 SV *text = DDS_TEMP(newSVpvs("Ignored Obj ["));
864 12 SV *plain = DDS_TEMP(newSV(0));
865  
866 12 sv_setpvf(plain, "%s(0x%" UVxf ")", sv_reftype(target, TRUE), PTR2UV(target));
867 12 ▶ if (SvOBJECT(target)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvOBJECT(target)) { 12 0 12
868 24 sv_setpvf(plain, "%s=%s(0x%" UVxf ")", DDS_PV(class_name), sv_reftype(target, FALSE),
869 PTR2UV(target));
870 }
871 12 DDS_CAT(text, plain);
872 12 sv_catpvs(text, "]");
873 12 dds_write(aTHX_ ctx, dds_quote(aTHX_ text, FALSE));
874 PERL_UNUSED_ARG(rv);
875 }
876 10096 return ignored;
877 }
878  
879 /* Emit a gensym expression and queue its enabled glob slots once, loading
880 * Symbol lazily in the generated code.
881 */
882 74 static void dds_emit_symbol(pTHX_ dds_ctx *ctx, GV *gv, SV *name, UV depth, bool deref)
883 {
884 74 dds_node *node = dds_find(aTHX_ ctx, (SV *)gv, TRUE);
885  
886 74 ▶ if (deref)
Branch: 1 branch
BranchTrueFalseTotal
if (deref) 1 73 74
887 1 dds_put(aTHX_ ctx, "*{ ");
888 74 ▶ if (!ctx->symbol_required) {
Branch: 1 branch
BranchTrueFalseTotal
if (!ctx->symbol_required) { 60 14 74
889 60 dds_put(aTHX_ ctx, "do{ require Symbol; Symbol::gensym }");
890 60 ctx->symbol_required = TRUE;
891 } else
892 14 dds_put(aTHX_ ctx, "Symbol::gensym");
893 74 ▶ if (deref)
Branch: 1 branch
BranchTrueFalseTotal
if (deref) 1 73 74
894 1 dds_put(aTHX_ ctx, " }");
895  
896 74 ▶ if (ctx->style.dumpglob && !node->glob_dumped) {
Branch: 2 branches
BranchTrueFalseTotal
if (ctx->style.dumpglob && !node->glob_dumped) { 74 0 74
if (ctx->style.dumpglob && !node->glob_dumped) { 74 0 74
897 dds_fix *fix =
898 74 dds_new_fix(aTHX_ DDS_FIX_GLOB, dds_child_name(aTHX_ name, '*', NULL, 0), NULL);
899  
900 74 node->glob_dumped = TRUE;
901 74 fix->glob = (GV *)SvREFCNT_inc((SV *)gv);
902 74 fix->depth = depth + 1;
903 74 dds_add_fix(aTHX_ ctx, fix);
904 }
905 74 }
906  
907 /*
908 * Scalar slots
909 *
910 * Slot aliasing is independent of referent sharing. Resolve the slot first,
911 * then emit its literal or yield to reference construction.
912 */
913  
914 /* Advance a scalar-slot continuation, handling aliases, root assignments,
915 * literals and references before queuing readonly or weak fixups.
916 */
917 36997 static bool dds_step_sv(pTHX_ dds_ctx *ctx, struct dds_frame *f)
918 {
919 36997 SV *sv = f->sv, *name = f->name;
920 36997 UV depth = f->depth;
921 36997 dds_mark *mark = f->mark;
922 36997 IV indent = f->indent;
923 36997 bool is_ref = f->is_ref;
924 36997 dds_result result = {NULL, NULL};
925 36997 ▶ dds_node *node = dds_candidate(aTHX_ sv) ? dds_find(aTHX_ ctx, sv, FALSE) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
dds_node *node = dds_candidate(aTHX_ sv) ? dds_find(aTHX_ ctx, sv, FALSE) : NULL; 6587 30410 36997
926 36997 ▶ dds_role *role = node && node->slot.present ? &node->slot : NULL;
Branch: 2 branches
BranchTrueFalseTotal
dds_role *role = node && node->slot.present ? &node->slot : NULL; 4719 32278 36997
dds_role *role = node && node->slot.present ? &node->slot : NULL; 4705 14 4719
927 36997 ▶ SV *clean = SvOK(name) ? dds_clean_name(aTHX_ name) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
SV *clean = SvOK(name) ? dds_clean_name(aTHX_ name) : &PL_sv_undef; 36997 0 36997
928 36997 ▶ bool readonly = role ? role->readonly : cBOOL(SvREADONLY(sv));
Branch: 1 branch
BranchTrueFalseTotal
bool readonly = role ? role->readonly : cBOOL(SvREADONLY(sv)); 4705 32292 36997
929 bool add_do, is_ro;
930  
931 36997 ▶ if (f->stage != DDS_STAGE_INITIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if (f->stage != DDS_STAGE_INITIAL) { 10096 26901 36997
932 10096 role = f->role;
933 10096 add_do = f->add_do;
934 10096 goto child_done;
935 }
936  
937 26901 ctx->do_nl = FALSE;
938 26901 ▶ if (SvGMAGICAL(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvGMAGICAL(sv)) { 9 26892 26901
939 9 dds_callback_guard(aTHX_ ctx);
940 9 av_push(ctx->keepalive, SvREFCNT_inc(sv));
941 9 mg_get(sv);
942 }
943  
944 /* A scalar slot can be aliased independently of its referent. Resolve
945 * that relationship before choosing how to print the slot's value. */
946 26901 ▶ if (role) {
Branch: 1 branch
BranchTrueFalseTotal
if (role) { 3100 23801 26901
947 3100 bool different =
948 3449 ▶ role->depth == depth && sv_cmp(role->name, clean) && DDS_PV(name)[0] != '&';
Branch: 3 branches
BranchTrueFalseTotal
role->depth == depth && sv_cmp(role->name, clean) && DDS_PV(name)[0] != '&'; 2845 255 3100
role->depth == depth && sv_cmp(role->name, clean) && DDS_PV(name)[0] != '&'; 349 2496 2845
role->depth == depth && sv_cmp(role->name, clean) && DDS_PV(name)[0] != '&'; 349 0 349
949  
950 3100 ▶ if (!role->original && (role->done || role->depth < depth || different)) {
Branch: 4 branches
BranchTrueFalseTotal
if (!role->original && (role->done || role->depth < depth || different)) { 2934 166 3100
if (!role->original && (role->done || role->depth < depth || different)) { 2511 423 2934
if (!role->original && (role->done || role->depth < depth || different)) { 2370 141 2511
if (!role->original && (role->done || role->depth < depth || different)) { 12 2358 2370
951 576 SV *text = DDS_TEMP(newSVpvs(""));
952  
953 576 ▶ if (is_ref) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_ref) { 221 355 576
954 221 ▶ if ((role->depth == 1 && !ctx->style.declare) ||
Branch: 2 branches
BranchTrueFalseTotal
if ((role->depth == 1 && !ctx->style.declare) || 104 117 221
if ((role->depth == 1 && !ctx->style.declare) || 34 70 104
955 151 ▶ (role->done && role->done->ready) || !ctx->style.purity) {
Branch: 3 branches
BranchTrueFalseTotal
(role->done && role->done->ready) || !ctx->style.purity) { 53 98 151
(role->done && role->done->ready) || !ctx->style.purity) { 19 34 53
(role->done && role->done->ready) || !ctx->style.purity) { 6 111 117
956 110 sv_catpvs(text, "\\");
957 110 DDS_CAT(text, role->name);
958 } else {
959 111 bool need_do = strnEQ(DDS_PV(name), "$$$", 3);
960 dds_fix *fix;
961  
962 111 ▶ if (need_do) {
Branch: 1 branch
BranchTrueFalseTotal
if (need_do) { 4 107 111
963 4 sv_catpvs(text, "do");
964 4 DDS_CAT(text, ctx->style.space);
965 4 sv_catpvs(text, "{");
966 4 DDS_CAT(text, ctx->style.space);
967 4 sv_catpvs(text, "my");
968 4 DDS_CAT(text, ctx->style.space);
969 4 sv_catpvs(text, "$f");
970 4 DDS_CAT(text, ctx->style.space);
971 4 sv_catpvs(text, "=");
972 4 DDS_CAT(text, ctx->style.space);
973 }
974 111 ▶ DDS_CAT(text,
Branch: 1 branch
BranchTrueFalseTotal
DDS_CAT(text, 111 0 111
975 ctx->style.verbose
976 ? dds_quote(aTHX_ dds_concat(aTHX_ "R: ", role->name, ""), FALSE)
977 : DDS_TEMP(newSVpvs("'R'")));
978 111 result.deferred = dds_new_mark(aTHX_ ctx);
979 111 fix = dds_new_fix(aTHX_ DDS_FIX_SLOT, name, node);
980 111 fix->mark = result.deferred;
981 111 dds_add_fix(aTHX_ ctx, fix);
982 111 ▶ if (need_do) {
Branch: 1 branch
BranchTrueFalseTotal
if (need_do) { 4 107 111
983 4 DDS_CAT(text, ctx->style.space);
984 4 sv_catpvs(text, "}");
985 }
986 }
987 355 ▶ } else if (depth == 1) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (depth == 1) { 36 319 355
988 36 ▶ if (ctx->style.declare && !ctx->class_head) {
Branch: 2 branches
BranchTrueFalseTotal
if (ctx->style.declare && !ctx->class_head) { 0 36 36
if (ctx->style.declare && !ctx->class_head) { 0 0 0
989 0 sv_catpvs(text, "my ");
990 0 DDS_CAT(text, name);
991 0 sv_catpvs(text, ";\n");
992 }
993 36 sv_catpvs(text, "alias_ref(\\");
994 36 DDS_CAT(text, name);
995 36 sv_catpvs(text, ",\\");
996 36 DDS_CAT(text, role->name);
997 36 sv_catpvs(text, ")");
998 319 ▶ } else if (ctx->style.purity) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (ctx->style.purity) { 311 8 319
999 311 ▶ DDS_CAT(text, ctx->style.verbose
Branch: 1 branch
BranchTrueFalseTotal
DDS_CAT(text, ctx->style.verbose 311 0 311
1000 ? dds_quote(aTHX_ dds_concat(aTHX_ "A: ", role->name, ""), FALSE)
1001 : DDS_TEMP(newSVpvs("'A'")));
1002 311 result.alias = node;
1003 } else {
1004 8 sv_catpvs(text, "alias_to(");
1005 8 DDS_CAT(text, role->name);
1006 8 sv_catpvs(text, ")");
1007 }
1008 576 ctx->column += sv_len_utf8(text);
1009 576 dds_write(aTHX_ ctx, text);
1010 576 f->result = result;
1011 576 return TRUE;
1012 }
1013 2524 ▶ if (!role->done)
Branch: 1 branch
BranchTrueFalseTotal
if (!role->done) 2513 11 2524
1014 2513 role->done = mark;
1015 }
1016  
1017 /* Root assignments introduce names; nested values only emit an RHS. */
1018 26325 ▶ if (depth == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (depth == 1) { 1897 24428 26325
1019 2042 ▶ if (role && sv_cmp(name, clean) && DDS_PV(name)[0] != '*' && role->count > 1) {
Branch: 4 branches
BranchTrueFalseTotal
if (role && sv_cmp(name, clean) && DDS_PV(name)[0] != '*' && role->count > 1) { 1890 7 1897
if (role && sv_cmp(name, clean) && DDS_PV(name)[0] != '*' && role->count > 1) { 145 1745 1890
if (role && sv_cmp(name, clean) && DDS_PV(name)[0] != '*' && role->count > 1) { 145 0 145
if (role && sv_cmp(name, clean) && DDS_PV(name)[0] != '*' && role->count > 1) { 145 0 145
1020 145 ▶ if (node->ref.present) {
Branch: 1 branch
BranchTrueFalseTotal
if (node->ref.present) { 19 126 145
1021 19 SV *other = dds_child_name(aTHX_ node->ref.name, '$', NULL, 0);
1022  
1023 19 sv_setsv(role->name, other);
1024 }
1025 145 role->done = NULL;
1026 }
1027 3695 ▶ if (!ctx->style.terse && DDS_PV(name)[0] != '&') {
Branch: 2 branches
BranchTrueFalseTotal
if (!ctx->style.terse && DDS_PV(name)[0] != '&') { 1798 99 1897
if (!ctx->style.terse && DDS_PV(name)[0] != '&') { 1791 7 1798
1028 1791 SV *prefix = DDS_TEMP(newSVpvs(""));
1029  
1030 2169 ▶ if (ctx->style.declare && !ctx->class_head && DDS_PV(name)[0] != '*' &&
Branch: 2 branches
BranchTrueFalseTotal
if (ctx->style.declare && !ctx->class_head && DDS_PV(name)[0] != '*' && 189 1602 1791
if (ctx->style.declare && !ctx->class_head && DDS_PV(name)[0] != '*' && 189 0 189
1031 189 !hv_exists_ent(ctx->lexical_added, name, 0)) {
1032 189 sv_catpvs(prefix, "my");
1033 189 DDS_CAT(prefix, ctx->style.space);
1034 }
1035 1791 DDS_CAT(prefix, name);
1036 1791 DDS_CAT(prefix, ctx->style.space);
1037 1791 sv_catpvs(prefix, "=");
1038 1791 DDS_CAT(prefix, ctx->style.space);
1039 1791 indent = sv_len_utf8(prefix);
1040 1791 dds_write(aTHX_ ctx, prefix);
1041 1790 ctx->column = 0;
1042 } else
1043 106 indent = 0;
1044 }
1045  
1046 26324 ▶ if (is_ref)
Branch: 1 branch
BranchTrueFalseTotal
if (is_ref) 354 25970 26324
1047 354 dds_put(aTHX_ ctx, "\\");
1048  
1049 /* A mutable scalar reference needs storage. The do block supplies
1050 * a private scalar instead of taking a reference to a constant. */
1051 26324 add_do =
1052 26226 ▶ ctx->style.purity && !readonly && is_ref && !(SvROK(sv) && SvOBJECT(SvRV(sv))) &&
Branch: 4 branches
BranchTrueFalseTotal
ctx->style.purity && !readonly && is_ref && !(SvROK(sv) && SvOBJECT(SvRV(sv))) && 26167 59 26226
ctx->style.purity && !readonly && is_ref && !(SvROK(sv) && SvOBJECT(SvRV(sv))) && 299 25868 26167
ctx->style.purity && !readonly && is_ref && !(SvROK(sv) && SvOBJECT(SvRV(sv))) && 199 100 299
ctx->style.purity && !readonly && is_ref && !(SvROK(sv) && SvOBJECT(SvRV(sv))) && 178 21 199
1053 52766 ▶ SvTYPE(sv) != SVt_PVGV &&
Branch: 2 branches
BranchTrueFalseTotal
SvTYPE(sv) != SVt_PVGV && 26226 98 26324
SvTYPE(sv) != SVt_PVGV && 216 62 278
1054 216 ▶ (!SvROK(sv) || (SvTYPE(SvRV(sv)) <= SVt_PVMG && !SvROK(SvRV(sv)) && !SvREADONLY(SvRV(sv))));
Branch: 4 branches
BranchTrueFalseTotal
(!SvROK(sv) || (SvTYPE(SvRV(sv)) <= SVt_PVMG && !SvROK(SvRV(sv)) && !SvREADONLY(SvRV(sv)))); 178 38 216
(!SvROK(sv) || (SvTYPE(SvRV(sv)) <= SVt_PVMG && !SvROK(SvRV(sv)) && !SvREADONLY(SvRV(sv)))); 83 95 178
(!SvROK(sv) || (SvTYPE(SvRV(sv)) <= SVt_PVMG && !SvROK(SvRV(sv)) && !SvREADONLY(SvRV(sv)))); 32 51 83
(!SvROK(sv) || (SvTYPE(SvRV(sv)) <= SVt_PVMG && !SvROK(SvRV(sv)) && !SvREADONLY(SvRV(sv)))); 4 28 32
1055 26324 ▶ if (add_do) {
Branch: 1 branch
BranchTrueFalseTotal
if (add_do) { 42 26282 26324
1056 42 dds_put(aTHX_ ctx, "do");
1057 42 dds_write(aTHX_ ctx, ctx->style.space);
1058 42 dds_put(aTHX_ ctx, "{");
1059 42 dds_write(aTHX_ ctx, ctx->style.space);
1060 42 dds_put(aTHX_ ctx, "my");
1061 42 dds_write(aTHX_ ctx, ctx->style.space);
1062 42 dds_put(aTHX_ ctx, "$v");
1063 42 dds_write(aTHX_ ctx, ctx->style.space);
1064 42 dds_put(aTHX_ ctx, "=");
1065 42 dds_write(aTHX_ ctx, ctx->style.space);
1066 42 ctx->column += 13;
1067 }
1068  
1069 26324 ▶ is_ro = ctx->style.readonly && readonly && !is_ref;
Branch: 3 branches
BranchTrueFalseTotal
is_ro = ctx->style.readonly && readonly && !is_ref; 26324 0 26324
is_ro = ctx->style.readonly && readonly && !is_ref; 63 26261 26324
is_ro = ctx->style.readonly && readonly && !is_ref; 12 51 63
1070 26324 ▶ if (SvROK(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv)) { 10096 16228 26324
1071 10096 ctx->do_nl = TRUE;
1072 10096 f->stage = DDS_STAGE_CHILD;
1073 10096 f->role = role;
1074 10096 f->add_do = add_do;
1075 10096 dds_push_frame(aTHX_ ctx, DDS_FRAME_REF, sv, depth + 1, mark, name, indent,
1076 10096 ▶ is_ref && !add_do);
Branch: 2 branches
BranchTrueFalseTotal
is_ref && !add_do); 204 9892 10096
is_ref && !add_do); 200 4 204
1077 10096 return FALSE;
1078 16228 ▶ } else if (!SvOK(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (!SvOK(sv)) { 116 16112 16228
1079 116 dds_put(aTHX_ ctx, "undef");
1080 116 ctx->column += 5;
1081 } else {
1082 16112 ▶ if (is_ro && !ctx->style.purity && !ctx->style.terse) {
Branch: 3 branches
BranchTrueFalseTotal
if (is_ro && !ctx->style.purity && !ctx->style.terse) { 11 16101 16112
if (is_ro && !ctx->style.purity && !ctx->style.terse) { 1 10 11
if (is_ro && !ctx->style.purity && !ctx->style.terse) { 1 0 1
1083 1 dds_put(aTHX_ ctx, "make_ro(");
1084 1 dds_write(aTHX_ ctx, ctx->style.space);
1085 }
1086 16112 ▶ if (SvTYPE(sv) == SVt_PVGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvTYPE(sv) == SVt_PVGV) { 71 16041 16112
1087 71 SV *glob = dds_glob_name(aTHX_(GV *) sv);
1088  
1089 71 ▶ if (strnEQ(DDS_PV(glob), "*Symbol::GEN", 12))
Branch: 1 branch
BranchTrueFalseTotal
if (strnEQ(DDS_PV(glob), "*Symbol::GEN", 12)) 1 70 71
1090 1 dds_emit_symbol(aTHX_ ctx, (GV *)sv, name, depth, TRUE);
1091 else {
1092 dds_node *gnode;
1093  
1094 70 dds_write(aTHX_ ctx, glob);
1095 70 ctx->column += sv_len_utf8(glob);
1096 70 ▶ gnode = ctx->style.dumpglob ? dds_find(aTHX_ ctx, sv, TRUE) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
gnode = ctx->style.dumpglob ? dds_find(aTHX_ ctx, sv, TRUE) : NULL; 67 3 70
1097 70 ▶ if (gnode && !gnode->glob_dumped) {
Branch: 2 branches
BranchTrueFalseTotal
if (gnode && !gnode->glob_dumped) { 67 3 70
if (gnode && !gnode->glob_dumped) { 67 0 67
1098 67 dds_fix *fix = dds_new_fix(aTHX_ DDS_FIX_GLOB, glob, NULL);
1099  
1100 67 gnode->glob_dumped = TRUE;
1101 67 fix->glob = (GV *)SvREFCNT_inc(sv);
1102 67 fix->depth = depth + 1;
1103 67 dds_add_fix(aTHX_ ctx, fix);
1104 }
1105 }
1106 } else {
1107 16041 SV *quoted = NULL;
1108  
1109 16041 ▶ if (ctx->style.dualvars && SvNIOK(sv) && SvPOK(sv)) {
Branch: 3 branches
BranchTrueFalseTotal
if (ctx->style.dualvars && SvNIOK(sv) && SvPOK(sv)) { 16039 2 16041
if (ctx->style.dualvars && SvNIOK(sv) && SvPOK(sv)) { 13950 2089 16039
if (ctx->style.dualvars && SvNIOK(sv) && SvPOK(sv)) { 7 13943 13950
1110 SV *number =
1111 7 ▶ DDS_TEMP(SvIOK(sv) ? (SvIsUV(sv) ? newSVuv(SvUV(sv)) : newSViv(SvIV(sv)))
Branch: 2 branches
BranchTrueFalseTotal
DDS_TEMP(SvIOK(sv) ? (SvIsUV(sv) ? newSVuv(SvUV(sv)) : newSViv(SvIV(sv))) 7 0 7
DDS_TEMP(SvIOK(sv) ? (SvIsUV(sv) ? newSVuv(SvUV(sv)) : newSViv(SvIV(sv))) 2 5 7
1112 : newSVnv(SvNV(sv)));
1113  
1114 7 ▶ if (sv_cmp(number, sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (sv_cmp(number, sv)) { 7 0 7
1115 7 quoted = DDS_TEMP(newSVpvs("dualvar( "));
1116 7 DDS_CAT(quoted, number);
1117 7 sv_catpvs(quoted, ",");
1118 7 DDS_CAT(quoted, ctx->style.space);
1119 7 DDS_CAT(quoted, dds_quote(aTHX_ sv, FALSE));
1120 7 DDS_CAT(quoted, ctx->style.space);
1121 7 sv_catpvs(quoted, ")");
1122 }
1123 }
1124 16041 ▶ if (!quoted && ctx->style.compress && SvTRUE(ctx->style.compressor) &&
Branch: 3 branches
BranchTrueFalseTotal
if (!quoted && ctx->style.compress && SvTRUE(ctx->style.compressor) && 16034 7 16041
if (!quoted && ctx->style.compress && SvTRUE(ctx->style.compressor) && 9 16025 16034
if (!quoted && ctx->style.compress && SvTRUE(ctx->style.compressor) && 9 0 9
1125 9 ▶ (ctx->style.compress < 0 || sv_len_utf8(sv) > (UV)ctx->style.compress)) {
Branch: 2 branches
BranchTrueFalseTotal
(ctx->style.compress < 0 || sv_len_utf8(sv) > (UV)ctx->style.compress)) { 0 9 9
(ctx->style.compress < 0 || sv_len_utf8(sv) > (UV)ctx->style.compress)) { 0 0 0
1126 SV *args[3];
1127  
1128 9 args[0] = sv;
1129 9 args[1] = ctx->owner;
1130 9 quoted = dds_invoke(aTHX_ ctx, ctx->style.compressor, FALSE, G_SCALAR, 2, args);
1131 }
1132 16041 ▶ if (!quoted)
Branch: 1 branch
BranchTrueFalseTotal
if (!quoted) 16025 16 16041
1133 16025 quoted = dds_quote(aTHX_ sv, FALSE);
1134 16041 ctx->column += sv_len_utf8(quoted);
1135 16041 dds_write(aTHX_ ctx, quoted);
1136 }
1137 16112 ▶ if (!ctx->style.terse) {
Branch: 1 branch
BranchTrueFalseTotal
if (!ctx->style.terse) { 16099 13 16112
1138 16099 ▶ if (is_ro && ctx->style.purity)
Branch: 2 branches
BranchTrueFalseTotal
if (is_ro && ctx->style.purity) 10 16089 16099
if (is_ro && ctx->style.purity) 9 1 10
1139 9 dds_call_fix(aTHX_ ctx, "make_ro", name, NULL, NULL);
1140 16090 ▶ else if (is_ro) {
Branch: 1 branch
BranchTrueFalseTotal
else if (is_ro) { 1 16089 16090
1141 1 dds_write(aTHX_ ctx, ctx->style.space);
1142 1 dds_put(aTHX_ ctx, ")");
1143 }
1144 }
1145 16112 ctx->do_nl = FALSE;
1146 }
1147  
1148 26324 child_done:
1149 26324 ▶ if (add_do) {
Branch: 1 branch
BranchTrueFalseTotal
if (add_do) { 42 26282 26324
1150 42 dds_write(aTHX_ ctx, ctx->style.space);
1151 42 dds_put(aTHX_ ctx, "}");
1152 }
1153 26324 ▶ if ((role && role->weak) || (SvROK(sv) && SvWEAKREF(sv)))
Branch: 4 branches
BranchTrueFalseTotal
if ((role && role->weak) || (SvROK(sv) && SvWEAKREF(sv))) 2523 23801 26324
if ((role && role->weak) || (SvROK(sv) && SvWEAKREF(sv))) 2477 46 2523
if ((role && role->weak) || (SvROK(sv) && SvWEAKREF(sv))) 10050 16228 26278
if ((role && role->weak) || (SvROK(sv) && SvWEAKREF(sv))) 699 9351 10050
1154 745 dds_call_fix(aTHX_ ctx, "weaken", name, NULL, NULL);
1155 26324 f->result = result;
1156 26324 return TRUE;
1157 }
1158  
1159 /* Queue one postdump hook per original frozen object, owning a reference to
1160 * that original independently of any shared proxy.
1161 */
1162 7316 static void dds_queue_postdump(pTHX_ dds_ctx *ctx, dds_node *node, SV *original)
1163 {
1164 dds_postop *postop;
1165  
1166 7316 ▶ if (!node || node->ignored || node->postop_queued || !node->postop)
Branch: 4 branches
BranchTrueFalseTotal
if (!node || node->ignored || node->postop_queued || !node->postop) 7316 0 7316
if (!node || node->ignored || node->postop_queued || !node->postop) 7315 1 7316
if (!node || node->ignored || node->postop_queued || !node->postop) 7299 16 7315
if (!node || node->ignored || node->postop_queued || !node->postop) 7262 37 7299
1167 7279 return;
1168  
1169 /* Completion belongs to the original frozen object, not its proxy:
1170 * distinct originals can share one reconstructed replacement. Own a
1171 * snapshot from the already-fetched referent. Copying a magical RV
1172 * here would FETCH again and could select a different object. */
1173 37 Newxz(postop, 1, dds_postop);
1174 37 postop->node = node;
1175 37 node->postop_queued = TRUE;
1176 37 ▶ if (ctx->postop_tail)
Branch: 1 branch
BranchTrueFalseTotal
if (ctx->postop_tail) 17 20 37
1177 17 ctx->postop_tail->next = postop;
1178 else
1179 20 ctx->postop_head = postop;
1180 37 ctx->postop_tail = postop;
1181 37 postop->invocant = newRV_inc(original);
1182 }
1183  
1184 /* Run queued hooks for original objects after graph output and fixups finish,
1185 * releasing each queued record before invoking Perl.
1186 */
1187 1507 static void dds_run_postdump(pTHX_ dds_ctx *ctx)
1188 {
1189 /* A noncanonical occurrence may precede its proxy's construction.
1190 * Run restoration hooks only after all graph output and fixups are
1191 * complete, so hooks cannot change data still awaiting serialization. */
1192 1543 ▶ while (ctx->postop_head) {
Branch: 1 branch
BranchTrueFalseTotal
while (ctx->postop_head) { 37 1506 1543
1193 37 dds_postop *postop = ctx->postop_head;
1194 37 dds_node *node = postop->node;
1195 37 SV *invocant = postop->invocant;
1196  
1197 37 ctx->postop_head = postop->next;
1198 37 ▶ if (!ctx->postop_head)
Branch: 1 branch
BranchTrueFalseTotal
if (!ctx->postop_head) 20 17 37
1199 20 ctx->postop_tail = NULL;
1200 37 Safefree(postop);
1201 37 DDS_TEMP(invocant);
1202 37 (void)dds_invoke(aTHX_ ctx, node->postop, !SvROK(node->postop), G_VOID | G_DISCARD, 1,
1203 &invocant);
1204 }
1205 1506 }
1206  
1207 /* Resolution borrows source/proxy values and catalogue records. This state
1208 * lives only during the initial step. Continuations retain their owned
1209 * strings and borrowed stable metadata in the emission frame. */
1210 typedef struct {
1211 SV *rv, *target, *class_name, *thaw;
1212 dds_node *node;
1213 dds_role *role;
1214 dds_mark *mark;
1215 bool replacement;
1216 } dds_ref_value;
1217  
1218 /*
1219 * Referent construction
1220 *
1221 * Resolve freezer proxies and select canonical metadata before deciding
1222 * whether to reuse a value or construct it. New values pass through begin,
1223 * payload and finish phases.
1224 */
1225  
1226 /* Follow freezer replacements to an emit-ready value, queueing original-object
1227 * hooks; return false when ignored or textual output already handled it.
1228 */
1229 10096 static bool dds_resolve_ref(pTHX_ dds_ctx *ctx, struct dds_frame *f, dds_ref_value *value)
1230 {
1231 10096 UV proxy_limit = 0;
1232  
1233 10096 Zero(value, 1, dds_ref_value);
1234 10096 value->rv = f->sv;
1235 10096 value->mark = f->mark;
1236 10096 value->target = SvRV(value->rv);
1237  
1238 126 while (1) {
1239 10222 bool force = value->replacement;
1240  
1241 10222 ▶ if (dds_candidate(aTHX_ value->rv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (dds_candidate(aTHX_ value->rv)) { 2532 7690 10222
1242 2532 dds_node *slot = dds_find(aTHX_ ctx, value->rv, FALSE);
1243  
1244 2532 ▶ force = force || (slot && slot->slot.original);
Branch: 3 branches
BranchTrueFalseTotal
force = force || (slot && slot->slot.original); 2532 0 2532
force = force || (slot && slot->slot.original); 1611 921 2532
force = force || (slot && slot->slot.original); 166 1445 1611
1245 }
1246  
1247 9930 ▶ value->node = force || dds_candidate(aTHX_ value->target) || SvOBJECT(value->target) ||
Branch: 2 branches
BranchTrueFalseTotal
value->node = force || dds_candidate(aTHX_ value->target) || SvOBJECT(value->target) || 2588 7342 9930
value->node = force || dds_candidate(aTHX_ value->target) || SvOBJECT(value->target) || 2588 0 2588
1248 2588 ▶ SvREADONLY(value->target)
Branch: 1 branch
BranchTrueFalseTotal
SvREADONLY(value->target) 30 2558 2588
1249 7664 ? dds_find(aTHX_ ctx, value->target, FALSE)
1250 12780 ▶ : NULL;
Branch: 1 branch
BranchTrueFalseTotal
: NULL; 9930 292 10222
1251  
1252 10222 ▶ if (value->node && value->node->ignored) {
Branch: 2 branches
BranchTrueFalseTotal
if (value->node && value->node->ignored) { 7313 2909 10222
if (value->node && value->node->ignored) { 9 7304 7313
1253 9 (void)dds_emit_ignored(aTHX_ ctx, value->rv, value->target, TRUE);
1254 9 return FALSE;
1255 }
1256 10213 ▶ if (value->node && (!value->node->proxy || SvROK(value->node->proxy)))
Branch: 3 branches
BranchTrueFalseTotal
if (value->node && (!value->node->proxy || SvROK(value->node->proxy))) 7304 2909 10213
if (value->node && (!value->node->proxy || SvROK(value->node->proxy))) 126 7178 7304
if (value->node && (!value->node->proxy || SvROK(value->node->proxy))) 126 0 126
1257 7304 dds_queue_postdump(aTHX_ ctx, value->node, value->target);
1258  
1259 10213 ▶ if (value->node && value->node->proxy) {
Branch: 2 branches
BranchTrueFalseTotal
if (value->node && value->node->proxy) { 7304 2909 10213
if (value->node && value->node->proxy) { 126 7178 7304
1260 126 ▶ if (!SvROK(value->node->proxy)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(value->node->proxy)) { 0 126 126
1261 0 dds_write(aTHX_ ctx, value->node->proxy);
1262 0 return FALSE;
1263 }
1264 126 value->thaw = value->node->thaw;
1265 126 value->rv = value->node->proxy;
1266 126 value->target = SvRV(value->rv);
1267 126 value->replacement = TRUE;
1268 131 ▶ if (value->thaw && SvTRUE(value->thaw) && !strnEQ(DDS_PV(value->thaw), "->", 2))
Branch: 3 branches
BranchTrueFalseTotal
if (value->thaw && SvTRUE(value->thaw) && !strnEQ(DDS_PV(value->thaw), "->", 2)) 5 121 126
if (value->thaw && SvTRUE(value->thaw) && !strnEQ(DDS_PV(value->thaw), "->", 2)) 5 0 5
if (value->thaw && SvTRUE(value->thaw) && !strnEQ(DDS_PV(value->thaw), "->", 2)) 4 1 5
1269 4 value->mark = dds_new_mark(aTHX_ ctx);
1270 126 ▶ if (++proxy_limit > 100)
Branch: 1 branch
BranchTrueFalseTotal
if (++proxy_limit > 100) 0 126 126
1271 0 croak("Cyclic freezer replacement");
1272 126 continue;
1273 }
1274 10087 break;
1275 }
1276  
1277 10087 ▶ if (dds_emit_ignored(aTHX_ ctx, value->rv, value->target, FALSE))
Branch: 1 branch
BranchTrueFalseTotal
if (dds_emit_ignored(aTHX_ ctx, value->rv, value->target, FALSE)) 3 10084 10087
1278 3 return FALSE;
1279 10084 return TRUE;
1280 }
1281  
1282 /* Choose persistent or frame-local referent metadata and its canonical
1283 * expression, suppressing redundant blessing for ordinary regexps.
1284 */
1285 10084 static void dds_select_ref_role(pTHX_ dds_ctx *ctx, struct dds_frame *f, dds_ref_value *value)
1286 {
1287 10084 SV *name = f->name;
1288 10084 UV depth = f->depth;
1289  
1290 10084 value->class_name = dds_class(aTHX_ value->target);
1291 10084 ▶ if (dds_is_regexp(aTHX_ value->target) && SvOK(value->class_name) &&
Branch: 2 branches
BranchTrueFalseTotal
if (dds_is_regexp(aTHX_ value->target) && SvOK(value->class_name) && 134 9950 10084
if (dds_is_regexp(aTHX_ value->target) && SvOK(value->class_name) && 134 0 134
1292 268 ▶ strEQ(DDS_PV(value->class_name), "Regexp"))
Branch: 1 branch
BranchTrueFalseTotal
strEQ(DDS_PV(value->class_name), "Regexp")) 102 32 134
1293 102 value->class_name = &PL_sv_undef;
1294  
1295 10084 ▶ if (!value->node) {
Branch: 1 branch
BranchTrueFalseTotal
if (!value->node) { 2906 7178 10084
1296 2906 ▶ if (value->replacement || dds_candidate(aTHX_ value->target) || SvREADONLY(value->target) ||
Branch: 3 branches
BranchTrueFalseTotal
if (value->replacement || dds_candidate(aTHX_ value->target) || SvREADONLY(value->target) || 2906 0 2906
if (value->replacement || dds_candidate(aTHX_ value->target) || SvREADONLY(value->target) || 2588 318 2906
if (value->replacement || dds_candidate(aTHX_ value->target) || SvREADONLY(value->target) || 2558 30 2588
1297 2558 ▶ SvTYPE(value->target) == SVt_PVGV) {
Branch: 1 branch
BranchTrueFalseTotal
SvTYPE(value->target) == SVt_PVGV) { 8 2550 2558
1298 356 value->node = dds_find(aTHX_ ctx, value->target, TRUE);
1299 356 ▶ if (!value->node->ref.present) {
Branch: 1 branch
BranchTrueFalseTotal
if (!value->node->ref.present) { 356 0 356
1300 356 value->node->ref.present = TRUE;
1301 356 value->node->ref.name = newSVsv(name);
1302 356 value->node->ref.depth = depth;
1303 }
1304 } else {
1305 /* Unique values need only frame-local metadata. No fixup may
1306 * retain this embedded node after the frame completes. */
1307 2550 f->temporary.address = PTR2UV(value->target);
1308 2550 f->temporary.ref.name = name;
1309 2550 f->temporary.ref.depth = depth;
1310 2550 value->node = &f->temporary;
1311 }
1312 }
1313  
1314 10084 value->role = &value->node->ref;
1315 10084 ▶ if (!value->role->name) {
Branch: 1 branch
BranchTrueFalseTotal
if (!value->role->name) { 0 10084 10084
1316 0 value->role->name = newSVsv(name);
1317 0 value->role->depth = depth;
1318 0 value->role->present = TRUE;
1319 }
1320 10084 }
1321  
1322 /* Emit a use of an already known canonical referent, or a placeholder and
1323 * deferred assignment; return false when this occurrence must construct it.
1324 */
1325 10084 static bool dds_emit_ref_use(pTHX_ dds_ctx *ctx, struct dds_frame *f, dds_ref_value *value)
1326 {
1327 10084 SV *name = f->name, *target = value->target, *class_name = value->class_name;
1328 10084 dds_node *node = value->node;
1329 10084 dds_role *role = value->role;
1330 10084 bool add_do = f->is_ref;
1331  
1332 10084 ▶ if (role->done && role->done->ready) {
Branch: 2 branches
BranchTrueFalseTotal
if (role->done && role->done->ready) { 2478 7606 10084
if (role->done && role->done->ready) { 179 2299 2478
1333 SV *text;
1334  
1335 358 ▶ if (strchr("@%&", DDS_PV(role->name)[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (strchr("@%&", DDS_PV(role->name)[0])) { 58 121 179
1336 58 ▶ if (SvTYPE(target) == SVt_PVHV && SvREADONLY(target)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTYPE(target) == SVt_PVHV && SvREADONLY(target)) { 38 20 58
if (SvTYPE(target) == SVt_PVHV && SvREADONLY(target)) { 4 34 38
1337 4 dds_fix *fix = dds_new_fix(aTHX_ DDS_FIX_LOCK, NULL, node);
1338  
1339 4 fix->args = (AV *)SvREFCNT_inc((SV *)dds_hidden_keys(aTHX_(HV *) target));
1340 4 dds_add_fix(aTHX_ ctx, fix);
1341 }
1342 58 text = dds_ref_expression(aTHX_ ctx, role->name, class_name);
1343 } else
1344 121 text = role->name;
1345 179 dds_write(aTHX_ ctx, text);
1346 179 ctx->column += sv_len_utf8(text);
1347 179 return TRUE;
1348 }
1349  
1350 /* Glob-slot analysis and deferred emission have different frame
1351 * depths. The canonical expression, rather than that numeric depth,
1352 * decides which occurrence is allowed to construct the referent. */
1353 17511 if (role->done ||
1354 11634 ▶ (sv_cmp(role->name, name) && DDS_PV(name)[0] != '&' && DDS_PV(role->name)[0] != '&')) {
Branch: 2 branches
BranchTrueFalseTotal
(sv_cmp(role->name, name) && DDS_PV(name)[0] != '&' && DDS_PV(role->name)[0] != '&')) { 2014 0 2014
(sv_cmp(role->name, name) && DDS_PV(name)[0] != '&' && DDS_PV(role->name)[0] != '&')) { 2014 0 2014
1355 8626 ▶ if (strchr("@%&", DDS_PV(role->name)[0]) && !ctx->style.declare) {
Branch: 2 branches
BranchTrueFalseTotal
if (strchr("@%&", DDS_PV(role->name)[0]) && !ctx->style.declare) { 74 4239 4313
if (strchr("@%&", DDS_PV(role->name)[0]) && !ctx->style.declare) { 38 36 74
1356 38 SV *text = dds_ref_expression(aTHX_ ctx, role->name, class_name);
1357  
1358 38 dds_write(aTHX_ ctx, text);
1359 38 ctx->column += sv_len_utf8(text);
1360 4275 ▶ } else if (!ctx->style.purity) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (!ctx->style.purity) { 5 4270 4275
1361 5 dds_write(aTHX_ ctx, role->name);
1362 5 ctx->column += sv_len_utf8(role->name);
1363 } else {
1364 4270 dds_fix *fix = dds_new_fix(aTHX_ DDS_FIX_REF, name, node);
1365 8540 SV *text = ctx->style.verbose
1366 4270 ? dds_quote(aTHX_ dds_concat(aTHX_ "V: ", role->name, ""), FALSE)
1367 4270 ▶ : DDS_TEMP(newSVpvs("'V'"));
Branch: 1 branch
BranchTrueFalseTotal
: DDS_TEMP(newSVpvs("'V'")); 4270 0 4270
1368  
1369 4270 ▶ if (SvOK(class_name))
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(class_name)) 40 4230 4270
1370 40 fix->class_name = newSVsv(class_name);
1371 4270 ▶ if (add_do) {
Branch: 1 branch
BranchTrueFalseTotal
if (add_do) { 42 4228 4270
1372 42 dds_put(aTHX_ ctx, "do { my $v = ");
1373 42 ctx->column += 12;
1374 }
1375 4270 dds_write(aTHX_ ctx, text);
1376 4270 ctx->column += sv_len_utf8(text);
1377 4270 ▶ if (add_do) {
Branch: 1 branch
BranchTrueFalseTotal
if (add_do) { 42 4228 4270
1378 42 dds_write(aTHX_ ctx, ctx->style.space);
1379 42 dds_put(aTHX_ ctx, "}");
1380 42 ctx->column += sv_len_utf8(ctx->style.space) + 1;
1381 }
1382 4270 dds_add_fix(aTHX_ ctx, fix);
1383 }
1384 4313 return TRUE;
1385 }
1386 5592 return FALSE;
1387 }
1388  
1389 /* Begin a referent's construction wrappers and save blessing, locking and thaw
1390 * state needed after its payload completes.
1391 */
1392 5592 static void dds_begin_ref(pTHX_ dds_ctx *ctx, struct dds_frame *f, dds_ref_value *value)
1393 {
1394 5592 SV *rv = value->rv, *target = value->target;
1395 5592 SV *name = f->name, *class_name = value->class_name;
1396 5592 SV *thaw = value->thaw;
1397 5592 dds_node *node = value->node;
1398 5592 dds_role *role = value->role;
1399 5592 dds_mark *mark = value->mark;
1400 5592 AV *hidden = NULL;
1401 5592 bool overloaded, add_bless, add_lock, fix_lock = FALSE;
1402 5592 bool inline_thaw = FALSE, function_thaw = FALSE;
1403  
1404 5592 role->done = mark;
1405 5592 overloaded = dds_overloaded(aTHX_ rv);
1406 5592 ▶ if (!thaw)
Branch: 1 branch
BranchTrueFalseTotal
if (!thaw) 5588 4 5592
1407 5588 thaw = node->thaw;
1408 5592 ▶ if (thaw && SvTRUE(thaw)) {
Branch: 2 branches
BranchTrueFalseTotal
if (thaw && SvTRUE(thaw)) { 4 5588 5592
if (thaw && SvTRUE(thaw)) { 4 0 4
1409 STRLEN len;
1410 4 const char *p = SvPV(thaw, len);
1411 4 bool simple = TRUE;
1412 STRLEN i;
1413  
1414 40 ▶ for (i = 0; i < len; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < len; i++) { 36 4 40
1415 36 ▶ if (!isALNUMC_A(p[i]) && !strchr("_:>()-", p[i]))
Branch: 2 branches
BranchTrueFalseTotal
if (!isALNUMC_A(p[i]) && !strchr("_:>()-", p[i])) 7 29 36
if (!isALNUMC_A(p[i]) && !strchr("_:>()-", p[i])) 0 7 7
1416 0 simple = FALSE;
1417 }
1418 4 ▶ inline_thaw = !node->class_fields && simple && strnEQ(p, "->", 2);
Branch: 3 branches
BranchTrueFalseTotal
inline_thaw = !node->class_fields && simple && strnEQ(p, "->", 2); 4 0 4
inline_thaw = !node->class_fields && simple && strnEQ(p, "->", 2); 4 0 4
inline_thaw = !node->class_fields && simple && strnEQ(p, "->", 2); 1 3 4
1419 4 ▶ function_thaw = simple && len >= 2 && strEQ(p + len - 2, "()");
Branch: 3 branches
BranchTrueFalseTotal
function_thaw = simple && len >= 2 && strEQ(p + len - 2, "()"); 4 0 4
function_thaw = simple && len >= 2 && strEQ(p + len - 2, "()"); 4 0 4
function_thaw = simple && len >= 2 && strEQ(p + len - 2, "()"); 1 3 4
1420 4 ▶ if (inline_thaw && function_thaw) {
Branch: 2 branches
BranchTrueFalseTotal
if (inline_thaw && function_thaw) { 1 3 4
if (inline_thaw && function_thaw) { 0 1 1
1421 0 dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(p + 2, len - 4)));
1422 0 dds_put(aTHX_ ctx, "(");
1423 0 dds_write(aTHX_ ctx, ctx->style.space);
1424 }
1425 }
1426  
1427 5592 ▶ add_lock = SvTYPE(target) == SVt_PVHV && SvREADONLY(target);
Branch: 2 branches
BranchTrueFalseTotal
add_lock = SvTYPE(target) == SVt_PVHV && SvREADONLY(target); 1665 3927 5592
add_lock = SvTYPE(target) == SVt_PVHV && SvREADONLY(target); 39 1626 1665
1428 5592 ▶ if (add_lock) {
Branch: 1 branch
BranchTrueFalseTotal
if (add_lock) { 39 5553 5592
1429 39 hidden = dds_hidden_keys(aTHX_(HV *) target);
1430 39 ▶ if (DDS_PV(name)[0] != '$') {
Branch: 1 branch
BranchTrueFalseTotal
if (DDS_PV(name)[0] != '$') { 8 31 39
1431 8 fix_lock = TRUE;
1432 8 add_lock = FALSE;
1433 } else {
1434 31 ▶ dds_put(aTHX_ ctx, av_len(hidden) >= 0 ? "lock_ref_keys_plus(" : "lock_ref_keys(");
Branch: 1 branch
BranchTrueFalseTotal
dds_put(aTHX_ ctx, av_len(hidden) >= 0 ? "lock_ref_keys_plus(" : "lock_ref_keys("); 26 5 31
1435 31 dds_write(aTHX_ ctx, ctx->style.space);
1436 }
1437 }
1438  
1439 5754 ▶ add_bless = SvOK(class_name) && !strchr("@%&", DDS_PV(name)[0]);
Branch: 2 branches
BranchTrueFalseTotal
add_bless = SvOK(class_name) && !strchr("@%&", DDS_PV(name)[0]); 162 5430 5592
add_bless = SvOK(class_name) && !strchr("@%&", DDS_PV(name)[0]); 126 36 162
1440 5592 ▶ if (add_bless && !overloaded) {
Branch: 2 branches
BranchTrueFalseTotal
if (add_bless && !overloaded) { 126 5466 5592
if (add_bless && !overloaded) { 98 28 126
1441 STRLEN len;
1442 98 const char *p = SvPV(ctx->style.bless, len);
1443  
1444 98 ▶ dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(p, len ? len - 1 : 0)));
Branch: 1 branch
BranchTrueFalseTotal
dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(p, len ? len - 1 : 0))); 98 0 98
1445 98 dds_write(aTHX_ ctx, ctx->style.space);
1446 }
1447  
1448 /* Only continuation state survives the child frame's temporary scope. */
1449 5592 f->class_name = SvREFCNT_inc(class_name);
1450 5592 f->node = node;
1451 5592 f->role = role;
1452 5592 f->overloaded = overloaded;
1453 5592 f->add_bless = add_bless;
1454 5592 f->add_lock = add_lock;
1455 5592 f->fix_lock = fix_lock;
1456 5592 f->hidden = (AV *)SvREFCNT_inc((SV *)hidden);
1457 5592 f->thaw = thaw;
1458 5592 f->inline_thaw = inline_thaw;
1459 5592 f->function_thaw = function_thaw;
1460 5592 }
1461  
1462 /* Emit a referent payload or push a child continuation; return true when no
1463 * child traversal remains pending.
1464 */
1465 5592 static bool dds_emit_ref_value(pTHX_ dds_ctx *ctx, struct dds_frame *f, dds_ref_value *value)
1466 {
1467 5592 SV *rv = value->rv, *target = value->target;
1468 5592 SV *name = f->name, *class_name = f->class_name;
1469 5592 dds_node *node = f->node;
1470 5592 dds_mark *mark = value->mark;
1471 5592 UV depth = f->depth;
1472 5592 IV indent = f->indent;
1473  
1474 5592 ctx->do_nl = TRUE;
1475 5592 ▶ if (dds_is_regexp(aTHX_ target))
Branch: 1 branch
BranchTrueFalseTotal
if (dds_is_regexp(aTHX_ target)) 133 5459 5592
1476 133 dds_write(aTHX_ ctx, dds_regex(aTHX_ ctx, rv));
1477 5459 ▶ else if (SvTYPE(target) == SVt_PVAV || SvTYPE(target) == SVt_PVHV) {
Branch: 2 branches
BranchTrueFalseTotal
else if (SvTYPE(target) == SVt_PVAV || SvTYPE(target) == SVt_PVHV) { 2369 3090 5459
else if (SvTYPE(target) == SVt_PVAV || SvTYPE(target) == SVt_PVHV) { 1665 704 2369
1478 4755 f->stage = DDS_STAGE_CHILD;
1479 4755 ▶ dds_push_frame(aTHX_ ctx, SvTYPE(target) == SVt_PVAV ? DDS_FRAME_ARRAY : DDS_FRAME_HASH,
Branch: 1 branch
BranchTrueFalseTotal
dds_push_frame(aTHX_ ctx, SvTYPE(target) == SVt_PVAV ? DDS_FRAME_ARRAY : DDS_FRAME_HASH, 3090 1665 4755
1480 target, depth, mark, name, indent, FALSE);
1481 4755 ▶ ctx->frames->node = node == &f->temporary ? NULL : node;
Branch: 1 branch
BranchTrueFalseTotal
ctx->frames->node = node == &f->temporary ? NULL : node; 2327 2428 4755
1482 4755 return FALSE;
1483 758 ▶ } else if (SvTYPE(target) == SVt_PVCV || SvTYPE(target) == SVt_PVFM) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (SvTYPE(target) == SVt_PVCV || SvTYPE(target) == SVt_PVFM) { 654 50 704
} else if (SvTYPE(target) == SVt_PVCV || SvTYPE(target) == SVt_PVFM) { 4 650 654
1484 SV *args[4], *code;
1485  
1486 54 args[0] = rv;
1487 54 args[1] = name;
1488 54 args[2] = DDS_TEMP(newSViv(indent));
1489 54 args[3] = class_name;
1490 54 ▶ code = dds_call(aTHX_ ctx, SvTYPE(target) == SVt_PVCV ? "_xs_code_text" : "_xs_format_text",
Branch: 1 branch
BranchTrueFalseTotal
code = dds_call(aTHX_ ctx, SvTYPE(target) == SVt_PVCV ? "_xs_code_text" : "_xs_format_text", 50 4 54
1491 ctx->owner, G_SCALAR, 4, args);
1492 54 dds_write(aTHX_ ctx, code);
1493 650 ▶ } else if (SvTYPE(target) == SVt_PVIO)
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTYPE(target) == SVt_PVIO) 2 648 650
1494 2 dds_put(aTHX_ ctx, "*{Symbol::gensym()}{IO}");
1495 648 ▶ else if (SvTYPE(target) == SVt_PVGV &&
Branch: 1 branch
BranchTrueFalseTotal
else if (SvTYPE(target) == SVt_PVGV && 135 513 648
1496 270 ▶ strnEQ(DDS_PV(dds_glob_name(aTHX_(GV *) target)), "*Symbol::GEN", 12))
Branch: 1 branch
BranchTrueFalseTotal
strnEQ(DDS_PV(dds_glob_name(aTHX_(GV *) target)), "*Symbol::GEN", 12)) 73 62 135
1497 73 dds_emit_symbol(aTHX_ ctx, (GV *)target, name, depth, FALSE);
1498 575 ▶ else if (SvTYPE(target) <= SVt_PVMG || SvTYPE(target) == SVt_PVGV) {
Branch: 2 branches
BranchTrueFalseTotal
else if (SvTYPE(target) <= SVt_PVMG || SvTYPE(target) == SVt_PVGV) { 62 513 575
else if (SvTYPE(target) <= SVt_PVMG || SvTYPE(target) == SVt_PVGV) { 62 0 62
1499 575 f->stage = DDS_STAGE_SCALAR_REF;
1500 575 dds_push_frame(aTHX_ ctx, DDS_FRAME_SV, target, depth + 1, mark,
1501 dds_child_name(aTHX_ name, '$', NULL, 0), indent, TRUE);
1502 575 return FALSE;
1503 } else
1504 0 croak("Cannot emit Perl SV type %d", (int)SvTYPE(target));
1505 262 return TRUE;
1506 }
1507  
1508 /* Close construction wrappers and queue deferred blessing, locking or thaw
1509 * actions after a referent payload completes.
1510 */
1511 5592 static void dds_finish_ref(pTHX_ dds_ctx *ctx, struct dds_frame *f)
1512 {
1513 5592 SV *class_name = f->class_name, *thaw = f->thaw;
1514 5592 dds_node *node = f->node;
1515 5592 AV *hidden = f->hidden;
1516  
1517 5592 ▶ if (f->add_bless) {
Branch: 1 branch
BranchTrueFalseTotal
if (f->add_bless) { 126 5466 5592
1518 126 ▶ if (!f->overloaded) {
Branch: 1 branch
BranchTrueFalseTotal
if (!f->overloaded) { 98 28 126
1519 STRLEN len;
1520 98 const char *p = SvPV(ctx->style.bless, len);
1521  
1522 98 dds_put(aTHX_ ctx, ",");
1523 98 dds_write(aTHX_ ctx, ctx->style.space);
1524 98 dds_write(aTHX_ ctx, dds_quote(aTHX_ class_name, FALSE));
1525 98 dds_write(aTHX_ ctx, ctx->style.space);
1526 98 ▶ if (len)
Branch: 1 branch
BranchTrueFalseTotal
if (len) 98 0 98
1527 98 dds_write(aTHX_ ctx, DDS_TEMP(newSVpvn(p + len - 1, 1)));
1528 } else {
1529 28 dds_fix *fix = dds_new_fix(aTHX_ DDS_FIX_BLESS, NULL, node);
1530  
1531 28 fix->text = newSVsv(class_name);
1532 28 dds_add_fix(aTHX_ ctx, fix);
1533 }
1534 }
1535  
1536 5592 ▶ if (f->fix_lock && !SvOK(class_name)) {
Branch: 2 branches
BranchTrueFalseTotal
if (f->fix_lock && !SvOK(class_name)) { 8 5584 5592
if (f->fix_lock && !SvOK(class_name)) { 4 4 8
1537 4 dds_fix *fix = dds_new_fix(aTHX_ DDS_FIX_LOCK, NULL, node);
1538  
1539 4 fix->args = (AV *)SvREFCNT_inc((SV *)hidden);
1540 4 dds_add_fix(aTHX_ ctx, fix);
1541 }
1542  
1543 5592 ▶ if (f->add_lock) {
Branch: 1 branch
BranchTrueFalseTotal
if (f->add_lock) { 31 5561 5592
1544 SSize_t i;
1545  
1546 77 ▶ for (i = 0; i <= av_len(hidden); i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= av_len(hidden); i++) { 46 31 77
1547 46 dds_put(aTHX_ ctx, ",");
1548 46 dds_write(aTHX_ ctx, ctx->style.space);
1549 46 dds_write(aTHX_ ctx, dds_quote(aTHX_ * av_fetch(hidden, i, 0), FALSE));
1550 }
1551 31 dds_write(aTHX_ ctx, ctx->style.space);
1552 31 dds_put(aTHX_ ctx, ")");
1553 }
1554  
1555 5592 ▶ if (thaw && SvTRUE(thaw)) {
Branch: 2 branches
BranchTrueFalseTotal
if (thaw && SvTRUE(thaw)) { 4 5588 5592
if (thaw && SvTRUE(thaw)) { 4 0 4
1556 4 ▶ if (f->inline_thaw) {
Branch: 1 branch
BranchTrueFalseTotal
if (f->inline_thaw) { 1 3 4
1557 1 ▶ if (f->function_thaw) {
Branch: 1 branch
BranchTrueFalseTotal
if (f->function_thaw) { 0 1 1
1558 0 dds_write(aTHX_ ctx, ctx->style.space);
1559 0 dds_put(aTHX_ ctx, ")");
1560 } else {
1561 1 dds_put(aTHX_ ctx, "->");
1562 1 dds_put(aTHX_ ctx, DDS_PV(thaw) + 2);
1563 1 dds_put(aTHX_ ctx, "()");
1564 }
1565 } else {
1566 3 dds_fix *fix = dds_new_fix(aTHX_ DDS_FIX_THAW, NULL, node);
1567  
1568 3 fix->text = newSVsv(thaw);
1569 3 dds_add_fix(aTHX_ ctx, fix);
1570 }
1571 }
1572  
1573 5592 ctx->do_nl = TRUE;
1574 5592 Zero(&f->result, 1, dds_result);
1575 5592 }
1576  
1577 /* Coordinate reference resolution, canonical reuse, payload traversal and
1578 * completion across initial and resumed frame stages.
1579 */
1580 15426 static bool dds_step_ref(pTHX_ dds_ctx *ctx, struct dds_frame *f)
1581 {
1582 15426 ▶ if (f->stage == DDS_STAGE_INITIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if (f->stage == DDS_STAGE_INITIAL) { 10096 5330 15426
1583 dds_ref_value value;
1584  
1585 10096 ▶ if (!dds_resolve_ref(aTHX_ ctx, f, &value))
Branch: 1 branch
BranchTrueFalseTotal
if (!dds_resolve_ref(aTHX_ ctx, f, &value)) 12 10084 10096
1586 9834 return TRUE;
1587  
1588 10084 dds_select_ref_role(aTHX_ ctx, f, &value);
1589 10084 ▶ if (dds_emit_ref_use(aTHX_ ctx, f, &value))
Branch: 1 branch
BranchTrueFalseTotal
if (dds_emit_ref_use(aTHX_ ctx, f, &value)) 4492 5592 10084
1590 4492 return TRUE;
1591  
1592 5592 dds_begin_ref(aTHX_ ctx, f, &value);
1593 5592 ▶ if (!dds_emit_ref_value(aTHX_ ctx, f, &value))
Branch: 1 branch
BranchTrueFalseTotal
if (!dds_emit_ref_value(aTHX_ ctx, f, &value)) 5330 262 5592
1594 5330 return FALSE;
1595 5330 ▶ } else if (f->stage == DDS_STAGE_SCALAR_REF && f->result.deferred) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (f->stage == DDS_STAGE_SCALAR_REF && f->result.deferred) { 575 4755 5330
} else if (f->stage == DDS_STAGE_SCALAR_REF && f->result.deferred) { 111 464 575
1596 111 f->role->done = f->result.deferred;
1597 }
1598  
1599 5592 dds_finish_ref(aTHX_ ctx, f);
1600 5592 return TRUE;
1601 }
1602  
1603 /*
1604 * Emission driver and output
1605 *
1606 * The driver drains heap continuations for one value. The output coordinator
1607 * constructs roots, resolves remaining dependencies and runs original-object
1608 * postdump hooks.
1609 */
1610  
1611 /* Drive heap continuations until one requested value is emitted, returning its
1612 * alias or deferred-completion result to the caller.
1613 */
1614 2025 dds_result dds_emit_sv(pTHX_ dds_ctx *ctx, SV *sv, UV depth, dds_mark *mark, SV *name, IV indent,
1615 bool is_ref)
1616 {
1617 2025 struct dds_frame *base = ctx->frames;
1618 2025 dds_result result = {NULL, NULL};
1619  
1620 2025 dds_push_frame(aTHX_ ctx, DDS_FRAME_SV, sv, depth, mark, name, indent, is_ref);
1621 83503 ▶ while (ctx->frames != base) {
Branch: 1 branch
BranchTrueFalseTotal
while (ctx->frames != base) { 81479 2024 83503
1622 81479 struct dds_frame *frame = ctx->frames;
1623 81479 bool done = FALSE;
1624  
1625 /* Scratch values expire after this step. Frames own every string
1626 * or fetched temporary needed when child traversal returns. */
1627 81479 ENTER;
1628 81479 SAVETMPS;
1629  
1630 81479 switch (frame->kind) {
1631 36997 case DDS_FRAME_SV:
1632 36997 done = dds_step_sv(aTHX_ ctx, frame);
1633 36996 break;
1634 15426 case DDS_FRAME_REF:
1635 15426 done = dds_step_ref(aTHX_ ctx, frame);
1636 15426 break;
1637 10691 case DDS_FRAME_ARRAY:
1638 10691 done = dds_step_array(aTHX_ ctx, frame);
1639 10691 break;
1640 18365 case DDS_FRAME_HASH:
1641 18365 done = dds_step_hash(aTHX_ ctx, frame);
1642 18365 break;
1643 }
1644  
1645 81478 ▶ if (done) {
Branch: 1 branch
BranchTrueFalseTotal
if (done) { 41751 39727 81478
1646 41751 result = frame->result;
1647 41751 ctx->frames = frame->parent;
1648 41751 ctx->active = frame->active.parent;
1649 41751 ▶ if (ctx->frames != base)
Branch: 1 branch
BranchTrueFalseTotal
if (ctx->frames != base) 39727 2024 41751
1650 39727 ctx->frames->result = result;
1651 41751 frame->parent = ctx->free_frames;
1652 41751 ctx->free_frames = frame;
1653 41751 dds_release_frame(aTHX_ frame);
1654 }
1655  
1656 81478 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 76239 5239 81478
1657 81478 LEAVE;
1658 }
1659  
1660 2024 return result;
1661 }
1662  
1663 /* Emit or defer enabled glob-slot assignments according to canonical names,
1664 * fetching each live slot immediately before use.
1665 */
1666 141 void dds_emit_glob(pTHX_ dds_ctx *ctx, GV *gv, SV *name, UV depth)
1667 {
1668 141 ▶ UV i, limit = ctx->style.deparse && ctx->style.deparseglob ? 4 : 3;
Branch: 2 branches
BranchTrueFalseTotal
UV i, limit = ctx->style.deparse && ctx->style.deparseglob ? 4 : 3; 141 0 141
UV i, limit = ctx->style.deparse && ctx->style.deparseglob ? 4 : 3; 141 0 141
1669 static const char *slots[] = {"SCALAR", "HASH", "ARRAY", "CODE"};
1670  
1671 701 ▶ for (i = 0; i < limit; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < limit; i++) { 561 140 701
1672 SV *value, *target, *rv;
1673 dds_node *node;
1674 dds_mark *mark;
1675 dds_result result;
1676 SV *path;
1677 561 UV replacements = 0;
1678  
1679 /* Fetch each slot from the owned glob immediately before use;
1680 * earlier slot callbacks may have replaced later slots. */
1681 561 switch (i) {
1682 141 case 0:
1683 141 value = GvSV(gv);
1684 141 break;
1685 140 case 1:
1686 140 value = (SV *)GvHV(gv);
1687 140 break;
1688 140 case 2:
1689 140 value = (SV *)GvAV(gv);
1690 140 break;
1691 140 default:
1692 140 value = (SV *)GvCV(gv);
1693 140 break;
1694 }
1695 561 ▶ if (!value || (i == 0 && !SvOK(value)))
Branch: 3 branches
BranchTrueFalseTotal
if (!value || (i == 0 && !SvOK(value))) 157 404 561
if (!value || (i == 0 && !SvOK(value))) 24 133 157
if (!value || (i == 0 && !SvOK(value))) 0 24 24
1696 468 continue;
1697  
1698 157 target = value;
1699 157 node = dds_find(aTHX_ ctx, target, FALSE);
1700 157 ▶ if (node && (!node->proxy || SvROK(node->proxy)) && node->postop && !node->postop_queued)
Branch: 5 branches
BranchTrueFalseTotal
if (node && (!node->proxy || SvROK(node->proxy)) && node->postop && !node->postop_queued) 157 0 157
if (node && (!node->proxy || SvROK(node->proxy)) && node->postop && !node->postop_queued) 43 114 157
if (node && (!node->proxy || SvROK(node->proxy)) && node->postop && !node->postop_queued) 43 0 43
if (node && (!node->proxy || SvROK(node->proxy)) && node->postop && !node->postop_queued) 20 137 157
if (node && (!node->proxy || SvROK(node->proxy)) && node->postop && !node->postop_queued) 11 9 20
1701 11 dds_queue_postdump(aTHX_ ctx, node, target);
1702 201 ▶ while (node && node->proxy && SvROK(node->proxy)) {
Branch: 3 branches
BranchTrueFalseTotal
while (node && node->proxy && SvROK(node->proxy)) { 201 0 201
while (node && node->proxy && SvROK(node->proxy)) { 44 157 201
while (node && node->proxy && SvROK(node->proxy)) { 44 0 44
1703 44 target = SvRV(node->proxy);
1704 44 node = dds_find(aTHX_ ctx, target, FALSE);
1705 44 ▶ if (node && (!node->proxy || SvROK(node->proxy)) && node->postop &&
Branch: 4 branches
BranchTrueFalseTotal
if (node && (!node->proxy || SvROK(node->proxy)) && node->postop && 44 0 44
if (node && (!node->proxy || SvROK(node->proxy)) && node->postop && 1 43 44
if (node && (!node->proxy || SvROK(node->proxy)) && node->postop && 1 0 1
if (node && (!node->proxy || SvROK(node->proxy)) && node->postop && 1 43 44
1706 1 ▶ !node->postop_queued)
Branch: 1 branch
BranchTrueFalseTotal
!node->postop_queued) 1 0 1
1707 1 dds_queue_postdump(aTHX_ ctx, node, target);
1708 44 ▶ if (++replacements > 100)
Branch: 1 branch
BranchTrueFalseTotal
if (++replacements > 100) 0 44 44
1709 0 croak("Cyclic freezer replacement");
1710 }
1711 157 ▶ if (!node || !node->ref.present)
Branch: 2 branches
BranchTrueFalseTotal
if (!node || !node->ref.present) 157 0 157
if (!node || !node->ref.present) 1 156 157
1712 1 continue;
1713  
1714 156 path = DDS_TEMP(newSVsv(name));
1715 156 sv_catpvf(path, "{%s}", slots[i]);
1716 156 ▶ if (sv_cmp(node->ref.name, path)) {
Branch: 1 branch
BranchTrueFalseTotal
if (sv_cmp(node->ref.name, path)) { 63 93 156
1717 63 dds_fix *fix = dds_new_fix(aTHX_ DDS_FIX_REF, name, node);
1718 63 SV *class_name = dds_class(aTHX_ target);
1719  
1720 63 ▶ if (SvOK(class_name))
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(class_name)) 0 63 63
1721 0 fix->class_name = newSVsv(class_name);
1722 63 dds_add_fix(aTHX_ ctx, fix);
1723 63 continue;
1724 }
1725  
1726 93 rv = DDS_TEMP(newRV_inc(value));
1727 93 mark = dds_new_mark(aTHX_ ctx);
1728 93 ▶ if (!ctx->style.terse) {
Branch: 1 branch
BranchTrueFalseTotal
if (!ctx->style.terse) { 93 0 93
1729 93 dds_write(aTHX_ ctx, name);
1730 92 dds_put(aTHX_ ctx, " = ");
1731 }
1732  
1733 /* Only the actual canonical slot may construct the value. Other
1734 * slots defer their assignment until that construction is ready. */
1735 92 result = dds_emit_sv(aTHX_ ctx, rv, depth, mark, path, sv_len_utf8(name) + 3, FALSE);
1736 92 ▶ if (result.alias)
Branch: 1 branch
BranchTrueFalseTotal
if (result.alias) 0 92 92
1737 0 croak("Unexpected alias for glob slot");
1738 92 dds_put(aTHX_ ctx, ";\n");
1739 92 mark->ready = TRUE;
1740 }
1741  
1742 140 ▶ if (ctx->style.deparse && ctx->style.deparseglob && GvFORM(gv)) {
Branch: 3 branches
BranchTrueFalseTotal
if (ctx->style.deparse && ctx->style.deparseglob && GvFORM(gv)) { 140 0 140
if (ctx->style.deparse && ctx->style.deparseglob && GvFORM(gv)) { 140 0 140
if (ctx->style.deparse && ctx->style.deparseglob && GvFORM(gv)) { 1 139 140
1743 SV *args[2], *text;
1744  
1745 1 args[0] = DDS_TEMP(newRV_inc((SV *)gv));
1746 1 args[1] = name;
1747 1 text = dds_call(aTHX_ ctx, "_xs_glob_format_text", ctx->owner, G_SCALAR, 2, args);
1748 1 ▶ if (SvOK(text))
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(text)) 1 0 1
1749 1 dds_write(aTHX_ ctx, text);
1750 }
1751 140 }
1752  
1753 /* Emit private named class-field snapshots and release fixups made ready by
1754 * each snapshot assignment.
1755 */
1756 0 static void dds_emit_class_fields(pTHX_ dds_ctx *ctx)
1757 {
1758 dds_node *node;
1759  
1760 0 ▶ for (node = ctx->class_head; node; node = node->class_next) {
Branch: 1 branch
BranchTrueFalseTotal
for (node = ctx->class_head; node; node = node->class_next) { 0 0 0
1761 0 dds_mark *mark = dds_new_mark(aTHX_ ctx);
1762  
1763 0 dds_put(aTHX_ ctx, "my ");
1764 0 dds_write(aTHX_ ctx, node->class_fields_name);
1765 0 dds_put(aTHX_ ctx, " = ");
1766 0 (void)dds_emit_sv(aTHX_ ctx, node->class_fields, node->ref.depth + 1, mark,
1767 node->class_fields_name, 0, FALSE);
1768 0 dds_put(aTHX_ ctx, ";\n");
1769 0 mark->ready = TRUE;
1770 0 dds_apply_fixes(aTHX_ ctx, FALSE);
1771 }
1772 0 }
1773  
1774 /* Prepare output context, construct roots and class snapshots, drain fixups in
1775 * dependency order, then run postdump hooks and deliver void-context output.
1776 */
1777 1509 SV *dds_output(pTHX_ dds_ctx *ctx, I32 gimme)
1778 {
1779 UV i;
1780 AV *names, *declared;
1781 SV *printer;
1782 bool class_terse, class_declare;
1783  
1784 1509 dds_clear_emission(aTHX_ ctx);
1785 1509 dds_load_style(aTHX_ ctx);
1786  
1787 /* Root replacement invalidates the saved catalogue. Structural edits
1788 * inside the graph still require the caller to run Data again. */
1789 2351 ▶ for (i = 0; ctx->cataloged && i < ctx->root_count; i++)
Branch: 2 branches
BranchTrueFalseTotal
for (i = 0; ctx->cataloged && i < ctx->root_count; i++) 1268 1083 2351
for (i = 0; ctx->cataloged && i < ctx->root_count; i++) 842 426 1268
1790 842 ▶ if (ctx->roots[i].analyzed_ref != (SvROK(ctx->roots[i].sv) ? SvRV(ctx->roots[i].sv) : NULL))
Branch: 2 branches
BranchTrueFalseTotal
if (ctx->roots[i].analyzed_ref != (SvROK(ctx->roots[i].sv) ? SvRV(ctx->roots[i].sv) : NULL)) 734 108 842
if (ctx->roots[i].analyzed_ref != (SvROK(ctx->roots[i].sv) ? SvRV(ctx->roots[i].sv) : NULL)) 2 840 842
1791 2 ctx->cataloged = FALSE;
1792 1509 ▶ if (!ctx->cataloged)
Branch: 1 branch
BranchTrueFalseTotal
if (!ctx->cataloged) 1083 426 1509
1793 1083 dds_analyze(aTHX_ ctx);
1794  
1795 /* Class snapshots need named storage even for a terse expression. */
1796 1509 ▶ class_terse = ctx->class_head && ctx->style.terse;
Branch: 2 branches
BranchTrueFalseTotal
class_terse = ctx->class_head && ctx->style.terse; 0 1509 1509
class_terse = ctx->class_head && ctx->style.terse; 0 0 0
1797 1509 ▶ class_declare = ctx->class_head && (ctx->style.declare || class_terse);
Branch: 3 branches
BranchTrueFalseTotal
class_declare = ctx->class_head && (ctx->style.declare || class_terse); 0 1509 1509
class_declare = ctx->class_head && (ctx->style.declare || class_terse); 0 0 0
class_declare = ctx->class_head && (ctx->style.declare || class_terse); 0 0 0
1798 1509 ▶ if (class_terse) {
Branch: 1 branch
BranchTrueFalseTotal
if (class_terse) { 0 1509 1509
1799 0 ctx->style.terse = FALSE;
1800 0 ctx->style.declare = TRUE;
1801 }
1802  
1803 1509 ctx->out = newSVpvs("");
1804 1509 ▶ if (gimme == G_ARRAY)
Branch: 1 branch
BranchTrueFalseTotal
if (gimme == G_ARRAY) 11 1498 1509
1805 11 ctx->chunks = newAV();
1806 1509 printer = dds_hget(aTHX_ ctx->object, "fh");
1807 1509 ▶ if (SvTRUE(printer))
Branch: 1 branch
BranchTrueFalseTotal
if (SvTRUE(printer)) 6 1503 1509
1808 6 ctx->printer = newSVsv(printer);
1809  
1810 1509 names = newAV();
1811 1509 declared = newAV();
1812 1509 hv_stores(ctx->object, "out_names", newRV_noinc((SV *)names));
1813 1509 hv_stores(ctx->object, "declare", newRV_noinc((SV *)declared));
1814 3442 ▶ for (i = 0; i < ctx->root_count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < ctx->root_count; i++) { 1933 1509 3442
1815 1933 av_push(names, newSVsv(ctx->roots[i].name));
1816 1933 av_push(declared, newSVsv(ctx->roots[i].name));
1817 }
1818  
1819 1509 ▶ if (ctx->style.compress && SvTRUE(ctx->style.compressor)) {
Branch: 2 branches
BranchTrueFalseTotal
if (ctx->style.compress && SvTRUE(ctx->style.compressor)) { 9 1500 1509
if (ctx->style.compress && SvTRUE(ctx->style.compressor)) { 9 0 9
1820 9 SV *prelude = dds_invoke(aTHX_ ctx, ctx->style.compressor, FALSE, G_SCALAR, 0, NULL);
1821  
1822 9 ▶ if (SvTRUE(prelude))
Branch: 1 branch
BranchTrueFalseTotal
if (SvTRUE(prelude)) 9 0 9
1823 9 dds_write(aTHX_ ctx, prelude);
1824 }
1825 1509 ▶ if (class_terse)
Branch: 1 branch
BranchTrueFalseTotal
if (class_terse) 0 1509 1509
1826 0 dds_put(aTHX_ ctx, "do {\n");
1827  
1828 1509 ▶ if (HvTOTALKEYS(ctx->lexical_added)) {
Branch: 1 branch
BranchTrueFalseTotal
if (HvTOTALKEYS(ctx->lexical_added)) { 11 1498 1509
1829 11 AV *keys = (AV *)DDS_TEMP((SV *)newAV());
1830 HE *he;
1831 SSize_t k;
1832  
1833 11 hv_iterinit(ctx->lexical_added);
1834 38 ▶ while ((he = hv_iternext(ctx->lexical_added)))
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(ctx->lexical_added))) 27 11 38
1835 27 av_push(keys, newSVsv(hv_iterkeysv(he)));
1836 11 sortsv(AvARRAY(keys), av_len(keys) + 1, Perl_sv_cmp);
1837 11 dds_put(aTHX_ ctx, "my (");
1838 38 ▶ for (k = 0; k <= av_len(keys); k++) {
Branch: 1 branch
BranchTrueFalseTotal
for (k = 0; k <= av_len(keys); k++) { 27 11 38
1839 27 ▶ if (k)
Branch: 1 branch
BranchTrueFalseTotal
if (k) 16 11 27
1840 16 dds_put(aTHX_ ctx, ",");
1841 27 dds_write(aTHX_ ctx, *av_fetch(keys, k, 0));
1842 }
1843 11 dds_put(aTHX_ ctx, ");\n");
1844 }
1845  
1846 1509 ▶ if (ctx->class_head) {
Branch: 1 branch
BranchTrueFalseTotal
if (ctx->class_head) { 0 1509 1509
1847 0 ▶ if (class_declare) {
Branch: 1 branch
BranchTrueFalseTotal
if (class_declare) { 0 0 0
1848 0 ▶ for (i = 0; i < ctx->root_count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < ctx->root_count; i++) { 0 0 0
1849 0 SV *name = ctx->roots[i].name;
1850  
1851 0 ▶ if (DDS_PV(name)[0] == '*' || DDS_PV(name)[0] == '&' ||
Branch: 1 branch
BranchTrueFalseTotal
if (DDS_PV(name)[0] == '*' || DDS_PV(name)[0] == '&' || 0 0 0
1852 0 hv_exists_ent(ctx->lexical_added, name, 0))
1853 0 continue;
1854 0 dds_put(aTHX_ ctx, "my ");
1855 0 dds_write(aTHX_ ctx, name);
1856 0 dds_put(aTHX_ ctx, ";\n");
1857 }
1858 }
1859 0 dds_put(aTHX_ ctx, "{\n");
1860 }
1861  
1862 /* Construct roots first. Ready fixups can follow each assignment. */
1863 3440 ▶ for (i = 0; i < ctx->root_count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < ctx->root_count; i++) { 1933 1507 3440
1864 1933 dds_mark *mark = dds_new_mark(aTHX_ ctx);
1865 dds_result result =
1866 1933 dds_emit_sv(aTHX_ ctx, ctx->roots[i].sv, 1, mark, ctx->roots[i].name, 0, FALSE);
1867  
1868 1932 ▶ if (result.alias)
Branch: 1 branch
BranchTrueFalseTotal
if (result.alias) 0 1932 1932
1869 0 croak("Unexpected root alias");
1870 1932 dds_put(aTHX_ ctx, ";\n");
1871 1932 mark->ready = TRUE;
1872 1932 dds_apply_fixes(aTHX_ ctx, FALSE);
1873 }
1874  
1875 /* Hydration shares the reconstructed field slots, so it must wait
1876 * until assignments and aliases into those snapshots are complete. */
1877 1507 ▶ if (ctx->class_head) {
Branch: 1 branch
BranchTrueFalseTotal
if (ctx->class_head) { 0 1507 1507
1878 dds_node *node;
1879  
1880 0 dds_emit_class_fields(aTHX_ ctx);
1881 0 ▶ for (node = ctx->class_head; node; node = node->class_next)
Branch: 1 branch
BranchTrueFalseTotal
for (node = ctx->class_head; node; node = node->class_next) 0 0 0
1882 0 dds_add_fix(aTHX_ ctx, dds_new_fix(aTHX_ DDS_FIX_CLASS, NULL, node));
1883 }
1884  
1885 1507 dds_apply_fixes(aTHX_ ctx, TRUE);
1886  
1887 /* Weakening comes last: temporary strong edges protect cyclic data
1888 * while thaws, class hydration and other fixups are still pending. */
1889 1507 ctx->final_weakening = TRUE;
1890 1507 dds_apply_fixes(aTHX_ ctx, TRUE);
1891 1507 ▶ if (ctx->fix_head)
Branch: 1 branch
BranchTrueFalseTotal
if (ctx->fix_head) 0 1507 1507
1892 0 croak("DDS cannot resolve graph fixups; call Data again if the graph changed");
1893  
1894 1507 ▶ if (ctx->class_head)
Branch: 1 branch
BranchTrueFalseTotal
if (ctx->class_head) 0 1507 1507
1895 0 dds_put(aTHX_ ctx, "}\n");
1896 1507 ▶ if (class_terse) {
Branch: 1 branch
BranchTrueFalseTotal
if (class_terse) { 0 1507 1507
1897 0 ▶ for (i = 0; i < ctx->root_count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < ctx->root_count; i++) { 0 0 0
1898 0 ▶ if (i)
Branch: 1 branch
BranchTrueFalseTotal
if (i) 0 0 0
1899 0 dds_put(aTHX_ ctx, ", ");
1900 0 dds_write(aTHX_ ctx, dds_ref_expression(aTHX_ ctx, ctx->roots[i].name, &PL_sv_undef));
1901 }
1902 0 dds_put(aTHX_ ctx, ";\n};\n");
1903 }
1904  
1905 1507 dds_run_postdump(aTHX_ ctx);
1906  
1907 1506 ▶ if (gimme == G_VOID && !ctx->printer) {
Branch: 2 branches
BranchTrueFalseTotal
if (gimme == G_VOID && !ctx->printer) { 9 1497 1506
if (gimme == G_VOID && !ctx->printer) { 5 4 9
1908 SV *args[2];
1909  
1910 5 args[0] = DDS_TEMP(newRV_inc((SV *)gv_fetchpvs("main::STDOUT", GV_ADD, SVt_PVIO)));
1911 5 args[1] = ctx->out;
1912  
1913 /* Dispatch through the actual glob: it may be localized or tied.
1914 * PRINT is user code and needs the same guard as a To callback. */
1915 5 (void)dds_invoke(aTHX_ ctx, DDS_TEMP(newSVpvs("print")), TRUE, G_VOID | G_DISCARD, 2, args);
1916 }
1917  
1918 1505 return ctx->out;
1919 }
« dds_api.c ↑ Summary dds_format.c »