Skip to content
Snippets Groups Projects
Commit 2128ff87 authored by Jesper's avatar Jesper
Browse files

Refactor cache dump template

Removed unnecessary variables by moving template from context ASTDecl to
AttrDecl.
parent 9a65594c
No related branches found
No related tags found
No related merge requests found
...@@ -115,14 +115,10 @@ aspect IncrementalDebug { ...@@ -115,14 +115,10 @@ aspect IncrementalDebug {
*/ */
public String ASTDecl.genDumpAttributeValuesString() { public String ASTDecl.genDumpAttributeValuesString() {
StringBuffer res = new StringBuffer(); StringBuffer res = new StringBuffer();
TemplateContext tt = templateContext();
for (AttrDecl attr : listOfCachedAttributes()) { for (AttrDecl attr : listOfCachedAttributes()) {
// TODO(joqvist): use AttrDecl as template context instead. TemplateContext tt = attr.templateContext();
tt.bind("IsParameterized", attr.getNumParameter() > 0);
tt.bind("SimpleCacheCheck", attr.simpleCacheCheck());
tt.bind("PrintAsObject", attr.isPrimitive() || attr.getType().equals("String")); tt.bind("PrintAsObject", attr.isPrimitive() || attr.getType().equals("String"));
tt.bind("AttrSign", attr.signature()); res.append(tt.expand("AttrDecl.dumpCachedAttributeValue"));
res.append(tt.expand("ASTDecl.dumpCachedAttributeValue"));
} }
return res.toString(); return res.toString();
} }
......
...@@ -126,29 +126,29 @@ $endif ...@@ -126,29 +126,29 @@ $endif
]] ]]
# Generate code for dumping a cached attribute value # Generate code for dumping a cached attribute value
ASTDecl.dumpCachedAttributeValue = [[ AttrDecl.dumpCachedAttributeValue = [[
$if (IsParameterized) $if (#isParameterized)
if ($(AttrSign)_values != null) { if (#(signature)_values != null) {
for (java.util.Iterator itr = $(AttrSign)_values.keySet().iterator();itr.hasNext();) { for (java.util.Iterator itr = #(signature)_values.keySet().iterator();itr.hasNext();) {
Object key = (Object)itr.next(); Object key = (Object)itr.next();
Object value = $(AttrSign)_values.get(key); Object value = #(signature)_values.get(key);
System.out.println("value(" + relativeNodeID() + ":$(AttrSign)[" + System.out.println("value(" + relativeNodeID() + ":#(signature)[" +
(key instanceof $ASTNode ? (($ASTNode) key).relativeNodeID() : (key instanceof $ASTNode ? (($ASTNode) key).relativeNodeID() :
(key instanceof java.util.List ? printParamList((java.util.List)key) : key) ) + "], " + (key instanceof java.util.List ? printParamList((java.util.List)key) : key) ) + "], " +
(value instanceof $ASTNode ? (($ASTNode) value).relativeNodeID() : printValue(value)) + ")"); (value instanceof $ASTNode ? (($ASTNode) value).relativeNodeID() : printValue(value)) + ")");
} }
} }
$else $else
$if (SimpleCacheCheck) $if (#simpleCacheCheck)
if ($(AttrSign)_computed) { if (#(signature)_computed) {
$else $else
if ($(AttrSign)_computed == $StateClass.NON_CYCLE || $(AttrSign)_computed == state().cycle()) { if (#(signature)_computed == $StateClass.NON_CYCLE || #(signature)_computed == state().cycle()) {
$endif $endif
$if (PrintAsObject) $if (PrintAsObject)
System.out.println("value(" + relativeNodeID() + ":$(AttrSign), " + $(AttrSign)_value + ")"); System.out.println("value(" + relativeNodeID() + ":#(signature), " + #(signature)_value + ")");
$else $else
Object obj = $(AttrSign)_value; Object obj = #(signature)_value;
System.out.println("value(" + relativeNodeID() + ":$(AttrSign), " + System.out.println("value(" + relativeNodeID() + ":#(signature), " +
(obj instanceof $ASTNode ? (($ASTNode) obj).relativeNodeID() : obj) + ")"); (obj instanceof $ASTNode ? (($ASTNode) obj).relativeNodeID() : obj) + ")");
$endif $endif
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment