Ejemplo n.º 1
0
        private int FindPrecedingIndex(int startingIndex, BranchStackFrame frame, IEnumerator <BranchStackFrame> stack)
        {
            var index = startingIndex;

            while (true)
            {
                if (index < 0)
                {
                    this.ImportPrecedingIntoBranches(stack);
                    frame.CurrentIndex += 1;
                    index += 1;
                }

                var kind = frame.Elements[index].Kind;
                if (kind == ElementKind.Undefined)
                {
                    throw new InvalidOperationException("Element " + frame.Elements[index] + " must be identified as either statement or expression to be traversed over or captured.");
                }

                if (kind == ElementKind.Expression)
                {
                    return(index);
                }

                if (kind == ElementKind.Statement)
                {
                    index -= 1;
                }
            }
        }
Ejemplo n.º 2
0
        private void ApplyRecursive(IList<IElement> elements, Stack<BranchStackFrame> branchStack, DecompilationContext context)
        {
            for (var i = 0; i < elements.Count; i++) {
                var element = elements[i];
                var branching = element as BranchingElement;
                if (branching != null) {
                    foreach (var branch in branching.GetBranches()) {
                        var frame = new BranchStackFrame(elements, branching, i);
                        branchStack.Push(frame);
                        this.ApplyRecursive(branch, branchStack, context);
                        branchStack.Pop();

                        i = frame.CurrentIndex;
                    }
                }

                this.ApplyToSpecificElement(ref i, elements, branchStack, context);
            }
        }
Ejemplo n.º 3
0
        private int GetPrecedingIndex()
        {
            //BranchStackFrame frame;
            //IEnumerator<BranchStackFrame> stackEnumerator;

            //if (branchStack.Count == 0) {
            var frame           = new BranchStackFrame(this.elements, null, this.CurrentIndex);
            var stackEnumerator = this.branchStack.GetEnumerator();
            //}
            //else {
            //    stackEnumerator = this.branchStack.GetEnumerator();
            //    stackEnumerator.MoveNext();
            //    frame = stackEnumerator.Current;
            //}

            var index = this.FindPrecedingIndex(this.CurrentIndex - 1, frame, stackEnumerator);

            this.CurrentIndex = frame.CurrentIndex;
            return(index);
        }
        private int FindPrecedingIndex(int startingIndex, BranchStackFrame frame, IEnumerator<BranchStackFrame> stack)
        {
            var index = startingIndex;
            while (true) {
                if (index < 0) {
                    this.ImportPrecedingIntoBranches(stack);
                    frame.CurrentIndex += 1;
                    index += 1;
                }

                var kind = frame.Elements[index].Kind;
                if (kind == ElementKind.Undefined)
                    throw new InvalidOperationException("Element " + frame.Elements[index] + " must be identified as either statement or expression to be traversed over or captured.");

                if (kind == ElementKind.Expression)
                    return index;

                if (kind == ElementKind.Statement)
                    index -= 1;
            }
        }
Ejemplo n.º 5
0
        private void ApplyRecursive(IList <IElement> elements, Stack <BranchStackFrame> branchStack, DecompilationContext context)
        {
            for (var i = 0; i < elements.Count; i++)
            {
                var element   = elements[i];
                var branching = element as BranchingElement;
                if (branching != null)
                {
                    foreach (var branch in branching.GetBranches())
                    {
                        var frame = new BranchStackFrame(elements, branching, i);
                        branchStack.Push(frame);
                        this.ApplyRecursive(branch, branchStack, context);
                        branchStack.Pop();

                        i = frame.CurrentIndex;
                    }
                }

                this.ApplyToSpecificElement(ref i, elements, branchStack, context);
            }
        }
        private int GetPrecedingIndex()
        {
            //BranchStackFrame frame;
            //IEnumerator<BranchStackFrame> stackEnumerator;

            //if (branchStack.Count == 0) {
                var frame = new BranchStackFrame(this.elements, null, this.CurrentIndex);
                var stackEnumerator = this.branchStack.GetEnumerator();
            //}
            //else {
            //    stackEnumerator = this.branchStack.GetEnumerator();
            //    stackEnumerator.MoveNext();
            //    frame = stackEnumerator.Current;
            //}

            var index = this.FindPrecedingIndex(this.CurrentIndex - 1, frame, stackEnumerator);
            this.CurrentIndex = frame.CurrentIndex;
            return index;
        }