private void Instrument(DeclWithFormals dwf) { foreach (var rule in _rules) { foreach (var procSig in rule.ProcedureToMatchToInsertion.Keys) { // match references attribute bool matchPtrs = QKeyValue.FindBoolAttribute(procSig.Attributes, ExprMatchVisitor.BoogieKeyWords.MatchPtrs); int anyParamsPosition; QKeyValue anyParamsAttributes; int anyParamsPositionOut; QKeyValue anyParamsAttributesOut; Dictionary <Declaration, Expr> paramSubstitution; if (ProcedureSigMatcher.MatchSig(procSig, dwf, _program, out anyParamsAttributes, out anyParamsPosition, out anyParamsAttributesOut, out anyParamsPositionOut, out paramSubstitution, matchPtrs)) { Implementation impl = null; if (dwf is Implementation) { impl = (Implementation)dwf; } else if (dwf is Procedure) { var proc = (Procedure)dwf; var newInParams = new List <Variable>(); foreach (var v in proc.InParams) { newInParams.Add(new LocalVariable(v.tok, v.TypedIdent)); } var newOutParams = new List <Variable>(); foreach (var v in proc.OutParams) { newOutParams.Add(new LocalVariable(v.tok, v.TypedIdent)); } impl = new Implementation(proc.tok, proc.Name, proc.TypeParameters, newInParams, newOutParams, new List <Variable>(), new List <Block>()); impl.Proc = proc; //_program.AddTopLevelDeclaration(impl); } InjectCode(impl, anyParamsPosition, anyParamsAttributes, anyParamsPositionOut, anyParamsAttributesOut, procSig, rule, paramSubstitution); if (dwf is Procedure && impl.Blocks.Count > 0) { _program.AddTopLevelDeclaration(impl); } //TODO: sig matching is broken, so is the stat Stats.count("Times " + PropertyKeyWords.ProcedureRule + " injected code"); //only take the first match return; } } } }
private void Instrument(DeclWithFormals dwf) { foreach (var rule in _rules) { foreach (var procSig in rule.ProcedureToMatchToInsertion.Keys) { int anyParamsPosition; QKeyValue anyParamsAttributes; int anyParamsPositionOut; QKeyValue anyParamsAttributesOut; Dictionary <Declaration, Expr> paramSubstitution; if (ProcedureSigMatcher.MatchSig(procSig, dwf, _program, out anyParamsAttributes, out anyParamsPosition, out anyParamsAttributesOut, out anyParamsPositionOut, out paramSubstitution)) { Implementation impl = null; if (dwf is Implementation) { impl = (Implementation)dwf; } else if (dwf is Procedure) { var proc = (Procedure)dwf; var newInParams = new List <Variable>(); foreach (var v in proc.InParams) { newInParams.Add(new LocalVariable(v.tok, v.TypedIdent)); } var newOutParams = new List <Variable>(); foreach (var v in proc.OutParams) { newOutParams.Add(new LocalVariable(v.tok, v.TypedIdent)); } impl = new Implementation(proc.tok, proc.Name, proc.TypeParameters, newInParams, newOutParams, new List <Variable>(), new List <Block>()); _program.AddTopLevelDeclaration(impl); } InjectCode(impl, anyParamsPosition, anyParamsAttributes, anyParamsPositionOut, anyParamsAttributesOut, procSig, rule, paramSubstitution); Stats.count("Times " + PropertyKeyWords.ProcedureRule + " injected code"); //only take the first match return; } } } }