/* TODO
*
* Refactor this to split out D:M code from Devel::Size code.
- *
* Start migrating Devel::Size's Size.xs towards the new code.
*
- * ADD_PRE_ATTR for index should check if the ptr is new first. Currently we're
- * generating lots of ADD_PRE_ATTR's for SVs that we've already seen via other paths.
- * That's wasteful and likely to cause subtle bugs.
- *
- * Give HE's their own node so keys and values can be tied together
- *
*/
#undef NDEBUG /* XXX */
#define NPtype_MAGIC 0x04
#define NPtype_OP 0x05
-/* XXX these should probably be generalizes into flag bits */
+/* XXX these should probably be generalized into flag bits */
#define NPattr_LEAFSIZE 0x00
#define NPattr_NAME 0x01
#define NPattr_PADFAKE 0x02
#define NPattr_PADNAME 0x03
#define NPattr_PADTMP 0x04
#define NPattr_NOTE 0x05
-#define NPattr_PRE_ATTR 0x06 /* deprecated */
#define _ADD_ATTR_NP(st, attr_type, attr_name, attr_value, np) \
STMT_START { \
} \
} STMT_END
-#define ADD_ATTR(st, attr_type, attr_name, attr_value) _ADD_ATTR_NP(st, attr_type, attr_name, attr_value, NP-1)
+#define ADD_ATTR(st, attr_type, attr_name, attr_value) \
+ _ADD_ATTR_NP(st, attr_type, attr_name, attr_value, NP-1)
+
#define ADD_LINK_ATTR(st, attr_type, attr_name, attr_value) \
STMT_START { \
assert(NP->seqn); \
_ADD_ATTR_NP(st, attr_type, attr_name, attr_value, NP); \
} STMT_END;
-#define ADD_PRE_ATTR(st, attr_type, attr_name, attr_value) \
- STMT_START { \
- assert(!attr_type); \
- _ADD_ATTR_NP(st, NPattr_PRE_ATTR, attr_name, attr_value, NP-1); \
- } STMT_END;
#define _NPathLink(np, nid, ntype) (((np)->id=nid), ((np)->type=ntype), ((np)->seqn=0))
#define NPathLink(nid) (_NPathLink(NP, nid, NPtype_LINK), NP)
}
}
-static void
+static int
hek_size(pTHX_ struct state *st, HEK *hek, U32 shared, pPATH)
{
dNPathNodes(1, NPathArg);
/* Hash keys can be shared. Have we seen this before? */
if (!check_new(st, hek))
- return;
+ return 0;
NPathPushNode("hek", NPtype_NAME);
ADD_SIZE(st, "hek_len", HEK_BASESIZE + hek->hek_len
#if PERL_VERSION < 8
ADD_SIZE(st, "shared_he", STRUCT_OFFSET(struct shared_he, shared_he_hek));
#endif
}
+ return 1;
}
static void
}
my $indent = ": ";
-my $pending_pre_attr = {};
while (<>) {
warn "\t\t\t\t== $_" if $opt_debug;
die "Depth out of sync\n" if $val != @stack;
my $node = enter_node({
id => $id, type => $type, name => $name, extra => $extra,
- attr => { %$pending_pre_attr },
- leaves => {}, depth => $val, self_size=>0, kids_size=>0
+ attr => { }, leaves => {}, depth => $val, self_size=>0, kids_size=>0
});
- %$pending_pre_attr = ();
$stack[$val] = $node;
$seqn2node{$id} = $node;
}
my $node = $seqn2node{$id} || die;
my $attr = $node->{attr} || die;
- # attributes to queue up and apply to the next node
- if (NPattr_PRE_ATTR == $type) {
- $pending_pre_attr->{$name} = $val;
- }
# attributes where the string is a key (or always empty and the type is the key)
- elsif ($type == NPattr_NAME or $type == NPattr_NOTE) {
+ if ($type == NPattr_NAME or $type == NPattr_NOTE) {
printf "%s~%s(%s) %d [t%d]\n", $indent x ($node->{depth}+1), $attr_type_name[$type], $name, $val, $type
if $opt_text;
warn "Node $id already has attribute $type:$name (value $attr->{$type}{$name})\n"
}
die "panic: seqn2node should be empty ". Dumper(\%seqn2node)
if %seqn2node;
- %$pending_pre_attr = ();
if ($dot_fh) {
print $dot_fh "}\n";