This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 08.05.2010 16:32, Daniel Kraft wrote:The value is disallowed to being _assigned to_. However, it can change (I think) if Y changes in your previous example. Otherwise, I don't see the point compared to a block construct with a temporary variable.
Hi all,
as my first smaller project (before I'll have more time during the summer and holidays) I'd like to work on implementing the ASSOCIATE construct as well as finishing the SELECT TYPE construct.
My proposed implementation strategy is like this:
Basically, there are two cases that have to be distinguished: For one, names may be associated with expressions, such as "x => 2 * COS (0.25 + Y)" -- in this case, the value is calculated at the beginning of the construct and x may be used within it to represent the result. I think for this, we can internally translate the ASSOCIATE to a BLOCK construct and generate an assignment at the beginning to set it.
However, this value is (obviously) disallowed from being changed;
As a start, one could use a naive implementation which stores the TREE expression in the associate_symbol->backend_decl so that a reference to the associate_symbol will just paste the expression. This way, there is no need to distinguish between variable and expression.Second, if a name is associated to a variable (i.e., some EXPR_VARIABLE in the gfortran code), it may also be used in assignment-contexts and changes the referenced variable (or array section, derived-type component or what ever). I think the best way to handle this situation is by keeping a special "compile time" table of those names and replace each occurence with a copy of the original gfc_expr when resolving the tree (or even when parsing, at least directly in the front-end before code is generated). This should have the semantics we want and need for the standard (e.g., basically that the associate-name has all the same attributes as the variable it references).
One can add later optimizations, with dependency analysis, etc.
Thanks, Daniel
-- Done: Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz To go: Hea-Kni-Mon-Pri
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |