Beispiel #1
0
 internal QueryFunction(string name, ValueDataType returnType, ValueDataType[] paramTypes, QueryFunctionFlag flags)
 {
     this.name       = name;
     this.returnType = returnType;
     this.paramTypes = paramTypes;
     this.flags      = flags;
 }
Beispiel #2
0
 public static string Resolve(ValueDataType dataType)
 {
     switch (dataType)
     {
         case ValueDataType.Int:
             return typeof(int).ToString();
         case ValueDataType.Decimal:
             return typeof(decimal).ToString();
         case ValueDataType.ByteArray:
             return typeof(byte[]).ToString();
         case ValueDataType.DateTime:
             return typeof(DateTime).ToString();
         case ValueDataType.Bool:
             return typeof(bool).ToString();
         case ValueDataType.Image:
             return typeof(Image).ToString();
         case ValueDataType.Json:
             return "Json";
         case ValueDataType.Xml:
             return "Xml";
         case ValueDataType.String:
             return typeof(string).ToString();
         default:
             return "Custom";
     }
 }
Beispiel #3
0
            void CompileXsltFunction(XPathXsltFunctionExpr expr)
            {
                // Compile each argument expression first, introducing a typecast where appropriate
                // Arguments are pushed C style - right to left
                if (expr.SubExprCount > 0)
                {
                    XPathExprList paramList = expr.SubExpr;
                    for (int i = paramList.Count - 1; i >= 0; --i)
                    {
                        XPathExpr param = paramList[i];
                        this.CompileExpression(param);
                        ValueDataType paramType = XPathXsltFunctionExpr.ConvertTypeFromXslt(expr.Function.ArgTypes[i]);
                        if (ValueDataType.None != paramType)
                        {
                            if (param.ReturnType != paramType)
                            {
                                this.CompileTypecast(paramType);
                            }
                        }
                    }
                }

                if (expr.Function is XPathMessageFunction)
                {
                    this.codeBlock.Append(new XPathMessageFunctionCallOpcode((XPathMessageFunction)expr.Function, expr.SubExprCount));
                    if (IsSpecialInternalFunction(expr))
                    {
                        this.codeBlock.Append(new PopSequenceToValueStackOpcode());
                    }
                }
                else
                {
                    this.codeBlock.Append(new XsltFunctionCallOpcode(expr.Context, expr.Function, expr.SubExprCount));
                }
            }
 public ValueObject(string text, ValueDataType type)
 {
     DirtyObserver = new DirtyObserver(this);
     EnumValues    = new ObservableCollection <EnumValue>();
     DataType      = type;
     Text          = text;
 }
Beispiel #5
0
 private void CompileXsltFunction(XPathXsltFunctionExpr expr)
 {
     if (expr.SubExprCount > 0)
     {
         XPathExprList subExpr = expr.SubExpr;
         for (int i = subExpr.Count - 1; i >= 0; i--)
         {
             XPathExpr expr2 = subExpr[i];
             this.CompileExpression(expr2);
             ValueDataType destType = XPathXsltFunctionExpr.ConvertTypeFromXslt(expr.Function.ArgTypes[i]);
             if ((destType != ValueDataType.None) && (expr2.ReturnType != destType))
             {
                 this.CompileTypecast(destType);
             }
         }
     }
     if (expr.Function is XPathMessageFunction)
     {
         this.codeBlock.Append(new XPathMessageFunctionCallOpcode((XPathMessageFunction)expr.Function, expr.SubExprCount));
         if (this.IsSpecialInternalFunction(expr))
         {
             this.codeBlock.Append(new PopSequenceToValueStackOpcode());
         }
     }
     else
     {
         this.codeBlock.Append(new XsltFunctionCallOpcode(expr.Context, expr.Function, expr.SubExprCount));
     }
 }
Beispiel #6
0
        public static string Resolve(ValueDataType dataType)
        {
            switch (dataType)
            {
            case ValueDataType.Int:
                return(typeof(int).ToString());

            case ValueDataType.Decimal:
                return(typeof(decimal).ToString());

            case ValueDataType.ByteArray:
                return(typeof(byte[]).ToString());

            case ValueDataType.DateTime:
                return(typeof(DateTime).ToString());

            case ValueDataType.Bool:
                return(typeof(bool).ToString());

            case ValueDataType.Image:
                return(typeof(Image).ToString());

            case ValueDataType.Json:
                return("Json");

            case ValueDataType.Xml:
                return("Xml");

            case ValueDataType.String:
                return(typeof(string).ToString());

            default:
                return("Custom");
            }
        }
Beispiel #7
0
        internal void ConvertTo(ProcessingContext context, ValueDataType newType)
        {
            if (newType != this.type)
            {
                switch (newType)
                {
                case ValueDataType.Boolean:
                    this.boolVal = this.ToBoolean();
                    break;

                case ValueDataType.Double:
                    this.dblVal = this.ToDouble();
                    break;

                case ValueDataType.String:
                    this.strVal = this.ToString();
                    break;
                }
                if (ValueDataType.Sequence == this.type)
                {
                    this.ReleaseSequence(context);
                }
                this.type = newType;
            }
        }
 internal QueryFunction(string name, ValueDataType returnType, ValueDataType[] paramTypes, QueryFunctionFlag flags)
 {
     this.name = name;
     this.returnType = returnType;
     this.paramTypes = paramTypes;
     this.flags = flags;
 }
        internal void ConvertTo(ProcessingContext context, ValueDataType newType)
        {
            Fx.Assert(null != context, "");

            if (newType == this.type)
            {
                return;
            }

            switch (newType)
            {
            default:
                break;

            case ValueDataType.Boolean:
                this.boolVal = this.ToBoolean();
                break;

            case ValueDataType.Double:
                this.dblVal = this.ToDouble();
                break;

            case ValueDataType.String:
                this.strVal = this.ToString();
                break;
            }

            if (ValueDataType.Sequence == this.type)
            {
                this.ReleaseSequence(context);
            }
            this.type = newType;
        }
        public static ActionObject Create(string text, ValueDataType type)
        {
            ActionObject ao = new ActionObject();

            ao.Name     = text;
            ao.DataType = type;
            return(ao);
        }
Beispiel #11
0
 public int DynamicAdjustor(ValueDataInfo vd, ValueDataType type)
 {
     if (type == ValueDataType.TYPE_TOTAL)
     {
         return(this.GenericCalculator(vd, DynamicProperty.Adjustor(vd)));
     }
     return(this.GenericBaseCalculator(vd, DynamicProperty.Adjustor(vd)));
 }
Beispiel #12
0
 public int EpRecCalculator(ValueDataInfo vd, ValueDataType type)
 {
     if (type == ValueDataType.TYPE_TOTAL)
     {
         return(this.EpProportionCalculator(vd, vd.baseValue));
     }
     return(this.EpBaseProportionCalculator(vd, vd.baseValue));
 }
Beispiel #13
0
 internal void Clear(ProcessingContext context)
 {
     if (ValueDataType.Sequence == this.type)
     {
         this.ReleaseSequence(context);
     }
     this.type = ValueDataType.None;
 }
Beispiel #14
0
 public int GrowCalculator(ValueDataInfo vd, ValueDataType type)
 {
     if (type == ValueDataType.TYPE_TOTAL)
     {
         return(this.GenericCalculator(vd, vd.baseValue));
     }
     return(this.GenericBaseCalculator(vd, vd.baseValue));
 }
Beispiel #15
0
 public int EpGrowCalculator(ValueDataInfo vd, ValueDataType type)
 {
     if (type == ValueDataType.TYPE_TOTAL)
     {
         return(this.EpNumericalCalculator(vd, vd.baseValue));
     }
     return(this.EpBaseNumericalCalculator(vd, vd.baseValue));
 }
