Esempio n. 1
0
 internal GenericSeekableNavigator(GenericSeekableNavigator navigator)
 {
     this.navigator       = navigator.navigator.Clone();
     this.nodes           = default(QueryBuffer <XPathNavigator>);
     this.currentPosition = navigator.currentPosition;
     this.dom             = navigator.dom;
 }
Esempio n. 2
0
 internal GenericSeekableNavigator(XPathNavigator navigator)
 {
     this.navigator       = navigator;
     this.nodes           = new QueryBuffer <XPathNavigator>(4);
     this.currentPosition = -1;
     this.dom             = this;
 }
        void FixupJumps()
        {
            QueryBuffer <Opcode> treePath   = this.diverger.TreePath;
            QueryBuffer <Opcode> insertPath = this.diverger.InsertPath;

            for (int i = 0; i < insertPath.Count; ++i)
            {
                if (insertPath[i].TestFlag(OpcodeFlags.Jump))
                {
                    Fx.Assert(treePath[i].ID == insertPath[i].ID, "");
                    JumpOpcode insertJump = (JumpOpcode)insertPath[i];
                    // Opcodes in 'insertPath' have equivalent opcodes in the query tree: i.e. the query tree contains an
                    // an equivalent execution path (upto the point of divergence naturally) that will produce in an identical
                    // result. The remainder of the query tree (anything that lies beyond the point of divergence) represents
                    // a distinct execution path and is grafted onto the tree as a new branch. In fact, we simply break off
                    // the remainder from the query being inserted and graft it onto the query tree.
                    // If there are jumps on the insert path that jump to opcodes NOT in the insert path, then the jumps
                    // will reach opcodes in the new branch we will add(see above). However, because the actual jump opcodes
                    // are shared (used as is from the query tree), the actual jump must also be branched. One jump will
                    // continue to jump to the original opcode and the second new one will jump to an opcode in the grafted branch.
                    if (-1 == insertPath.IndexOf(insertJump.Jump, i + 1))
                    {
                        Fx.Assert(insertJump.Jump.ID == OpcodeID.BlockEnd, "");

                        BlockEndOpcode jumpTo = (BlockEndOpcode)insertJump.Jump;
                        // no longer jumping from insertJump to jumpTo
                        insertJump.RemoveJump(jumpTo);

                        // Instead, jumping from treePath[i] to jumpTo
                        JumpOpcode treeJump = (JumpOpcode)treePath[i];
                        treeJump.AddJump(jumpTo);
                    }
                }
            }
        }
 internal Diverger(Opcode tree, Opcode insert)
 {
     this.treePath     = new QueryBuffer <Opcode>(16);
     this.insertPath   = new QueryBuffer <Opcode>(16);
     this.treeOpcode   = tree;
     this.insertOpcode = insert;
 }
Esempio n. 5
0
        internal void CopyFrom(ref QueryBuffer <T> addBuffer)
        {
            int addCount = addBuffer.count;

            switch (addCount)
            {
            default:
                if (addCount > this.buffer.Length)
                {
                    this.buffer = new T[addCount];
                }
                // Copy all the new elements in
                Array.Copy(addBuffer.buffer, 0, this.buffer, 0, addCount);
                this.count = addCount;
                break;

            case 0:
                this.count = 0;
                break;

            case 1:
                if (this.buffer.Length == 0)
                {
                    this.buffer = new T[1];
                }
                this.buffer[0] = addBuffer.buffer[0];
                this.count     = 1;
                break;
            }
        }
        internal void CopyFrom(ref QueryBuffer <T> addBuffer)
        {
            int count = addBuffer.count;

            switch (count)
            {
            case 0:
                this.count = 0;
                return;

            case 1:
                if (this.buffer.Length == 0)
                {
                    this.buffer = new T[1];
                }
                this.buffer[0] = addBuffer.buffer[0];
                this.count     = 1;
                return;
            }
            if (count > this.buffer.Length)
            {
                this.buffer = new T[count];
            }
            Array.Copy(addBuffer.buffer, 0, this.buffer, 0, count);
            this.count = count;
        }
Esempio n. 7
0
 internal EvalStack(ref EvalStack stack)
 {
     this.buffer        = new QueryBuffer <Value>(stack.buffer);
     this.stackCapacity = stack.stackCapacity;
     this.frameCapacity = stack.frameCapacity;
     this.stack         = stack.stack;
     this.frames        = stack.frames;
 }
