public override CompilerResult VisitMulDivModExpr(DesignScriptParser.MulDivModExprContext context)
        {
            VisitExpr(context.expr()[0]);
            var lhs = valueStack.Pop();

            VisitExpr(context.expr()[1]);
            var rhs = valueStack.Pop();

            LLVMValueRef val = default;

            if (context.Op.Text == "*")
            {
                val = LLVM.BuildFMul(builder, lhs, rhs, "multmp");
            }
            else if (context.Op.Text == "/")
            {
                val = LLVM.BuildFDiv(builder, lhs, rhs, "divtmp");
            }
            else if (context.Op.Text == "%")
            {
                val = LLVM.BuildFRem(builder, lhs, rhs, "modtmp");
            }

            valueStack.Push(val);

            return(new NullCompilerResult());
        }
Example #2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>mulDivModExpr</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 VisitMulDivModExpr([NotNull] DesignScriptParser.MulDivModExprContext context)
 {
     return(VisitChildren(context));
 }