Skip to content
Snippets Groups Projects
Commit ffae1863 authored by Emma Söderberg's avatar Emma Söderberg
Browse files

Updates the incremental/param code generation.

- Adjusting to work with CNTAs.
- Removes use of init_children and children_computed.
- Some issues remaining but incremental/param tests now compile.

Tested successfully with jastadd-test and default tests that should pass.
parent 74c24137
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,10 @@ aspect IncrementalDDG { ...@@ -60,6 +60,10 @@ aspect IncrementalDDG {
if (name().equals(config().astNodeType())) { if (name().equals(config().astNodeType())) {
tt.expand("ASTDecl.createASTHandlers", out); tt.expand("ASTDecl.createASTHandlers", out);
} }
// Rewrite attribute.
if (hasRewriteAttribute()) {
tt.expand("ASTDecl.createRewriteAttributeHandler", out);
}
// Collect attributes. // Collect attributes.
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
for (AttrDecl attr : synDecls()) { for (AttrDecl attr : synDecls()) {
......
...@@ -32,10 +32,11 @@ ...@@ -32,10 +32,11 @@
TemplateContext tt = templateContext(); TemplateContext tt = templateContext();
tt.expand("ASTNode.incFlushRewritesLocateEnclosingRewriteMethod", out); // tt.expand("ASTNode.incFlushRewritesLocateEnclosingRewriteMethod", out);
tt.expand("ASTNode.incResetRewritesMethod", out); // tt.expand("ASTNode.incResetRewritesMethod", out);
tt.expand("ASTNode.incRestoreEnclosingRewriteMethod", out); // tt.expand("ASTNode.incRestoreEnclosingRewriteMethod", out);
tt.expand("ASTNode.incRestoreInitialForIndexMethod", out); // tt.expand("ASTNode.incRestoreInitialForIndexMethod", out);
tt.expand("ASTNode.incLocateInitialCopyMethod", out); tt.expand("ASTNode.incLocateInitialCopyMethod", out);
tt.bind("AttrAffectedChecks", emitAttrAffectedChecksString()); tt.bind("AttrAffectedChecks", emitAttrAffectedChecksString());
......
...@@ -42,8 +42,6 @@ $if(IncrementalEnabled) ...@@ -42,8 +42,6 @@ $if(IncrementalEnabled)
for (int i = 0; node.children != null && i < node.children.length; i++) { for (int i = 0; node.children != null && i < node.children.length; i++) {
node.children[i] = null; node.children[i] = null;
} }
node.init_children = null;
node.children_computed = null;
inc_copyHandlers(node); inc_copyHandlers(node);
$endif $endif
$if(Concurrent) $if(Concurrent)
......
...@@ -79,7 +79,6 @@ OptDecl.constructor = [[ ...@@ -79,7 +79,6 @@ OptDecl.constructor = [[
ListDecl.constructor = [[ ListDecl.constructor = [[
public $List.$List(T... initialChildren) { public $List.$List(T... initialChildren) {
children = new $ASTNode[initialChildren.length]; children = new $ASTNode[initialChildren.length];
#genIncrementalInitChildHandlers
for (int i = 0; i < children.length; ++i) { for (int i = 0; i < children.length; ++i) {
addChild(initialChildren[i]); addChild(initialChildren[i]);
} }
......
...@@ -499,6 +499,11 @@ ASTDecl.createNodeHandler = [[ ...@@ -499,6 +499,11 @@ ASTDecl.createNodeHandler = [[
protected $DDGNodeName #name.handler = new $DDGNodeName(this); protected $DDGNodeName #name.handler = new $DDGNodeName(this);
]] ]]
# Create DDG node for rewrite attribute.
ASTDecl.createRewriteAttributeHandler = [[
protected $DDGNodeName #name.rewrittenNode_handler;
]]
# Create DDG node for attribute # Create DDG node for attribute
ASTDecl.createAttributeHandler = [[ ASTDecl.createAttributeHandler = [[
$if (IncrementalLevelParam) $if (IncrementalLevelParam)
......
...@@ -117,15 +117,6 @@ $endif ...@@ -117,15 +117,6 @@ $endif
# Generate code for method dumping cached values # Generate code for method dumping cached values
ASTDecl.dumpCachedValuesMethod = [[ ASTDecl.dumpCachedValuesMethod = [[
public void #name.dumpCachedValues() { public void #name.dumpCachedValues() {
$if (#isASTNodeDecl)
// Rewritten children
for (int k = 0; children_computed != null && k < children_computed.length; k++) {
if (children_computed[k]) {
System.out.println(children[k].relativeNodeID() + " rewritten, initial=" +
(init_children[k] != null ? init_children[k].relativeNodeID() : null));
}
}
$endif
$DumpAttributeValues $DumpAttributeValues
// TODO: dump collection values // TODO: dump collection values
$if (!#isASTNodeDecl) $if (!#isASTNodeDecl)
......
...@@ -181,34 +181,6 @@ $if(IncrementalChangeFlush) ...@@ -181,34 +181,6 @@ $if(IncrementalChangeFlush)
// flush children // flush children
$if(IncrementalLevelParam) $if(IncrementalLevelParam)
$if(#isASTNodeDecl)
if (attrID.equals("getChild")) {
int i = (Integer)_parameters;
if (children_computed != null && i < children_computed.length && children_computed[i]) {
// Make sure this condition is false before calling notify.
// There may be a circular dependency resulting in a double flush otherwise.
// A double flush will cause null to be moved in as the initial child.
children_computed[i] = false;
children[i].inc_resetRewrites();
// outer rewrites
if (init_children[i] != null) {
// set up change
$ASTNode oldChild = children[i];
$ASTNode newChild = init_children[i];
// make change
oldChild.inc_flush_subtree(getChild_handler[i]);
children[i] = newChild;
init_children[i] = null;
// set parent and notify
newChild.setParent(this);
getChild_handler[i].notifyDependencies();
} else {
// inner rewrites
inc_restoreEnclosingRewrite();
}
}
}
$endif
$endif $endif
$if(IncrementalLevelAttr) $if(IncrementalLevelAttr)
......
...@@ -212,6 +212,8 @@ $if(IncrementalEnabled) ...@@ -212,6 +212,8 @@ $if(IncrementalEnabled)
$if(#isASTNodeDecl) $if(#isASTNodeDecl)
/** @apilevel internal */ /** @apilevel internal */
protected $ASTNode $ASTNode.inc_locateInitialCopy() { protected $ASTNode $ASTNode.inc_locateInitialCopy() {
//TODO(emso): fix this method to work with CNTAs.
if (true) return null;
// locate enclosing rewrite // locate enclosing rewrite
$ASTNode child = this; $ASTNode child = this;
$ASTNode parent = getParent(); $ASTNode parent = getParent();
...@@ -219,9 +221,9 @@ $if(#isASTNodeDecl) ...@@ -219,9 +221,9 @@ $if(#isASTNodeDecl)
while (parent != null) { while (parent != null) {
int index = child.childIndex; int index = child.childIndex;
indexList.addFirst(Integer.valueOf(index)); indexList.addFirst(Integer.valueOf(index));
if (parent.init_children != null && index >= 0 && index < parent.init_children.length && parent.init_children[index] != null) { //if (parent.init_children != null && index >= 0 && index < parent.init_children.length && parent.init_children[index] != null) {
break; // break;
} //}
child = parent; child = parent;
parent = child.getParent(); parent = child.getParent();
} }
...@@ -235,7 +237,7 @@ $if(#isASTNodeDecl) ...@@ -235,7 +237,7 @@ $if(#isASTNodeDecl)
int index = ((Integer)itr.next()).intValue(); int index = ((Integer)itr.next()).intValue();
if (first) { if (first) {
first = false; first = false;
child = parent.init_children[index]; //child = parent.init_children[index];
parent = child; parent = child;
} else if (index < parent.getNumChildNoTransform()) { } else if (index < parent.getNumChildNoTransform()) {
child = parent.getChildNoTransform(index); child = parent.getChildNoTransform(index);
......
...@@ -277,9 +277,6 @@ $if(#isASTNodeDecl) ...@@ -277,9 +277,6 @@ $if(#isASTNodeDecl)
if (child != null) { if (child != null) {
child.inc_throwAway(); child.inc_throwAway();
} }
if (init_children != null && i < init_children.length && init_children[i] != null) {
init_children[i].inc_throwAway();
}
} }
$endif $endif
$if(IncrementalLevelAttr) $if(IncrementalLevelAttr)
...@@ -291,9 +288,6 @@ $if(#isASTNodeDecl) ...@@ -291,9 +288,6 @@ $if(#isASTNodeDecl)
if (child != null) { if (child != null) {
child.inc_throwAway(); child.inc_throwAway();
} }
if (init_children != null && i < init_children.length && init_children[i] != null) {
init_children[i].inc_throwAway();
}
} }
$endif $endif
$if(IncrementalLevelNode) $if(IncrementalLevelNode)
...@@ -303,9 +297,6 @@ $if(#isASTNodeDecl) ...@@ -303,9 +297,6 @@ $if(#isASTNodeDecl)
if (child != null) { if (child != null) {
child.inc_throwAway(); child.inc_throwAway();
} }
if (init_children != null && i < init_children.length && init_children[i] != null) {
init_children[i].inc_throwAway();
}
} }
$endif $endif
$if(IncrementalLevelRegion) $if(IncrementalLevelRegion)
...@@ -317,9 +308,6 @@ $if(#isASTNodeDecl) ...@@ -317,9 +308,6 @@ $if(#isASTNodeDecl)
if (child != null) { if (child != null) {
child.inc_throwAway(); child.inc_throwAway();
} }
if (init_children != null && i < init_children.length && init_children[i] != null) {
init_children[i].inc_throwAway();
}
} }
$endif $endif
$else $else
......
...@@ -119,6 +119,7 @@ $endif ...@@ -119,6 +119,7 @@ $endif
$endif $endif
]] ]]
ASTNode.incHookGetChild1 = [[ ASTNode.incHookGetChild1 = [[
$if(IncrementalEnabled) $if(IncrementalEnabled)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment