Make contribution target optional when the collection root is the target node

Create issue
Issue #242 resolved
Jesper Öqvist created an issue

JastAdd 2.1.13

We can make the for part optional in collection contribution statements if the declared root type is the same as the host type for the collection and the target node should be identical to the root node.

Using implicit collection target could enable faster code generation because the generated code then does not need to evaluate the contribution target expression for each contribution. The generated code could pass a reference to the root node to each method called during the survey phase of a collection attribute evaluation.

Allowing the collection target to be optional would shorten the collection contribution statements for some types of collection attributes, notably error collection attributes which tend to contribute only to the root node. An example of a collection attribute omitting the contribution target expression:

import java.util.LinkedList;

aspect Test {
  coll LinkedList<Leaf> Tree.leaves() [new LinkedList<Leaf>()];

  Leaf contributes this to Tree.leaves();
}

Comments (4)

  1. Jesper Öqvist reporter

    Make contribution target optional

    The contribution target expression is now optional when the collection root node is the same as the collection target.

    fixes #242 (bitbucket)

    → <<cset 695643337b97>>

  2. Log in to comment