示例#1
0
 public CodegenExpression EventBeanFragmentCodegen(
     CodegenExpression beanExpression,
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     return CodegenExpressionBuilder.ConstantNull();
 }
示例#2
0
 public CodegenExpression UnderlyingFragmentCodegen(
     CodegenExpression underlyingExpression,
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     return CodegenExpressionBuilder.ConstantNull();
 }
示例#3
0
            public CodegenExpression CodegenPremade(
                Type evaluationType,
                CodegenExpression input,
                Type inputType,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                if (inputType.CanNotBeNull() || inputType.IsNumeric())
                {
                    return(numericTypeCaster.Codegen(input, inputType, codegenMethodScope, codegenClassScope));
                }

                var methodNode = codegenMethodScope
                                 .MakeChild(evaluationType, typeof(NumberCasterComputer), codegenClassScope)
                                 .AddParam(inputType, "input");

                methodNode.Block
                .IfInstanceOf("input", typeof(object))
                .BlockReturn(
                    numericTypeCaster.Codegen(
                        CodegenExpressionBuilder.Ref("input"),
                        inputType,
                        methodNode,
                        codegenClassScope))
                .MethodReturn(CodegenExpressionBuilder.ConstantNull());
                return(CodegenExpressionBuilder.LocalMethod(methodNode, input));
            }
示例#4
0
 private CodegenMethod GetCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(typeof(GenericRecord), "record")
         .Block
         .DeclareVar<GenericRecord>(
             "inner",
             CodegenExpressionBuilder.Cast(
                 typeof(GenericRecord),
                 CodegenExpressionBuilder.StaticMethod(
                     typeof(GenericRecordExtensions),
                     "Get",
                     CodegenExpressionBuilder.Ref("record"),
                     CodegenExpressionBuilder.Constant(_fieldTop))))
         .MethodReturn(
             CodegenExpressionBuilder.Conditional(
                 CodegenExpressionBuilder.EqualsNull(CodegenExpressionBuilder.Ref("inner")),
                 CodegenExpressionBuilder.ConstantNull(),
                 _getter.UnderlyingGetCodegen(
                     CodegenExpressionBuilder.Ref("inner"),
                     codegenMethodScope,
                     codegenClassScope)));
 }
示例#5
0
        internal static CodegenMethod NavigatePolyCodegen(
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope,
            AvroEventPropertyGetter[] getters)
        {
            var block = codegenMethodScope.MakeChild(
                    typeof(GenericRecord),
                    typeof(AvroEventBeanGetterDynamicPoly),
                    codegenClassScope)
                .AddParam(typeof(GenericRecord), "record")
                .Block;
            block.DeclareVar<object>("value", CodegenExpressionBuilder.ConstantNull());
            for (var i = 0; i < getters.Length - 1; i++) {
                block.AssignRef(
                        "value",
                        getters[i]
                            .UnderlyingGetCodegen(
                                CodegenExpressionBuilder.Ref("record"),
                                codegenMethodScope,
                                codegenClassScope))
                    .IfRefNotTypeReturnConst("value", typeof(GenericRecord), null)
                    .AssignRef(
                        "record",
                        CodegenExpressionBuilder.Cast(typeof(GenericRecord), CodegenExpressionBuilder.Ref("value")));
            }

            return block.MethodReturn(CodegenExpressionBuilder.Ref("record"));
        }
