示例#1
0
 public CGCachedExpr(CGExpr expr, CachedAtom cachedAtom, List <CGCachedExpr> caches)
 {
     this.expr        = expr;
     this.cachedAtom  = cachedAtom;
     this.cacheNumber = caches.Count;
     caches.Add(this);
 }
示例#2
0
文件: Conj.cs 项目: josiahdj/SDFCalc
		public override PathCond AndNot(CachedAtom cond) {
			if (conds.Contains(cond)) {
				return FALSE;
			}
			else {
				return Make(AddItem(this.conds, cond.Negate()));
			}
		}
示例#3
0
		public override PathCond AndNot(CachedAtom cond) {
			if (this.Equals(cond)) {
				return FALSE;
			}
			else {
				return Conj.Make(this, cond.Negate());
			}
		}
示例#4
0
		public override PathCond And(CachedAtom cond) {
			if (this.EqualsNega(cond)) {
				return FALSE;
			}
			else {
				return Conj.Make(this, cond);
			}
		}
示例#5
0
文件: Disj.cs 项目: josiahdj/SDFCalc
		public override PathCond And(CachedAtom cond) {
			return Conj.Make(this, cond);
			// Alternatively, weed out disjuncts inconsistent with the condition, 
			// using an order-preserving version of this code:
			// HashSet<PathCond> result = new HashSet<PathCond>();
			// result.AddAll(conds);
			// result.Filter(disj => !(disj is NegAtom && (disj as NegAtom).cond.Equals(cond) 
			// || disj is Conj && (disj as Conj).conds.Contains(new NegAtom(cond))));
			// return Conj.Make(Make(result.ToArray(), new Atom(cond));
		}
示例#6
0
文件: Conj.cs 项目: glycerine/SDFCalc
 public override PathCond AndNot(CachedAtom cond)
 {
     if (conds.Contains(cond))
     {
         return(FALSE);
     }
     else
     {
         return(Make(AddItem(this.conds, cond.Negate())));
     }
 }
示例#7
0
 public override PathCond AndNot(CachedAtom cond)
 {
     if (this.Equals(cond))
     {
         return(FALSE);
     }
     else
     {
         return(Conj.Make(this, cond.Negate()));
     }
 }
示例#8
0
文件: Disj.cs 项目: glycerine/SDFCalc
 public override PathCond And(CachedAtom cond)
 {
     return(Conj.Make(this, cond));
     // Alternatively, weed out disjuncts inconsistent with the condition,
     // using an order-preserving version of this code:
     // HashSet<PathCond> result = new HashSet<PathCond>();
     // result.AddAll(conds);
     // result.Filter(disj => !(disj is NegAtom && (disj as NegAtom).cond.Equals(cond)
     // || disj is Conj && (disj as Conj).conds.Contains(new NegAtom(cond))));
     // return Conj.Make(Make(result.ToArray(), new Atom(cond));
 }
示例#9
0
 public override void EvalCond(PathCond evalCond,
                               IDictionary <FullCellAddr, PathCond> evalConds,
                               List <CGCachedExpr> caches)
 {
     if (es.Length == 3)
     {
         CachedAtom atom = new CachedAtom(es[0], caches);
         es[0].EvalCond(evalCond, evalConds, caches);
         es[0] = atom.cachedExpr;
         es[1].EvalCond(evalCond.And(atom), evalConds, caches);
         es[2].EvalCond(evalCond.AndNot(atom), evalConds, caches);
     }
 }
示例#10
0
文件: CGOr.cs 项目: josiahdj/SDFCalc
		public override void EvalCond(PathCond evalCond,
									  IDictionary<FullCellAddr, PathCond> evalConds,
									  List<CGCachedExpr> caches) {
			for (int i = 0; i < es.Length; i++) {
				es[i].EvalCond(evalCond, evalConds, caches);
				if (SHORTCIRCUIT_EVALCONDS && i != es.Length - 1) {
					// Take short-circuit evaluation into account for precision
					CachedAtom atom = new CachedAtom(es[i], caches);
					evalCond = evalCond.AndNot(atom);
					es[i] = atom.cachedExpr;
				}
			}
		}
