boolean wasSupplied = b.useGlobalParameter(getVariableFingerprint(), this);
if (wasSupplied) {
return b.getGlobalVariableValue(this);
} else {
if (isRequiredParam()) {
DynamicError e = new DynamicError("No value supplied for required parameter $" +
context.getController().getNamePool().getDisplayName(getVariableFingerprint()));
e.setXPathContext(context);
e.setLocator(getSourceLocator());
e.setErrorCode("XT0050");
throw e;
// TODO: we aren't reporting this error if the required parameter is never referenced
}
// This is the first reference to a global variable; try to evaluate it now.
// But first set a flag to stop looping. This flag is set in the Bindery because
// the VariableReference itself can be used by multiple threads simultaneously
try {
b.setExecuting(this, true);
//XPathContext c2 = context.newCleanContext();
Value value = getSelectValue(context);
b.defineGlobalVariable(this, value);
b.setExecuting(this, false);
return value;
} catch (XPathException err) {
if (err instanceof XPathException.Circularity) {
DynamicError e = new DynamicError("Circular definition of parameter " + getVariableName());
e.setXPathContext(context);
e.setErrorCode("XT0640");
throw e;
} else {
throw err;
}
}