internal static void SubstringLimit(ProcessingContext context) { StackFrame topArg = context.TopArg; StackFrame secondArg = context.SecondArg; StackFrame frame3 = context[2]; while (topArg.basePtr <= topArg.endPtr) { string str2; string str = context.PeekString(topArg.basePtr); int startIndex = ((int)Math.Round(context.PeekDouble(secondArg.basePtr))) - 1; if (startIndex < 0) { startIndex = 0; } int length = (int)Math.Round(context.PeekDouble(frame3.basePtr)); if ((length < 1) || ((startIndex + length) >= str.Length)) { str2 = string.Empty; } else { str2 = str.Substring(startIndex, length); } context.SetValue(context, frame3.basePtr, str2); secondArg.basePtr++; topArg.basePtr++; frame3.basePtr++; } context.PopFrame(); context.PopFrame(); }
internal static void NumberRound(ProcessingContext context) { StackFrame topArg = context.TopArg; while (topArg.basePtr <= topArg.endPtr) { context.PeekDouble(topArg.basePtr); context.SetValue(context, topArg.basePtr, QueryValueModel.Round(context.PeekDouble(topArg.basePtr))); topArg.basePtr++; } }
internal static void NumberFloor(ProcessingContext context) { StackFrame topArg = context.TopArg; while (topArg.basePtr <= topArg.endPtr) { context.SetValue(context, topArg.basePtr, Math.Floor(context.PeekDouble(topArg.basePtr))); topArg.basePtr++; } }
internal static void NumberCeiling(ProcessingContext context) { StackFrame arg = context.TopArg; while (arg.basePtr <= arg.endPtr) { context.SetValue(context, arg.basePtr, Math.Ceiling(context.PeekDouble(arg.basePtr))); arg.basePtr++; } }
internal static void SubstringLimit(ProcessingContext context) { StackFrame argString = context.TopArg; StackFrame argStartAt = context.SecondArg; StackFrame argLimit = context[2]; Fx.Assert(argString.Count == argStartAt.Count, ""); Fx.Assert(argString.Count == argLimit.Count, ""); while (argString.basePtr <= argString.endPtr) { string str = context.PeekString(argString.basePtr); int startAt = ((int)Math.Round(context.PeekDouble(argStartAt.basePtr))) - 1; if (startAt < 0) { startAt = 0; } int length = (int)Math.Round(context.PeekDouble(argLimit.basePtr)); string substr; if (length < 1 || ((startAt + length) >= str.Length)) { substr = string.Empty; } else { substr = str.Substring(startAt, length); } context.SetValue(context, argLimit.basePtr, substr); argStartAt.basePtr++; argString.basePtr++; argLimit.basePtr++; } context.PopFrame(); context.PopFrame(); }
internal static void Substring(ProcessingContext context) { StackFrame topArg = context.TopArg; StackFrame secondArg = context.SecondArg; while (topArg.basePtr <= topArg.endPtr) { string str = context.PeekString(topArg.basePtr); int startIndex = ((int)Math.Round(context.PeekDouble(secondArg.basePtr))) - 1; if (startIndex < 0) { startIndex = 0; } context.SetValue(context, secondArg.basePtr, (startIndex >= str.Length) ? string.Empty : str.Substring(startIndex)); topArg.basePtr++; secondArg.basePtr++; } context.PopFrame(); }
internal static void Substring(ProcessingContext context) { StackFrame arg1 = context.TopArg; StackFrame arg2 = context.SecondArg; Fx.Assert(arg1.Count == arg2.Count, ""); while (arg1.basePtr <= arg1.endPtr) { string str = context.PeekString(arg1.basePtr); int startAt = ((int)Math.Round(context.PeekDouble(arg2.basePtr))) - 1; if (startAt < 0) { startAt = 0; } context.SetValue(context, arg2.basePtr, (startAt >= str.Length) ? string.Empty : str.Substring(startAt)); arg1.basePtr++; arg2.basePtr++; } context.PopFrame(); }
internal override Opcode Eval(ProcessingContext context) { XPathNavigator nav = context.Processor.ContextNode; if (nav != null && context.Processor.ContextMessage != null) { ((SeekableMessageNavigator)nav).Atomize(); } if (this.argCount == 0) { context.PushFrame(); int count = context.IterationCount; if (count > 0) { object ret = this.function.Invoke(this.xsltContext, NullArgs, nav); switch (this.function.ReturnType) { case XPathResultType.String: context.Push((string)ret, count); break; case XPathResultType.Number: context.Push((double)ret, count); break; case XPathResultType.Boolean: context.Push((bool)ret, count); break; case XPathResultType.NodeSet: NodeSequence seq = context.CreateSequence(); XPathNodeIterator iter = (XPathNodeIterator)ret; seq.Add(iter); context.Push(seq, count); break; default: // This should never be reached throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ReturnType.ToString()))); } } } else { // PERF, [....], see if we can cache these arrays to avoid allocations object[] xsltArgs = new object[this.argCount]; int iterationCount = context.TopArg.Count; for (int iteration = 0; iteration < iterationCount; ++iteration) { for (int i = 0; i < this.argCount; ++i) { StackFrame arg = context[i]; Fx.Assert(iteration < arg.Count, ""); switch (this.function.ArgTypes[i]) { case XPathResultType.String: xsltArgs[i] = context.PeekString(arg[iteration]); break; case XPathResultType.Number: xsltArgs[i] = context.PeekDouble(arg[iteration]); break; case XPathResultType.Boolean: xsltArgs[i] = context.PeekBoolean(arg[iteration]); break; case XPathResultType.NodeSet: NodeSequenceIterator iter = new NodeSequenceIterator(context.PeekSequence(arg[iteration])); xsltArgs[i] = iter; this.iterList.Add(iter); break; default: // This should never be reached throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ArgTypes[i].ToString()))); } } object ret = this.function.Invoke(this.xsltContext, xsltArgs, nav); if (this.iterList != null) { for (int i = 0; i < this.iterList.Count; ++i) { this.iterList[i].Clear(); } this.iterList.Clear(); } switch (this.function.ReturnType) { case XPathResultType.String: context.SetValue(context, context[this.argCount - 1][iteration], (string)ret); break; case XPathResultType.Number: context.SetValue(context, context[this.argCount - 1][iteration], (double)ret); break; case XPathResultType.Boolean: context.SetValue(context, context[this.argCount - 1][iteration], (bool)ret); break; case XPathResultType.NodeSet: NodeSequence seq = context.CreateSequence(); XPathNodeIterator iter = (XPathNodeIterator)ret; seq.Add(iter); context.SetValue(context, context[this.argCount - 1][iteration], seq); break; default: // This should never be reached throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ReturnType.ToString()))); } } for (int i = 0; i < this.argCount - 1; ++i) { context.PopFrame(); } } return this.next; }
internal static void NumberRound(ProcessingContext context) { StackFrame arg = context.TopArg; while (arg.basePtr <= arg.endPtr) { double val = context.PeekDouble(arg.basePtr); context.SetValue(context, arg.basePtr, QueryValueModel.Round(context.PeekDouble(arg.basePtr))); arg.basePtr++; } }
internal static void NumberFloor(ProcessingContext context) { StackFrame arg = context.TopArg; while (arg.basePtr <= arg.endPtr) { context.SetValue(context, arg.basePtr, Math.Floor(context.PeekDouble(arg.basePtr))); arg.basePtr++; } }
internal static void NumberCeiling(ProcessingContext context) { StackFrame topArg = context.TopArg; while (topArg.basePtr <= topArg.endPtr) { context.SetValue(context, topArg.basePtr, Math.Ceiling(context.PeekDouble(topArg.basePtr))); topArg.basePtr++; } }
internal override Opcode Eval(ProcessingContext context) { XPathNavigator contextNode = context.Processor.ContextNode; if ((contextNode != null) && (context.Processor.ContextMessage != null)) { ((SeekableMessageNavigator)contextNode).Atomize(); } if (this.argCount == 0) { context.PushFrame(); int iterationCount = context.IterationCount; if (iterationCount > 0) { object obj2 = this.function.Invoke(this.xsltContext, NullArgs, contextNode); switch (this.function.ReturnType) { case XPathResultType.Number: context.Push((double)obj2, iterationCount); goto Label_03F6; case XPathResultType.String: context.Push((string)obj2, iterationCount); goto Label_03F6; case XPathResultType.Boolean: context.Push((bool)obj2, iterationCount); goto Label_03F6; case XPathResultType.NodeSet: { NodeSequence sequence = context.CreateSequence(); XPathNodeIterator iter = (XPathNodeIterator)obj2; sequence.Add(iter); context.Push(sequence, iterationCount); goto Label_03F6; } } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ReturnType.ToString() }))); } } else { object[] args = new object[this.argCount]; int count = context.TopArg.Count; for (int i = 0; i < count; i++) { for (int k = 0; k < this.argCount; k++) { StackFrame frame = context[k]; switch (this.function.ArgTypes[k]) { case XPathResultType.Number: args[k] = context.PeekDouble(frame[i]); break; case XPathResultType.String: args[k] = context.PeekString(frame[i]); break; case XPathResultType.Boolean: args[k] = context.PeekBoolean(frame[i]); break; case XPathResultType.NodeSet: { NodeSequenceIterator item = new NodeSequenceIterator(context.PeekSequence(frame[i])); args[k] = item; this.iterList.Add(item); break; } default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ArgTypes[k].ToString() }))); } } object obj3 = this.function.Invoke(this.xsltContext, args, contextNode); if (this.iterList != null) { for (int m = 0; m < this.iterList.Count; m++) { this.iterList[m].Clear(); } this.iterList.Clear(); } switch (this.function.ReturnType) { case XPathResultType.Number: { StackFrame frame4 = context[this.argCount - 1]; context.SetValue(context, frame4[i], (double)obj3); break; } case XPathResultType.String: { StackFrame frame3 = context[this.argCount - 1]; context.SetValue(context, frame3[i], (string)obj3); break; } case XPathResultType.Boolean: { StackFrame frame5 = context[this.argCount - 1]; context.SetValue(context, frame5[i], (bool)obj3); break; } case XPathResultType.NodeSet: { NodeSequence val = context.CreateSequence(); XPathNodeIterator iterator3 = (XPathNodeIterator)obj3; val.Add(iterator3); StackFrame frame6 = context[this.argCount - 1]; context.SetValue(context, frame6[i], val); break; } default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ReturnType.ToString() }))); } } for (int j = 0; j < (this.argCount - 1); j++) { context.PopFrame(); } } Label_03F6: return(base.next); }
internal override Opcode Eval(ProcessingContext context) { XPathNavigator nav = context.Processor.ContextNode; if (nav != null && context.Processor.ContextMessage != null) { ((SeekableMessageNavigator)nav).Atomize(); } if (this.argCount == 0) { context.PushFrame(); int count = context.IterationCount; if (count > 0) { object ret = this.function.Invoke(this.xsltContext, NullArgs, nav); switch (this.function.ReturnType) { case XPathResultType.String: context.Push((string)ret, count); break; case XPathResultType.Number: context.Push((double)ret, count); break; case XPathResultType.Boolean: context.Push((bool)ret, count); break; case XPathResultType.NodeSet: NodeSequence seq = context.CreateSequence(); XPathNodeIterator iter = (XPathNodeIterator)ret; seq.Add(iter); context.Push(seq, count); break; default: // This should never be reached throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ReturnType.ToString()))); } } } else { // PERF, [....], see if we can cache these arrays to avoid allocations object[] xsltArgs = new object[this.argCount]; int iterationCount = context.TopArg.Count; for (int iteration = 0; iteration < iterationCount; ++iteration) { for (int i = 0; i < this.argCount; ++i) { StackFrame arg = context[i]; Fx.Assert(iteration < arg.Count, ""); switch (this.function.ArgTypes[i]) { case XPathResultType.String: xsltArgs[i] = context.PeekString(arg[iteration]); break; case XPathResultType.Number: xsltArgs[i] = context.PeekDouble(arg[iteration]); break; case XPathResultType.Boolean: xsltArgs[i] = context.PeekBoolean(arg[iteration]); break; case XPathResultType.NodeSet: NodeSequenceIterator iter = new NodeSequenceIterator(context.PeekSequence(arg[iteration])); xsltArgs[i] = iter; this.iterList.Add(iter); break; default: // This should never be reached throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ArgTypes[i].ToString()))); } } object ret = this.function.Invoke(this.xsltContext, xsltArgs, nav); if (this.iterList != null) { for (int i = 0; i < this.iterList.Count; ++i) { this.iterList[i].Clear(); } this.iterList.Clear(); } switch (this.function.ReturnType) { case XPathResultType.String: context.SetValue(context, context[this.argCount - 1][iteration], (string)ret); break; case XPathResultType.Number: context.SetValue(context, context[this.argCount - 1][iteration], (double)ret); break; case XPathResultType.Boolean: context.SetValue(context, context[this.argCount - 1][iteration], (bool)ret); break; case XPathResultType.NodeSet: NodeSequence seq = context.CreateSequence(); XPathNodeIterator iter = (XPathNodeIterator)ret; seq.Add(iter); context.SetValue(context, context[this.argCount - 1][iteration], seq); break; default: // This should never be reached throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ReturnType.ToString()))); } } for (int i = 0; i < this.argCount - 1; ++i) { context.PopFrame(); } } return(this.next); }
internal static void SubstringLimit(ProcessingContext context) { StackFrame topArg = context.TopArg; StackFrame secondArg = context.SecondArg; StackFrame frame3 = context[2]; while (topArg.basePtr <= topArg.endPtr) { string str2; string str = context.PeekString(topArg.basePtr); int startIndex = ((int) Math.Round(context.PeekDouble(secondArg.basePtr))) - 1; if (startIndex < 0) { startIndex = 0; } int length = (int) Math.Round(context.PeekDouble(frame3.basePtr)); if ((length < 1) || ((startIndex + length) >= str.Length)) { str2 = string.Empty; } else { str2 = str.Substring(startIndex, length); } context.SetValue(context, frame3.basePtr, str2); secondArg.basePtr++; topArg.basePtr++; frame3.basePtr++; } context.PopFrame(); context.PopFrame(); }
internal static void Substring(ProcessingContext context) { StackFrame topArg = context.TopArg; StackFrame secondArg = context.SecondArg; while (topArg.basePtr <= topArg.endPtr) { string str = context.PeekString(topArg.basePtr); int startIndex = ((int) Math.Round(context.PeekDouble(secondArg.basePtr))) - 1; if (startIndex < 0) { startIndex = 0; } context.SetValue(context, secondArg.basePtr, (startIndex >= str.Length) ? string.Empty : str.Substring(startIndex)); topArg.basePtr++; secondArg.basePtr++; } context.PopFrame(); }
internal override Opcode Eval(ProcessingContext context) { XPathNavigator contextNode = context.Processor.ContextNode; if ((contextNode != null) && (context.Processor.ContextMessage != null)) { ((SeekableMessageNavigator) contextNode).Atomize(); } if (this.argCount == 0) { context.PushFrame(); int iterationCount = context.IterationCount; if (iterationCount > 0) { object obj2 = this.function.Invoke(this.xsltContext, NullArgs, contextNode); switch (this.function.ReturnType) { case XPathResultType.Number: context.Push((double) obj2, iterationCount); goto Label_03F6; case XPathResultType.String: context.Push((string) obj2, iterationCount); goto Label_03F6; case XPathResultType.Boolean: context.Push((bool) obj2, iterationCount); goto Label_03F6; case XPathResultType.NodeSet: { NodeSequence sequence = context.CreateSequence(); XPathNodeIterator iter = (XPathNodeIterator) obj2; sequence.Add(iter); context.Push(sequence, iterationCount); goto Label_03F6; } } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ReturnType.ToString() }))); } } else { object[] args = new object[this.argCount]; int count = context.TopArg.Count; for (int i = 0; i < count; i++) { for (int k = 0; k < this.argCount; k++) { StackFrame frame = context[k]; switch (this.function.ArgTypes[k]) { case XPathResultType.Number: args[k] = context.PeekDouble(frame[i]); break; case XPathResultType.String: args[k] = context.PeekString(frame[i]); break; case XPathResultType.Boolean: args[k] = context.PeekBoolean(frame[i]); break; case XPathResultType.NodeSet: { NodeSequenceIterator item = new NodeSequenceIterator(context.PeekSequence(frame[i])); args[k] = item; this.iterList.Add(item); break; } default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ArgTypes[k].ToString() }))); } } object obj3 = this.function.Invoke(this.xsltContext, args, contextNode); if (this.iterList != null) { for (int m = 0; m < this.iterList.Count; m++) { this.iterList[m].Clear(); } this.iterList.Clear(); } switch (this.function.ReturnType) { case XPathResultType.Number: { StackFrame frame4 = context[this.argCount - 1]; context.SetValue(context, frame4[i], (double) obj3); break; } case XPathResultType.String: { StackFrame frame3 = context[this.argCount - 1]; context.SetValue(context, frame3[i], (string) obj3); break; } case XPathResultType.Boolean: { StackFrame frame5 = context[this.argCount - 1]; context.SetValue(context, frame5[i], (bool) obj3); break; } case XPathResultType.NodeSet: { NodeSequence val = context.CreateSequence(); XPathNodeIterator iterator3 = (XPathNodeIterator) obj3; val.Add(iterator3); StackFrame frame6 = context[this.argCount - 1]; context.SetValue(context, frame6[i], val); break; } default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ReturnType.ToString() }))); } } for (int j = 0; j < (this.argCount - 1); j++) { context.PopFrame(); } } Label_03F6: return base.next; }