getXNoTransform() for NTAs

Issue #215 open
Jesper Mattsson created an issue

When an NTA is declared in the .ast file with the /X/ syntax, then a getXNoTransform() method is generated, but it does not calculate the value of the NTA - only calls getChildNoTransform(). Thus, if you call getXNoTransform() before the first call to getX(), you will get null.

I would expect the NTA to be calculated, but no rewrites triggered.

Comments (8)

  1. Jesper Öqvist

    Compute NTA components via getXNoTransform()

    Accessing an NTA component via getXNoTransform() now returns the NTA value, instead of returning the uninitialized NTA, i.e. null.

    fixes #215 (bitbucket)

    → <<cset 7e668c176a69>>

  2. Jesper Mattsson reporter

    It looks like getXNoTransform() now is equivalent to getX()? Is that true? That would seem to invalidate the reason for even having it in the first place. I agree that it is better than the previous behavior, though.

  3. Jesper Öqvist

    Yes, this made getX() and getXNoTransform() equivalent for NTA components. However, it's good to have getXNoTransform() generated for all components just for symmetry, and making getXNoTransform() actually skip rewrites in this case would mean a much bigger change in JastAdd because the rewrite is built-in to the method that computes the NTA.

  4. Jesper Mattsson reporter

    How about adding a getXNoCreate() method that for normal children just calls getXNoTransform(), and for NTAs has the old behavior of getXNoTransform(). If you then use getXNoCreate() when calculating inherited attributes, then you can re-introduce your change.

    Moving the rewrites on NTAs to getChild()/getX() and having getXNoTransform() only create without triggering the rewrites could then be a possible future enhancement.

  5. Log in to comment