private void collectUsedVars(VColl vcoll, Cmd c) { Debug.Assert(c is PredicateCmd); var pc = c as PredicateCmd; collectUsedVars(vcoll, pc.Expr); }
private ISet <Variable> getUsedVars(Implementation implementation) { var vcoll = new VColl(); var declaredVars = new HashSet <Variable>(implementation.InParams); declaredVars.UnionWith(implementation.OutParams); declaredVars.UnionWith(implementation.LocVars); foreach (var v in declaredVars) { if (v.TypedIdent.WhereExpr != null) { collectUsedVars(vcoll, v.TypedIdent.WhereExpr); } } foreach (var bb in implementation.Blocks) { foreach (var s in bb.Cmds) { collectUsedVars(vcoll, s); } } foreach (var v in vcoll.usedVars) { addUsedVar(v); // if (usedVarsByName.ContainsKey(v.Name)) // Debugger.Break(); } return(vcoll.usedVars); }
private void collectUsedVars(VColl vcoll, Expr e) { if (e is LiteralExpr) { vcoll.literals.Add(e as LiteralExpr); } else if (e is IdentifierExpr) { var ide = e as IdentifierExpr; vcoll.addVar(ide.Decl); } else if (e is QuantifierExpr) { collectUsedVars(vcoll, (e as QuantifierExpr).Body); } else if (e is NAryExpr) { var fae = e as NAryExpr; vcoll.functions.Add(fae.Fun); foreach (var a in fae.Args) { collectUsedVars(vcoll, a); } } else if (e is BvExtractExpr) { collectUsedVars(vcoll, (e as BvExtractExpr).Bitvector); } else if (e is BvConcatExpr) { var bve = e as BvConcatExpr; collectUsedVars(vcoll, bve.E0); collectUsedVars(vcoll, bve.E1); } else if (e is OldExpr) { collectUsedVars(vcoll, (e as OldExpr).Expr); } else { throw new System.Exception("Unknown Boogie2 targetE type - \"" + e.Type + "\""); } }