public class MethodVariantASTTransformation
extends Object
implements ASTTransformation
Handles a Decreases annotation placed on a method (the loop case is handled by LoopVariantASTTransformation). The closure is a termination measure over the method's parameters that must strictly decrease, and stay non-negative, on every recursive re-entry.
The method body is wrapped so that, conceptually:
def $m = <measure>
def $prev = MethodVariantSupport.enter("<key>", $m) // checks decrease vs the enclosing frame
try { <original body> } finally { MethodVariantSupport.exit("<key>", $prev) }
The check is pure entry/exit bookkeeping keyed by method signature, so no
static analysis of recursive call sites is needed.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
visit(ASTNode[] nodes, SourceUnit source)Instruments a method annotated with Decreases. |
Instruments a method annotated with Decreases. The closure must contain a single measure expression; an empty closure is reported and left unchanged. Anything other than that annotation placed on a method is ignored.