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
Branches
Tags
No related merge requests found
......@@ -60,6 +60,10 @@ aspect IncrementalDDG {
if (name().equals(config().astNodeType())) {
tt.expand("ASTDecl.createASTHandlers", out);
}
// Rewrite attribute.
if (hasRewriteAttribute()) {
tt.expand("ASTDecl.createRewriteAttributeHandler", out);
}
// Collect attributes.
ArrayList list = new ArrayList();
for (AttrDecl attr : synDecls()) {
......
......@@ -32,10 +32,11 @@
TemplateContext tt = templateContext();
tt.expand("ASTNode.incFlushRewritesLocateEnclosingRewriteMethod", out);
tt.expand("ASTNode.incResetRewritesMethod", out);
tt.expand("ASTNode.incRestoreEnclosingRewriteMethod", out);
tt.expand("ASTNode.incRestoreInitialForIndexMethod", out);
// tt.expand("ASTNode.incFlushRewritesLocateEnclosingRewriteMethod", out);
// tt.expand("ASTNode.incResetRewritesMethod", out);
// tt.expand("ASTNode.incRestoreEnclosingRewriteMethod", out);
// tt.expand("ASTNode.incRestoreInitialForIndexMethod", out);
tt.expand("ASTNode.incLocateInitialCopyMethod", out);
tt.bind("AttrAffectedChecks", emitAttrAffectedChecksString());
......
......@@ -42,8 +42,6 @@ $if(IncrementalEnabled)
for (int i = 0; node.children != null && i < node.children.length; i++) {
node.children[i] = null;
}
node.init_children = null;
node.children_computed = null;
inc_copyHandlers(node);
$endif
$if(Concurrent)
......
......@@ -79,7 +79,6 @@ OptDecl.constructor = [[
ListDecl.constructor = [[
public $List.$List(T... initialChildren) {
children = new $ASTNode[initialChildren.length];
#genIncrementalInitChildHandlers
for (int i = 0; i < children.length; ++i) {
addChild(initialChildren[i]);
}
......
......@@ -499,6 +499,11 @@ ASTDecl.createNodeHandler = [[
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
ASTDecl.createAttributeHandler = [[
$if (IncrementalLevelParam)
......
......@@ -117,15 +117,6 @@ $endif
# Generate code for method dumping cached values
ASTDecl.dumpCachedValuesMethod = [[
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
// TODO: dump collection values
$if (!#isASTNodeDecl)
......
......@@ -181,34 +181,6 @@ $if(IncrementalChangeFlush)
// flush children
$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
$if(IncrementalLevelAttr)
......
......@@ -212,6 +212,8 @@ $if(IncrementalEnabled)
$if(#isASTNodeDecl)
/** @apilevel internal */
protected $ASTNode $ASTNode.inc_locateInitialCopy() {
//TODO(emso): fix this method to work with CNTAs.
if (true) return null;
// locate enclosing rewrite
$ASTNode child = this;
$ASTNode parent = getParent();
......@@ -219,9 +221,9 @@ $if(#isASTNodeDecl)
while (parent != null) {
int index = child.childIndex;
indexList.addFirst(Integer.valueOf(index));
if (parent.init_children != null && index >= 0 && index < parent.init_children.length && parent.init_children[index] != null) {
break;
}
//if (parent.init_children != null && index >= 0 && index < parent.init_children.length && parent.init_children[index] != null) {
// break;
//}
child = parent;
parent = child.getParent();
}
......@@ -235,7 +237,7 @@ $if(#isASTNodeDecl)
int index = ((Integer)itr.next()).intValue();
if (first) {
first = false;
child = parent.init_children[index];
//child = parent.init_children[index];
parent = child;
} else if (index < parent.getNumChildNoTransform()) {
child = parent.getChildNoTransform(index);
......
......@@ -277,9 +277,6 @@ $if(#isASTNodeDecl)
if (child != null) {
child.inc_throwAway();
}
if (init_children != null && i < init_children.length && init_children[i] != null) {
init_children[i].inc_throwAway();
}
}
$endif
$if(IncrementalLevelAttr)
......@@ -291,9 +288,6 @@ $if(#isASTNodeDecl)
if (child != null) {
child.inc_throwAway();
}
if (init_children != null && i < init_children.length && init_children[i] != null) {
init_children[i].inc_throwAway();
}
}
$endif
$if(IncrementalLevelNode)
......@@ -303,9 +297,6 @@ $if(#isASTNodeDecl)
if (child != null) {
child.inc_throwAway();
}
if (init_children != null && i < init_children.length && init_children[i] != null) {
init_children[i].inc_throwAway();
}
}
$endif
$if(IncrementalLevelRegion)
......@@ -317,9 +308,6 @@ $if(#isASTNodeDecl)
if (child != null) {
child.inc_throwAway();
}
if (init_children != null && i < init_children.length && init_children[i] != null) {
init_children[i].inc_throwAway();
}
}
$endif
$else
......
......@@ -119,6 +119,7 @@ $endif
$endif
]]
ASTNode.incHookGetChild1 = [[
$if(IncrementalEnabled)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment