Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Static analysis using PPI

by PerlOnTheWay (Scribe)
on Dec 13, 2011 at 12:22 UTC ( #943316=perlquestion: print w/ replies, xml ) Need Help??
PerlOnTheWay has asked for the wisdom of the Perl Monks concerning the following question:

my $a = 1; .. my $b = func1($a); .. sub t{ my ($c) = @_; } t(func2($b));

Since Parse::Perl::Independant can parse Perl itself,is it possible to know that $c is first converted from $a and then converted from $b programatically(which is obvious for human)?

If yes,any advice?

Comment on Static analysis using PPI
Select or Download Code
Re: Static analysis using PPI
by Corion (Pope) on Dec 13, 2011 at 12:37 UTC

    Yes - look at type inference. For a language like Perl, real type inference and/or dataflow analysis will be limited, because eval can be used to overwrite call sequences in various places, as can glob assignment. But for a class of programs that don't do this, it is in theory possible.

Re: Static analysis using PPI
by bluescreen (Friar) on Dec 13, 2011 at 12:48 UTC

    Any static analysis over Perl code is not reliable Perl Cannot Be Parsed: A Formal Proof, in simple cases like this you might be able to trace the origins of a variable but as long as you attempt the same thing over more complex code you will get into trouble because the Perl parser adapts to the run time environment.

Re: Static analysis using PPI
by Anonymous Monk on Dec 13, 2011 at 13:35 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://943316]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (15)
As of 2014-07-24 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (160 votes), past polls