Package com.singularsys.jep.misc.overloadedfunctions

# 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`

public class OverloadResolver extends GenericDoNothingVisitor<Void>
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:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor

  `ft, nf, ot`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OverloadResolver()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `JepComponent`
  `getLightWeightInstance()`
  Gets a light-weight instance suitable for using in multiple threads.
  `Node`
  `visit(ASTFunNode node, Void data)`
  Visit a function node
  `Node`
  `visit(ASTOpNode node, Void data)`
  Visit an operator node
  `Node`
  `visit(Node node)`
  Visits the node and its dependents resolving `OverloadedFunctionByStructure` and `AlternateFunctions`.
  `Node`
  `visit(Node node, Void data)`
  Visit a node calling the appropriate overloaded method.

  ### Methods inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor

  `childrenHaveChanged, copyChildrenIfNeeded, copyChildrenIfNeeded, init, makeException, visit, visit`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface com.singularsys.jep.GenericVisitor

  `makeException, visitChildren`

- ## Constructor Details

  - ### OverloadResolver

    public OverloadResolver()

- ## Method Details

  - ### getLightWeightInstance

    public JepComponent getLightWeightInstance()
    Description copied from interface: `JepComponent`
    Gets a light-weight instance suitable for using in multiple threads.
    Specified by:
      `getLightWeightInstance` in interface `JepComponent`
    Overrides:
      `getLightWeightInstance` in class `GenericDoNothingVisitor<Void>`
    Returns:
      either a new instance, null or 'this'.

  - ### visit

    public Node visit(Node node) throws ParseException
    Visits the node and its dependents resolving `OverloadedFunctionByStructure` and `AlternateFunctions`.
    Parameters:
      `node` - root node
    Returns:
      the same node, possible with operators and pfmc's replaced
    Throws:
      `ParseException`

  - ### visit

    public Node visit(Node node, Void data) throws ParseException
    Description copied from interface: `GenericVisitor`
    Visit a node calling the appropriate overloaded method.
    Parameters:
      `node` - current node
      `data` - context data passed to each child
    Returns:
      result of visiting the node
    Throws:
      `ParseException`

  - ### visit

    public Node visit(ASTOpNode node, Void data) throws ParseException
    Description copied from interface: `GenericVisitor`
    Visit an operator node
    Specified by:
      `visit` in interface `GenericVisitor<Node,Void,ParseException>`
    Overrides:
      `visit` in class `GenericDoNothingVisitor<Void>`
    Parameters:
      `node` - current node
      `data` - context data
    Returns:
      the result of visiting the node
    Throws:
      `ParseException`

  - ### visit

    public Node visit(ASTFunNode node, Void data) throws ParseException
    Description copied from interface: `GenericVisitor`
    Visit a function node
    Specified by:
      `visit` in interface `GenericVisitor<Node,Void,ParseException>`
    Overrides:
      `visit` in class `GenericDoNothingVisitor<Void>`
    Parameters:
      `node` - current node
      `data` - context data
    Returns:
      the result of visiting the node
    Throws:
      `ParseException`