diff --git a/ChangeLog b/ChangeLog index ca8d92c7041b51b7decff84381c03c585f351ec3..3b7bd0ec77bd58210f5868bd9c2437c4b9cc7138 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2016-05-29 Jesper Öqvist <joqvist@google.com> + + * Inherited equations on parameterized NTAs can no longer use the child + index which depended on evaluation order. + * Made parameterized NTA proxy object more loosely coupled to + parameterized NTA values in non-legacy rewrite mode (only setting parent + links to proxy object). + 2016-03-23 Jesper Öqvist <jesper.oqvist@cs.lth.se> * Added a new variation of the contributes statement to allow NTA children diff --git a/src/template/ast/Attributes.tt b/src/template/ast/Attributes.tt index 84db75b902c82c9403cad71b098d72311ecd2a77..41df0ccbd6590a41415e1344ee91e9bceb052a95 100644 --- a/src/template/ast/Attributes.tt +++ b/src/template/ast/Attributes.tt @@ -56,7 +56,7 @@ $endif $else $if(#declaredNTA) /** @apilevel internal */ - protected $List #(signature)_list; + protected $ASTNode #(signature)_proxy; $endif $if(LazyMaps) /** @apilevel internal */ @@ -233,12 +233,14 @@ $endif SynDecl.higherOrderAttributeCode:norewrite [[ $if(#isParameterized) -if (#(signature)_list == null) { - #(signature)_list = new $List(); +if (#(signature)_proxy == null) { + #(signature)_proxy = new $ASTNode(); $include(AttrDecl.incHookCreateNtaList) - #(signature)_list.setParent(this); + #(signature)_proxy.setParent(this); +} +if (#(signature)_value != null) { + #(signature)_value.setParent(#(signature)_proxy); } -#(signature)_list.add(#(signature)_value); $else #(signature)_value.setParent(this); $endif @@ -246,19 +248,26 @@ $endif SynDecl.higherOrderAttributeCode:rewritesEnabled [[ $if(#isParameterized) -if (#(signature)_list == null) { - #(signature)_list = new $List(); +if (#(signature)_proxy == null) { + #(signature)_proxy = new $ASTNode(); $include(AttrDecl.incHookCreateNtaList) $if(LegacyRewrite) - #(signature)_list.is$$Final = true; + #(signature)_proxy.is$$Final = true; $endif - #(signature)_list.setParent(this); + #(signature)_proxy.setParent(this); } -#(signature)_list.add(#(signature)_value); if (#(signature)_value != null) { - #(signature)_value = (#boxedType) #(signature)_list.getChild(#(signature)_list.numChildren - 1); $if(LegacyRewrite) + #(signature)_proxy.addChild(#(signature)_value); + // Proxy child access is used to trigger rewrite of NTA value. + #(signature)_value = (#boxedType) #(signature)_proxy.getChild(#(signature)_proxy.numChildren - 1); #(signature)_value.is$$Final = true; + $else + #(signature)_value.setParent(#(signature)_proxy); + if (#(signature)_value.mayHaveRewrite()) { + #(signature)_value = (#boxedType) #(signature)_value.rewrittenNode(); + #(signature)_value.setParent(#(signature)_proxy); + } $endif } $else diff --git a/src/template/ast/Circular.tt b/src/template/ast/Circular.tt index 1fb3873ac194cb86b54ab42d5e496644a298f427..5614f7f0bcc19756cddecd3f8fb868f240ddd6be 100644 --- a/src/template/ast/Circular.tt +++ b/src/template/ast/Circular.tt @@ -165,11 +165,11 @@ AttrDecl.circularEquation:parameterized [[ _value.value = $BottomValue; $if(#getNTA) if (_value.value != null) { - if (#(signature)_list == null) { - #(signature)_list = new $List(); - #(signature)_list.setParent(#ntaParent); + if (#(signature)_proxy == null) { + #(signature)_proxy = new $ASTNode(); + #(signature)_proxy.setParent(#ntaParent); } - (($ASTNode) _value.value).setParent(#(signature)_list); + (($ASTNode) _value.value).setParent(#(signature)_proxy); } $endif } @@ -196,11 +196,11 @@ $endif _value.value = new_#(signature)_value; $if(#getNTA) if (_value.value != null) { - if (#(signature)_list == null) { - #(signature)_list = new $List(); - #(signature)_list.setParent(#ntaParent); + if (#(signature)_proxy == null) { + #(signature)_proxy = new $ASTNode(); + #(signature)_proxy.setParent(#ntaParent); } - (($ASTNode) _value.value).setParent(#(signature)_list); + (($ASTNode) _value.value).setParent(#(signature)_proxy); } $endif } @@ -249,11 +249,11 @@ $endif _value.value = new_#(signature)_value; $if(#getNTA) if (_value.value != null) { - if (#(signature)_list == null) { - #(signature)_list = new $List(); - #(signature)_list.setParent(#ntaParent); + if (#(signature)_proxy == null) { + #(signature)_proxy = new $ASTNode(); + #(signature)_proxy.setParent(#ntaParent); } - (($ASTNode) _value.value).setParent(#(signature)_list); + (($ASTNode) _value.value).setParent(#(signature)_proxy); } $endif } diff --git a/src/template/ast/InheritedAttributes.tt b/src/template/ast/InheritedAttributes.tt index 2bf4e8473dfb3a4794414a2ba08b1d1d5fa301d6..0283b7cf5541383a66eb1c5f24da998ce85f8118 100644 --- a/src/template/ast/InheritedAttributes.tt +++ b/src/template/ast/InheritedAttributes.tt @@ -122,7 +122,7 @@ $EvalStmt # non-terminal child equation clause InhEq.emitNTAClause [[ $if(IsParameterized) -if (_callerNode == $(AttrSignature)_list) { +if (_callerNode == $(AttrSignature)_proxy) { // #declaredat int $ChildIndexVar = _callerNode.getIndexOfChild(_childNode); $EvalStmt diff --git a/src/template/flush/Flush.tt b/src/template/flush/Flush.tt index 37219f83711817b8ae07280309b6b851dfad81f6..7edb61cefbceba97feb8e683a7b0aab05634136e 100644 --- a/src/template/flush/Flush.tt +++ b/src/template/flush/Flush.tt @@ -137,7 +137,7 @@ $if(#isLazy) #(signature)_values = $CreateDefaultMap; $endif $if(#getNTA) -#(signature)_list = null; +#(signature)_proxy = null; $endif $else $if(#simpleCacheCheck) diff --git a/src/template/incremental/Debug.tt b/src/template/incremental/Debug.tt index c2d247a100914cdc7ec465f88c258b2e72ee957c..ef8b0ad51bc8ac8e312793f3b967b306f8adce5d 100644 --- a/src/template/incremental/Debug.tt +++ b/src/template/incremental/Debug.tt @@ -224,8 +224,8 @@ if ($(AttrSign)_handler != null) { $endif $if (IsNTA) $if (IsParameterized) -if ($(AttrSign)_list != null) { - $(AttrSign)_list.dumpDependencies(); +if ($(AttrSign)_proxy != null) { + $(AttrSign)_proxy.dumpDependencies(); } $else if ($(AttrSign)_computed && ($(AttrSign)_value instanceof $ASTNode)) { @@ -240,8 +240,8 @@ if ($(AttrSign)_handler != null) { } $if (IsNTA) $if (IsParameterized) -if ($(AttrSign)_list != null) { - $(AttrSign)_list.dumpDependencies(); +if ($(AttrSign)_proxy != null) { + $(AttrSign)_proxy.dumpDependencies(); } $else if ($(AttrSign)_computed && ($(AttrSign)_value instanceof $ASTNode)) { @@ -270,8 +270,8 @@ public void #name.dumpDepsInTree() { # Generate string with code for dumping dependencies in NTAs ASTDecl.checkAndDumpNTADeps = [[ $if (IsParameterized) -if ($(AttrSign)_list != null) { - $(AttrSign)_list.dumpDepsInTree(); +if ($(AttrSign)_proxy != null) { + $(AttrSign)_proxy.dumpDepsInTree(); } $else if ($(AttrSign)_computed && ($(AttrSign)_value instanceof $ASTNode)) { diff --git a/src/template/incremental/NTAs.tt b/src/template/incremental/NTAs.tt index 19efeb55f5cdc03cf3d6f4ec789b749d2248c42a..9fac34d9d528a606e37bfd8a4d8cac43b0656a72 100644 --- a/src/template/incremental/NTAs.tt +++ b/src/template/incremental/NTAs.tt @@ -63,13 +63,13 @@ $if(IncrementalEnabled) $if(IncrementalLevelNode) $if(#getNTA) -#(signature)_list.inc_internalNTAList(#(signature)_values); +#(signature)_proxy.inc_internalNTAList(#(signature)_values); $endif $endif $if(IncrementalLevelRegion) $if(#getNTA) -#(signature)_list.inc_internalNTAList(#(signature)_values); +#(signature)_proxy.inc_internalNTAList(#(signature)_values); $endif $endif diff --git a/src/template/incremental/Notification.tt b/src/template/incremental/Notification.tt index 2cb60e274f62d7ae3e2fb2ded1f75800f00da380..d8528d09377a02e601c76d895ef5ea276539d9c9 100644 --- a/src/template/incremental/Notification.tt +++ b/src/template/incremental/Notification.tt @@ -252,12 +252,12 @@ $if(IsParameterized) if (attrID.equals("$AttrSign") && $(AttrSign)_values != null && $(AttrSign)_values.containsKey(_parameters)) { $if(IsNTA) $AttrType value = ($AttrType)$(AttrSign)_values.remove(_parameters); - for (int i = 0; i < $(AttrSign)_list.children.length; i++) { - $ASTNode child = $(AttrSign)_list.children[i]; + for (int i = 0; i < $(AttrSign)_proxy.children.length; i++) { + $ASTNode child = $(AttrSign)_proxy.children[i]; if (child != null && value == child) { // using dummy node to flush dependencies from NTA value.inc_flush_subtree(($DDGNodeName)$(AttrSign)_handler.get(_parameters)); - $(AttrSign)_list.removeChild(i); + $(AttrSign)_proxy.removeChild(i); break; } } @@ -296,10 +296,10 @@ $if(IncrementalLevelAttr) $if(IsParameterized) if (attrID.equals("$AttrSign") && $(AttrSign)_values != null && !$(AttrSign)_values.isEmpty()) { $if(IsNTA) - if ($(AttrSign)_list != null) { - $(AttrSign)_list.setParent(null); + if ($(AttrSign)_proxy != null) { + $(AttrSign)_proxy.setParent(null); // using dummy node to flush dependencies from NTA - $(AttrSign)_list.inc_flush_subtree($(AttrSign)_handler); + $(AttrSign)_proxy.inc_flush_subtree($(AttrSign)_handler); } $endif $AttrResetVisit @@ -763,12 +763,12 @@ $if(IncrementalChangeFlush) $if(IsNTA) $if(IsParameterized) -if ($(AttrSign)_list != null) { - for (int index = 0; index < $(AttrSign)_list.numChildren; index++) { - $ASTNode value = $(AttrSign)_list.children[index]; +if ($(AttrSign)_proxy != null) { + for (int index = 0; index < $(AttrSign)_proxy.numChildren; index++) { + $ASTNode value = $(AttrSign)_proxy.children[index]; if (!value.isRegionRoot()) { state().enterConstruction(); - $(AttrSign)_list.removeChild(index); + $(AttrSign)_proxy.removeChild(index); // removeChild will decrease the index of all remaining children and numChildren // hence, to visit the remainder of the list index need to be decreased by one for each removeChild index--; @@ -998,8 +998,8 @@ $if(IncrementalEnabled) $if(IncrementalChangeFlush) $if(IsNTA) $if(IsParameterized) -if ($(AttrSign)_list != null) { - $(AttrSign)_list.inc_flush_subtree(h); +if ($(AttrSign)_proxy != null) { + $(AttrSign)_proxy.inc_flush_subtree(h); } $else $if(IsNtaWithTree) diff --git a/src/template/incremental/State.tt b/src/template/incremental/State.tt index e0d32a5ee315e556fbe6933ac73c170ac37f9927..aa359045528c18a1dc9fe8574005093060ae2965 100644 --- a/src/template/incremental/State.tt +++ b/src/template/incremental/State.tt @@ -250,8 +250,8 @@ if ($(AttrSign)_handler != null) { $endif $if(ChangeStateValue) $if(IsParameterized) -if ($(AttrSign)_list != null) { - $(AttrSign)_list.inc_changeState(newState); +if ($(AttrSign)_proxy != null) { + $(AttrSign)_proxy.inc_changeState(newState); } $else if ($(AttrSign)_computed && ($(AttrSign)_value instanceof $ASTNode)) { @@ -363,8 +363,8 @@ if ($(AttrSign)_handler != null) { $endif $if(ThrowAwayValue) $if(IsParameterized) -if ($(AttrSign)_list != null) { - $(AttrSign)_list.inc_throwAway(); +if ($(AttrSign)_proxy != null) { + $(AttrSign)_proxy.inc_throwAway(); } $else if ($(AttrSign)_computed && ($(AttrSign)_value instanceof $ASTNode)) {