diff --git a/src/jastadd/incremental/IncrementalDDG.jadd b/src/jastadd/incremental/IncrementalDDG.jadd index 86ef22b24c8891b0306a47e9093cf371e8d1f4e9..05e34c23ef787bb57c6986e1c9d8d0941bc90e62 100644 --- a/src/jastadd/incremental/IncrementalDDG.jadd +++ b/src/jastadd/incremental/IncrementalDDG.jadd @@ -39,7 +39,7 @@ aspect IncrementalDDG { /** * Generate DDG cleanup methods, * - * Methods: cleanupDependants, cleanupDependantsInTree + * Methods: cleanupListeners, cleanupListenersInTree * * After introducing single direction edges in the DDG flushed (emptied) * dependants (or listeners) may remain in the DDG. The purpose of these @@ -48,11 +48,11 @@ aspect IncrementalDDG { public void ASTDecl.genIncrementalCleanup(PrintWriter out) { if (!config().incremental()) return; TemplateContext tt = templateContext(); - tt.bind("CleanupTokenDependants", genCleanupTokenDependantsString()); - tt.bind("CleanupAttributeDependants", genCleanupAttributeDependantsString()); - tt.expand("ASTDecl.cleanupDependantsMethod", out); - tt.bind("CleanupDependantsInNTAs", genCleanupDependantsInNTAsString()); - tt.expand("ASTDecl.cleanupDependantsInTreeMethod", out); + tt.bind("CleanupTokenListeners", genCleanupTokenListenersString()); + tt.bind("CleanupAttributeListeners", genCleanupAttributeListenersString()); + tt.expand("ASTDecl.cleanupListenersMethod", out); + tt.bind("CleanupListenersInNTAs", genCleanupListenersInNTAsString()); + tt.expand("ASTDecl.cleanupListenersInTreeMethod", out); } /** @@ -142,7 +142,7 @@ aspect IncrementalDDG { /** * Generate string with code for cleaning up dependants in NTAs. */ - public String ASTDecl.genCleanupDependantsInNTAsString() { + public String ASTDecl.genCleanupListenersInNTAsString() { StringBuffer res = new StringBuffer(); TemplateContext tt = templateContext(); for (AttrDecl attr : listOfCachedAttributes()) { @@ -150,7 +150,7 @@ aspect IncrementalDDG { !(attr.type().equals("String") || attr.type().equals("java.lang.String"))) { tt.bind("IsParameterized", attr.getNumParameter() > 0); tt.bind("AttrSign", attr.signature()); - res.append(tt.expand("ASTDecl.checkAndCleanupNTADependants")); + res.append(tt.expand("ASTDecl.checkAndCleanupNTAListeners")); } } return res.toString(); @@ -159,7 +159,7 @@ aspect IncrementalDDG { /** * Generate string with code for cleaning up dependants. */ - public String ASTDecl.genCleanupAttributeDependantsString() { + public String ASTDecl.genCleanupAttributeListenersString() { StringBuffer res = new StringBuffer(); TemplateContext tt = templateContext(); // Add dump string for each attribute @@ -168,7 +168,7 @@ aspect IncrementalDDG { tt.bind("IsNTA", (attr.isNTA() || attr.getNTA()) && !attr.isPrimitive() && !(attr.type().equals("String") || attr.type().equals("java.lang.String"))); tt.bind("AttrSign", attr.signature()); - res.append(tt.expand("ASTDecl.checkAndCleanupAttributeDependants")); + res.append(tt.expand("ASTDecl.checkAndCleanupAttributeListeners")); } return res.toString(); } @@ -176,14 +176,14 @@ aspect IncrementalDDG { /** * Generate string with code for cleaning up token dependants. */ - public String ASTDecl.genCleanupTokenDependantsString() { + public String ASTDecl.genCleanupTokenListenersString() { StringBuffer res = new StringBuffer(); TemplateContext tt = templateContext(); if (config().incrementalLevelParam() || config().incrementalLevelAttr()) { for (Component c : components()) { if (c instanceof TokenComponent && !c.isNTA()) { tt.bind("Id", ((TokenComponent)c).getTokenId().getID()); - res.append(tt.expand("ASTDecl.checkAndCleanupTokenDependants")); + res.append(tt.expand("ASTDecl.checkAndCleanupTokenListeners")); } } } diff --git a/src/template/incremental/DDGNode.tt b/src/template/incremental/DDGNode.tt index e2d8fdd1a6fcde630c5e7e49353ad678dbba41d1..2b355a5fdc3b589731205224a153ee2a77abeed8 100644 --- a/src/template/incremental/DDGNode.tt +++ b/src/template/incremental/DDGNode.tt @@ -120,7 +120,7 @@ $if (IncrementalLevelAttr) java.util.HashSet<$DDGNodeName> k = fDependencySet; fDependencySet = new java.util.HashSet<$DDGNodeName>(4); for ($DDGNodeName node : k) { - node.removeDependant(this); + node.removeListener(this); } fNode.reactToDependencyChange(fAttrID); } @@ -148,7 +148,7 @@ $if (IncrementalLevelNode) java.util.HashSet<$DDGNodeName> k = fDependencySet; fDependencySet = new java.util.HashSet<$DDGNodeName>(4); for ($DDGNodeName node : k) { - node.removeDependant(this); + node.removeListener(this); } fNode.reactToDependencyChange(); } @@ -176,7 +176,7 @@ $if (IncrementalLevelRegion) java.util.HashSet<$DDGNodeName> k = fDependencySet; fDependencySet = new java.util.HashSet<$DDGNodeName>(4); for ($DDGNodeName node : k) { - node.removeDependant(this); + node.removeListener(this); } fNode.reactToDependencyChange(); } @@ -186,19 +186,19 @@ $endif public java.util.HashSet<$DDGNodeName> fListenerSet = new java.util.HashSet<$DDGNodeName>(4); - public boolean hasDependants() { + public boolean hasListeners() { return !fListenerSet.isEmpty(); } - public void addDependant($DDGNodeName node) { + public void addListener($DDGNodeName node) { fListenerSet.add(node); } - public void removeDependant($DDGNodeName node) { + public void removeListener($DDGNodeName node) { fListenerSet.remove(node); } - public void cleanupDependants() { + public void cleanupListeners() { java.util.Iterator<$DDGNodeName> itr = fListenerSet.iterator(); while (itr.hasNext()) { $DDGNodeName node = itr.next(); @@ -208,7 +208,7 @@ $endif } } - public void clearDependants() { + public void clearListeners() { fListenerSet.clear(); } @@ -220,10 +220,10 @@ $endif return; for ($DDGNodeName l : node.fListenerSet) { if (!l.isGarbage()) { - this.addDependant(l); + this.addListener(l); } } - node.clearDependants(); + node.clearListeners(); node.throwAway(); } @@ -270,7 +270,7 @@ $else java.util.HashSet<$DDGNodeName> k = fDependencySet; fDependencySet = new java.util.HashSet<$DDGNodeName>(4); for ($DDGNodeName node : k) { - node.removeDependant(this); + node.removeListener(this); } $if (IncrementalLevelAttr) fNode.reactToDependencyChange(fAttrID); @@ -525,109 +525,109 @@ $if (IncrementalLevelParam) $endif ]] -# Generate code for cleanup dependants method. -ASTDecl.cleanupDependantsMethod = [[ -private boolean #name.inc_cleanupDependants_visited = false; -public void #name.cleanupDependants() { - if (inc_cleanupDependants_visited) { +# Generate code for cleanup listeners method. +ASTDecl.cleanupListenersMethod = [[ +private boolean #name.inc_cleanupListeners_visited = false; +public void #name.cleanupListeners() { + if (inc_cleanupListeners_visited) { return; } - inc_cleanupDependants_visited = true; + inc_cleanupListeners_visited = true; $if (#isASTNodeDecl) $if (IncrementalLevelParam) - getParent_handler.cleanupDependants(); - numChildren_handler.cleanupDependants(); + getParent_handler.cleanupListeners(); + numChildren_handler.cleanupListeners(); for (int k = 0; getChild_handler != null && k < getChild_handler.length; k++) { if (getChild_handler[k] != null) { - getChild_handler[k].cleanupDependants(); + getChild_handler[k].cleanupListeners(); } } $endif $endif $if (IncrementalLevelRegion) $if (IsRegionRoot) - handler.cleanupDependants(); + handler.cleanupListeners(); $endif $endif - $CleanupTokenDependants - $CleanupAttributeDependants + $CleanupTokenListeners + $CleanupAttributeListeners $if (!#isASTNodeDecl) $if (IncrementalLevelRegion) $if (!IsRegionRoot) - super.cleanupDependants(); + super.cleanupListeners(); $endif $else - super.cleanupDependants(); + super.cleanupListeners(); $endif $endif - inc_cleanupDependants_visited = false; + inc_cleanupListeners_visited = false; } ]] -# Generate code for checking token handler and cleaning up dependants. -ASTDecl.checkAndCleanupTokenDependants = [[ +# Generate code for checking token handler and cleaning up listeners. +ASTDecl.checkAndCleanupTokenListeners = [[ if (get$(Id)_handler != null) { - get$(Id)_handler.cleanupDependants(); + get$(Id)_handler.cleanupListeners(); } ]] -# Generate code for checking attribute handler and cleaning up dependants. -ASTDecl.checkAndCleanupAttributeDependants = [[ +# Generate code for checking attribute handler and cleaning up listeners. +ASTDecl.checkAndCleanupAttributeListeners = [[ $if (IncrementalLevelParam) $if (IsParameterized) for (java.util.Iterator itr = $(AttrSign)_handler.values().iterator(); itr.hasNext();) { $DDGNodeName handler = ($DDGNodeName)itr.next(); - handler.cleanupDependants(); + handler.cleanupListeners(); } $else if ($(AttrSign)_handler != null) { - $(AttrSign)_handler.cleanupDependants(); + $(AttrSign)_handler.cleanupListeners(); } $endif $if (IsNTA) $if (IsParameterized) if ($(AttrSign)_proxy != null) { - $(AttrSign)_proxy.cleanupDependants(); + $(AttrSign)_proxy.cleanupListeners(); } $else if ($(AttrSign)_computed && ($(AttrSign)_value instanceof $ASTNode)) { - $(AttrSign)_value.cleanupDependants(); + $(AttrSign)_value.cleanupListeners(); } $endif $endif $endif ]] -# Generate code for method cleanupDependantsInTree. -ASTDecl.cleanupDependantsInTreeMethod = [[ -private boolean #name.inc_cleanupDependantsInTree_visited = false; -public void #name.cleanupDependantsInTree() { - if (inc_cleanupDependantsInTree_visited) { +# Generate code for method cleanupListenersInTree. +ASTDecl.cleanupListenersInTreeMethod = [[ +private boolean #name.inc_cleanupListenersInTree_visited = false; +public void #name.cleanupListenersInTree() { + if (inc_cleanupListenersInTree_visited) { return; } - inc_cleanupDependantsInTree_visited = true; - cleanupDependants(); + inc_cleanupListenersInTree_visited = true; + cleanupListeners(); for (int i = 0; children != null && i < children.length; i++) { $ASTNode child = children[i]; if (child == null) { continue; } - child.cleanupDependantsInTree(); + child.cleanupListenersInTree(); } - $CleanupDependantsInNTAs - inc_cleanupDependantsInTree_visited = false; + $CleanupListenersInNTAs + inc_cleanupListenersInTree_visited = false; } ]] -# Generate string with code for cleaning up dependants in NTAs. -ASTDecl.checkAndCleanupNTADependants = [[ +# Generate string with code for cleaning up listeners in NTAs. +ASTDecl.checkAndCleanupNTAListeners = [[ $if (IsParameterized) if ($(AttrSign)_proxy != null) { - $(AttrSign)_proxy.cleanupDependantsInTree(); + $(AttrSign)_proxy.cleanupListenersInTree(); } $else if ($(AttrSign)_computed && ($(AttrSign)_value instanceof $ASTNode)) { - $(AttrSign)_value.cleanupDependantsInTree(); + $(AttrSign)_value.cleanupListenersInTree(); } $endif ]] diff --git a/src/template/incremental/Regions.tt b/src/template/incremental/Regions.tt index ffd58ee45efe53885289ab4113dd822dfa01aa0a..09b40aa0b8e392fb83a93b17b8d2c3d23730e3ca 100644 --- a/src/template/incremental/Regions.tt +++ b/src/template/incremental/Regions.tt @@ -90,7 +90,7 @@ ASTDecl.trackGetParentForRegionMethod = [[ public $ASTNode #name.getParent() { $ASTNode parent = super.getParent(); if (state().IN_COMPUTATION > 0 && parent != null) { - parent.handler().addDependant(handler); + parent.handler().addListener(handler); } return parent; } @@ -104,7 +104,7 @@ $if(IsListOrOpt) public T #name.getChild(int i) { $ASTNode child = super.getChild(i); if (state().IN_COMPUTATION > 0 && child.isRegionRoot()) { - child.handler().addDependant(handler()); + child.handler().addListener(handler()); } return (T) child; } @@ -112,7 +112,7 @@ $else public $ASTNode #name.getChild(int i) { $ASTNode child = super.getChild(i); if (state().IN_COMPUTATION > 0 && child.isRegionRoot()) { - child.handler().addDependant(handler()); + child.handler().addListener(handler()); } return child; } @@ -127,7 +127,7 @@ $if(IsListOrOpt) public T #name.getChildNoTransform(int i) { $ASTNode child = super.getChildNoTransform(i); if (state().IN_COMPUTATION > 0 && child.isRegionRoot()) { - child.handler().addDependant(handler()); + child.handler().addListener(handler()); } return (T) child; } @@ -135,7 +135,7 @@ $else public $ASTNode #name.getChildNoTransform(int i) { $ASTNode child = super.getChildNoTransform(i); if (state().IN_COMPUTATION > 0 && child.isRegionRoot()) { - child.handler().addDependant(handler()); + child.handler().addListener(handler()); } return child; } diff --git a/src/template/incremental/State.tt b/src/template/incremental/State.tt index 24913d4f808b0468ea8da3b4396af82b819bccb4..18c6eac3145af20604a010581f6f23e536c0d83d 100644 --- a/src/template/incremental/State.tt +++ b/src/template/incremental/State.tt @@ -50,7 +50,7 @@ $endif if (!handlerStack.isEmpty()) { //throw new Error("Handler stack is empty at addition of dependency!"); $ASTNode$$DepGraphNode top = ($ASTNode$$DepGraphNode) handlerStack.peek(); - handler.addDependant(top); + handler.addListener(top); $if(IncrementalPropLimit) if (!handler.cacheInDependent) diff --git a/src/template/incremental/Tracking.tt b/src/template/incremental/Tracking.tt index 7d6a9dd4dd9132180a753cdcb431c01adc422ea6..cb83738f3158ddf6e860377045ecc89ae850dfd1 100644 --- a/src/template/incremental/Tracking.tt +++ b/src/template/incremental/Tracking.tt @@ -44,7 +44,7 @@ $endif $if (IncrementalLevelRegion) $if (#isRegionRoot) if (state().IN_COMPUTATION > 0 && parent != null) { - parent.handler().addDependant(handler); + parent.handler().addListener(handler); } $endif $endif @@ -266,14 +266,14 @@ $endif $if(IncrementalLevelNode) if (node != null) { this.state().addHandlerDepTo(node.handler); - this.handler.addDependant(node.handler); + this.handler.addListener(node.handler); } $endif $if(IncrementalLevelRegion) if (node != null && node.isRegionRoot()) { - this.handler().addDependant(node.handler()); - node.handler().addDependant(this.handler()); + this.handler().addListener(node.handler()); + node.handler().addListener(this.handler()); } $endif @@ -286,7 +286,7 @@ $if(IncrementalEnabled) $if(IncrementalLevelRegion) $if(#isRegionRoot) if (state().IN_COMPUTATION > 0) { - node.handler().addDependant(handler); + node.handler().addListener(handler); } $endif $endif @@ -321,7 +321,7 @@ $endif $if(IncrementalLevelRegion) $if(#isRegionRoot) if (state().IN_COMPUTATION > 0 && child != null) { - child.handler().addDependant(handler); + child.handler().addListener(handler); } $endif $endif @@ -356,7 +356,7 @@ $endif $if(IncrementalLevelRegion) $if(#isRegionRoot) if (state().IN_COMPUTATION > 0 && child != null) { - child.handler().addDependant(handler); + child.handler().addListener(handler); } $endif $endif @@ -417,7 +417,7 @@ $if(IncrementalLevelRegion) $if(!IsStringToken) $if(!#isPrimitive) if (token$(TypeInSignature)_$(Id) instanceof $ASTNode && token$(TypeInSignature)_$(Id).isRegionRoot()) { - (($ASTNode) token$(TypeInSignature)_$(Id)).handler().addDependant(handler()); + (($ASTNode) token$(TypeInSignature)_$(Id)).handler().addListener(handler()); } $endif $endif @@ -506,7 +506,7 @@ $if(#getNTA) // Creating a dummy handler to collect dependencies $DDGNodeName newHandler = new $DDGNodeName(this); // Adding dependency to this region because it may be read during the computation -handler.addDependant(newHandler); +handler.addListener(newHandler); state().enterAttrStoreEval(newHandler); $else $DDGNodeName tmpHandler = new $DDGNodeName(this); @@ -543,7 +543,7 @@ $if(#getNTA) // Creating a dummy handler to collect dependencies $DDGNodeName newHandler = new $DDGNodeName(this); // Adding dep. to this region because it may be read during the computation -handler.addDependant(newHandler); +handler.addListener(newHandler); state().enterAttrStoreEval(newHandler); $else state().enterAttrStoreEval(handler); @@ -592,8 +592,8 @@ state().IN_COMPUTATION--; $if(#getNTA) if (#(signature)_value != null && #(signature)_value.isRegionRoot()) { $DDGNodeName nodeHandler = handler(); - nodeHandler.addDependant(#(signature)_value.handler()); - #(signature)_value.handler().addDependant(nodeHandler); + nodeHandler.addListener(#(signature)_value.handler()); + #(signature)_value.handler().addListener(nodeHandler); } $endif $endif @@ -634,8 +634,8 @@ state().IN_COMPUTATION--; $if(#getNTA) if (#(signature)_value.isRegionRoot()) { $DDGNodeName nodeHandler = handler(); - nodeHandler.addDependant(#(signature)_value.handler()); - #(signature)_value.handler().addDependant(nodeHandler); + nodeHandler.addListener(#(signature)_value.handler()); + #(signature)_value.handler().addListener(nodeHandler); } $endif $endif