Beispiel #1
0
        private static IReadOnlyList <Property> GetLocalsForStackEntry(EvaluationState evalState, int frameIndex)
        {
            var stackEntry = evalState.GetStackEntryForFrame(frameIndex);

            return(DebugInfo.ComputeCurrentLocals(stackEntry)
                   .Select(lvar => new Property(lvar.Name.ToDisplayString(evalState.Context), lvar.Value))
                   .ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// Creates a simulation of a local scope such that passed local variable indexes match
        /// </summary>
        private static FunctionScope BuildLocalScopeForLocalVars(Context context, StackEntry stackEntry)
        {
            var stringTable = context.StringTable;
            var localScope  = new FunctionScope();

            var localVariables = DebugInfo.ComputeCurrentLocals(stackEntry);

            if (localVariables.Count == 0)
            {
                return(localScope);
            }

            // Sort variables by index
            var localsByIndex = new SortedDictionary <int, ILocalVar>();

            foreach (var localVar in localVariables)
            {
                localsByIndex[localVar.Index] = localVar;
            }

            // Construct a local scope where variable indexes are respected, filling with dummy variables if there are holes in the index range
            int currentIndex = 0;

            foreach (int index in localsByIndex.Keys)
            {
                Contract.Assert(currentIndex <= index);

                while (index != currentIndex)
                {
                    var dummyIndex = localScope.AddVariable(SymbolAtom.Create(stringTable, "__dummy_var__" + currentIndex), default(UniversalLocation), isConstant: false);
                    Contract.Assert(dummyIndex != null);
                    currentIndex++;
                }

                var indexResult = localScope.AddVariable(localsByIndex[index].Name, default(UniversalLocation), isConstant: false);
                Contract.Assert(indexResult == index);
                currentIndex++;
            }

            return(localScope);
        }