public void Update(StateUpdate stateUpdate) { if (stateUpdate == null) { return; } //if (stateUpdate.Empty) return; if (this._frozen) { Console.WriteLine("WARNING: State:Update: state is frozen, nothing added."); return; } lock (this._ctxLock) { this.UndefGrounding = false; stateUpdate.Update(this); } this.solver_Dirty = true; this.solver_U_Dirty = true; }
/// <summary>Merge Constructor Method</summary> private void MergeConstructor(State state1, State state2) { #region Handle Inconsistent states { bool consistent1 = state1.IsConsistent == Tv.ONE; bool consistent2 = state2.IsConsistent == Tv.ONE; if (!consistent1 && !consistent2) { Console.WriteLine("WARNING: State: merge constructor: states have to be consistent. state1 consistent = " + consistent1 + "; state2 consistent = " + consistent2); } if (!consistent1) { lock (this._ctxLock) { state2.Copy(this); } return; } if (!consistent2) { lock (this._ctxLock) { state1.Copy(this); } return; } } #endregion #region Prepare States state1.UndefGrounding = false; state2.UndefGrounding = false; state1.Simplify(); state2.Simplify(); #endregion lock (this._ctxLock) { Context ctx = this._ctx; this._branchInfoStore = BranchInfoStore.RetrieveSharedBranchInfo(state1.BranchInfoStore, state2.BranchInfoStore, ctx); // merge the contents of both solvers { ISet <BoolExpr> mergedContent = new HashSet <BoolExpr>(); #pragma warning disable DisposableFixer // Undisposed ressource. foreach (BoolExpr b in state1.Solver.Assertions) { mergedContent.Add(b.Translate(ctx) as BoolExpr); } foreach (BoolExpr b in state2.Solver.Assertions) { mergedContent.Add(b.Translate(ctx) as BoolExpr); } foreach (BoolExpr b in mergedContent) { this.Solver.Assert(b); } ISet <BoolExpr> mergedContent_U = new HashSet <BoolExpr>(); foreach (BoolExpr b in state1.Solver_U.Assertions) { mergedContent_U.Add(b.Translate(ctx) as BoolExpr); } foreach (BoolExpr b in state2.Solver_U.Assertions) { mergedContent_U.Add(b.Translate(ctx) as BoolExpr); } foreach (BoolExpr b in mergedContent_U) { this.Solver_U.Assert(b); } #pragma warning restore DisposableFixer // Undisposed resource. } // merge the head and tail { if (state1.HeadKey == state2.HeadKey) { this.HeadKey = state1.HeadKey; } else { this.HeadKey = Tools.CreateKey(this.Tools.Rand); string head1 = state1.HeadKey; string head2 = state2.HeadKey; using (StateUpdate stateUpdateForward = new StateUpdate("!ERROR_1", this.HeadKey, this.Tools)) { BoolExpr dummyBranchCondttion = ctx.MkBoolConst("DymmyBC" + this.HeadKey); foreach (Rn reg in this.Tools.StateConfig.GetRegOn()) { stateUpdateForward.Set(reg, ctx.MkITE(dummyBranchCondttion, Tools.Create_Key(reg, head1, ctx), Tools.Create_Key(reg, head2, ctx)) as BitVecExpr); } foreach (Flags flag in this.Tools.StateConfig.GetFlagOn()) { stateUpdateForward.Set(flag, ctx.MkITE(dummyBranchCondttion, Tools.Create_Key(flag, head1, ctx), Tools.Create_Key(flag, head2, ctx)) as BoolExpr); } stateUpdateForward.Set_Mem(ctx.MkITE(dummyBranchCondttion, Tools.Create_Mem_Key(head1, ctx), Tools.Create_Mem_Key(head2, ctx)) as ArrayExpr); this.Update_Forward(stateUpdateForward); } } if (state1.TailKey == state2.TailKey) { this.TailKey = state1.TailKey; } else { this.TailKey = Tools.CreateKey(this.Tools.Rand); //TODO does merging the tail make any sense? } } } }