/*
 * FunctionFrame.java
 * 
 * Created on Oct 31, 2007, 8:10:37 PM
 */

package saxon.xslt.stacktrace;

import javax.xml.namespace.QName;
import org.xml.sax.Locator;

/**
 * Represent an XSLT stack frame for a function.
 *
 * @author Florent Georges
 */
public class FunctionFrame
        extends StackFrame
{
    /**
     * Build a new function frame.
     * 
     * @param curr_item
     *             The path to the current node if any.
     * 
     * @param name
     *             The name of the function.
     * 
     * @param arity
     *             The arity of the function (its number of parameters).
     * 
     * @param locator
     *             The SAX locator for the function.
     */
    public FunctionFrame(String curr_item, QName name, int arity, Locator locator)
    {
        myPath = curr_item;
        myName = name;
        myArity = arity;
        myLocator = locator;
    }

    /**
     * Return the name of the function.
     */
    public QName getName()
    {
        return myName;
    }

    /**
     * Return the arity of the function (its number of parameters).
     */
    public int getArity()
    {
        return myArity;
    }

    @Override
    public String toString()
    {
        return "function " + displayQName(myName) + " #" + myArity;
    }

    public void acceptVisitor(StackVisitor visitor)
    {
        visitor.visitFunctionFrame(this);
        if ( getNext() != null ) {
            getNext().acceptVisitor(visitor);
        }
    }

    private QName myName;
    private int myArity;
}
