XmlILAnnotation.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / XmlUtils / System / Xml / Xsl / IlGen / XmlILAnnotation.cs / 1305376 / XmlILAnnotation.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// [....] 
//-----------------------------------------------------------------------------
using System; 
using System.Reflection; 
using System.Xml.Xsl.Qil;
 
namespace System.Xml.Xsl.IlGen {

    /// 
    /// Several annotations are created and attached to Qil nodes during the optimization and code generation phase. 
    /// 
    internal class XmlILAnnotation : ListBase { 
        private object annPrev; 
        private MethodInfo funcMethod;
        private int argPos; 
        private IteratorDescriptor iterInfo;
        private XmlILConstructInfo constrInfo;
        private OptimizerPatterns optPatt;
 

        //----------------------------------------------- 
        // Constructor 
        //-----------------------------------------------
 
        /// 
        /// Create and initialize XmlILAnnotation for the specified node.
        /// 
        public static XmlILAnnotation Write(QilNode nd) { 
            XmlILAnnotation ann = nd.Annotation as XmlILAnnotation;
 
            if (ann == null) { 
                ann = new XmlILAnnotation(nd.Annotation);
                nd.Annotation = ann; 
            }

            return ann;
        } 

        private XmlILAnnotation(object annPrev) { 
            this.annPrev = annPrev; 
        }
 

        //-----------------------------------------------
        // Annotations
        //----------------------------------------------- 

        ///  
        /// User-defined functions and global variables and parameters are bound to Clr MethodInfo objects. 
        /// Attached to Function, global Let, and global Parameter nodes.
        ///  
        public MethodInfo FunctionBinding {
            get { return this.funcMethod; }
            set { this.funcMethod = value; }
        } 

        ///  
        /// Function arguments are tracked by position. 
        /// Attached to function Parameter nodes.
        ///  
        public int ArgumentPosition {
            get { return this.argPos; }
            set { this.argPos = value; }
        } 

        ///  
        /// The IteratorDescriptor that is derived for Qil For and Let nodes is cached so that it can be used when the 
        /// For/Let node is referenced.
        /// Attached to For and Let nodes. 
        /// 
        public IteratorDescriptor CachedIteratorDescriptor {
            get { return this.iterInfo; }
            set { this.iterInfo = value; } 
        }
 
        ///  
        /// Contains information about how this expression will be constructed by ILGen.
        /// Attached to any kind of Qil node. 
        /// 
        public XmlILConstructInfo ConstructInfo {
            get { return this.constrInfo; }
            set { this.constrInfo = value; } 
        }
 
        ///  
        /// Contains patterns that the subtree rooted at this node matches.
        /// Attached to any kind of Qil node. 
        /// 
        public OptimizerPatterns Patterns {
            get { return this.optPatt; }
            set { this.optPatt = value; } 
        }
 
 
        //-----------------------------------------------
        // ListBase implementation 
        //-----------------------------------------------

        /// 
        /// Return the count of sub-annotations maintained by this annotation. 
        /// 
        public override int Count { 
            get { return (this.annPrev != null) ? 3 : 2; } 
        }
 
        /// 
        /// Return the annotation at the specified index.
        /// 
        public override object this[int index] { 
            get {
                if (this.annPrev != null) { 
                    if (index == 0) 
                        return this.annPrev;
 
                    index--;
                }

                switch (index) { 
                    case 0: return this.constrInfo;
                    case 1: return this.optPatt; 
                } 

                throw new IndexOutOfRangeException(); 
            }
            set {
                throw new NotSupportedException();
            } 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.


                        

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK