Exemplo n.º 1
0
            public override object VisitFunCallStmtNode(FunCallStmtNode 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, "Too few arguments");

                    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);
            }
Exemplo n.º 2
0
        public override object VisitFunCallStmtNode(FunCallStmtNode n)
        {
            Visit(n.name);
            foreach (Expression e in n.args)
            {
                Visit(e);
            }
            n.name.Type = DoInfer(n.name.Type, n.args);

            return(null);
        }
Exemplo n.º 3
0
        public virtual T VisitFunCallStmtNode(FunCallStmtNode n)
        {
            T a = n.name.Accept(this);

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

            return(default(T));
        }
Exemplo n.º 4
0
        public object VisitFunCallStmtNode(FunCallStmtNode n)
        {
            WriteLine(n.kind);
            Indent();
            Visit(n.name);
            foreach (Expression c in n.args)
            {
                Visit(c);
            }
            Dedent();

            return(null);
        }
Exemplo n.º 5
0
 public override LData VisitFunCallStmtNode(FunCallStmtNode n)
 {
     if (n.name is IdenExprNode)
     {
         var paras = n.args.Select(e => Visit(e)).ToArray();
         interp.CallFunction((n.name as IdenExprNode).Type.FunctionName, paras);
     }
     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);
 }
Exemplo n.º 6
0
 public override MIPSRegister VisitFunCallStmtNode(FunCallStmtNode n)
 {
     return(base.VisitFunCallStmtNode(n));
 }
Exemplo n.º 7
0
 public override LLVMRegister VisitFunCallStmtNode(FunCallStmtNode n)
 {
     throw new NotImplementedException();
 }