Class OverloadResolver
java.lang.Object
com.singularsys.jep.walkers.GenericDoNothingVisitor<Void>
com.singularsys.jep.misc.overloadedfunctions.OverloadResolver
- All Implemented Interfaces:
GenericVisitor<Node,,Void, ParseException> JepComponent,Serializable
Resolves
OverloadedOperator, OverloadedFunctionByStructure
and AlternateFunctions setting the
operator or PostfixMathCommand of the node based on a test of the node.
UnaryFunction uf = new ArcTangent();
BinaryFunction bf =new ArcTangent2();
AlternateFunctions af = new AlternateFunctions(uf, bf);
jep.addFunction("atan",af);
jep.reinitializeComponents();
OverloadResolver or = new OverloadResolver();
Node node = jep.parse("atan(1)");
or.visit(node);
assertSame(uf,node.getPFMC()); // The single argument function is selected.
This visitor modifies the nodes in place.
- See Also:
-
Field Summary
Fields inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor
ft, nf, ot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets a light-weight instance suitable for using in multiple threads.visit(ASTFunNode node, Void data) Visit a function nodeVisit an operator nodeVisits the node and its dependents resolvingOverloadedFunctionByStructureandAlternateFunctions.Visit a node calling the appropriate overloaded method.Methods inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor
childrenHaveChanged, copyChildrenIfNeeded, copyChildrenIfNeeded, init, makeException, visit, visitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.singularsys.jep.GenericVisitor
makeException, visitChildren
-
Constructor Details
-
OverloadResolver
public OverloadResolver()
-
-
Method Details
-
getLightWeightInstance
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Overrides:
getLightWeightInstancein classGenericDoNothingVisitor<Void>- Returns:
- either a new instance, null or 'this'.
-
visit
Visits the node and its dependents resolvingOverloadedFunctionByStructureandAlternateFunctions.- Parameters:
node- root node- Returns:
- the same node, possible with operators and pfmc's replaced
- Throws:
ParseException
-
visit
Description copied from interface:GenericVisitorVisit a node calling the appropriate overloaded method.- Parameters:
node- current nodedata- context data passed to each child- Returns:
- result of visiting the node
- Throws:
ParseException
-
visit
Description copied from interface:GenericVisitorVisit an operator node- Specified by:
visitin interfaceGenericVisitor<Node,Void, ParseException> - Overrides:
visitin classGenericDoNothingVisitor<Void>- Parameters:
node- current nodedata- context data- Returns:
- the result of visiting the node
- Throws:
ParseException
-
visit
Description copied from interface:GenericVisitorVisit a function node- Specified by:
visitin interfaceGenericVisitor<Node,Void, ParseException> - Overrides:
visitin classGenericDoNothingVisitor<Void>- Parameters:
node- current nodedata- context data- Returns:
- the result of visiting the node
- Throws:
ParseException
-