Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PdbLocalScope"/> class.
        /// </summary>
        /// <param name="function">Function that contains this scope.</param>
        /// <param name="block">Block symbol read from PDB.</param>
        /// <param name="parent">Parent scope.</param>
        internal PdbLocalScope(PdbFunction function, BlockSymbol block, PdbLocalScope parent = null)
        {
            Function      = function;
            Block         = block;
            Parent        = parent;
            childrenCache = SimpleCache.CreateStruct(() =>
            {
                IEnumerable <BlockSymbol> blocks = Block.Children.OfType <BlockSymbol>();
                int count = blocks.Count();
                IPdbLocalScope[] children = new IPdbLocalScope[count];
                int i = 0;

                foreach (BlockSymbol b in blocks)
                {
                    children[i++] = new PdbLocalScope(Function, b, this);
                }
                return(children);
            });
            constantsCache = SimpleCache.CreateStruct(() =>
            {
                IEnumerable <ConstantSymbol> symbols = Block.Children.OfType <ConstantSymbol>();
                int count = symbols.Count();
                IPdbLocalConstant[] constants = new IPdbLocalConstant[count];
                int i = 0;

                foreach (ConstantSymbol symbol in symbols)
                {
                    constants[i++] = new PdbLocalConstant(this, symbol);
                }
                return(constants);
            });
            variablesCache = SimpleCache.CreateStruct(() =>
            {
                IEnumerable <AttributeSlotSymbol> slots = Block.Children.OfType <AttributeSlotSymbol>();
                int count = slots.Count();
                IPdbLocalVariable[] variables = new IPdbLocalVariable[count];
                int i = 0;

                foreach (AttributeSlotSymbol slot in slots)
                {
                    variables[i++] = new PdbLocalVariable(this, slot);
                }
                return(variables);
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PdbLocalScope"/> class.
        /// </summary>
        /// <param name="function">Function that contains this scope.</param>
        /// <param name="handle">Our metadata reader handle.</param>
        /// <param name="parent">Parent scope.</param>
        internal PdbLocalScope(PdbFunction function, LocalScopeHandle handle, IPdbLocalScope parent = null)
        {
            Function        = function;
            localScopeCache = SimpleCache.CreateStruct(() => function.PdbFile.Reader.GetLocalScope(handle));
            childrenCache   = SimpleCache.CreateStruct(() =>
            {
                var enumerator = LocalScope.GetChildren();
                List <IPdbLocalScope> children = new List <IPdbLocalScope>();

                while (enumerator.MoveNext())
                {
                    children.Add(new PdbLocalScope(function, enumerator.Current, this));
                }
                return(children);
            });
            constantsCache = SimpleCache.CreateStruct(() =>
            {
                var localConstants            = LocalScope.GetLocalConstants();
                IPdbLocalConstant[] constants = new IPdbLocalConstant[localConstants.Count];
                int i = 0;

                foreach (var c in localConstants)
                {
                    constants[i++] = new PdbLocalConstant(this, c);
                }
                return(constants);
            });
            variablesCache = SimpleCache.CreateStruct(() =>
            {
                var localVariables            = LocalScope.GetLocalVariables();
                IPdbLocalVariable[] variables = new IPdbLocalVariable[localVariables.Count];
                int i = 0;

                foreach (var v in localVariables)
                {
                    variables[i++] = new PdbLocalVariable(this, v);
                }
                return(variables);
            });
        }