Esempio n. 8
0
 internal EvalStack(int frameCapacity, int stackCapacity)
 {
     this.buffer = new QueryBuffer <Value>(frameCapacity + stackCapacity);
     this.stack  = new StackRegion(new QueryRange(0, stackCapacity - 1));
     this.buffer.Reserve(stackCapacity);
     this.frames = new StackRegion(new QueryRange(stackCapacity, (stackCapacity + frameCapacity) - 1));
     this.buffer.Reserve(frameCapacity);
     this.contextOnTopOfStack = false;
 }
Esempio n. 9
0
        internal void Init(Value[] buffer, int stackCapacity, int frameCapacity)
        {
            Fx.Assert(null != buffer, "");
            this.stackCapacity = stackCapacity;
            this.frameCapacity = frameCapacity;

            this.buffer = new QueryBuffer <Value>(buffer);
            this.stack  = new StackRegion(new QueryRange(0, stackCapacity - 1));
            this.buffer.Reserve(stackCapacity);
            this.frames = new StackRegion(new QueryRange(stackCapacity, stackCapacity + frameCapacity - 1));
            this.buffer.Reserve(frameCapacity);
        }
Esempio n. 10
0
        internal EvalStack(int frameCapacity, int stackCapacity)
        {
            Fx.Assert(frameCapacity >= 0 && stackCapacity >= 0, "");

            // All structs! Cost of allocation is relatively mild...
            this.buffer = new QueryBuffer <Value>(frameCapacity + stackCapacity);
            this.stack  = new StackRegion(new QueryRange(0, stackCapacity - 1));
            this.buffer.Reserve(stackCapacity);
            this.frames = new StackRegion(new QueryRange(stackCapacity, stackCapacity + frameCapacity - 1));
            this.buffer.Reserve(frameCapacity);
            this.contextOnTopOfStack = false;
        }
 internal void Add(ref QueryBuffer <T> addBuffer)
 {
     if (1 == addBuffer.count)
     {
         this.Add(addBuffer.buffer[0]);
     }
     else
     {
         int capacity = this.count + addBuffer.count;
         if (capacity >= this.buffer.Length)
         {
             this.Grow(capacity);
         }
         Array.Copy(addBuffer.buffer, 0, this.buffer, this.count, addBuffer.count);
         this.count = capacity;
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Add all the elements in the given buffer to this one
        /// We can do this very efficiently using an Array Copy
        /// </summary>
        internal void Add(ref QueryBuffer <T> addBuffer)
        {
            if (1 == addBuffer.count)
            {
                this.Add(addBuffer.buffer[0]);
                return;
            }

            int newCount = this.count + addBuffer.count;

            if (newCount >= this.buffer.Length)
            {
                this.Grow(newCount);
            }
            // Copy all the new elements in
            Array.Copy(addBuffer.buffer, 0, this.buffer, this.count, addBuffer.count);
            this.count = newCount;
        }
Esempio n. 13
0
        private void FixupJumps()
        {
            QueryBuffer <Opcode> treePath   = this.diverger.TreePath;
            QueryBuffer <Opcode> insertPath = this.diverger.InsertPath;

            for (int i = 0; i < insertPath.Count; i++)
            {
                if (insertPath[i].TestFlag(OpcodeFlags.Jump))
                {
                    JumpOpcode opcode = (JumpOpcode)insertPath[i];
                    if (-1 == insertPath.IndexOf(opcode.Jump, i + 1))
                    {
                        BlockEndOpcode jump = (BlockEndOpcode)opcode.Jump;
                        opcode.RemoveJump(jump);
                        ((JumpOpcode)treePath[i]).AddJump(jump);
                    }
                }
            }
        }
Esempio n. 14
0
 internal BoundedStack(int capacity)
 {
     this.buffer  = new QueryBuffer <T>(0);
     this.maxSize = capacity;
 }
Esempio n. 15
0
 internal QueryBranchResultSet(int capacity)
 {
     this.results = new QueryBuffer <QueryBranchResult>(capacity);
 }
Esempio n. 16
0
 public OpcodeList(int capacity)
 {
     this.opcodes = new QueryBuffer <Opcode>(capacity);
 }
Esempio n. 17
0
 internal QueryBuffer(QueryBuffer <T> buffer)
 {
     this.buffer = (T[])buffer.buffer.Clone();
     this.count  = buffer.count;
 }
Esempio n. 18
0
 internal GenericSeekableNavigator()
 {
     this.nodes           = new QueryBuffer <XPathNavigator>(4);
     this.currentPosition = -1;
 }
Esempio n. 19
0
 internal MultipleResultOpcode(OpcodeID id) : base(id)
 {
     base.flags  |= OpcodeFlags.Multiple;
     this.results = new QueryBuffer <object>(1);
 }
 internal BlockEndOpcode() : base(OpcodeID.BlockEnd)
 {
     this.sourceJumps = new QueryBuffer <Opcode>(1);
 }