Esempio n. 1
0
        internal override bool Equals(QueryFunction function)
        {
            XPathFunction function2 = function as XPathFunction;

            if (function2 == null)
            {
                return(false);
            }
            return(function2.ID == this.ID);
        }
Esempio n. 2
0
        internal override bool Equals(QueryFunction function)
        {
            XPathFunction xpathFunction = function as XPathFunction;

            if (null == xpathFunction)
            {
                return(false);
            }

            return(xpathFunction.ID == this.ID);
        }
Esempio n. 3
0
            private bool CompileFunctionSpecial(XPathFunctionExpr expr)
            {
                XPathFunction function = expr.Function as XPathFunction;

                if (((function != null) && (XPathFunctionID.StartsWith == function.ID)) && (XPathExprType.String == expr.SubExpr[1].Type))
                {
                    this.CompileFunctionParam(function, expr.SubExpr, 0);
                    this.codeBlock.Append(new StringPrefixOpcode(((XPathStringExpr)expr.SubExpr[1]).String));
                    return(true);
                }
                return(false);
            }
 static XPathFunctionLibrary()
 {
     XPathFunction[] functionArray = new XPathFunction[0x24];
     ValueDataType[] argTypes = new ValueDataType[1];
     functionArray[0] = new XPathFunction(XPathFunctionID.Boolean, "boolean", ValueDataType.Boolean, argTypes);
     functionArray[1] = new XPathFunction(XPathFunctionID.False, "false", ValueDataType.Boolean);
     functionArray[2] = new XPathFunction(XPathFunctionID.True, "true", ValueDataType.Boolean);
     functionArray[3] = new XPathFunction(XPathFunctionID.Not, "not", ValueDataType.Boolean, new ValueDataType[] { ValueDataType.Boolean });
     functionArray[4] = new XPathFunction(XPathFunctionID.Lang, "lang", ValueDataType.Boolean, new ValueDataType[] { ValueDataType.String });
     ValueDataType[] typeArray4 = new ValueDataType[1];
     functionArray[5] = new XPathFunction(XPathFunctionID.Number, "number", ValueDataType.Double, typeArray4);
     functionArray[6] = new XPathFunction(XPathFunctionID.NumberDefault, "number", ValueDataType.Double);
     functionArray[7] = new XPathFunction(XPathFunctionID.Sum, "sum", ValueDataType.Double, new ValueDataType[] { ValueDataType.Sequence });
     functionArray[8] = new XPathFunction(XPathFunctionID.Floor, "floor", ValueDataType.Double, new ValueDataType[] { ValueDataType.Double });
     functionArray[9] = new XPathFunction(XPathFunctionID.Ceiling, "ceiling", ValueDataType.Double, new ValueDataType[] { ValueDataType.Double });
     functionArray[10] = new XPathFunction(XPathFunctionID.Round, "round", ValueDataType.Double, new ValueDataType[] { ValueDataType.Double });
     ValueDataType[] typeArray9 = new ValueDataType[1];
     functionArray[11] = new XPathFunction(XPathFunctionID.String, "string", ValueDataType.String, typeArray9);
     functionArray[12] = new XPathFunction(XPathFunctionID.StringDefault, "string", ValueDataType.String, QueryFunctionFlag.UsesContextNode);
     functionArray[13] = new XPathFunction(XPathFunctionID.ConcatTwo, "concat", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String });
     functionArray[14] = new XPathFunction(XPathFunctionID.ConcatThree, "concat", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String, ValueDataType.String });
     functionArray[15] = new XPathFunction(XPathFunctionID.ConcatFour, "concat", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String, ValueDataType.String, ValueDataType.String });
     functionArray[0x10] = new XPathFunction(XPathFunctionID.StartsWith, "starts-with", ValueDataType.Boolean, new ValueDataType[] { ValueDataType.String, ValueDataType.String });
     functionArray[0x11] = new XPathFunction(XPathFunctionID.NormalizeSpace, "normalize-space", ValueDataType.String, new ValueDataType[] { ValueDataType.String });
     functionArray[0x12] = new XPathFunction(XPathFunctionID.NormalizeSpaceDefault, "normalize-space", ValueDataType.String, QueryFunctionFlag.UsesContextNode);
     functionArray[0x13] = new XPathFunction(XPathFunctionID.Contains, "contains", ValueDataType.Boolean, new ValueDataType[] { ValueDataType.String, ValueDataType.String });
     functionArray[20] = new XPathFunction(XPathFunctionID.SubstringBefore, "substring-before", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String });
     functionArray[0x15] = new XPathFunction(XPathFunctionID.SubstringAfter, "substring-after", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String });
     functionArray[0x16] = new XPathFunction(XPathFunctionID.Substring, "substring", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.Double });
     functionArray[0x17] = new XPathFunction(XPathFunctionID.SubstringLimit, "substring", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.Double, ValueDataType.Double });
     functionArray[0x18] = new XPathFunction(XPathFunctionID.StringLength, "string-length", ValueDataType.Double, new ValueDataType[] { ValueDataType.String });
     functionArray[0x19] = new XPathFunction(XPathFunctionID.StringLengthDefault, "string-length", ValueDataType.Double, QueryFunctionFlag.UsesContextNode);
     functionArray[0x1a] = new XPathFunction(XPathFunctionID.Translate, "translate", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String, ValueDataType.String });
     functionArray[0x1b] = new XPathFunction(XPathFunctionID.Last, "last", ValueDataType.Double, QueryFunctionFlag.UsesContextNode);
     functionArray[0x1c] = new XPathFunction(XPathFunctionID.Position, "position", ValueDataType.Double, QueryFunctionFlag.UsesContextNode);
     functionArray[0x1d] = new XPathFunction(XPathFunctionID.Count, "count", ValueDataType.Double, new ValueDataType[] { ValueDataType.Sequence });
     functionArray[30] = new XPathFunction(XPathFunctionID.LocalName, "local-name", ValueDataType.String, new ValueDataType[] { ValueDataType.Sequence });
     functionArray[0x1f] = new XPathFunction(XPathFunctionID.LocalNameDefault, "local-name", ValueDataType.String, QueryFunctionFlag.UsesContextNode);
     functionArray[0x20] = new XPathFunction(XPathFunctionID.Name, "name", ValueDataType.String, new ValueDataType[] { ValueDataType.Sequence });
     functionArray[0x21] = new XPathFunction(XPathFunctionID.NameDefault, "name", ValueDataType.String, QueryFunctionFlag.UsesContextNode);
     functionArray[0x22] = new XPathFunction(XPathFunctionID.NamespaceUri, "namespace-uri", ValueDataType.String, new ValueDataType[] { ValueDataType.Sequence });
     functionArray[0x23] = new XPathFunction(XPathFunctionID.NamespaceUriDefault, "namespace-uri", ValueDataType.String, QueryFunctionFlag.UsesContextNode);
     functionTable = functionArray;
 }
 static XPathFunctionLibrary()
 {
     XPathFunction[] functionArray = new XPathFunction[0x24];
     ValueDataType[] argTypes      = new ValueDataType[1];
     functionArray[0] = new XPathFunction(XPathFunctionID.Boolean, "boolean", ValueDataType.Boolean, argTypes);
     functionArray[1] = new XPathFunction(XPathFunctionID.False, "false", ValueDataType.Boolean);
     functionArray[2] = new XPathFunction(XPathFunctionID.True, "true", ValueDataType.Boolean);
     functionArray[3] = new XPathFunction(XPathFunctionID.Not, "not", ValueDataType.Boolean, new ValueDataType[] { ValueDataType.Boolean });
     functionArray[4] = new XPathFunction(XPathFunctionID.Lang, "lang", ValueDataType.Boolean, new ValueDataType[] { ValueDataType.String });
     ValueDataType[] typeArray4 = new ValueDataType[1];
     functionArray[5]  = new XPathFunction(XPathFunctionID.Number, "number", ValueDataType.Double, typeArray4);
     functionArray[6]  = new XPathFunction(XPathFunctionID.NumberDefault, "number", ValueDataType.Double);
     functionArray[7]  = new XPathFunction(XPathFunctionID.Sum, "sum", ValueDataType.Double, new ValueDataType[] { ValueDataType.Sequence });
     functionArray[8]  = new XPathFunction(XPathFunctionID.Floor, "floor", ValueDataType.Double, new ValueDataType[] { ValueDataType.Double });
     functionArray[9]  = new XPathFunction(XPathFunctionID.Ceiling, "ceiling", ValueDataType.Double, new ValueDataType[] { ValueDataType.Double });
     functionArray[10] = new XPathFunction(XPathFunctionID.Round, "round", ValueDataType.Double, new ValueDataType[] { ValueDataType.Double });
     ValueDataType[] typeArray9 = new ValueDataType[1];
     functionArray[11]   = new XPathFunction(XPathFunctionID.String, "string", ValueDataType.String, typeArray9);
     functionArray[12]   = new XPathFunction(XPathFunctionID.StringDefault, "string", ValueDataType.String, QueryFunctionFlag.UsesContextNode);
     functionArray[13]   = new XPathFunction(XPathFunctionID.ConcatTwo, "concat", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String });
     functionArray[14]   = new XPathFunction(XPathFunctionID.ConcatThree, "concat", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String, ValueDataType.String });
     functionArray[15]   = new XPathFunction(XPathFunctionID.ConcatFour, "concat", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String, ValueDataType.String, ValueDataType.String });
     functionArray[0x10] = new XPathFunction(XPathFunctionID.StartsWith, "starts-with", ValueDataType.Boolean, new ValueDataType[] { ValueDataType.String, ValueDataType.String });
     functionArray[0x11] = new XPathFunction(XPathFunctionID.NormalizeSpace, "normalize-space", ValueDataType.String, new ValueDataType[] { ValueDataType.String });
     functionArray[0x12] = new XPathFunction(XPathFunctionID.NormalizeSpaceDefault, "normalize-space", ValueDataType.String, QueryFunctionFlag.UsesContextNode);
     functionArray[0x13] = new XPathFunction(XPathFunctionID.Contains, "contains", ValueDataType.Boolean, new ValueDataType[] { ValueDataType.String, ValueDataType.String });
     functionArray[20]   = new XPathFunction(XPathFunctionID.SubstringBefore, "substring-before", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String });
     functionArray[0x15] = new XPathFunction(XPathFunctionID.SubstringAfter, "substring-after", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String });
     functionArray[0x16] = new XPathFunction(XPathFunctionID.Substring, "substring", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.Double });
     functionArray[0x17] = new XPathFunction(XPathFunctionID.SubstringLimit, "substring", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.Double, ValueDataType.Double });
     functionArray[0x18] = new XPathFunction(XPathFunctionID.StringLength, "string-length", ValueDataType.Double, new ValueDataType[] { ValueDataType.String });
     functionArray[0x19] = new XPathFunction(XPathFunctionID.StringLengthDefault, "string-length", ValueDataType.Double, QueryFunctionFlag.UsesContextNode);
     functionArray[0x1a] = new XPathFunction(XPathFunctionID.Translate, "translate", ValueDataType.String, new ValueDataType[] { ValueDataType.String, ValueDataType.String, ValueDataType.String });
     functionArray[0x1b] = new XPathFunction(XPathFunctionID.Last, "last", ValueDataType.Double, QueryFunctionFlag.UsesContextNode);
     functionArray[0x1c] = new XPathFunction(XPathFunctionID.Position, "position", ValueDataType.Double, QueryFunctionFlag.UsesContextNode);
     functionArray[0x1d] = new XPathFunction(XPathFunctionID.Count, "count", ValueDataType.Double, new ValueDataType[] { ValueDataType.Sequence });
     functionArray[30]   = new XPathFunction(XPathFunctionID.LocalName, "local-name", ValueDataType.String, new ValueDataType[] { ValueDataType.Sequence });
     functionArray[0x1f] = new XPathFunction(XPathFunctionID.LocalNameDefault, "local-name", ValueDataType.String, QueryFunctionFlag.UsesContextNode);
     functionArray[0x20] = new XPathFunction(XPathFunctionID.Name, "name", ValueDataType.String, new ValueDataType[] { ValueDataType.Sequence });
     functionArray[0x21] = new XPathFunction(XPathFunctionID.NameDefault, "name", ValueDataType.String, QueryFunctionFlag.UsesContextNode);
     functionArray[0x22] = new XPathFunction(XPathFunctionID.NamespaceUri, "namespace-uri", ValueDataType.String, new ValueDataType[] { ValueDataType.Sequence });
     functionArray[0x23] = new XPathFunction(XPathFunctionID.NamespaceUriDefault, "namespace-uri", ValueDataType.String, QueryFunctionFlag.UsesContextNode);
     functionTable       = functionArray;
 }