Beispiel #16
0
 internal XPathConjunctExpr(XPathExprType type, ValueDataType returnType, XPathExpr left, XPathExpr right) : base(type, returnType)
 {
     if ((left == null) || (right == null))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.InvalidExpression));
     }
     base.SubExpr.Add(left);
     base.SubExpr.Add(right);
 }
 internal static ValueDataType[] MakeTypes(int size)
 {
     ValueDataType[] typeArray = new ValueDataType[size];
     for (int i = 0; i < size; i++)
     {
         typeArray[i] = ValueDataType.String;
     }
     return(typeArray);
 }
 internal XPathConjunctExpr(XPathExprType type, ValueDataType returnType, XPathExpr left, XPathExpr right) : base(type, returnType)
 {
     if ((left == null) || (right == null))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.InvalidExpression));
     }
     base.SubExpr.Add(left);
     base.SubExpr.Add(right);
 }
Beispiel #19
0
 public int DynamicAdjustorForMgcEffect(ValueDataInfo vd, ValueDataType type)
 {
     if (type == ValueDataType.TYPE_TOTAL)
     {
         int num = this.GenericCalculator(vd, DynamicProperty.Adjustor(vd));
         return(num + vd.totalEftValueByMgc);
     }
     return(this.GenericBaseCalculator(vd, DynamicProperty.Adjustor(vd)));
 }
 internal static ValueDataType[] MakeTypes(int size)
 {
     ValueDataType[] typeArray = new ValueDataType[size];
     for (int i = 0; i < size; i++)
     {
         typeArray[i] = ValueDataType.String;
     }
     return typeArray;
 }
Beispiel #21
0
 internal static ValueDataType[] MakeTypes(int size)
 {
     ValueDataType[] t = new ValueDataType[size];
     for (int i = 0; i < size; ++i)
     {
         t[i] = ValueDataType.String;
     }
     return(t);
 }
Beispiel #22
0
        internal void Add(string expression, XmlNamespaceManager names, object item, bool forceExternal)
        {
            Fx.Assert(null != item, "");

            // Compile the new filter

            bool        compiled  = false;
            OpcodeBlock codeBlock = new OpcodeBlock();

            codeBlock.Append(new NoOpOpcode(OpcodeID.QueryTree));
            if (!forceExternal)
            {
                try
                {
                    ValueDataType returnType = ValueDataType.None;

                    // Try to compile and merge the compiled query into the query tree
                    codeBlock.Append(QueryMatcher.CompileForInternalEngine(expression, names, QueryCompilerFlags.InverseQuery, out returnType));

                    MultipleResultOpcode opcode;

                    if (!this.match)
                    {
                        opcode = new QueryMultipleResultOpcode();
                    }
                    else
                    {
                        opcode = new MatchMultipleResultOpcode();
                    }

                    opcode.AddItem(item);
                    codeBlock.Append(opcode);
                    compiled = true;

                    // Perform SubExpression Elimination
                    codeBlock        = new OpcodeBlock(this.elim.Add(item, codeBlock.First));
                    this.subExprVars = this.elim.VariableCount;
                }
                catch (QueryCompileException)
                {
                    // If the filter couldn't be compiled, we drop down to the framework engine
                }
            }

            if (!compiled)
            {
                codeBlock.Append(QueryMatcher.CompileForExternalEngine(expression, names, item, this.match));
            }

            // Merge the compiled query into the query tree
            QueryTreeBuilder builder = new QueryTreeBuilder();

            this.query = builder.Build(this.query, codeBlock);
            // To de-merge this filter from the tree, we'll have to walk backwards up the tree... so we
            // have to remember the last opcode that is executed on behalf of this filter
            this.lastLookup[item] = builder.LastOpcode;
        }
Beispiel #23
0
        private static void ConvertFirstArg(ProcessingContext context, ValueDataType type)
        {
            StackFrame topArg = context.TopArg;

            Value[] values = context.Values;
            while (topArg.basePtr <= topArg.endPtr)
            {
                values[topArg.basePtr++].ConvertTo(context, type);
            }
        }
