Class VariableShifter
- java.lang.Object
-
- com.singularsys.extensions.rewrite.VariableShifter
-
- All Implemented Interfaces:
RewriteVisitor.VariableRuleI,JepComponent,java.io.Serializable
public class VariableShifter extends java.lang.Object implements RewriteVisitor.VariableRuleI
Replaces a variable "x" by "x + d" where d is a double value. This adds aNode.HookKeyto all matching variable nodes. These can be removed by callingremoveHooks(Node)- Since:
- Jep 4.0/Extentions 2.1
- See Also:
RewriteVisitor, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description VariableShifter(java.lang.String name, double value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Nodeapply(ASTVarNode node)Rewrites the nodeJepComponentgetLightWeightInstance()Gets a light-weight instance suitable for using in multiple threads.static Node.HookKeygetVariableShifterHook()Hook used by this classvoidinit(Jep jep)Initialize the component.static voidremoveHooks(Node node)Remove all instances of the hook used by this classbooleantest(ASTVarNode node)Returns true if node needs to be rewritten, according to this rule.
-
-
-
Method Detail
-
init
public void init(Jep jep)
Description copied from interface:JepComponentInitialize the component. This methods is called whenever a component is added to Jep. Hence it allows components to keep track of the other components they may rely on.- Specified by:
initin interfaceJepComponent- Parameters:
jep- the current Jep instance
-
getLightWeightInstance
public JepComponent getLightWeightInstance()
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either an new instance, null or 'this'.
-
test
public boolean test(ASTVarNode node) throws ParseException
Description copied from interface:RewriteVisitor.VariableRuleIReturns true if node needs to be rewritten, according to this rule.- Specified by:
testin interfaceRewriteVisitor.VariableRuleI- Throws:
ParseException- if for some reason rewriting cannot be performed.
-
apply
public Node apply(ASTVarNode node) throws ParseException
Description copied from interface:RewriteVisitor.VariableRuleIRewrites the node- Specified by:
applyin interfaceRewriteVisitor.VariableRuleI- Throws:
ParseException
-
removeHooks
public static void removeHooks(Node node) throws JepException
Remove all instances of the hook used by this class- Parameters:
node-- Throws:
JepException
-
getVariableShifterHook
public static Node.HookKey getVariableShifterHook()
Hook used by this class- Returns:
-
-