示例#6
0
            public CodegenExpression Codegen(
                CodegenMethodScope codegenMethodScope,
                CodegenClassScope codegenClassScope,
                CodegenExpressionRef left,
                CodegenExpressionRef right,
                Type ltype,
                Type rtype)
            {
                var method = codegenMethodScope.MakeChild(typeof(int?), typeof(DivideInt), codegenClassScope)
                             .AddParam(typeof(int?), "i1")
                             .AddParam(typeof(int?), "i2")
                             .Block

                             .IfCondition(
                    CodegenExpressionBuilder.EqualsIdentity(
                        CodegenExpressionBuilder.Ref("i2"),
                        CodegenExpressionBuilder.Constant(0)))
                             .BlockReturn(CodegenExpressionBuilder.ConstantNull())

                             .MethodReturn(
                    CodegenExpressionBuilder.Op(
                        CodegenExpressionBuilder.Ref("i1"),
                        "/",
                        CodegenExpressionBuilder.Ref("i2")));

                return(CodegenExpressionBuilder.LocalMethod(
                           method,
                           CodegenAsInt(left, ltype),
                           CodegenAsInt(right, rtype)));
            }
            public CodegenExpression EvaluateCodegen(
                Type requiredType,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode = codegenMethodScope.MakeChild(
                    typeof(object),
                    typeof(ExprForgeStreamWithGetter),
                    codegenClassScope);
                var refEPS = exprSymbol.GetAddEPS(methodNode);

                methodNode.Block
                .DeclareVar <EventBean>(
                    "theEvent",
                    CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(0)))
                .IfRefNotNull("theEvent")
                .BlockReturn(
                    getter.EventBeanGetCodegen(
                        CodegenExpressionBuilder.Ref("theEvent"),
                        methodNode,
                        codegenClassScope))
                .MethodReturn(CodegenExpressionBuilder.ConstantNull());
                return(CodegenExpressionBuilder.LocalMethod(methodNode));
            }
            public static CodegenExpression Codegen(
                IntervalComputerFinishedByThresholdForge forge,
                CodegenExpression leftStart,
                CodegenExpression leftEnd,
                CodegenExpression rightStart,
                CodegenExpression rightEnd,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode = codegenMethodScope.MakeChild(
                    typeof(bool?),
                    typeof(IntervalComputerFinishedByThresholdEval),
                    codegenClassScope)
                                 .AddParam(IntervalForgeCodegenNames.PARAMS);

                methodNode.Block
                .DeclareVar <long>(
                    "threshold",
                    forge.thresholdExpr.Codegen(
                        CodegenExpressionBuilder.StaticMethod(
                            typeof(Math),
                            "Min",
                            IntervalForgeCodegenNames.REF_RIGHTEND,
                            IntervalForgeCodegenNames.REF_LEFTEND),
                        methodNode,
                        exprSymbol,
                        codegenClassScope))
                .IfCondition(
                    CodegenExpressionBuilder.Relational(
                        CodegenExpressionBuilder.Ref("threshold"),
                        CodegenExpressionRelational.CodegenRelational.LT,
                        CodegenExpressionBuilder.Constant(0)))
                .StaticMethod(
                    typeof(IntervalComputerFinishedByThresholdEval),
                    METHOD_LOGWARNINGINTERVALFINISHEDBYTHRESHOLD)
                .BlockReturn(CodegenExpressionBuilder.ConstantNull())
                .IfConditionReturnConst(
                    CodegenExpressionBuilder.Relational(
                        IntervalForgeCodegenNames.REF_LEFTSTART,
                        CodegenExpressionRelational.CodegenRelational.GE,
                        IntervalForgeCodegenNames.REF_RIGHTSTART),
                    false)
                .DeclareVar <long>(
                    "delta",
                    CodegenExpressionBuilder.StaticMethod(
                        typeof(Math),
                        "Abs",
                        CodegenExpressionBuilder.Op(
                            IntervalForgeCodegenNames.REF_LEFTEND,
                            "-",
                            IntervalForgeCodegenNames.REF_RIGHTEND)))
                .MethodReturn(
                    CodegenExpressionBuilder.Relational(
                        CodegenExpressionBuilder.Ref("delta"),
                        CodegenExpressionRelational.CodegenRelational.LE,
                        CodegenExpressionBuilder.Ref("threshold")));
                return(CodegenExpressionBuilder.LocalMethod(methodNode, leftStart, leftEnd, rightStart, rightEnd));
            }
            public CodegenExpression Codegen(
                CodegenMethodScope codegenMethodScope,
                CodegenClassScope codegenClassScope,
                CodegenExpressionRef left,
                CodegenExpressionRef right,
                Type ltype,
                Type rtype)
            {
                var resultType = typeof(decimal);

                if (ltype.IsNullable() || rtype.IsNullable() || _divisionByZeroReturnsNull)
                {
                    resultType = typeof(decimal?);
                }

                var block = codegenMethodScope
                            .MakeChild(resultType, typeof(DivideDecimalConvComputerBase), codegenClassScope)
                            .AddParam(ltype, "d1")
                            .AddParam(rtype, "d2")
                            .Block
                            .DeclareVar <decimal>(
                    "s1",
                    _convOne.CoerceCodegen(CodegenExpressionBuilder.Ref("d1"), ltype))
                            .DeclareVar <decimal>(
                    "s2",
                    _convTwo.CoerceCodegen(CodegenExpressionBuilder.Ref("d2"), rtype));
                var ifZeroDivisor =
                    block.IfCondition(
                        CodegenExpressionBuilder.EqualsIdentity(
                            CodegenExpressionBuilder.Ref("s2"),
                            CodegenExpressionBuilder.Constant(0.0m)));

                if (_divisionByZeroReturnsNull)
                {
                    ifZeroDivisor.BlockReturn(CodegenExpressionBuilder.ConstantNull());
                }
                else
                {
                    ifZeroDivisor.DeclareVar <decimal>(
                        "result",
                        CodegenExpressionBuilder.Op(
                            CodegenExpressionBuilder.Ref("s1"),
                            "/",
                            CodegenExpressionBuilder.Constant(0.0m)))
                    .BlockReturn(CodegenExpressionBuilder.Ref("result"));
                }

                var method = block.MethodReturn(
                    DoDivideCodegen(
                        CodegenExpressionBuilder.Ref("s1"),
                        CodegenExpressionBuilder.Ref("s2"),
                        codegenClassScope));

                return(CodegenExpressionBuilder
                       .LocalMethodBuild(method)
                       .Pass(left)
                       .Pass(right)
                       .Call());
            }
