internal override void Add(Opcode opcode)
        {
            LiteralRelationOpcode opcode2 = this.ValidateOpcode(opcode);

            if (opcode2 == null)
            {
                base.Add(opcode);
            }
            else
            {
                QueryBranch literalBranch = this.branchIndex[opcode2.Literal];
                if (literalBranch == null)
                {
                    this.nextID++;
                    literalBranch = new QueryBranch(opcode2, this.nextID);
                    opcode2.Prev  = this;
                    this.branchIndex[opcode2.Literal] = literalBranch;
                }
                else
                {
                    literalBranch.Branch.Next.Add(opcode2.Next);
                }
                opcode2.Flags |= OpcodeFlags.InConditional;
                this.AddAlwaysBranch(literalBranch, opcode2.Next);
            }
        }
Example #2
0
        internal override void Add(Opcode opcode)
        {
            LiteralRelationOpcode literal = this.ValidateOpcode(opcode);

            if (null == literal)
            {
                base.Add(opcode);
                return;
            }

            // Was this literal already added to the index?
            QueryBranch queryBranch = this.branchIndex[literal.Literal];

            if (null == queryBranch)
            {
                // First time. New branch
                this.nextID++;
                queryBranch  = new QueryBranch(literal, this.nextID);
                literal.Prev = this;
                this.branchIndex[literal.Literal] = queryBranch;
            }
            else
            {
                Fx.Assert(!object.ReferenceEquals(queryBranch.Branch, literal), "");
                Fx.Assert(literal.ID == queryBranch.Branch.ID, "");
                // literal already exists.. but what follows the literal must be branched
                // Should never get here, but just in case
                queryBranch.Branch.Next.Add(literal.Next);
            }
            literal.Flags |= OpcodeFlags.InConditional;

            this.AddAlwaysBranch(queryBranch, literal.Next);
        }
        internal void AddAlwaysBranch(Opcode literal, Opcode next)
        {
            LiteralRelationOpcode opcode = this.ValidateOpcode(literal);

            if (opcode != null)
            {
                this.AddAlwaysBranch(opcode, next);
            }
        }
Example #4
0
        // Whether or not the given literal matches, we must always take the branch rooted at 'next'
        // Add to the AlwaysBranches table if not already there..
        internal void AddAlwaysBranch(LiteralRelationOpcode literal, Opcode next)
        {
            Fx.Assert(null != literal && null != next, "");

            QueryBranch literalBranch = this.branchIndex[literal.Literal];

            Fx.Assert(null != literalBranch, "");

            this.AddAlwaysBranch(literalBranch, next);
        }
Example #5
0
        internal void AddAlwaysBranch(Opcode literal, Opcode next)
        {
            LiteralRelationOpcode literalOp = this.ValidateOpcode(literal);

            Fx.Assert(null != literalOp, "");
            if (null != literalOp)
            {
                this.AddAlwaysBranch(literalOp, next);
            }
        }
 internal QueryBranch GetBranch(Opcode op)
 {
     if (op.TestFlag(OpcodeFlags.Literal))
     {
         LiteralRelationOpcode opcode = this.ValidateOpcode(op);
         if (opcode != null)
         {
             QueryBranch branch = this.branchIndex[opcode.Literal];
             if ((branch != null) && (branch.Branch.ID == op.ID))
             {
                 return(branch);
             }
         }
     }
     return(null);
 }
Example #7
0
        internal QueryBranch GetBranch(Opcode op)
        {
            if (op.TestFlag(OpcodeFlags.Literal))
            {
                LiteralRelationOpcode relOp = this.ValidateOpcode(op);
                if (null != relOp)
                {
                    QueryBranch branch = this.branchIndex[relOp.Literal];
                    if (null != branch && branch.Branch.ID == op.ID)
                    {
                        return(branch);
                    }
                }
            }

            return(null);
        }
        internal override void RemoveChild(Opcode opcode)
        {
            LiteralRelationOpcode opcode2 = this.ValidateOpcode(opcode);
            QueryBranch           branch  = this.branchIndex[opcode2.Literal];

            this.branchIndex.Remove(opcode2.Literal);
            Opcode opcode1 = branch.Branch;

            opcode1.Flags &= ~OpcodeFlags.NoContextCopy;
            if (this.alwaysBranches != null)
            {
                int index = this.alwaysBranches.IndexOfID(branch.ID);
                if (index >= 0)
                {
                    this.alwaysBranches.RemoveAt(index);
                    if (this.alwaysBranches.Count == 0)
                    {
                        this.alwaysBranches = null;
                    }
                }
            }
        }
Example #9
0
        internal override void RemoveChild(Opcode opcode)
        {
            LiteralRelationOpcode literal = this.ValidateOpcode(opcode);

            Fx.Assert(null != literal, "");

            QueryBranch branch = this.branchIndex[literal.Literal];

            Fx.Assert(null != branch, "");
            this.branchIndex.Remove(literal.Literal);
            branch.Branch.Flags &= (~OpcodeFlags.NoContextCopy);
            if (null != this.alwaysBranches)
            {
                int removeAt = this.alwaysBranches.IndexOfID(branch.ID);
                if (removeAt >= 0)
                {
                    this.alwaysBranches.RemoveAt(removeAt);
                    if (0 == this.alwaysBranches.Count)
                    {
                        this.alwaysBranches = null;
                    }
                }
            }
        }
        internal void AddAlwaysBranch(LiteralRelationOpcode literal, Opcode next)
        {
            QueryBranch literalBranch = this.branchIndex[literal.Literal];

            this.AddAlwaysBranch(literalBranch, next);
        }
 internal void AddAlwaysBranch(LiteralRelationOpcode literal, Opcode next)
 {
     QueryBranch literalBranch = this.branchIndex[literal.Literal];
     this.AddAlwaysBranch(literalBranch, next);
 }