Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^5: Introspecting type informations? HvNAME(SvSTASH(SvRV(ST(0))))

by roboticus (Chancellor)
on Aug 04, 2019 at 16:04 UTC ( [id://11103861]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Introspecting type informations? HvNAME(SvSTASH(SvRV(ST(0))))
in thread Introspecting type informations?

LanX:

In the page you linked, it looks like lines 1612 and 1613 (inside subroutine maybe_my) fetch the information from the PAD if it's a typed PAD:

1607: if ($op->private & OPpLVAL_INTRO and not $self->{'avoid_local'}{ +$$op}) { 1608: # Check $padname->FLAGS for statehood, rather than $op->p +rivate, 1609: # because enteriter ops do not carry the flag. 1610: my $my = 1611: $self->keyword($padname->FLAGS & SVpad_STATE ? "state +" : "my"); 1612: if ($padname->FLAGS & SVpad_TYPED) { 1613: $my .= ' ' . $padname->SvSTASH->NAME; 1614: }

I didn't dig any further into it because it looks like the right thing. Hopefully that'll get you on the trail to the info you're looking for.

Note: I got lucky when looking for it, as I first did a ^F in the browser looking for my, but it indicated over 1000 results. However, it also added highlights, drawing my attention to the first item: OPpTARGET_MY. Changing the search to _my gave a mere 6 locations, and the third one shows where the type name gets added to the "my TYPE VAR" output for Deparse. Had it not done so, it may have taken a while to dig it up.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^6: Introspecting type informations? ($padname->SvSTASH->NAME)
by LanX (Saint) on Aug 04, 2019 at 17:45 UTC
    Hi roboticus

    Thanks!

    You seem to be spot on, though this $padname->SvSTASH->NAME is a strange name for the type.

    So the information seems to be hidden in the lexical pad.

    After this year's YAPC I'll try to find out for sure, patching B::Deparse to through debug information is actually not that difficult.

    Ideally B::Concise could be patched to show it too.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11103861]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-29 06:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found