public EnumAggregateEventsForgeEval( EnumAggregateEventsForge forge, ExprEvaluator initialization, ExprEvaluator innerExpression) { _forge = forge; _initialization = initialization; _innerExpression = innerExpression; }
public static CodegenExpression Codegen( EnumAggregateEventsForge forge, EnumForgeCodegenParams args, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { var typeMember = codegenClassScope.AddDefaultFieldUnshared( true, typeof(ObjectArrayEventType), Cast( typeof(ObjectArrayEventType), EventTypeUtility.ResolveTypeCodegen( forge.ResultEventType, EPStatementInitServicesConstants.REF))); var scope = new ExprForgeCodegenSymbol(false, null); var methodNode = codegenMethodScope.MakeChildWithScope( forge.Initialization.EvaluationType, typeof(EnumAggregateEventsForgeEval), scope, codegenClassScope) .AddParam(EnumForgeCodegenNames.PARAMS); var initType = forge.Initialization.EvaluationType; var initTypeBoxed = initType.GetBoxedType(); var unboxRequired = initType != initTypeBoxed; var innerType = forge.InnerExpression.EvaluationType; var block = methodNode.Block; block.DeclareVar( initTypeBoxed, "value", forge.Initialization.EvaluateCodegen(initType, methodNode, scope, codegenClassScope)) .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty")) .BlockReturn( unboxRequired ? (CodegenExpression) ExprDotName(Ref("value"), "Value") : (CodegenExpression) Ref("value")); block.DeclareVar<ObjectArrayEventBean>( "resultEvent", NewInstance<ObjectArrayEventBean>(NewArrayByLength(typeof(object), Constant(1)), typeMember)) .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("resultEvent")) .DeclareVar<object[]>("props", ExprDotName(Ref("resultEvent"), "Properties")); block.ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL) .AssignArrayElement("props", Constant(0), Ref("value")) .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda + 1), Ref("next")) .AssignRef( "value", forge.InnerExpression.EvaluateCodegen( innerType, methodNode, scope, codegenClassScope)) .BlockEnd(); block.MethodReturn( unboxRequired ? (CodegenExpression) ExprDotName(Ref("value"), "Value") : (CodegenExpression) Ref("value")); return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx); }