Exemplo n.º 1
0
 public CGCachedExpr(CGExpr expr, CachedAtom cachedAtom, List <CGCachedExpr> caches)
 {
     this.expr        = expr;
     this.cachedAtom  = cachedAtom;
     this.cacheNumber = caches.Count;
     caches.Add(this);
 }
Exemplo n.º 2
0
		public override PathCond AndNot(CachedAtom cond) {
			if (conds.Contains(cond)) {
				return FALSE;
			}
			else {
				return Make(AddItem(this.conds, cond.Negate()));
			}
		}
Exemplo n.º 3
0
		public override PathCond AndNot(CachedAtom cond) {
			if (this.Equals(cond)) {
				return FALSE;
			}
			else {
				return Conj.Make(this, cond.Negate());
			}
		}
Exemplo n.º 4
0
		public override PathCond And(CachedAtom cond) {
			if (this.EqualsNega(cond)) {
				return FALSE;
			}
			else {
				return Conj.Make(this, cond);
			}
		}
Exemplo n.º 5
0
		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));
		}
Exemplo n.º 6
0
 public override PathCond AndNot(CachedAtom cond)
 {
     if (conds.Contains(cond))
     {
         return(FALSE);
     }
     else
     {
         return(Make(AddItem(this.conds, cond.Negate())));
     }
 }
Exemplo n.º 7
0
 public override PathCond AndNot(CachedAtom cond)
 {
     if (this.Equals(cond))
     {
         return(FALSE);
     }
     else
     {
         return(Conj.Make(this, cond.Negate()));
     }
 }
Exemplo n.º 8
0
 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));
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 10
0
		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;
				}
			}
		}
Exemplo n.º 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);
				}
			}
		}
Exemplo n.º 12
0
 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;
         }
     }
 }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 14
0
 private CachedAtom(CachedAtom atom, bool negated)
 {
     this.cachedExpr = atom.cachedExpr;
     this.negated    = negated;
 }
Exemplo n.º 15
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);
			}
		}
Exemplo n.º 16
0
		public CGCachedExpr(CGExpr expr, CachedAtom cachedAtom, List<CGCachedExpr> caches) {
			this.expr = expr;
			this.cachedAtom = cachedAtom;
			this.cacheNumber = caches.Count;
			caches.Add(this);
		}
Exemplo n.º 17
0
		private CachedAtom(CachedAtom atom, bool negated) {
			this.cachedExpr = atom.cachedExpr;
			this.negated = negated;
		}
Exemplo n.º 18
0
		public override PathCond AndNot(CachedAtom cond) { return Conj.Make(this, cond.Negate()); }
Exemplo n.º 19
0
 public abstract PathCond AndNot(CachedAtom expr);
Exemplo n.º 20
0
        public override bool Equals(PathCond other)
        {
            CachedAtom atom = other as CachedAtom;

            return(atom != null && cachedExpr.Equals(atom.cachedExpr) && negated == atom.negated);
        }
Exemplo n.º 21
0
 public override PathCond AndNot(CachedAtom cond)
 {
     return(Conj.Make(this, cond.Negate()));
 }
Exemplo n.º 22
0
        public bool EqualsNega(PathCond other)
        {
            CachedAtom atom = other as CachedAtom;

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