Beispiel #1
0
            public CodegenExpression EvaluateCodegen(
                Type requiredType,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var arrayType  = TypeHelper.GetArrayType(componentReturnType);
                var methodNode = codegenMethodScope.MakeChild(arrayType, GetType(), codegenClassScope);

                methodNode.Block
                .DeclareVar <EventBean[]>(
                    "events",
                    CodegenExpressionBuilder.Cast(
                        typeof(EventBean[]),
                        inner.EvaluateCodegen(requiredType, methodNode, exprSymbol, codegenClassScope)))
                .IfRefNullReturnNull("events")
                .DeclareVar(
                    arrayType,
                    "values",
                    CodegenExpressionBuilder.NewArrayByLength(
                        componentReturnType,
                        CodegenExpressionBuilder.ArrayLength(CodegenExpressionBuilder.Ref("events"))))
                .ForLoopIntSimple("i", CodegenExpressionBuilder.ArrayLength(CodegenExpressionBuilder.Ref("events")))
                .AssignArrayElement(
                    "values",
                    CodegenExpressionBuilder.Ref("i"),
                    CodegenExpressionBuilder.Cast(
                        componentReturnType,
                        CodegenExpressionBuilder.ExprDotUnderlying(
                            CodegenExpressionBuilder.ArrayAtIndex(
                                CodegenExpressionBuilder.Ref("events"),
                                CodegenExpressionBuilder.Ref("i")))))
                .BlockEnd()
                .MethodReturn(CodegenExpressionBuilder.Ref("values"));
                return(CodegenExpressionBuilder.LocalMethod(methodNode));
            }