Esempio n. 6
0
            // Some functions are compiled with special opcodes to optimize perf in special situations
            // 1. starts-with(string, literal)
            bool CompileFunctionSpecial(XPathFunctionExpr expr)
            {
                XPathFunction function = expr.Function as XPathFunction;

                if (null != function)
                {
                    if (XPathFunctionID.StartsWith == function.ID)
                    {
                        // Does the 2nd parameter start with a string literal? Use a special opcode to handle those..
                        Fx.Assert(expr.SubExprCount == 2, "");
                        if (XPathExprType.String == expr.SubExpr[1].Type)
                        {
                            this.CompileFunctionParam(function, expr.SubExpr, 0);
                            this.codeBlock.Append(new StringPrefixOpcode(((XPathStringExpr)expr.SubExpr[1]).String));
                            return(true);
                        }
                    }
                }

                return(false);
            }
Esempio n. 7
0
 internal static void NumberNumberDefault(ProcessingContext context)
 {
     XPathFunction.IterateAndPushSequences(context);
     XPathFunction.NumberNumber(context);
 }
Esempio n. 8
0
 internal static void NodesetNamespaceUriDefault(ProcessingContext context)
 {
     XPathFunction.IterateAndPushSequences(context);
     XPathFunction.NodesetNamespaceUri(context);
 }
