示例#1
0
 private static void CodegenDeclareInts(
     CodegenBlock block,
     CalendarWithTimeForge forge,
     CodegenMethod methodNode,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var hourType = forge.Hour.EvaluationType;
     var minType = forge.Min.EvaluationType;
     var secType = forge.Sec.EvaluationType;
     var msecType = forge.Msec.EvaluationType;
     block
         .DeclareVar<int?>(
             "hour",
             SimpleNumberCoercerFactory.CoercerInt.CoerceCodegenMayNull(
                 forge.Hour.EvaluateCodegen(hourType, methodNode, exprSymbol, codegenClassScope),
                 hourType,
                 methodNode,
                 codegenClassScope))
         .DeclareVar<int?>(
             "minute",
             SimpleNumberCoercerFactory.CoercerInt.CoerceCodegenMayNull(
                 forge.Min.EvaluateCodegen(minType, methodNode, exprSymbol, codegenClassScope),
                 minType,
                 methodNode,
                 codegenClassScope))
         .DeclareVar<int?>(
             "second",
             SimpleNumberCoercerFactory.CoercerInt.CoerceCodegenMayNull(
                 forge.Sec.EvaluateCodegen(secType, methodNode, exprSymbol, codegenClassScope),
                 secType,
                 methodNode,
                 codegenClassScope))
         .DeclareVar<int?>(
             "msec",
             SimpleNumberCoercerFactory.CoercerInt.CoerceCodegenMayNull(
                 forge.Msec.EvaluateCodegen(msecType, methodNode, exprSymbol, codegenClassScope),
                 msecType,
                 methodNode,
                 codegenClassScope));
 }
示例#2
0
        public static CodegenExpression CodegenDateTimeEx(
            CalendarWithTimeForge forge,
            CodegenExpression dtx,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope
                .MakeChild(typeof(DateTimeEx), typeof(CalendarWithTimeForgeOp), codegenClassScope)
                .AddParam(typeof(DateTimeEx), "dtx");

            var block = methodNode.Block;
            CodegenDeclareInts(block, forge, methodNode, exprSymbol, codegenClassScope);
            block.MethodReturn(
                StaticMethod(
                    typeof(CalendarWithTimeForgeOp),
                    "ActionSetHMSMDateTimeEx",
                    Ref("dtx"),
                    Ref("hour"),
                    Ref("minute"),
                    Ref("second"),
                    Ref("msec")));
            return LocalMethod(methodNode, dtx);
        }