public EnumMinMaxEventsForgeEval( EnumMinMaxEventsForge forge, ExprEvaluator innerExpression) { _forge = forge; _innerExpression = innerExpression; }
public static CodegenExpression Codegen( EnumMinMaxEventsForge forge, EnumForgeCodegenParams args, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { var innerType = forge.InnerExpression.EvaluationType; var innerTypeBoxed = Boxing.GetBoxedType(innerType); //var paramTypes = (innerType == typeof(EventBean)) // ? EnumForgeCodegenNames.PARAMS_EVENTBEAN // : EnumForgeCodegenNames.PARAMS_OBJECT; var paramTypes = EnumForgeCodegenNames.PARAMS; var scope = new ExprForgeCodegenSymbol(false, null); var methodNode = codegenMethodScope .MakeChildWithScope(innerTypeBoxed, typeof(EnumMinMaxEventsForgeEval), scope, codegenClassScope) .AddParam(paramTypes); var block = methodNode.Block .DeclareVar(innerTypeBoxed, "minKey", ConstantNull()); var forEach = block.ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL) .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("next")) .DeclareVar( innerTypeBoxed, "value", forge.InnerExpression.EvaluateCodegen(innerTypeBoxed, methodNode, scope, codegenClassScope)); if (innerType.CanBeNull()) { forEach.IfRefNull("value").BlockContinue(); } forEach.IfCondition(EqualsNull(Ref("minKey"))) .AssignRef("minKey", Ref("value")) .IfElse() .IfCondition( Relational( ExprDotMethod(Unbox(Ref("minKey"), innerTypeBoxed), "CompareTo", Ref("value")), forge.max ? LT : GT, Constant(0))) .AssignRef("minKey", Ref("value")); block.MethodReturn(Ref("minKey")); return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx); }