Esempio n. 9
0
 internal static void NodesetLocalNameDefault(ProcessingContext context)
 {
     XPathFunction.IterateAndPushSequences(context);
     XPathFunction.NodesetLocalName(context);
 }
Esempio n. 10
0
        internal override void Eval(ProcessingContext context)
        {
            Fx.Assert(null != context, "");

            switch (this.functionID)
            {
            default:
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException(SR.GetString(SR.QueryNotImplemented, this.name)));

            case XPathFunctionID.IterateSequences:
                XPathFunction.IterateAndPushSequences(context);
                break;

            case XPathFunctionID.Count:
                XPathFunction.NodesetCount(context);
                break;

            case XPathFunctionID.Position:
                XPathFunction.NodesetPosition(context);
                break;

            case XPathFunctionID.Last:
                XPathFunction.NodesetLast(context);
                break;

            case XPathFunctionID.LocalName:
                XPathFunction.NodesetLocalName(context);
                break;

            case XPathFunctionID.LocalNameDefault:
                XPathFunction.NodesetLocalNameDefault(context);
                break;

            case XPathFunctionID.Name:
                XPathFunction.NodesetName(context);
                break;

            case XPathFunctionID.NameDefault:
                XPathFunction.NodesetNameDefault(context);
                break;

            case XPathFunctionID.NamespaceUri:
                XPathFunction.NodesetNamespaceUri(context);
                break;

            case XPathFunctionID.NamespaceUriDefault:
                XPathFunction.NodesetNamespaceUriDefault(context);
                break;

            case XPathFunctionID.Boolean:
                XPathFunction.BooleanBoolean(context);
                break;

            case XPathFunctionID.False:
                XPathFunction.BooleanFalse(context);
                break;

            case XPathFunctionID.True:
                XPathFunction.BooleanTrue(context);
                break;

            case XPathFunctionID.Not:
                XPathFunction.BooleanNot(context);
                break;

            case XPathFunctionID.Lang:
                XPathFunction.BooleanLang(context);
                break;

            case XPathFunctionID.Contains:
                XPathFunction.StringContains(context);
                break;

            case XPathFunctionID.Number:
                XPathFunction.NumberNumber(context);
                break;

            case XPathFunctionID.NumberDefault:
                XPathFunction.NumberNumberDefault(context);
                break;

            case XPathFunctionID.Ceiling:
                XPathFunction.NumberCeiling(context);
                break;

            case XPathFunctionID.Floor:
                XPathFunction.NumberFloor(context);
                break;

            case XPathFunctionID.Round:
                XPathFunction.NumberRound(context);
                break;

            case XPathFunctionID.Sum:
                XPathFunction.NumberSum(context);
                break;

            case XPathFunctionID.String:
                XPathFunction.StringString(context);
                break;

            case XPathFunctionID.StringDefault:
                XPathFunction.StringStringDefault(context);
                break;

            case XPathFunctionID.ConcatTwo:
                XPathFunction.StringConcatTwo(context);
                break;

            case XPathFunctionID.ConcatThree:
                XPathFunction.StringConcatThree(context);
                break;

            case XPathFunctionID.ConcatFour:
                XPathFunction.StringConcatFour(context);
                break;

            case XPathFunctionID.StartsWith:
                XPathFunction.StringStartsWith(context);
                break;

            case XPathFunctionID.StringLength:
                XPathFunction.StringLength(context);
                break;

            case XPathFunctionID.StringLengthDefault:
                XPathFunction.StringLengthDefault(context);
                break;

            case XPathFunctionID.SubstringBefore:
                XPathFunction.SubstringBefore(context);
                break;

            case XPathFunctionID.SubstringAfter:
                XPathFunction.SubstringAfter(context);
                break;

            case XPathFunctionID.Substring:
                XPathFunction.Substring(context);
                break;

            case XPathFunctionID.SubstringLimit:
                XPathFunction.SubstringLimit(context);
                break;

            case XPathFunctionID.Translate:
                XPathFunction.Translate(context);
                break;

            case XPathFunctionID.NormalizeSpace:
                XPathFunction.NormalizeSpace(context);
                break;

            case XPathFunctionID.NormalizeSpaceDefault:
                XPathFunction.NormalizeSpaceDefault(context);
                break;
            }
        }
Esempio n. 11
0
 internal static void NormalizeSpaceDefault(ProcessingContext context)
 {
     XPathFunction.IterateAndPushSequences(context);
     XPathFunction.ConvertFirstArg(context, ValueDataType.String);
     XPathFunction.NormalizeSpace(context);
 }
Esempio n. 12
0
 internal static void StringLengthDefault(ProcessingContext context)
 {
     XPathFunction.IterateAndPushSequences(context);
     XPathFunction.ConvertFirstArg(context, ValueDataType.String);
     XPathFunction.StringLength(context);
 }
Esempio n. 13
0
 internal static void StringStringDefault(ProcessingContext context)
 {
     XPathFunction.IterateAndPushSequences(context);
     XPathFunction.StringString(context);
 }