+2003-07-26 Piers Haken <piersh@friskit.com>
+
+ * Expression.cs: fix function evaluation with ambigous argument types
+ * XPathnavigator.cs: fix silly null reference bug
+
2003-07-26 Piers Haken <piersh@friskit.com>
* Iterator.cs:
internal class ExprFunctionCall : Expression
{
- protected XmlQualifiedName _name;
- protected ArrayList _args = new ArrayList ();
+ protected readonly XmlQualifiedName _name;
+ protected readonly ArrayList _args = new ArrayList ();
public ExprFunctionCall (XmlQualifiedName name, FunctionArguments args)
{
_name = name;
XPathResultType [] rgFuncTypes = func.ArgTypes;
for (int iArg = 0; iArg < _args.Count; iArg ++)
{
- XPathResultType typeArg = (iArg < rgFuncTypes.Length) ? rgFuncTypes [iArg] : rgFuncTypes [rgFuncTypes.Length - 1];
- rgArgs [iArg] = ((Expression) _args [iArg]).EvaluateAs (iter, typeArg);
+ XPathResultType typeArg;
+ if (rgFuncTypes == null)
+ typeArg = XPathResultType.Any;
+ else if (iArg < rgFuncTypes.Length)
+ typeArg = rgFuncTypes [iArg];
+ else
+ typeArg = rgFuncTypes [rgFuncTypes.Length - 1];
+
+ Expression arg = (Expression) _args [iArg];
+ object result = arg.EvaluateAs (iter, typeArg);
+ rgArgs [iArg] = result;
}
}
return func.Invoke (context, rgArgs, iter.Current);
public virtual object Evaluate (XPathExpression expr, XPathNodeIterator context)
{
- BaseIterator iterContext = (BaseIterator) context;
CompiledExpression cexpr = (CompiledExpression) expr;
if (context == null)
context = new NullIterator (this, cexpr.NamespaceManager);
+ BaseIterator iterContext = (BaseIterator) context;
iterContext.NamespaceManager = cexpr.NamespaceManager;
return cexpr.Evaluate (iterContext);
}