Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[photran-dev] Variable read/write information

I have added information to the VPG that allows you to determine
whether a particular occurrence of a variable name corresponds to a
read or a write of that variable.

You can view this information visually by opening a file in Photran
and clicking on Refactor > (Debugging) > Highlight Variable Accesses.
Within a refactoring (or other code), you can get this information
from a Token object by calling token.getVariableAccessType().

The information provided is generally correct -- notably, it figures
out whether a variable is passed to a subprogram as an intent(out) or
intent(inout) parameter -- although there are three cases I know of
where it does not (yet) always give correct information:

1. When a subprogram is declared in an interface block, it may get the
argument intents wrong.  (This is actually due to a scoping problem.)

2. When a variable is used in the spec list of an I/O statement, it
will often be marked as read/write (VariableAccess.RW).  (The code
that determines reads and writes does not distinguish between the
various options available for each I/O statement.)

3. A function call will be marked as though the function name is a
variable being read.  (This is, indirectly, due to the fact that array
accesses and function calls are syntactically ambiguous.)

Anyway, this code is very new, so please try out the visualization on
a few files and let me know where else you find errors.

Token#getVariableAccessType() should be sufficient for inferring the
INTENTs of subprogram arguments, as well as for determining when a
variable reference can be replaced with an equivalent expression
(e.g., for Encapsulate Variable and Unroll Loop).

We should have control flow graphs and du-chains available soon.

Jeff


Back to the top