Beispiel #1
0
        public override Expr VisitNAryExpr(NAryExpr node)
        {
            var sub     = Subs.Get(node.Fun.FunctionName);
            var newNode = node;

            if (sub != null)
            {
                var subFun = decls.Get(sub);
                if (subFun == null)
                {
                    Log.Out(Log.Error, "Could not find function " + sub + " in FunctionRenamer");
                }
                var paramMap = funMap.FindPair(node.Fun.FunctionName, sub);

                //map args by paramMap
                var thisFun = decls.Get(node.Fun.FunctionName);
                var newArgs = new List <Expr>();
                int i       = 0;
                if (subFun != null)
                {
                    foreach (Variable pv in subFun.InParams)
                    {
                        var pr = paramMap.Find(x => x.snd == pv.Name);
                        if (pr != null)
                        {
                            var arg = GetArgOfParam(pr.fst, node.Args.ToList(), thisFun.InParams);
                            if (arg == null)
                            {
                                Log.Out(Log.Error, "Mapped param does not seem to exist in FunctionRenamer");
                            }
                            newArgs.Add(arg);
                        }
                        else
                        {
                            newArgs.Add(node.Args[i]);
                        }
                        i++;
                    }

                    newNode = new NAryExpr(node.tok, new FunctionCall(Expr.Ident(sub, subFun.OutParams[0].TypedIdent.Type)), newArgs);
                    (newNode.Fun as FunctionCall).Func = subFun;
                }
            }
            return(base.VisitNAryExpr(newNode));
        }
Beispiel #2
0
 public ParamMap FindFunction(string f1, string f2)
 {
     return(functionMap.FindPair(f1, f2));
 }
Beispiel #3
0
 public ParamMap FindProcedure(string f1, string f2)
 {
     return(procMap.FindPair(f1, f2));
 }