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

Merged in feature-trace-coll (pull request #12)


Add tracing option coll

Approved-by: default avatarJesper Öqvist <jesper.oqvist@cs.lth.se>
parents 8abc63ad f35c7020
Branches
No related tags found
No related merge requests found
...@@ -249,6 +249,7 @@ public class Configuration { ...@@ -249,6 +249,7 @@ public class Configuration {
.addAcceptedValue("circularNTA", "trace circular attribute evaluation") .addAcceptedValue("circularNTA", "trace circular attribute evaluation")
.addAcceptedValue("copy", "trace node copy operations") .addAcceptedValue("copy", "trace node copy operations")
.addAcceptedValue("flush", "trace flush operations") .addAcceptedValue("flush", "trace flush operations")
.addAcceptedValue("coll", "trace collection attribute contributions")
.additionalDescription("All events are collected by default.\n" .additionalDescription("All events are collected by default.\n"
+ "Listen to events by calling ASTState.Trace.setReceiver()"); + "Listen to events by calling ASTState.Trace.setReceiver()");
...@@ -534,6 +535,7 @@ public class Configuration { ...@@ -534,6 +535,7 @@ public class Configuration {
tt.bind("TraceCircular", traceCircular()); tt.bind("TraceCircular", traceCircular());
tt.bind("TraceCopy", traceCopy()); tt.bind("TraceCopy", traceCopy());
tt.bind("TraceFlush", traceFlush()); tt.bind("TraceFlush", traceFlush());
tt.bind("TraceColl", traceColl());
// Set template variables to accommodate deprecated options // Set template variables to accommodate deprecated options
// (the deprecated options may alter the value of the template variable). // (the deprecated options may alter the value of the template variable).
...@@ -822,6 +824,14 @@ public class Configuration { ...@@ -822,6 +824,14 @@ public class Configuration {
return traceAll() || tracingOption.hasValue("flush"); return traceAll() || tracingOption.hasValue("flush");
} }
/**
* @return {@code true} if collection attributes should be traced
*/
public boolean traceColl() {
return traceAll() || tracingOption.hasValue("coll");
}
/** /**
* @return ASTNode type name * @return ASTNode type name
*/ */
......
...@@ -234,6 +234,7 @@ $endif ...@@ -234,6 +234,7 @@ $endif
]] ]]
CollEq.contributeStatement [[ CollEq.contributeStatement [[
$include(CollEq.traceContributionBegin)
$if(#hasCondition) $if(#hasCondition)
if (#getCondition) { if (#getCondition) {
$include(CollEq.addValueToCollection) $include(CollEq.addValueToCollection)
...@@ -241,6 +242,7 @@ $if(#hasCondition) ...@@ -241,6 +242,7 @@ $if(#hasCondition)
$else $else
$include(CollEq.addValueToCollection) $include(CollEq.addValueToCollection)
$endif $endif
$include(CollEq.traceContributionEnd)
]] ]]
CollEq.addValueToCollection [[ CollEq.addValueToCollection [[
......
...@@ -322,3 +322,15 @@ state().trace().flushAttr(this, "#hostClassName.#signatureJavaStyle", "", #(sign ...@@ -322,3 +322,15 @@ state().trace().flushAttr(this, "#hostClassName.#signatureJavaStyle", "", #(sign
$endif $endif
$endif $endif
]] ]]
CollEq.traceContributionBegin [[
$if (TraceColl)
state().trace().contributionBegin(this, "#collectionId");
$endif
]]
CollEq.traceContributionEnd [[
$if (TraceColl)
state().trace().contributionEnd(this, "#collectionId");
$endif
]]
...@@ -79,7 +79,11 @@ public static class Trace { ...@@ -79,7 +79,11 @@ public static class Trace {
FLUSH_ATTR, FLUSH_ATTR,
FLUSH_REWRITE, FLUSH_REWRITE,
FLUSH_REWRITE_INIT, FLUSH_REWRITE_INIT,
INC_FLUSH_ATTR; INC_FLUSH_ATTR,
// Flag: --tracing=coll
CONTRIBUTION_BEGIN,
CONTRIBUTION_END;
} }
/** /**
...@@ -332,6 +336,20 @@ public static class Trace { ...@@ -332,6 +336,20 @@ public static class Trace {
public void flushIncAttr($ASTNode node, String attr, Object params, Object value) { public void flushIncAttr($ASTNode node, String attr, Object params, Object value) {
receiver.accept($StateClass.Trace.Event.INC_FLUSH_ATTR, node, attr, params, value); receiver.accept($StateClass.Trace.Event.INC_FLUSH_ATTR, node, attr, params, value);
} }
/**
* Trace that a contribution to a collection attribute begun.
*/
public void contributionBegin($ASTNode node, String attr) {
receiver.accept($StateClass.Trace.Event.CONTRIBUTION_BEGIN, node, attr, "", "");
}
/**
* Trace that a contribution to a collection attribute ended.
*/
public void contributionEnd($ASTNode node, String attr) {
receiver.accept($StateClass.Trace.Event.CONTRIBUTION_END, node, attr, "", "");
}
} }
$endif $endif
]] ]]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment