LocalVariable mark = context.markLocalVariables(true); try { Sequence returnSeq = expression.eval(contextSequence, contextItem); if (context.isProfilingEnabled()) context.getProfiler().end(this, "", returnSeq); return returnSeq; } catch(XPathException e) { if(e.getLine() == 0) e.setASTNode(getASTNode());  e.addFunctionCall(functionDef, getASTNode()); throw e; } finally { context.popLocalVariables(mark); }
if (context.tailRecursiveCall(functionDef.getSignature())) {  return new DeferredFunctionCallImpl(functionDef.getSignature(), contextSequence, contextItem); } else { context.functionStart(functionDef.getSignature()); LocalVariable mark = context.markLocalVariables(true); try { Sequence returnSeq = expression.eval(contextSequence, contextItem); if (returnSeq instanceof DeferredFunctionCall && functionDef.getSignature().equals(((DeferredFunctionCall)returnSeq).getSignature())) { returnSeq = ((DeferredFunctionCall) returnSeq).execute(); } if (context.isProfilingEnabled()) context.getProfiler().end(this, "", returnSeq); return returnSeq; } catch(XPathException e) { if(e.getLine() == 0) e.setASTNode(getASTNode());  e.addFunctionCall(functionDef, getASTNode()); throw e; } finally { context.popLocalVariables(mark); context.functionEnd(); } }
    public Sequence evalFunction(Sequence contextSequence, Item contextItem, Sequence[] seq) throws XPathException {        if (context.isProfilingEnabled()) {            context.getProfiler().start(this);                 context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies()));            if (contextSequence != null)                context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);            if (contextItem != null)                context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());        }        		//check access to the method		try {			ExistPDP pdp = context.getPDP();			if(pdp != null) {				RequestCtx request = pdp.getRequestHelper().createFunctionRequest(context, null, getName());				//if request is null, this function belongs to a main module and is allowed to be called				//otherwise, the access must be checked				if(request != null)					pdp.evaluate(request);			}		} catch (PermissionDeniedException pde) {			XPathException xe = new XPathException(getASTNode(), "Access to function '" + getName() + "'  denied.", pde);			xe.addFunctionCall(functionDef, getASTNode());			throw xe;		}		        functionDef.setArguments(seq);        LocalVariable mark = context.markLocalVariables(true);        try {			Sequence returnSeq = expression.eval(contextSequence, contextItem);            if (context.isProfilingEnabled())                context.getProfiler().end(this, "", returnSeq);            			return returnSeq;		} catch(XPathException e) {			if(e.getLine() == 0)				e.setASTNode(getASTNode());			// append location of the function call to the exception message:			e.addFunctionCall(functionDef, getASTNode());			throw e;		} finally {			context.popLocalVariables(mark);            		}    }