Exemple #1
0
        protected override ExprAST VisitCallExprAST(CallExprAST node)
        {
            var calleeF = LLVM.GetNamedFunction(this.module, node.Callee);

            if (calleeF.Pointer == IntPtr.Zero)
            {
                throw new Exception("Unknown function referenced");
            }

            if (LLVM.CountParams(calleeF) != node.Arguments.Count)
            {
                throw new Exception("Incorrect # arguments passed");
            }

            var argumentCount = (uint)node.Arguments.Count;
            var argsV         = new LLVMValueRef[Math.Max(argumentCount, 1)];

            for (int i = 0; i < argumentCount; ++i)
            {
                this.Visit(node.Arguments[i]);
                argsV[i] = this.valueStack.Pop();
            }

            valueStack.Push(LLVM.BuildCall(this.builder, calleeF, argsV, "calltmp"));

            return(node);
        }
Exemple #2
0
        protected internal virtual ExprAST VisitCallExprAST(CallExprAST node)
        {
            foreach (var argument in node.Arguments)
            {
                this.Visit(argument);
            }

            return(node);
        }
Exemple #3
0
        protected internal virtual ExprAST VisitCallExprAST(CallExprAST node)
        {
            foreach (var argument in node.Arguments)
            {
                this.Visit(argument);
            }

            return node;
        }
        public CallExprAST CallASTVisit(CallExprAST node)
        {
            var calleeF = LLVM.GetNamedFunction(this.module, node.Callee);

            if (calleeF.Pointer == IntPtr.Zero)
            {
                throw new Exception($"Function: {node.Callee} Not Found");
            }
            if (LLVM.CountParams(calleeF) != node.Args.Count)
            {
                throw new Exception("Incorrect Number of arguments passed.");
            }
            List <LLVMValueRef> ArgsV = new List <LLVMValueRef>();
            int i = 0;

            foreach (var arg in node.Args)
            {
                Visit(arg);
                ArgsV.Add(valueStack.Pop());
            }
            valueStack.Push(LLVM.BuildCall(builder, calleeF, ArgsV.ToArray(), "calltmp"));
            return(node);
        }