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

Initial trace changes

parent 8abc63ad
No related branches found
No related tags found
No related merge requests found
......@@ -249,6 +249,7 @@ public class Configuration {
.addAcceptedValue("circularNTA", "trace circular attribute evaluation")
.addAcceptedValue("copy", "trace node copy operations")
.addAcceptedValue("flush", "trace flush operations")
.addAcceptedValue("coll", "trace collection attribute contributions")
.additionalDescription("All events are collected by default.\n"
+ "Listen to events by calling ASTState.Trace.setReceiver()");
......@@ -534,6 +535,7 @@ public class Configuration {
tt.bind("TraceCircular", traceCircular());
tt.bind("TraceCopy", traceCopy());
tt.bind("TraceFlush", traceFlush());
tt.bind("TraceColl", traceColl());
// Set template variables to accommodate deprecated options
// (the deprecated options may alter the value of the template variable).
......@@ -822,6 +824,14 @@ public class Configuration {
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
*/
......
......@@ -234,6 +234,7 @@ $endif
]]
CollEq.contributeStatement [[
$include(CollEq.traceContributionBegin)
$if(#hasCondition)
if (#getCondition) {
$include(CollEq.addValueToCollection)
......@@ -241,6 +242,7 @@ $if(#hasCondition)
$else
$include(CollEq.addValueToCollection)
$endif
$include(CollEq.traceContributionEnd)
]]
CollEq.addValueToCollection [[
......
......@@ -322,3 +322,15 @@ state().trace().flushAttr(this, "#hostClassName.#signatureJavaStyle", "", #(sign
$endif
$endif
]]
CollEq.traceContributionBegin [[
$if (TraceColl)
state().trace.contributionBegin(this, "#hostClassName.#signatureJavaStyle", "", "");
$endif
]]
CollEq.traceContributionEnd [[
$if (TraceColl)
state().trace.contributionEnd(this, "#hostClassName.#signatureJavaStyle", "", "");
$endif
]]
......@@ -80,6 +80,10 @@ public static class Trace {
FLUSH_REWRITE,
FLUSH_REWRITE_INIT,
INC_FLUSH_ATTR;
// Flag: --tracing=coll
CONTRIBUTION_BEGIN,
CONTRIBUTION_END,
}
/**
......@@ -332,6 +336,20 @@ public static class Trace {
public void flushIncAttr($ASTNode node, String attr, Object params, Object 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, "", value);
}
/**
* 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, "", value);
}
}
$endif
]]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment