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

Add tracing of token reads

parent ad2fb7c6
Branches
No related tags found
No related merge requests found
......@@ -250,6 +250,7 @@ public class Configuration {
.addAcceptedValue("copy", "trace node copy operations")
.addAcceptedValue("flush", "trace flush operations")
.addAcceptedValue("coll", "trace collection attribute contributions")
.addAcceptedValue("token", "trace token reads")
.additionalDescription("All events are collected by default.\n"
+ "Listen to events by calling ASTState.Trace.setReceiver()");
......@@ -536,6 +537,7 @@ public class Configuration {
tt.bind("TraceCopy", traceCopy());
tt.bind("TraceFlush", traceFlush());
tt.bind("TraceColl", traceColl());
tt.bind("TraceToken", traceToken());
// Set template variables to accommodate deprecated options
// (the deprecated options may alter the value of the template variable).
......@@ -831,6 +833,13 @@ public class Configuration {
return traceAll() || tracingOption.hasValue("coll");
}
/**
* @return {@code true} if token reads should be traced
*/
public boolean traceToken() {
return traceAll() || tracingOption.hasValue("token");
}
/**
* @return ASTNode type name
......
......@@ -88,6 +88,7 @@ $if(!#isNTA)
*/
$include(TokenComponent.generatedAnnotations)
$Modifier $Type $Host.get$Id() {
$include(TokenComponent.traceTokenRead)
$include(TokenComponent.incHookGetToken)
return token$(TypeInSignature)_$Id != null ? token$(TypeInSignature)_$Id : "";
}
......@@ -99,6 +100,7 @@ $if(!#isNTA)
*/
$include(TokenComponent.generatedAnnotations)
$Modifier $Type $Host.get$Id() {
$include(TokenComponent.traceTokenRead)
$include(TokenComponent.incHookGetToken)
return token$(TypeInSignature)_$Id;
}
......
......@@ -344,3 +344,9 @@ state().trace().contributionCheckMatch(this, "#collectionId", "#escapeConditionF
$endif
$endif
]]
TokenComponent.traceTokenRead [[
$if (TraceToken)
state().trace().tokenRead(this, "$Id", token$(TypeInSignature)_$Id);
$endif
]]
......@@ -84,7 +84,10 @@ public static class Trace {
// Flag: --tracing=coll
CONTRIBUTION_CHECK_BEGIN,
CONTRIBUTION_CHECK_MATCH,
CONTRIBUTION_CHECK_END;
CONTRIBUTION_CHECK_END,
// Flag: --tracing=token
TOKEN_READ;
}
/**
......@@ -359,6 +362,13 @@ public static class Trace {
receiver.accept($StateClass.Trace.Event.CONTRIBUTION_CHECK_MATCH, node, attr, check, value);
}
/**
* Trace that a token was read.
*/
public void tokenRead($ASTNode node, String token, Object value) {
receiver.accept($StateClass.Trace.Event.TOKEN_READ, node, token, "", value);
}
}
$endif
]]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment