Exemple #1
0
        public static CodegenExpression Codegen(
            DTLocalDtoOpsIntervalForge forge,
            CodegenExpression start,
            CodegenExpression end,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope
                .MakeChild(typeof(bool?), typeof(DTLocalDtxOpsIntervalEval), codegenClassScope)
                .AddParam(typeof(DateTimeOffset), "start")
                .AddParam(typeof(DateTimeOffset), "end");

            var block = methodNode
                .Block
                .DebugStack()
                .DeclareVar<long>(
                    "startMs",
                    StaticMethod(
                        typeof(DatetimeLongCoercerDateTimeOffset),
                        "CoerceToMillis",
                        Ref("start")))
                .DeclareVar<long>(
                    "endMs",
                    StaticMethod(
                        typeof(DatetimeLongCoercerDateTimeOffset),
                        "CoerceToMillis",
                        Ref("end")))
                .DeclareVar<long>(
                    "deltaMSec",
                    Op(Ref("endMs"), "-", Ref("startMs")))
                .DeclareVar<DateTimeOffset>(
                    "result",
                    Ref("start"));

            EvaluateCalOpsDtoCodegen(block, "result", forge.calendarForges, methodNode, exprSymbol, codegenClassScope);

            block.DeclareVar<long>(
                "startLong",
                StaticMethod(
                    typeof(DatetimeLongCoercerDateTimeOffset),
                    "CoerceToMillis",
                    Ref("result")));
            block.DeclareVar<long>(
                "endTime", Op(Ref("startLong"), "+", Ref("deltaMSec")));
            block.MethodReturn(
                forge.intervalForge.Codegen(
                    Ref("startLong"),
                    Ref("endTime"),
                    methodNode,
                    exprSymbol,
                    codegenClassScope));
            return LocalMethod(methodNode, start, end);
        }
Exemple #2
0
        public static CodegenExpression Codegen(
            DTLocalDtoOpsIntervalForge forge,
            CodegenExpression inner,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope
                .MakeChild(typeof(bool?), typeof(DTLocalDtxOpsIntervalEval), codegenClassScope)
                .AddParam(typeof(DateTimeOffset), "target");

            var block = methodNode.Block;
            EvaluateCalOpsDtoCodegen(block, "target", forge.calendarForges, methodNode, exprSymbol, codegenClassScope);
            block.DeclareVar<long>(
                "time",
                StaticMethod(
                    typeof(DatetimeLongCoercerDateTimeOffset),
                    "CoerceToMillis",
                    Ref("target")));
            block.MethodReturn(
                forge.intervalForge.Codegen(Ref("time"), Ref("time"), methodNode, exprSymbol, codegenClassScope));
            return LocalMethod(methodNode, inner);
        }