示例#10
0
        public CodegenExpression UnderlyingFragmentCodegen(
            CodegenExpression underlyingExpression,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            if (_fragmentType == null) {
                return CodegenExpressionBuilder.ConstantNull();
            }

            return CodegenExpressionBuilder.LocalMethod(
                GetAvroFragmentCodegen(codegenMethodScope, codegenClassScope),
                underlyingExpression);
        }
            public static CodegenExpression Codegen(
                IntervalComputerCoincidesWithDeltaExprForge forge,
                CodegenExpression leftStart,
                CodegenExpression leftEnd,
                CodegenExpression rightStart,
                CodegenExpression rightEnd,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode = codegenMethodScope.MakeChild(
                    typeof(bool?),
                    typeof(IntervalComputerCoincidesWithDeltaExprEval),
                    codegenClassScope)
                                 .AddParam(IntervalForgeCodegenNames.PARAMS);

                var block = methodNode.Block
                            .DeclareVar <long>(
                    "startValue",
                    forge.start.Codegen(
                        CodegenExpressionBuilder.StaticMethod(
                            typeof(Math),
                            "Min",
                            IntervalForgeCodegenNames.REF_LEFTSTART,
                            IntervalForgeCodegenNames.REF_RIGHTSTART),
                        methodNode,
                        exprSymbol,
                        codegenClassScope))
                            .DeclareVar <long>(
                    "endValue",
                    forge.finish.Codegen(
                        CodegenExpressionBuilder.StaticMethod(
                            typeof(Math),
                            "Min",
                            IntervalForgeCodegenNames.REF_LEFTEND,
                            IntervalForgeCodegenNames.REF_RIGHTEND),
                        methodNode,
                        exprSymbol,
                        codegenClassScope));

                block.IfCondition(
                    CodegenExpressionBuilder.Or(
                        CodegenExpressionBuilder.Relational(
                            CodegenExpressionBuilder.Ref("startValue"),
                            CodegenExpressionRelational.CodegenRelational.LT,
                            CodegenExpressionBuilder.Constant(0)),
                        CodegenExpressionBuilder.Relational(
                            CodegenExpressionBuilder.Ref("endValue"),
                            CodegenExpressionRelational.CodegenRelational.LT,
                            CodegenExpressionBuilder.Constant(0))))
                .StaticMethod(
                    typeof(IntervalComputerCoincidesWithDeltaExprEval),
                    METHOD_WARNCOINCIDESTARTENDLESSZERO)
                .BlockReturn(CodegenExpressionBuilder.ConstantNull());
                block.MethodReturn(
                    CodegenExpressionBuilder.StaticMethod(
                        typeof(IntervalComputerConstantCoincides),
                        "ComputeIntervalCoincides",
                        IntervalForgeCodegenNames.REF_LEFTSTART,
                        IntervalForgeCodegenNames.REF_LEFTEND,
                        IntervalForgeCodegenNames.REF_RIGHTSTART,
                        IntervalForgeCodegenNames.REF_RIGHTEND,
                        CodegenExpressionBuilder.Ref("startValue"),
                        CodegenExpressionBuilder.Ref("endValue")));
                return(CodegenExpressionBuilder.LocalMethod(methodNode, leftStart, leftEnd, rightStart, rightEnd));
            }
            public static CodegenExpression Codegen(
                bool max,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope,
                ExprNode[] nodes,
                BigIntegerCoercer[] convertors)
            {
                var r0Type = nodes[0].Forge.EvaluationType.GetBoxedType();
                var r1Type = nodes[1].Forge.EvaluationType.GetBoxedType();

                if (r0Type == null || r1Type == null)
                {
                    return(CodegenExpressionBuilder.ConstantNull());
                }

                var methodNode = codegenMethodScope.MakeChild(
                    typeof(BigInteger?),
                    typeof(ComputerBigIntCoerce),
                    codegenClassScope);
                var block = methodNode.Block;

                block.DeclareVar(
                    r0Type,
                    "r0",
                    nodes[0].Forge.EvaluateCodegen(r0Type, methodNode, exprSymbol, codegenClassScope));
                if (r0Type.CanBeNull())
                {
                    block.IfRefNullReturnNull("r0");
                }

                block.DeclareVar(
                    r1Type,
                    "r1",
                    nodes[1].Forge.EvaluateCodegen(r1Type, methodNode, exprSymbol, codegenClassScope));
                if (r1Type.CanBeNull())
                {
                    block.IfRefNullReturnNull("r1");
                }

                block.DeclareVar <BigInteger?>(
                    "bi0",
                    convertors[0].CoerceBoxedBigIntCodegen(CodegenExpressionBuilder.Ref("r0"), r0Type));
                block.DeclareVar <BigInteger?>(
                    "bi1",
                    convertors[1].CoerceBoxedBigIntCodegen(CodegenExpressionBuilder.Ref("r1"), r1Type));

                block.DeclareVarNoInit(typeof(BigInteger?), "result");
                block.IfCondition(
                    MinMaxTypeCodegen.CodegenCompareCompareTo(
                        CodegenExpressionBuilder.Unbox(CodegenExpressionBuilder.Ref("bi0")),
                        CodegenExpressionBuilder.Unbox(CodegenExpressionBuilder.Ref("bi1")),
                        max))
                .AssignRef("result", CodegenExpressionBuilder.Ref("bi0"))
                .IfElse()
                .AssignRef("result", CodegenExpressionBuilder.Ref("bi1"))
                .BlockEnd();

                for (var i = 2; i < nodes.Length; i++)
                {
                    var nodeType      = nodes[i].Forge.EvaluationType;
                    var refnameNumber = "r" + i;
                    block.DeclareVar(
                        nodeType,
                        refnameNumber,
                        nodes[i].Forge.EvaluateCodegen(nodeType, methodNode, exprSymbol, codegenClassScope));
                    if (nodeType.CanBeNull())
                    {
                        block.IfRefNullReturnNull(refnameNumber);
                    }

                    var refnameBigint = "bi" + i;
                    block.DeclareVar <BigInteger>(
                        refnameBigint,
                        convertors[i].CoerceBoxedBigIntCodegen(CodegenExpressionBuilder.Ref(refnameNumber), nodeType));
                    block.IfCondition(
                        CodegenExpressionBuilder.Not(
                            MinMaxTypeCodegen.CodegenCompareCompareTo(
                                CodegenExpressionBuilder.Ref("result"),
                                CodegenExpressionBuilder.Ref(refnameBigint),
                                max)))
                    .AssignRef("result", CodegenExpressionBuilder.Ref(refnameBigint))
                    .BlockEnd();
                }

                block.MethodReturn(CodegenExpressionBuilder.Ref("result"));
                return(CodegenExpressionBuilder.LocalMethod(methodNode));
            }