示例#11
0
		public override void EvalCond(PathCond evalCond,
									  IDictionary<FullCellAddr, PathCond> evalConds,
									  List<CGCachedExpr> caches) {
			if (es.Length >= 1) {
				CachedAtom atom = new CachedAtom(es[0], caches);
				CGCachedExpr cached = atom.cachedExpr;
				es[0].EvalCond(evalCond, evalConds, caches);
				es[0] = cached;
				for (int i = 1; i < es.Length; i++) {
					CGExpr iConst = CGConst.Make(i);
					CGExpr cond = new CGEqual(new CGExpr[] {cached, iConst});
					es[i].EvalCond(evalCond.And(new CachedAtom(cond, caches)), evalConds, caches);
				}
			}
		}
示例#12
0
文件: CGOr.cs 项目: ajw0100/SDFCalc
 public override void EvalCond(PathCond evalCond,
                               IDictionary <FullCellAddr, PathCond> evalConds,
                               List <CGCachedExpr> caches)
 {
     for (int i = 0; i < es.Length; i++)
     {
         es[i].EvalCond(evalCond, evalConds, caches);
         if (SHORTCIRCUIT_EVALCONDS && i != es.Length - 1)
         {
             // Take short-circuit evaluation into account for precision
             CachedAtom atom = new CachedAtom(es[i], caches);
             evalCond = evalCond.AndNot(atom);
             es[i]    = atom.cachedExpr;
         }
     }
 }
示例#13
0
 public override void EvalCond(PathCond evalCond,
                               IDictionary <FullCellAddr, PathCond> evalConds,
                               List <CGCachedExpr> caches)
 {
     if (es.Length >= 1)
     {
         CachedAtom   atom   = new CachedAtom(es[0], caches);
         CGCachedExpr cached = atom.cachedExpr;
         es[0].EvalCond(evalCond, evalConds, caches);
         es[0] = cached;
         for (int i = 1; i < es.Length; i++)
         {
             CGExpr iConst = CGConst.Make(i);
             CGExpr cond   = new CGEqual(new CGExpr[] { cached, iConst });
             es[i].EvalCond(evalCond.And(new CachedAtom(cond, caches)), evalConds, caches);
         }
     }
 }
示例#14
0
 private CachedAtom(CachedAtom atom, bool negated)
 {
     this.cachedExpr = atom.cachedExpr;
     this.negated    = negated;
 }
示例#15
0
文件: CGIf.cs 项目: josiahdj/SDFCalc
		public override void EvalCond(PathCond evalCond,
									  IDictionary<FullCellAddr, PathCond> evalConds,
									  List<CGCachedExpr> caches) {
			if (es.Length == 3) {
				CachedAtom atom = new CachedAtom(es[0], caches);
				es[0].EvalCond(evalCond, evalConds, caches);
				es[0] = atom.cachedExpr;
				es[1].EvalCond(evalCond.And(atom), evalConds, caches);
				es[2].EvalCond(evalCond.AndNot(atom), evalConds, caches);
			}
		}
示例#16
0
		public CGCachedExpr(CGExpr expr, CachedAtom cachedAtom, List<CGCachedExpr> caches) {
			this.expr = expr;
			this.cachedAtom = cachedAtom;
			this.cacheNumber = caches.Count;
			caches.Add(this);
		}
示例#17
0
		private CachedAtom(CachedAtom atom, bool negated) {
			this.cachedExpr = atom.cachedExpr;
			this.negated = negated;
		}
示例#18
0
文件: Disj.cs 项目: josiahdj/SDFCalc
		public override PathCond AndNot(CachedAtom cond) { return Conj.Make(this, cond.Negate()); }
示例#19
0
 public abstract PathCond AndNot(CachedAtom expr);
示例#20
0
        public override bool Equals(PathCond other)
        {
            CachedAtom atom = other as CachedAtom;

            return(atom != null && cachedExpr.Equals(atom.cachedExpr) && negated == atom.negated);
        }
示例#21
0
文件: Disj.cs 项目: glycerine/SDFCalc
 public override PathCond AndNot(CachedAtom cond)
 {
     return(Conj.Make(this, cond.Negate()));
 }
示例#22
0
        public bool EqualsNega(PathCond other)
        {
            CachedAtom atom = other as CachedAtom;

            return(atom != null && cachedExpr.Equals(atom.cachedExpr) && negated != atom.negated);
        }