return_before_codeFragment.xsl
Weaving Rule that weaves a code fragment before a return statement.
- srcML element:
src:return - advice type:
before - codeModifier type:
codeFragment
Example 1
int foo() {
int i = 10;
return i;
}
Code Modifier
<codeModifier type="codeFragment">
<text>i = i * 2;</text>
</codeModifier>Modified Code
int foo() {
int i = 10;
i = i * 2;
return i;
}
Example 2
If the return statement is inside an if/for/while/do without a block, a block is added by the weaver.
int foo() {
if( true )
return 10;
else
return 20;
}
Code Modifier
<codeModifier type="codeFragment">
<text>printf("function returns");</text>
</codeModifier>Modified Code
int foo() {
if( true ) {
printf("function returns");
return 10;
} else {
printf("function returns");
return 20;
}
}
Examples in AspectX Sample Library
- CarPostCondition
- TraceMethodLeave
- Profiling
- Efficiency
- Trace
Examples in AspectX Test Suite
- Bug_00000112
- AllFunctionDollarVariables
- AllMultiplelineCodeFragments
- AllReturnBeforeCodeFragment
CVS Id:
Author:
ibirrer
Copyright:
2004, P&P Software GmbH
Match Templates Summary
src:return[ax:advice[@type='before' and position() = 1]/ax:codeModifier[@type='codeFragment']] (mode: weaving) - source
Adds the code fragment before the return statement
text()[following-sibling::src:else/src:if/src:then[src:return[ax:advice[@type='before' and position() = 1]/ax:codeModifier[@type='codeFragment']]]][position() = last()] (mode: weaving) - source
No short description available
text()[following-sibling::src:else[src:return[ax:advice[@type='before' and position() = 1]/ax:codeModifier[@type='codeFragment']]]][position() = last()] (mode: weaving) - source
No short description available
text()[following-sibling::src:return[ax:advice[@type='before' and position() = 1]/ax:codeModifier[@type='codeFragment']]][position() = last()] (mode: weaving) - source
No short description available
Match Templates Detail
src:return[ax:advice[@type='before' and position() = 1]/ax:codeModifier[@type='codeFragment']] (mode: weaving) - source
Adds the code fragment before the return statement
text()[following-sibling::src:else/src:if/src:then[src:return[ax:advice[@type='before' and position() = 1]/ax:codeModifier[@type='codeFragment']]]][position() = last()] (mode: weaving) - source
No short description available
text()[following-sibling::src:else[src:return[ax:advice[@type='before' and position() = 1]/ax:codeModifier[@type='codeFragment']]]][position() = last()] (mode: weaving) - source
No short description available
text()[following-sibling::src:return[ax:advice[@type='before' and position() = 1]/ax:codeModifier[@type='codeFragment']]][position() = last()] (mode: weaving) - source
No short description available