public EnumTakeWhileEventsForgeEval( EnumTakeWhileEventsForge forge, ExprEvaluator innerExpression) { _forge = forge; _innerExpression = innerExpression; }
public static CodegenExpression Codegen( EnumTakeWhileEventsForge forge, EnumForgeCodegenParams args, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { var returnType = typeof(FlexCollection); var paramTypes = EnumForgeCodegenNames.PARAMS; var scope = new ExprForgeCodegenSymbol(false, null); var methodNode = codegenMethodScope .MakeChildWithScope( returnType, typeof(EnumTakeWhileEventsForgeEval), scope, codegenClassScope) .AddParam(paramTypes); var innerValue = forge.InnerExpression.EvaluateCodegen( typeof(bool?), methodNode, scope, codegenClassScope); var block = methodNode.Block .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty")) .BlockReturn(EnumForgeCodegenNames.REF_ENUMCOLL); var blockSingle = block .IfCondition(EqualsIdentity(ExprDotName(EnumForgeCodegenNames.REF_ENUMCOLL, "Count"), Constant(1))) .DeclareVar<EventBean>("item", ExprDotMethod(ExprDotName(EnumForgeCodegenNames.REF_ENUMCOLL, "EventBeanCollection"), "First")) .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("item")); CodegenLegoBooleanExpression.CodegenReturnValueIfNotNullAndNotPass( blockSingle, forge.InnerExpression.EvaluationType, innerValue, FlexEmpty()); blockSingle.BlockReturn(FlexEvent(Ref("item"))); block.DeclareVar<ArrayDeque<EventBean>>("result", NewInstance(typeof(ArrayDeque<EventBean>))); var forEach = block .ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL) .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("next")); CodegenLegoBooleanExpression.CodegenBreakIfNotNullAndNotPass( forEach, forge.InnerExpression.EvaluationType, innerValue); forEach.Expression(ExprDotMethod(Ref("result"), "Add", Ref("next"))); block.MethodReturn(FlexWrap(Ref("result"))); return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx); }