2003-07-26 Piers Haken <piersh@friskit.com>
authorPiers Haken <piers@mono-cvs.ximian.com>
Sun, 27 Jul 2003 02:54:26 +0000 (02:54 -0000)
committerPiers Haken <piers@mono-cvs.ximian.com>
Sun, 27 Jul 2003 02:54:26 +0000 (02:54 -0000)
* Expression.cs: fix function evaluation with ambigous argument types
* XPathnavigator.cs: fix silly null reference bug

svn path=/trunk/mcs/; revision=16729

mcs/class/System.XML/System.Xml.XPath/ChangeLog
mcs/class/System.XML/System.Xml.XPath/Expression.cs
mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs

index 6a11832101f0fbeeece253bc21efaf768562813d..ffeab01e60808f26c3943a08ff1909ad0d4b3558 100644 (file)
@@ -1,3 +1,8 @@
+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:
index 345e2315bd86f70212b9cb2b426de59979d442ff..a09719faf28994eb772149f82937867f3b28f364 100644 (file)
@@ -1176,8 +1176,8 @@ namespace System.Xml.XPath
 
        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;
@@ -1253,8 +1253,17 @@ namespace System.Xml.XPath
                                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);
index 5d2c8b354b81bb451ca883fa89c715ba78a9cd44..bddaea9cfd232e5bfca4dcf068298326b11ee118 100644 (file)
@@ -81,10 +81,10 @@ namespace System.Xml.XPath
 
                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);
                }