示例#1
0
 private static void CodegenDeclareInts(
     CodegenBlock block,
     CalendarWithDateForge forge,
     CodegenMethod methodNode,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var yearType = forge.Year.EvaluationType;
     var monthType = forge.Month.EvaluationType;
     var dayType = forge.Day.EvaluationType;
     block.DeclareVar<int?>(
             "year",
             SimpleNumberCoercerFactory.CoercerInt.CoerceCodegenMayNull(
                 forge.Year.EvaluateCodegen(yearType, methodNode, exprSymbol, codegenClassScope),
                 yearType,
                 methodNode,
                 codegenClassScope))
         .DeclareVar<int?>(
             "month",
             SimpleNumberCoercerFactory.CoercerInt.CoerceCodegenMayNull(
                 forge.Month.EvaluateCodegen(monthType, methodNode, exprSymbol, codegenClassScope),
                 monthType,
                 methodNode,
                 codegenClassScope))
         .DeclareVar<int?>(
             "day",
             SimpleNumberCoercerFactory.CoercerInt.CoerceCodegenMayNull(
                 forge.Day.EvaluateCodegen(dayType, methodNode, exprSymbol, codegenClassScope),
                 dayType,
                 methodNode,
                 codegenClassScope));
 }
示例#2
0
        public static CodegenExpression CodegenDateTime(
            CalendarWithDateForge forge,
            CodegenExpression dateTime,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope
                .MakeChild(typeof(DateTime), typeof(CalendarWithDateForgeOp), codegenClassScope)
                .AddParam(typeof(DateTime), "value");

            var block = methodNode.Block;
            CodegenDeclareInts(block, forge, methodNode, exprSymbol, codegenClassScope);
            block.MethodReturn(
                StaticMethod(
                    typeof(CalendarWithDateForgeOp),
                    "ActionSetYMDDateTime",
                    Ref("value"),
                    Ref("year"),
                    Ref("month"),
                    Ref("day")));
            return LocalMethod(methodNode, dateTime);
        }