SubExpr BranchAt(Opcode op, SubExprEliminator elim) { Opcode firstOp = this.FirstOp; if (this.parent != null) { this.parent.RemoveChild(this); } else { elim.Exprs.Remove(this); } firstOp.DetachFromParent(); op.DetachFromParent(); SubExpr e = new SubExpr(this.parent, firstOp, elim.NewVarID()); if (this.parent != null) { this.parent.AddChild(e); } else { elim.Exprs.Add(e); } e.AddChild(this); this.parent = e; this.ops = new InternalSubExprOpcode(e); this.ops.Attach(op); return(e); }
internal override void AddChild(SubExpr expr) { base.AddChild(expr); RebuildIndex(); if (expr.useSpecial) { NodeQName qname = ((SelectOpcode)(expr.FirstOp)).Criteria.QName; string ns = qname.Namespace; Dictionary <string, List <SubExpr> > nextLookup; if (!this.nameLookup.TryGetValue(ns, out nextLookup)) { nextLookup = new Dictionary <string, List <SubExpr> >(); this.nameLookup.Add(ns, nextLookup); } string name = qname.Name; List <SubExpr> exprs = new List <SubExpr>(); if (!nextLookup.TryGetValue(name, out exprs)) { exprs = new List <SubExpr>(); nextLookup.Add(name, exprs); } exprs.Add(expr); } }
internal override void RemoveChild(SubExpr expr) { base.RemoveChild(expr); this.RebuildIndex(); if (expr.useSpecial) { Dictionary <string, List <SubExpr> > dictionary; NodeQName qName = ((SelectOpcode)expr.FirstOp).Criteria.QName; string key = qName.Namespace; if (this.nameLookup.TryGetValue(key, out dictionary)) { List <SubExpr> list; string name = qName.Name; if (dictionary.TryGetValue(name, out list)) { list.Remove(expr); if (list.Count == 0) { dictionary.Remove(name); } } if (dictionary.Count == 0) { this.nameLookup.Remove(key); } } } }
internal override void RemoveChild(SubExpr expr) { base.RemoveChild(expr); RebuildIndex(); if (expr.useSpecial) { NodeQName qname = ((SelectOpcode)(expr.FirstOp)).Criteria.QName; string ns = qname.Namespace; Dictionary <string, List <SubExpr> > nextLookup; if (this.nameLookup.TryGetValue(ns, out nextLookup)) { string name = qname.Name; List <SubExpr> exprs; if (nextLookup.TryGetValue(name, out exprs)) { exprs.Remove(expr); if (exprs.Count == 0) { nextLookup.Remove(name); } } if (nextLookup.Count == 0) { this.nameLookup.Remove(ns); } } } }
internal Opcode Add(object item, Opcode ops) { List <SubExpr> list = new List <SubExpr>(); this.removalMapping.Add(item, list); while (ops.Next != null) { ops = ops.Next; } Opcode opcode = ops; while (ops != null) { if (IsExprStarter(ops)) { SubExprOpcode opcode4; Opcode op = ops; Opcode prev = ops.Prev; ops.DetachFromParent(); ops = ops.Next; while (ops.ID == OpcodeID.Select) { ops = ops.Next; } ops.DetachFromParent(); SubExpr expr = null; for (int i = 0; i < this.exprList.Count; i++) { if (this.exprList[i].FirstOp.Equals(op)) { expr = this.exprList[i]; break; } } if (expr == null) { expr = new SubExpr(null, op, this.NewVarID()); this.exprList.Add(expr); opcode4 = new SubExprOpcode(expr); } else { opcode4 = expr.Add(op, this); } opcode4.Expr.IncRef(); list.Add(opcode4.Expr); opcode4.Attach(ops); ops = opcode4; if (prev != null) { prev.Attach(ops); } } opcode = ops; ops = ops.Prev; } return(opcode); }
internal Opcode Add(object item, Opcode ops) { List<SubExpr> list = new List<SubExpr>(); this.removalMapping.Add(item, list); while (ops.Next != null) { ops = ops.Next; } Opcode opcode = ops; while (ops != null) { if (IsExprStarter(ops)) { SubExprOpcode opcode4; Opcode op = ops; Opcode prev = ops.Prev; ops.DetachFromParent(); ops = ops.Next; while (ops.ID == OpcodeID.Select) { ops = ops.Next; } ops.DetachFromParent(); SubExpr expr = null; for (int i = 0; i < this.exprList.Count; i++) { if (this.exprList[i].FirstOp.Equals(op)) { expr = this.exprList[i]; break; } } if (expr == null) { expr = new SubExpr(null, op, this.NewVarID()); this.exprList.Add(expr); opcode4 = new SubExprOpcode(expr); } else { opcode4 = expr.Add(op, this); } opcode4.Expr.IncRef(); list.Add(opcode4.Expr); opcode4.Attach(ops); ops = opcode4; if (prev != null) { prev.Attach(ops); } } opcode = ops; ops = ops.Prev; } return opcode; }
internal SubExprOpcode Add(Opcode opseq, SubExprEliminator elim) { Opcode start = this.FirstOp; Opcode ops = opseq; while (start != null && ops != null && start.Equals(ops)) { start = start.Next; ops = ops.Next; } if (ops == null) { if (start == null) { return(new SubExprOpcode(this)); } else { SubExpr e = this.BranchAt(start, elim); return(new SubExprOpcode(e)); } } else { if (start == null) { ops.DetachFromParent(); for (int i = 0; i < this.children.Count; ++i) { if (this.children[i].FirstOp.Equals(ops)) { return(this.children[i].Add(ops, elim)); } } SubExpr e = new SubExpr(this, ops, elim.NewVarID()); this.AddChild(e); return(new SubExprOpcode(e)); } else { SubExpr e = this.BranchAt(start, elim); ops.DetachFromParent(); SubExpr ee = new SubExpr(e, ops, elim.NewVarID()); e.AddChild(ee); return(new SubExprOpcode(ee)); } } }
internal SubExpr(SubExpr parent, Opcode ops, int var) { this.var = var; this.parent = parent; this.useSpecial = false; if (parent != null) { this.ops = new InternalSubExprOpcode(parent); this.ops.Attach(ops); this.useSpecial = (parent is SubExprHeader) && (((SelectOpcode)ops).Criteria.Axis.Type == QueryAxisType.Child); } else { this.ops = ops; } }
internal SubExpr(SubExpr parent, Opcode ops, int var) { this.var = var; this.parent = parent; this.useSpecial = false; if (parent != null) { this.ops = new InternalSubExprOpcode(parent); this.ops.Attach(ops); this.useSpecial = (parent is SubExprHeader) && (((SelectOpcode) ops).Criteria.Axis.Type == QueryAxisType.Child); } else { this.ops = ops; } }
internal void CleanUp(SubExprEliminator elim) { if (this.refCount == 0) { if (this.children.Count == 0) { if (this.parent == null) { elim.Exprs.Remove(this); } else { this.parent.RemoveChild(this); this.parent.CleanUp(elim); } } else if (this.children.Count == 1) { SubExpr child = this.children[0]; Opcode op = child.FirstOp; op.DetachFromParent(); Opcode op2 = this.ops; while (op2.Next != null) { op2 = op2.Next; } op2.Attach(op); child.ops = this.ops; if (this.parent == null) { elim.Exprs.Remove(this); elim.Exprs.Add(child); child.parent = null; } else { this.parent.RemoveChild(this); this.parent.AddChild(child); child.parent = this.parent; } } } }
internal void CleanUp(SubExprEliminator elim) { if (this.refCount == 0) { if (this.children.Count == 0) { if (this.parent == null) { elim.Exprs.Remove(this); } else { this.parent.RemoveChild(this); this.parent.CleanUp(elim); } } else if (this.children.Count == 1) { SubExpr item = this.children[0]; Opcode firstOp = item.FirstOp; firstOp.DetachFromParent(); Opcode ops = this.ops; while (ops.Next != null) { ops = ops.Next; } ops.Attach(firstOp); item.ops = this.ops; if (this.parent == null) { elim.Exprs.Remove(this); elim.Exprs.Add(item); item.parent = null; } else { this.parent.RemoveChild(this); this.parent.AddChild(item); item.parent = this.parent; } } } }
internal SubExprOpcode Add(Opcode opseq, SubExprEliminator elim) { Opcode firstOp = this.FirstOp; Opcode op = opseq; while (((firstOp != null) && (op != null)) && firstOp.Equals(op)) { firstOp = firstOp.Next; op = op.Next; } if (op == null) { if (firstOp == null) { return(new SubExprOpcode(this)); } return(new SubExprOpcode(this.BranchAt(firstOp, elim))); } if (firstOp == null) { op.DetachFromParent(); for (int i = 0; i < this.children.Count; i++) { if (this.children[i].FirstOp.Equals(op)) { return(this.children[i].Add(op, elim)); } } SubExpr expr2 = new SubExpr(this, op, elim.NewVarID()); this.AddChild(expr2); return(new SubExprOpcode(expr2)); } SubExpr parent = this.BranchAt(firstOp, elim); op.DetachFromParent(); SubExpr expr = new SubExpr(parent, op, elim.NewVarID()); parent.AddChild(expr); return(new SubExprOpcode(expr)); }
internal SubExprOpcode Add(Opcode opseq, SubExprEliminator elim) { Opcode firstOp = this.FirstOp; Opcode op = opseq; while (((firstOp != null) && (op != null)) && firstOp.Equals(op)) { firstOp = firstOp.Next; op = op.Next; } if (op == null) { if (firstOp == null) { return new SubExprOpcode(this); } return new SubExprOpcode(this.BranchAt(firstOp, elim)); } if (firstOp == null) { op.DetachFromParent(); for (int i = 0; i < this.children.Count; i++) { if (this.children[i].FirstOp.Equals(op)) { return this.children[i].Add(op, elim); } } SubExpr expr2 = new SubExpr(this, op, elim.NewVarID()); this.AddChild(expr2); return new SubExprOpcode(expr2); } SubExpr parent = this.BranchAt(firstOp, elim); op.DetachFromParent(); SubExpr expr = new SubExpr(parent, op, elim.NewVarID()); parent.AddChild(expr); return new SubExprOpcode(expr); }
internal override void AddChild(SubExpr expr) { base.AddChild(expr); this.RebuildIndex(); if (expr.useSpecial) { Dictionary<string, List<SubExpr>> dictionary; NodeQName qName = ((SelectOpcode) expr.FirstOp).Criteria.QName; string key = qName.Namespace; if (!this.nameLookup.TryGetValue(key, out dictionary)) { dictionary = new Dictionary<string, List<SubExpr>>(); this.nameLookup.Add(key, dictionary); } string name = qName.Name; List<SubExpr> list = new List<SubExpr>(); if (!dictionary.TryGetValue(name, out list)) { list = new List<SubExpr>(); dictionary.Add(name, list); } list.Add(expr); } }
internal override void AddChild(SubExpr expr) { base.AddChild(expr); this.RebuildIndex(); if (expr.useSpecial) { Dictionary <string, List <SubExpr> > dictionary; NodeQName qName = ((SelectOpcode)expr.FirstOp).Criteria.QName; string key = qName.Namespace; if (!this.nameLookup.TryGetValue(key, out dictionary)) { dictionary = new Dictionary <string, List <SubExpr> >(); this.nameLookup.Add(key, dictionary); } string name = qName.Name; List <SubExpr> list = new List <SubExpr>(); if (!dictionary.TryGetValue(name, out list)) { list = new List <SubExpr>(); dictionary.Add(name, list); } list.Add(expr); } }
internal SubExprOpcode(SubExpr expr) : base(OpcodeID.SubExpr) { this.expr = expr; }
internal override void AddChild(SubExpr expr) { base.AddChild(expr); RebuildIndex(); if (expr.useSpecial) { NodeQName qname = ((SelectOpcode)(expr.FirstOp)).Criteria.QName; string ns = qname.Namespace; Dictionary<string, List<SubExpr>> nextLookup; if (!this.nameLookup.TryGetValue(ns, out nextLookup)) { nextLookup = new Dictionary<string, List<SubExpr>>(); this.nameLookup.Add(ns, nextLookup); } string name = qname.Name; List<SubExpr> exprs = new List<SubExpr>(); if (!nextLookup.TryGetValue(name, out exprs)) { exprs = new List<SubExpr>(); nextLookup.Add(name, exprs); } exprs.Add(expr); } }
internal virtual void RemoveChild(SubExpr expr) { this.children.Remove(expr); }
internal override void RemoveChild(SubExpr expr) { base.RemoveChild(expr); RebuildIndex(); if (expr.useSpecial) { NodeQName qname = ((SelectOpcode)(expr.FirstOp)).Criteria.QName; string ns = qname.Namespace; Dictionary<string, List<SubExpr>> nextLookup; if (this.nameLookup.TryGetValue(ns, out nextLookup)) { string name = qname.Name; List<SubExpr> exprs; if (nextLookup.TryGetValue(name, out exprs)) { exprs.Remove(expr); if (exprs.Count == 0) { nextLookup.Remove(name); } } if (nextLookup.Count == 0) { this.nameLookup.Remove(ns); } } } }
internal virtual void AddChild(SubExpr expr) { this.children.Add(expr); }
internal InternalSubExprOpcode(SubExpr expr) : base(expr) { }
internal Opcode Add(object item, Opcode ops) { List <SubExpr> exprs = new List <SubExpr>(); this.removalMapping.Add(item, exprs); while (ops.Next != null) { ops = ops.Next; } Opcode res = ops; while (ops != null) { if (IsExprStarter(ops)) { Opcode start = ops; Opcode p = ops.Prev; ops.DetachFromParent(); ops = ops.Next; while (ops.ID == OpcodeID.Select) { ops = ops.Next; } ops.DetachFromParent(); SubExpr e = null; for (int i = 0; i < this.exprList.Count; ++i) { if (this.exprList[i].FirstOp.Equals(start)) { e = this.exprList[i]; break; } } SubExprOpcode o; if (e == null) { e = new SubExpr(null, start, NewVarID()); this.exprList.Add(e); o = new SubExprOpcode(e); } else { o = e.Add(start, this); } o.Expr.IncRef(); exprs.Add(o.Expr); o.Attach(ops); ops = o; if (p != null) { p.Attach(ops); } } res = ops; ops = ops.Prev; } return(res); }
internal override void RemoveChild(SubExpr expr) { base.RemoveChild(expr); this.RebuildIndex(); if (expr.useSpecial) { Dictionary<string, List<SubExpr>> dictionary; NodeQName qName = ((SelectOpcode) expr.FirstOp).Criteria.QName; string key = qName.Namespace; if (this.nameLookup.TryGetValue(key, out dictionary)) { List<SubExpr> list; string name = qName.Name; if (dictionary.TryGetValue(name, out list)) { list.Remove(expr); if (list.Count == 0) { dictionary.Remove(name); } } if (dictionary.Count == 0) { this.nameLookup.Remove(key); } } } }
private SubExpr BranchAt(Opcode op, SubExprEliminator elim) { Opcode firstOp = this.FirstOp; if (this.parent != null) { this.parent.RemoveChild(this); } else { elim.Exprs.Remove(this); } firstOp.DetachFromParent(); op.DetachFromParent(); SubExpr expr = new SubExpr(this.parent, firstOp, elim.NewVarID()); if (this.parent != null) { this.parent.AddChild(expr); } else { elim.Exprs.Add(expr); } expr.AddChild(this); this.parent = expr; this.ops = new InternalSubExprOpcode(expr); this.ops.Attach(op); return expr; }
internal Opcode Add(object item, Opcode ops) { List<SubExpr> exprs = new List<SubExpr>(); this.removalMapping.Add(item, exprs); while (ops.Next != null) { ops = ops.Next; } Opcode res = ops; while (ops != null) { if (IsExprStarter(ops)) { Opcode start = ops; Opcode p = ops.Prev; ops.DetachFromParent(); ops = ops.Next; while (ops.ID == OpcodeID.Select) { ops = ops.Next; } ops.DetachFromParent(); SubExpr e = null; for (int i = 0; i < this.exprList.Count; ++i) { if (this.exprList[i].FirstOp.Equals(start)) { e = this.exprList[i]; break; } } SubExprOpcode o; if (e == null) { e = new SubExpr(null, start, NewVarID()); this.exprList.Add(e); o = new SubExprOpcode(e); } else { o = e.Add(start, this); } o.Expr.IncRef(); exprs.Add(o.Expr); o.Attach(ops); ops = o; if (p != null) { p.Attach(ops); } } res = ops; ops = ops.Prev; } return res; }
internal SubExprOpcode Add(Opcode opseq, SubExprEliminator elim) { Opcode start = this.FirstOp; Opcode ops = opseq; while (start != null && ops != null && start.Equals(ops)) { start = start.Next; ops = ops.Next; } if (ops == null) { if (start == null) { return new SubExprOpcode(this); } else { SubExpr e = this.BranchAt(start, elim); return new SubExprOpcode(e); } } else { if (start == null) { ops.DetachFromParent(); for (int i = 0; i < this.children.Count; ++i) { if (this.children[i].FirstOp.Equals(ops)) { return this.children[i].Add(ops, elim); } } SubExpr e = new SubExpr(this, ops, elim.NewVarID()); this.AddChild(e); return new SubExprOpcode(e); } else { SubExpr e = this.BranchAt(start, elim); ops.DetachFromParent(); SubExpr ee = new SubExpr(e, ops, elim.NewVarID()); e.AddChild(ee); return new SubExprOpcode(ee); } } }