NTA double cache check
Issue #182
resolved
Found this in some generated code for the class AnyType
:
/**
* @attribute syn nta
* @aspect Multiplicities
* @declaredat /home/jesper/git/multiplicities/src/main/jastadd/Multiplicities.jrag:6
*/
public Modifiers getModifiers() {
if(getModifiers_computed) {
return (Modifiers) getChild(getModifiersChildPosition());
}
if(getModifiers_computed) {
return getModifiers_value;
}
Abstract grammar for AnyType
:
abstract MultiplicityType : TypeDecl ::= /Modifiers/ /BodyDecl*/;
AnyType : MultiplicityType ::= ContainerType:Access /Modifiers/ /BodyDecl*/;
Attribute declarations:
syn nta Modifiers MultiplicityType.getModifiers() =
new Modifiers();
syn nta List<BodyDecl> MultiplicityType.getBodyDeclList() =
new List<BodyDecl>();
syn nta Modifiers AnyType.getModifiers() =
new Modifiers();
syn nta List<BodyDecl> AnyType.getBodyDeclList() =
new List<BodyDecl>();
Comments (6)
-
reporter -
reporter In version 2.1.10 the double cache check is still present, and what's worse is that the second cache check seems to be the correct one because NTA attributes do not cache their value with setChild. Either the NTA should cache using setChild, or the first cache check should be removed. In either case one of the cache checks should not be generated.
-
reporter An example from JModelica:
public Opt getFDynamicResolverOpt() { if(getFDynamicResolverOpt_computed) { return (Opt) getChild(getFDynamicResolverOptChildPosition()); } if(getFDynamicResolverOpt_computed) { return getFDynamicResolverOpt_value; } ASTNode$State state = state(); boolean intermediate = state.INTERMEDIATE_VALUE; state.INTERMEDIATE_VALUE = false; int num = state.boundariesCrossed; boolean isFinal = this.is$Final(); getFDynamicResolverOpt_value = new DynamicOpt(); getFDynamicResolverOpt_value.setParent(this); getFDynamicResolverOpt_value.is$Final = true; if (true) { getFDynamicResolverOpt_computed = true; } else { } state.INTERMEDIATE_VALUE |= intermediate; Opt node = (Opt) this.getChild(getFDynamicResolverOptChildPosition()); return node; }
-
reporter - changed title to NTA double cache check
-
reporter The Optional NTA caching is a separate issue. Th getChild cache access is needed to trigger rewrites, so it should be preserved. The second cache check should not happen.
-
reporter - changed status to resolved
- Log in to comment
Version of JastAdd2 used:
JastAdd2 2.1.4-36-g18008bb