public EnumToMapScalarLambdaForgeEval( EnumToMapScalarLambdaForge forge, ExprEvaluator innerExpression, ExprEvaluator secondExpression) { _forge = forge; _innerExpression = innerExpression; _secondExpression = secondExpression; }
public static CodegenExpression Codegen( EnumToMapScalarLambdaForge forge, EnumForgeCodegenParams args, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { var resultTypeMember = codegenClassScope.AddDefaultFieldUnshared( true, typeof(ObjectArrayEventType), Cast( typeof(ObjectArrayEventType), EventTypeUtility.ResolveTypeCodegen(forge.resultEventType, EPStatementInitServicesConstants.REF))); var scope = new ExprForgeCodegenSymbol(false, null); var methodNode = codegenMethodScope .MakeChildWithScope( typeof(IDictionary<object, object>), typeof(EnumToMapScalarLambdaForgeEval), scope, codegenClassScope) .AddParam(EnumForgeCodegenNames.PARAMS); var block = methodNode.Block .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty")) .BlockReturn(StaticMethod(typeof(Collections), "GetEmptyMap", new[] { typeof(object), typeof(object) })); block .DeclareVar<IDictionary<object, object>>("map", NewInstance(typeof(Dictionary<object, object>))) .DeclareVar<ObjectArrayEventBean>( "resultEvent", NewInstance<ObjectArrayEventBean>(NewArrayByLength(typeof(object), Constant(1)), resultTypeMember)) .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("resultEvent")) .DeclareVar<object[]>("props", ExprDotName(Ref("resultEvent"), "Properties")); var forEach = block .ForEach(typeof(object), "next", EnumForgeCodegenNames.REF_ENUMCOLL) .AssignArrayElement("props", Constant(0), Ref("next")) .DeclareVar<object>( "key", forge.InnerExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope)) .DeclareVar<object>( "value", forge.secondExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope)) .Expression(ExprDotMethod(Ref("map"), "Put", Ref("key"), Ref("value"))); block.MethodReturn(Ref("map")); return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx); }