public static CodegenExpression Codegen( DTLocalDateTimeOpsIntervalForge forge, CodegenExpression start, CodegenExpression end, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope .MakeChild(typeof(bool?), typeof(DTLocalDateTimeOpsIntervalEval), codegenClassScope) .AddParam(typeof(DateTime), "start") .AddParam(typeof(DateTime), "end"); var block = methodNode .Block .DebugStack() .DeclareVar<long>( "startMs", StaticMethod( typeof(DatetimeLongCoercerDateTime), "CoerceToMillis", Ref("start"))) .DeclareVar<long>( "endMs", StaticMethod( typeof(DatetimeLongCoercerDateTime), "CoerceToMillis", Ref("end"))) .DeclareVar<long>( "deltaMSec", Op(Ref("endMs"), "-", Ref("startMs"))) .DeclareVar<DateTime>( "result", Ref("start")); EvaluateCalOpsDateTimeCodegen(block, "result", forge.calendarForges, methodNode, exprSymbol, codegenClassScope); block.DeclareVar<long>( "startLong", StaticMethod( typeof(DatetimeLongCoercerDateTime), "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); }
public static CodegenExpression Codegen( DTLocalDateTimeOpsIntervalForge forge, CodegenExpression inner, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope .MakeChild(typeof(bool?), typeof(DTLocalDateTimeOpsIntervalEval), codegenClassScope) .AddParam(typeof(DateTime), "target"); var block = methodNode.Block; EvaluateCalOpsDateTimeCodegen(block, "target", forge.calendarForges, methodNode, exprSymbol, codegenClassScope); block.DeclareVar<long>( "time", StaticMethod( typeof(DatetimeLongCoercerDateTime), "CoerceToMillis", Ref("target"))); block.MethodReturn( forge.intervalForge.Codegen(Ref("time"), Ref("time"), methodNode, exprSymbol, codegenClassScope)); return LocalMethod(methodNode, inner); }