Beispiel #24
0
        internal QueryFunction(string name, ValueDataType returnType, ValueDataType[] paramTypes, QueryFunctionFlag flags)
        {
            Fx.Assert(null != paramTypes, "");
            Fx.Assert(null != name, "");

            this.name       = name;
            this.returnType = returnType;
            this.paramTypes = paramTypes;
            this.flags      = flags;
        }
Beispiel #25
0
        public void ConvertEnum(string xml, ValueDataType expectedResult)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            var result = doc.DocumentElement.GetAttributeEnumValue <ValueDataType>("value");

            Assert.That(result == expectedResult);
        }
Beispiel #26
0
        internal override Opcode Eval(ProcessingContext context)
        {
            Fx.Assert(this.results.Count > 0, "QueryMultipleQueryResultOpcode in the eval tree but no query present");
            Fx.Assert(context.Processor.ResultSet != null, "QueryMultipleQueryResultOpcode should only be used in eval cases");

            StackFrame    topFrame   = context.TopArg;
            ValueDataType resultType = context.Values[topFrame.basePtr].Type;
            XPathResult   result;

            switch (resultType)
            {
            case ValueDataType.Sequence:
            {
                SafeNodeSequenceIterator value = new SafeNodeSequenceIterator(context.Values[topFrame.basePtr].GetSequence(), context);
                result = new XPathResult(value);
            }
            break;

            case ValueDataType.Boolean:
            {
                bool value = context.Values[topFrame.basePtr].GetBoolean();
                result = new XPathResult(value);
            }
            break;

            case ValueDataType.String:
            {
                string value = context.Values[topFrame.basePtr].GetString();
                result = new XPathResult(value);
            }
            break;

            case ValueDataType.Double:
            {
                double value = context.Values[topFrame.basePtr].GetDouble();
                result = new XPathResult(value);
            }
            break;

            default:
                throw Fx.AssertAndThrow("Unexpected result type.");
            }

            context.Processor.ResultSet.Add(new KeyValuePair <MessageQuery, XPathResult>((MessageQuery)this.results[0], result));

            for (int i = 1; i < this.results.Count; i++)
            {
                context.Processor.ResultSet.Add(new KeyValuePair <MessageQuery, XPathResult>((MessageQuery)this.results[i], result.Copy()));
            }

            context.PopFrame();
            return(this.next);
        }
Beispiel #27
0
 public ConfigurationBase(string title, MainConfigType mainConfigType, ConfigArea configArea, ValueDataType valueDataType, Typography typography, ValueRepresentation valueRepresentation, ValueEditType valueEditType, ConfigRange configRange, int processingIndex)
 {
     Title = title;
     this.mainConfigType = mainConfigType;
     this.configArea     = configArea;
     ValueDataType       = valueDataType;
     Typography          = typography;
     ValueRepresentation = valueRepresentation;
     ValueEditType       = valueEditType;
     this.configRange    = configRange;
     ProcessingIndex     = processingIndex;
 }
Beispiel #28
0
 public BaseData(ConfigurationBase initializationData)
 {
     title                = initializationData.Title;
     mainConfigType       = initializationData.GetMainConfigType;
     configArea           = initializationData.GetConfigArea;
     valueDataType        = initializationData.ValueDataType;
     typography           = initializationData.Typography;
     valueRepresentation  = initializationData.ValueRepresentation;
     valueEditType        = initializationData.ValueEditType;
     configRange          = initializationData.configRange;
     this.processingIndex = initializationData.ProcessingIndex;
 }
Beispiel #29
0
        private void Load(XmlElement element, out ActionObject action)
        {
            string        name = element.GetAttributeStringValue(XmlNames.NameAttributeName);
            ValueDataType type = element.GetAttributeEnumValue <ValueDataType>(XmlNames.TypeAttributeName);

            action             = ActionObject.Create(name, type);
            action.LoadSaveId  = element.GetAttributeIntValue(XmlNames.IdAttributeName, XmlElementOption.MustHaveValue);
            action.DefaultText = element.GetAttributeStringValue(XmlNames.DefaultTextAttributeName, XmlElementOption.Optional);
            action.DefaultBool = element.GetAttributeBoolValue(XmlNames.DefaultBoolAttributeName);
            action.TooltipText = element.GetAttributeStringValue(XmlNames.TooltipTextAttributeName);
            LoadEnumValues(element, action);
        }
Beispiel #30
0
        public int DynamicAdjustorForMgcEffect(ValueDataInfo vd, ValueDataType type)
        {
            if (type != ValueDataType.TYPE_TOTAL)
            {
                return(this.GenericBaseCalculator(vd, DynamicProperty.Adjustor(vd)));
            }
            int num = this.GenericCalculator(vd, DynamicProperty.Adjustor(vd));

            if (vd.totalEftRatioByMgc > 0)
            {
                num += (vd.totalEftRatioByMgc * this.mActorValue[2].totalValue) / 0x2710;
            }
            return(num);
        }
Beispiel #31
0
        private void SetEditor(ValueDataType dataType)
        {
            switch (dataType)
            { 
                case ValueDataType.Int:
                    Editor = new SettingsIntEditor();
                    break;

                case ValueDataType.String:
                    Editor = new SettingsStringEditor();
                    break;

                case ValueDataType.Decimal:
                    Editor = new SettingsDecimalEditor();
                    break;

                case ValueDataType.ByteArray:
                    Editor = new SettingsBinaryEditor();
                    break;

                case ValueDataType.DateTime:
                    Editor = new SettingsDateTimeEditor();
                    break;

                case ValueDataType.Bool:
                    Editor = new SettingsBooleanEditor();
                    break;

                case ValueDataType.Json:
                    Editor = new SettingsJsonEditor();
                    break;

                case ValueDataType.Xml:
                    Editor = new SettingsXmlEditor();
                    break;

                case ValueDataType.Image:
                    Editor = new SettingsImageEditor();
                    break;

                default:
                    Editor = new SettingsCustomEditor();
                    break;
            }

            panelEditor.Controls.Clear();
            comboBox1.SelectedItem = Editor.ValueType.ToString();
            ((Control)Editor).Dock = DockStyle.Fill;
            panelEditor.Controls.Add((Control)Editor);
        }
Beispiel #32
0
        private void SetEditor(ValueDataType dataType)
        {
            switch (dataType)
            {
            case ValueDataType.Int:
                Editor = new SettingsIntEditor();
                break;

            case ValueDataType.String:
                Editor = new SettingsStringEditor();
                break;

            case ValueDataType.Decimal:
                Editor = new SettingsDecimalEditor();
                break;

            case ValueDataType.ByteArray:
                Editor = new SettingsBinaryEditor();
                break;

            case ValueDataType.DateTime:
                Editor = new SettingsDateTimeEditor();
                break;

            case ValueDataType.Bool:
                Editor = new SettingsBooleanEditor();
                break;

            case ValueDataType.Json:
                Editor = new SettingsJsonEditor();
                break;

            case ValueDataType.Xml:
                Editor = new SettingsXmlEditor();
                break;

            case ValueDataType.Image:
                Editor = new SettingsImageEditor();
                break;

            default:
                Editor = new SettingsCustomEditor();
                break;
            }

            panelEditor.Controls.Clear();
            comboBox1.SelectedItem = Editor.ValueType.ToString();
            ((Control)Editor).Dock = DockStyle.Fill;
            panelEditor.Controls.Add((Control)Editor);
        }
 internal PushXsltVariableOpcode(XsltContext context, IXsltContextVariable variable) : base(OpcodeID.PushXsltVariable)
 {
     this.xsltContext = context;
     this.variable    = variable;
     this.type        = XPathXsltFunctionExpr.ConvertTypeFromXslt(variable.VariableType);
     switch (this.type)
     {
     case ValueDataType.Boolean:
     case ValueDataType.Double:
     case ValueDataType.Sequence:
     case ValueDataType.String:
         return;
     }
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.InvalidType, System.ServiceModel.SR.GetString("QueryVariableTypeNotSupported", new object[] { this.variable.VariableType.ToString() })));
 }
        internal static XPathResultType ConvertTypeToXslt(ValueDataType type)
        {
            switch (type)
            {
            case ValueDataType.Boolean:
                return(XPathResultType.Boolean);

            case ValueDataType.Double:
                return(XPathResultType.Number);

            case ValueDataType.Sequence:
                return(XPathResultType.NodeSet);

            case ValueDataType.String:
                return(XPathResultType.String);
            }
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.InvalidTypeConversion));
        }
 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;
 }
Beispiel #36
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame    topFrame   = context.TopArg;
            ValueDataType resultType = context.Values[topFrame.basePtr].Type;
            XPathResult   result;

            switch (resultType)
            {
            case ValueDataType.Sequence:
            {
                SafeNodeSequenceIterator value = new SafeNodeSequenceIterator(context.Values[topFrame.basePtr].GetSequence(), context);
                result = new XPathResult(value);
            }
            break;

            case ValueDataType.Boolean:
            {
                bool value = context.Values[topFrame.basePtr].GetBoolean();
                result = new XPathResult(value);
            }
            break;

            case ValueDataType.String:
            {
                string value = context.Values[topFrame.basePtr].GetString();
                result = new XPathResult(value);
            }
            break;

            case ValueDataType.Double:
            {
                double value = context.Values[topFrame.basePtr].GetDouble();
                result = new XPathResult(value);
            }
            break;

            default:
                throw Fx.AssertAndThrow("Unexpected result type.");
            }

            context.Processor.QueryResult = result;
            context.PopFrame();
            return(this.next);
        }
 private void CompileTypecast(ValueDataType destType)
 {
     this.codeBlock.Append(new TypecastOpcode(destType));
 }
        internal static XPathResultType ConvertTypeToXslt(ValueDataType type)
        {
            switch (type)
            {
                case ValueDataType.Boolean:
                    return XPathResultType.Boolean;

                case ValueDataType.Double:
                    return XPathResultType.Number;

                case ValueDataType.Sequence:
                    return XPathResultType.NodeSet;

                case ValueDataType.String:
                    return XPathResultType.String;

                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.InvalidTypeConversion));
            }
        }
 internal TypecastOpcode(ValueDataType newType) : base(OpcodeID.Cast)
 {
     this.newType = newType;
 }
 internal void Clear(ProcessingContext context)
 {
     if (ValueDataType.Sequence == this.type)
     {
         this.ReleaseSequence(context);
     }
     this.type = ValueDataType.None;
 }
        internal static XPathResultType ResultType(ValueDataType dataType)
        {
            switch (dataType)
            {
                default:
                    break;
                    
                case ValueDataType.Boolean:
                    return XPathResultType.Boolean;

                case ValueDataType.Double:
                    return XPathResultType.Number;

                case ValueDataType.Sequence:
                    return XPathResultType.NodeSet;

                case ValueDataType.String:
                    return XPathResultType.String;
            }
            
            return XPathResultType.Any;
        }
 internal XPathExpr(XPathExprType type, ValueDataType returnType, XPathExprList subExpr) : this(type, returnType)
 {
     this.subExpr = subExpr;
 }
 internal XPathExpr(XPathExprType type, ValueDataType returnType)
 {
     this.type = type;
     this.returnType = returnType;
 }
 internal bool IsType(ValueDataType type)
 {
     return (type == this.type);
 }
 void CompileTypecast(ValueDataType destType)
 {
     Fx.Assert(ValueDataType.None != destType, "");
     this.codeBlock.Append(new TypecastOpcode(destType));
 }
 internal void Clear()
 {
     this.type = ValueDataType.None;
     this.sequence = null;
 }
        internal void ConvertTo(ProcessingContext context, ValueDataType newType)
        {
            if (newType != this.type)
            {
                switch (newType)
                {
                    case ValueDataType.Boolean:
                        this.boolVal = this.ToBoolean();
                        break;

                    case ValueDataType.Double:
                        this.dblVal = this.ToDouble();
                        break;

                    case ValueDataType.String:
                        this.strVal = this.ToString();
                        break;
                }
                if (ValueDataType.Sequence == this.type)
                {
                    this.ReleaseSequence(context);
                }
                this.type = newType;
            }
        }
        internal void ConvertTo(ProcessingContext context, ValueDataType newType)
        {
            Fx.Assert(null != context, "");

            if (newType == this.type)
            {
                return;
            }

            switch (newType)
            {
                default:
                    break;

                case ValueDataType.Boolean:
                    this.boolVal = this.ToBoolean();
                    break;

                case ValueDataType.Double:
                    this.dblVal = this.ToDouble();
                    break;

                case ValueDataType.String:
                    this.strVal = this.ToString();
                    break;
            }

            if (ValueDataType.Sequence == this.type)
            {
                this.ReleaseSequence(context);
            }
            this.type = newType;
        }
        internal QueryFunction(string name, ValueDataType returnType, ValueDataType[] paramTypes, QueryFunctionFlag flags)
        {
            Fx.Assert(null != paramTypes, "");
            Fx.Assert(null != name, "");

            this.name = name;
            this.returnType = returnType;
            this.paramTypes = paramTypes;
            this.flags = flags;
        }
 internal void StartFrame(int start)
 {
     this.type = ValueDataType.StackFrame;
     this.frame.basePtr = start + 1;
     this.frame.endPtr = start;
 }
 internal static ValueDataType[] MakeTypes(int size)
 {
     ValueDataType[] t = new ValueDataType[size];
     for (int i = 0; i < size; ++i)
     {
         t[i] = ValueDataType.String;
     }
     return t;
 }
 internal XPathLiteralExpr(XPathExprType type, ValueDataType returnType) : base(type, returnType)
 {
 }
 internal XPathFunction(XPathFunctionID functionID, string name, ValueDataType returnType, QueryFunctionFlag flags)
     : base(name, returnType, flags)
 {
     this.functionID = functionID;
 }
 internal XPathFunction(XPathFunctionID functionID, string name, ValueDataType returnType, ValueDataType[] argTypes)
     : base(name, returnType, argTypes)
 {
     this.functionID = functionID;
 }
        static void ConvertFirstArg(ProcessingContext context, ValueDataType type)
        {
            StackFrame arg = context.TopArg;
            Value[] values = context.Values;

            while (arg.basePtr <= arg.endPtr)
            {
                values[arg.basePtr++].ConvertTo(context, type);
            }
        }
 internal QueryFunction(string name, ValueDataType returnType, QueryFunctionFlag flags)
     : this(name, returnType, QueryFunction.emptyParams, flags)
 {
 }
 internal QueryFunction(string name, ValueDataType returnType) : this(name, returnType, emptyParams, QueryFunctionFlag.None)
 {
 }
        internal PushXsltVariableOpcode(XsltContext context, IXsltContextVariable variable)
            : base(OpcodeID.PushXsltVariable)
        {
            Fx.Assert(null != context && null != variable, "");

            this.xsltContext = context;
            this.variable = variable;
            this.type = XPathXsltFunctionExpr.ConvertTypeFromXslt(variable.VariableType);

            // Make sure the type is supported
            switch (this.type)
            {
                case ValueDataType.Boolean:
                case ValueDataType.Double:
                case ValueDataType.String:
                case ValueDataType.Sequence:
                    break;

                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.InvalidType, SR.GetString(SR.QueryVariableTypeNotSupported, this.variable.VariableType.ToString())));
            }
        }
 internal QueryFunction(string name, ValueDataType returnType, ValueDataType[] paramTypes)
     : this(name, returnType, paramTypes, QueryFunctionFlag.None)
 {
 }