Esempio n. 1
0
        public static CodegenExpression Codegen(
            EnumToMapEventsForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var scope = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope.MakeChildWithScope(
                    typeof(IDictionary<string, object>),
                    typeof(EnumToMapEventsForgeEval),
                    scope,
                    codegenClassScope)
                .AddParam(EnumForgeCodegenNames.PARAMS);

            var block = methodNode.Block
                .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty"))
                .BlockReturn(StaticMethod(typeof(Collections), "GetEmptyMap", new[] { typeof(string), typeof(object) }));
            block.DeclareVar<IDictionary<string, object>>("map", NewInstance(typeof(HashMap<string, object>)));
            block.ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("next"))
                .DeclareVar<string>(
                    "key",
                    forge.InnerExpression.EvaluateCodegen(typeof(string), 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);
        }
Esempio n. 2
0
 public EnumToMapEventsForgeEval(
     EnumToMapEventsForge forge,
     ExprEvaluator innerExpression,
     ExprEvaluator secondExpression)
 {
     _forge = forge;
     _innerExpression = innerExpression;
     _secondExpression = secondExpression;
 }