template.trace.TraceHooks.tt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jastadd Show documentation
Show all versions of jastadd Show documentation
A metacompilation framework for Java using attribute grammars.
# Copyright (c) 2013-2015, The JastAdd Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the Lund University nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
ASTNode.nodeToStringMethod [[
$if (TracingEnabled)
public static String $ASTNode.nodeToString(Object node) {
return (node != null ? node.getClass().getSimpleName() : "null");
}
$endif
]]
AttrDecl.traceComputeBegin [[
$if (TraceCompute)
$if(#isParameterized)
$if(#isCircular)
state().trace().computeBegin(this, "#hostClassName.#signatureJavaStyle", _parameters, "");
$else
$if(!#isMemoized)
$if(!VisitCheckEnabled)
$if(#hasOneParameter)
Object _parameters = #parameters;
$else
Object _parameters = java.util.Arrays.asList(#parameters);
$endif
$endif
$endif
state().trace().computeBegin(this, "#hostClassName.#signatureJavaStyle", _parameters, "");
$endif
$else
state().trace().computeBegin(this, "#hostClassName.#signatureJavaStyle", "", "");
$endif
$endif
]]
AttrDecl.traceComputeEnd [[
$if (TraceCompute)
$if(#isParameterized)
$if(#isCircular)
state().trace().computeEnd(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().computeEnd(this, "#hostClassName.#signatureJavaStyle", _parameters, #(signature)_value);
$endif
$else
state().trace().computeEnd(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$endif
]]
AttrDecl.traceComputeEndInline [[
$if (TraceCompute)
$if(#isParameterized)
state().trace().computeEnd(this, "#hostClassName.#signatureJavaStyle", _parameters, "");
$else
state().trace().computeEnd(this, "#hostClassName.#signatureJavaStyle", "", "");
$endif
$endif
]]
AttrDecl.traceCacheRead [[
$if (TraceCache)
$if(#isMemoized)
$if(#isParameterized)
$if(#isCircular)
state().trace().cacheRead(this, "#hostClassName.#signatureJavaStyle", _parameters, _cache);
$else
state().trace().cacheRead(this, "#hostClassName.#signatureJavaStyle", _parameters, #(signature)_values.get(_parameters));
$endif
$else
state().trace().cacheRead(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$endif
$endif
]]
AttrDecl.traceCacheStore [[
$if (TraceCache)
$if(#isMemoized)
$if(#isParameterized)
$if(#isCircular)
state().trace().cacheWrite(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().cacheWrite(this, "#hostClassName.#signatureJavaStyle", _parameters, #(signature)_value);
$endif
$else
state().trace().cacheWrite(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$endif
$endif
]]
AttrDecl.traceCacheAbort [[
$if (TraceCache)
$if(#isMemoized)
$if(#isParameterized)
$if(#isCircular)
state().trace().cacheAbort(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().cacheAbort(this, "#hostClassName.#signatureJavaStyle", _parameters, #(signature)_value);
$endif
$else
state().trace().cacheAbort(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$endif
$endif
]]
AttrDecl.traceCircularEnterCase1 [[
$if (TraceCircular)
$if(#getNTA)
$if(#isParameterized)
state().trace().enterCircularNTACase1(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().enterCircularNTACase1(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$else
$if(#isParameterized)
state().trace().enterCircularCase1(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().enterCircularCase1(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$endif
$endif
]]
AttrDecl.traceCircularCase1Change [[
$if (TraceCircular)
$if(#getNTA)
$if(#isParameterized)
state().trace().circularNTACase1Change(this, "#hostClassName.#signatureJavaStyle", _parameters,
_value.value + "->" + new_#(signature)_value);
$else
state().trace().circularNTACase1Change(this, "#hostClassName.#signatureJavaStyle", "",
#(signature)_value + "->" + new_#(signature)_value);
$endif
$else
$if(#isParameterized)
state().trace().circularCase1Change(this, "#hostClassName.#signatureJavaStyle", _parameters,
_value.value + "->" + new_#(signature)_value);
$else
state().trace().circularCase1Change(this, "#hostClassName.#signatureJavaStyle", "",
#(signature)_value + "->" + new_#(signature)_value);
$endif
$endif
$endif
]]
AttrDecl.traceCircularExitCase1 [[
$if (TraceCircular)
$if(#getNTA)
$if(#isParameterized)
state().trace().exitCircularNTACase1(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().exitCircularNTACase1(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$else
$if(#isParameterized)
state().trace().exitCircularCase1(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().exitCircularCase1(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$endif
$endif
]]
AttrDecl.traceCircularEnterCase2 [[
$if (TraceCircular)
$if(#getNTA)
$if(#isParameterized)
state().trace().enterCircularNTACase2(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().enterCircularNTACase2(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$else
$if(#isParameterized)
state().trace().enterCircularCase2(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().enterCircularCase2(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$endif
$endif
]]
AttrDecl.traceCircularCase2Change [[
$if (TraceCircular)
$if(#getNTA)
$if(#isParameterized)
state().trace().circularNTACase2Change(this, "#hostClassName.#signatureJavaStyle", _parameters,
_value.value + "->" + new_#(signature)_value);
$else
state().trace().circularNTACase2Change(this, "#hostClassName.#signatureJavaStyle", "",
#(signature)_value + "->" + new_#(signature)_value);
$endif
$else
$if(#isParameterized)
state().trace().circularCase2Change(this, "#hostClassName.#signatureJavaStyle", _parameters,
_value.value + "->" + new_#(signature)_value);
$else
state().trace().circularCase2Change(this, "#hostClassName.#signatureJavaStyle", "",
#(signature)_value + "->" + new_#(signature)_value);
$endif
$endif
$endif
]]
AttrDecl.traceCircularExitCase2 [[
$if (TraceCircular)
$if(#getNTA)
$if(#isParameterized)
state().trace().exitCircularNTACase2(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().exitCircularNTACase2(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$else
$if(#isParameterized)
state().trace().exitCircularCase2(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().exitCircularCase2(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$endif
$endif
]]
AttrDecl.traceCircularExitCase3 [[
$if (TraceCircular)
$if(#getNTA)
$if(#isParameterized)
state().trace().exitCircularNTACase3(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().exitCircularNTACase3(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$else
$if(#isParameterized)
state().trace().exitCircularCase3(this, "#hostClassName.#signatureJavaStyle", _parameters, _value.value);
$else
state().trace().exitCircularCase3(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$endif
$endif
]]
ASTNode.traceRewriteEnterCase1 [[
$if (TraceRewrite)
state().trace().enterRewriteCase1(this, "ASTNode.getChild", i, nodeToString(node));
$endif
]]
ASTNode.traceRewriteChange [[
$if (TraceRewrite)
if (this.state().peek() == $StateClass.REWRITE_CHANGE) {
state().trace().rewriteChange(this, "ASTNode.getChild", i,
nodeToString(oldNode) + "->" + nodeToString(node));
}
$endif
]]
ASTNode.traceRewriteCached [[
$if (TraceRewrite)
state().trace().cacheWrite(this, "ASTNode.getChild", i, nodeToString(node));
$endif
]]
ASTNode.traceRewriteCacheAbort [[
$if (TraceRewrite)
state().trace().cacheAbort(this, "ASTNode.getChild", i, nodeToString(node));
$endif
]]
ASTNode.traceRewriteExitCase1 [[
$if (TraceRewrite)
state().trace().exitRewriteCase1(this, "ASTNode.getChild", i, nodeToString(node));
$endif
]]
ASTNode.traceRewriteExitCase2 [[
$if (TraceRewrite)
state().trace().exitRewriteCase2(this, "ASTNode.getChild", i, nodeToString(node));
$endif
]]
ASTNode.traceRewriteExitCase3 [[
$if (TraceRewrite)
state().trace().exitRewriteCase3(this, "ASTNode.getChild", i, nodeToString(node));
$endif
]]
ASTDecl.traceCopyNode [[
$if (TraceCopy)
state().trace().copyNode(this, nodeToString(this));
$endif
]]
AttrDecl.traceFlushAttr [[
$if (TraceFlush)
$if(#isParameterized)
state().trace().flushAttr(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_values);
$else
state().trace().flushAttr(this, "#hostClassName.#signatureJavaStyle", "", #(signature)_value);
$endif
$endif
]]