Пример #1
0
            public override object VisitFunCallExprNode(FunCallExprNode n)
            {
                Visit(n.name);
                TypeSymbol funType = null;
                string     name    = "";

                if (n.name is IdenExprNode)
                {
                    name    = (n.name as IdenExprNode).name;
                    name    = TypeSymbol.MakeFunctionName(name, n.args);
                    funType = varTypes.IsInScope(name);
                }
                else
                {
                    funType = n.name.Type;
                }

                semanticChecker.CheckAndReport(funType != null, n.sourceLoc, $"Undeclared Function {name}");
                n.name.Type = funType;

                if (funType != null)
                {
                    semanticChecker.CheckAndReport(n.args.Count <= funType.ParameterTypes.Count, n.sourceLoc, string.Format("Too many arguments ({0}) given, {1} expected", n.args.Count, funType.ParameterTypes.Count));
                    semanticChecker.CheckAndReport(n.args.Count >= funType.ParameterTypes.Count, n.sourceLoc, string.Format("Too few arguments ({0}) given, {1} expected", n.args.Count, funType.ParameterTypes.Count));
                    for (int i = 0; i < Math.Min(funType.ParameterTypes.Count, n.args.Count); i++)
                    {
                        Visit(n.args[i]);
                        semanticChecker.CheckAndReport(funType.ParameterTypes[i].Match(n.args[i].Type), n.sourceLoc, "argument mismatch: " + (i + 1));
                    }
                }
                return(null);
            }
Пример #2
0
        public virtual T VisitFunCallExprNode(FunCallExprNode n)
        {
            T a = n.name.Accept(this);

            for (int i = 0; i < n.args.Count; i++)
            {
                n.args[i].Accept(this);
            }

            return(default(T));
        }
Пример #3
0
        public override object VisitFunCallExprNode(FunCallExprNode n)
        {
            Visit(n.name);
            foreach (Expression e in n.args)
            {
                Visit(e);
            }
            n.name.Type = DoInfer(n.name.Type, n.args);

            n.Type = n.name.Type.ReturnType;

            return(null);
        }
Пример #4
0
        public object VisitFunCallExprNode(FunCallExprNode n)
        {
            WriteLine(n.kind + " - " + n.Type);
            Indent();
            Visit(n.name);
            foreach (Expression c in n.args)
            {
                Visit(c);
            }
            Dedent();

            return(null);
        }
Пример #5
0
 public override LData VisitFunCallExprNode(FunCallExprNode n)
 {
     if (n.name is IdenExprNode)
     {
         return(interp.CallFunction((n.name as IdenExprNode).Type.FunctionName, n.args.Select(e => Visit(e)).ToArray()));
     }
     else
     {
         // ??? i don't know yet ... this concerns function pointers, and i honestly don't know how to do them elegantly
         // @TODO: Probably has to be done inside TypeSymbol
         return(null);
     }
 }
Пример #6
0
 public override MIPSRegister VisitFunCallExprNode(FunCallExprNode n)
 {
     return(base.VisitFunCallExprNode(n));
 }
Пример #7
0
 public override LLVMRegister VisitFunCallExprNode(FunCallExprNode n)
 {
     throw new NotImplementedException();
 }