public class OldVariableGenerationUtility
extends Object
Central place where code generation for the old closure variable takes place.
| Modifiers | Name | Description |
|---|---|---|
static String |
OLD_VARIABLES_METHOD |
Synthetic helper method name used to compute the old variable map for postconditions. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static void |
addOldVariableMethodNode(ClassNode classNode)Creates a synthetic method handling generation of the old variable map. |
|
public static Expression |
snapshotExpression(ClassNode type, Expression value)Returns an expression that snapshots value (of declared type type) for storage in
the old map. |
Synthetic helper method name used to compute the old variable map for postconditions.
Creates a synthetic method handling generation of the old variable map. If a super class declares the same synthetic method it will be called and the results will be merged.
classNode - which contains postconditions, so an old variable generating method makes sense here. Returns an expression that snapshots value (of declared type type) for storage in
the old map. The snapshot is only a defensive copy when one is needed and possible:
BigInteger/BigDecimal, the java.time.* types, enums,
@Immutable/@KnownImmutable types, ...) is stored by reference, since it cannot
change;clone(), so an
in-place change in the method body is not also seen through old;@Immutable rather than an ad-hoc list.
type - the declared type of the value being snapshottedvalue - the expression producing the value to snapshot