public virtual Cmd VisitStateCmd(StateCmd node) { Contract.Requires(node != null); Contract.Ensures(Contract.Result <Cmd>() != null); node.Locals = this.VisitVariableSeq(node.Locals); node.Cmds = this.VisitCmdSeq(node.Cmds); return(node); }
///////////////////////////////////////////////////////////////////////////////////// private void addLet(BasicBlock current, StateCmd stateCmd) { foreach (Variable v in stateCmd.Locals) { if (scope.findVariable(scope.getVarUName(v)) == null) { procedure.addVariable(new ProgramVariable(procedure.getVarUName(v), makeType(v.TypedIdent.Type), false, false, false, false)); } } foreach (Cmd c in stateCmd.Cmds) { addStatementToBasicBlock(current, c); } }
public override Cmd VisitStateCmd(StateCmd node) { return(base.VisitStateCmd((StateCmd)node.Clone())); }
public override Cmd VisitStateCmd(StateCmd node) { //Contract.Requires(node != null); Contract.Ensures(Contract.Result <Cmd>() != null); return(base.VisitStateCmd((StateCmd)node.Clone())); }
// perform in place update of liveSet public static void Propagate(Cmd cmd, HashSet <Variable /*!*/> /*!*/ liveSet, bool allGlobalsAreLive) { Contract.Requires(cmd != null); Contract.Requires(cce.NonNullElements(liveSet)); if (cmd is AssignCmd) { AssignCmd /*!*/ assignCmd = (AssignCmd)cce.NonNull(cmd); // I must first iterate over all the targets and remove the live ones. // After the removals are done, I must add the variables referred on // the right side of the removed targets AssignCmd simpleAssignCmd = assignCmd.AsSimpleAssignCmd; HashSet <int> indexSet = new HashSet <int>(); int index = 0; foreach (AssignLhs /*!*/ lhs in simpleAssignCmd.Lhss) { Contract.Assert(lhs != null); SimpleAssignLhs salhs = lhs as SimpleAssignLhs; Contract.Assert(salhs != null); Variable var = salhs.DeepAssignedVariable; if (var != null && (liveSet.Contains(var) || (allGlobalsAreLive && var is GlobalVariable))) { indexSet.Add(index); liveSet.Remove(var); } index++; } index = 0; foreach (Expr /*!*/ expr in simpleAssignCmd.Rhss) { Contract.Assert(expr != null); if (indexSet.Contains(index)) { VariableCollector /*!*/ collector = new VariableCollector(); collector.Visit(expr); if (allGlobalsAreLive) { liveSet.UnionWith(collector.usedVars.Where(v => v is LocalVariable || v is Formal)); } else { liveSet.UnionWith(collector.usedVars); } } index++; } } else if (cmd is HavocCmd) { HavocCmd /*!*/ havocCmd = (HavocCmd)cmd; foreach (IdentifierExpr /*!*/ expr in havocCmd.Vars) { Contract.Assert(expr != null); if (expr.Decl != null) { liveSet.Remove(expr.Decl); } } } else if (cmd is PredicateCmd) { Contract.Assert((cmd is AssertCmd || cmd is AssumeCmd)); PredicateCmd /*!*/ predicateCmd = (PredicateCmd)cce.NonNull(cmd); if (predicateCmd.Expr is LiteralExpr) { LiteralExpr le = (LiteralExpr)predicateCmd.Expr; if (le.IsFalse) { liveSet.Clear(); } } else { VariableCollector /*!*/ collector = new VariableCollector(); collector.Visit(predicateCmd.Expr); if (allGlobalsAreLive) { liveSet.UnionWith(collector.usedVars.Where(v => v is LocalVariable || v is Formal)); } else { liveSet.UnionWith(collector.usedVars); } } } else if (cmd is CommentCmd) { // comments are just for debugging and don't affect verification } else if (cmd is SugaredCmd) { SugaredCmd /*!*/ sugCmd = (SugaredCmd)cce.NonNull(cmd); Propagate(sugCmd.Desugaring, liveSet, allGlobalsAreLive); } else if (cmd is StateCmd) { StateCmd /*!*/ stCmd = (StateCmd)cce.NonNull(cmd); List <Cmd> /*!*/ cmds = cce.NonNull(stCmd.Cmds); int len = cmds.Count; for (int i = len - 1; i >= 0; i--) { Propagate(cmds[i], liveSet, allGlobalsAreLive); } foreach (Variable /*!*/ v in stCmd.Locals) { Contract.Assert(v != null); liveSet.Remove(v); } } else { { Contract.Assert(false); throw new cce.UnreachableException(); } } }
public void Cmd(string a_name, cmds a_cmd, GameState a_state) { StateCmd newCmd = new StateCmd(a_name, a_cmd, a_state); m_cmds.Add(newCmd); }