public override CompilerResult VisitFuncCallExpr(DesignScriptParser.FuncCallExprContext context) { var qualifiedIdentContext = context.qualifiedIdent(); var funcName = qualifiedIdentContext.Ident(0).GetText(); var calleeF = LLVM.GetNamedFunction(this.module, funcName); if (calleeF.Pointer == IntPtr.Zero) { throw new Exception("Unknown function referenced"); } var argumentCount = LLVM.CountParams(calleeF); var argsV = new LLVMValueRef[argumentCount]; var args = context.exprList(); VisitExprList(args); for (var i = 0; i < argumentCount; i++) { argsV[argumentCount - 1 - i] = valueStack.Pop(); } valueStack.Push(LLVM.BuildCall(this.builder, calleeF, argsV, "calltmp")); return(new NullCompilerResult()); }
/// <summary> /// Visit a parse tree produced by the <c>funcCallExpr</c> /// labeled alternative in <see cref="DesignScriptParser.expr"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitFuncCallExpr([NotNull] DesignScriptParser.FuncCallExprContext context) { return(VisitChildren(context)); }