public IntRangeTerm(IntRangeTerm that) // for copying only : base("..", that.lowBound, that.hiBound) { this.lowBound = that.lowBound; this.hiBound = that.hiBound; iEnum = GetEnumerator(); }
BaseTerm CopyEx(int newVerNo, bool mustBeNamed) { if (IsUnified) { return(ChainEnd().CopyEx(newVerNo, mustBeNamed)); } // A neater solution would be to use overrides for each term subtype. if (this is Variable) { Variable v = (Variable)this; if (newVerNo == v.verNo) { return(v.newVar); } v.verNo = newVerNo; return(v.newVar = (mustBeNamed && this is NamedVariable) ? new NamedVariable(((NamedVariable)v).Name) : new Variable()); } else if (this is CatchOpenTerm) { CatchOpenTerm c = (CatchOpenTerm)this; return(new CatchOpenTerm(c.Id, c.ExceptionClass, c.MsgVar.CopyEx(newVerNo, mustBeNamed), c.SeqNo, c.SaveStackSize)); } else { if (arity == 0) { return(this); } BaseTerm t = null; BaseTerm[] a = new BaseTerm[arity]; for (int i = 0; i < arity; i++) { if (args[i] != null) // may be null for a GapTerm { a[i] = args[i].CopyEx(newVerNo, mustBeNamed); // recursively refresh arguments } } if (this is ListPatternTerm) { t = new ListPatternTerm(a); } else if (this is AltListTerm) { AltListTerm alt = (AltListTerm)this; t = new AltListTerm(alt.LeftBracket, alt.RightBracket, a[0], a[1]); } else if (this is ListTerm) { if (((ListTerm)this).CharCodeString == null) { t = new ListTerm(a[0], a[1]); } else // it's an ISO-style string { t = new ListTerm(((ListTerm)this).CharCodeString); } } else if (this is OperatorTerm) { t = new OperatorTerm(((OperatorTerm)this).od, a); } else if (this is DcgTerm) { t = new DcgTerm(functor, a); } else if (this is WrapperTerm) { t = new WrapperTerm((WrapperTerm)this, a); } else if (this is IntRangeTerm) { t = new IntRangeTerm((IntRangeTerm)this); } else if (this is ListPatternElem) { t = new ListPatternElem(a, ((ListPatternElem)this).downRepFactor, ((ListPatternElem)this).IsNegSearch); } else if (this is CompoundTerm) { t = new CompoundTerm(functor, a); } else { IO.Error("CopyEx(): type '{0}' not handled explicitly", this.GetType()); } return(t); } }