示例#13
0
        public static CodegenExpression CodegenMinMax(
            bool min,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope,
            ExprNode[] nodes,
            Type returnType)
        {
            var r0Type = nodes[0].Forge.EvaluationType;
            var r1Type = nodes[1].Forge.EvaluationType;

            if (r0Type == null || r1Type == null)
            {
                return(CodegenExpressionBuilder.ConstantNull());
            }

            var methodNode = codegenMethodScope.MakeChild(
                returnType,
                typeof(MinMaxType.MaxComputerDoubleCoerce),
                codegenClassScope);
            var block = methodNode.Block;

            block.DeclareVar(
                r0Type,
                "r0",
                nodes[0].Forge.EvaluateCodegen(r0Type, methodNode, exprSymbol, codegenClassScope));
            if (r0Type.CanBeNull())
            {
                block.IfRefNullReturnNull("r0");
            }

            block.DeclareVar(
                r1Type,
                "r1",
                nodes[1].Forge.EvaluateCodegen(r1Type, methodNode, exprSymbol, codegenClassScope));
            if (r1Type.CanBeNull())
            {
                block.IfRefNullReturnNull("r1");
            }

            block.DeclareVarNoInit(returnType, "result");
            block.IfCondition(
                CodegenCompareRelop(
                    returnType,
                    min ? RelationalOpEnum.LT : RelationalOpEnum.GT,
                    CodegenExpressionBuilder.Ref("r0"),
                    r0Type,
                    CodegenExpressionBuilder.Ref("r1"),
                    r1Type))
            .AssignRef("result", TypeHelper.CoerceNumberToBoxedCodegen(
                           CodegenExpressionBuilder.Ref("r0"), r0Type, returnType))
            .IfElse()
            .AssignRef("result", TypeHelper.CoerceNumberToBoxedCodegen(
                           CodegenExpressionBuilder.Ref("r1"), r1Type, returnType))
            .BlockEnd();

            for (var i = 2; i < nodes.Length; i++)
            {
                var nodeType = nodes[i].Forge.EvaluationType;
                var refname  = "r" + i;
                block.DeclareVar(
                    nodeType,
                    refname,
                    nodes[i].Forge.EvaluateCodegen(nodeType, methodNode, exprSymbol, codegenClassScope));
                if (nodeType.CanBeNull())
                {
                    block.IfRefNullReturnNull(refname);
                }

                block.IfCondition(
                    CodegenExpressionBuilder.Not(
                        CodegenCompareRelop(
                            returnType,
                            min ? RelationalOpEnum.LT : RelationalOpEnum.GT,
                            CodegenExpressionBuilder.Ref("result"),
                            returnType,
                            CodegenExpressionBuilder.Ref(refname),
                            r1Type)))
                .AssignRef("result", TypeHelper.CoerceNumberToBoxedCodegen(CodegenExpressionBuilder.Ref(refname), nodeType, returnType))
                .BlockEnd();
            }

            block.MethodReturn(CodegenExpressionBuilder.Ref("result"));
            return(CodegenExpressionBuilder.LocalMethod(methodNode));
        }