예제 #1
0
        public static CodegenMethod GetBeanArrayValueCodegen(
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope,
            BeanEventPropertyGetter nestedGetter,
            int index)
        {
            return codegenMethodScope.MakeChild(typeof(object), typeof(BaseNestableEventUtil), codegenClassScope)
                .AddParam(typeof(object), "value")
                .Block
                .IfRefNullReturnNull("value")

                .IfNotInstanceOf("value", typeof(Array))
                .BlockReturn(ConstantNull())

                .DeclareVar<Array>("array", Cast<Array>(Ref("value")))
                .IfConditionReturnConst(
                    Relational(ExprDotName(Ref("array"), "Length"), LE, Constant(index)),
                    null)

                .DeclareVar<object>(
                    "arrayItem",
                    ExprDotMethod(Ref("array"), "GetValue", Constant(index)))

                .IfRefNullReturnNull("arrayItem")
                .MethodReturn(
                    nestedGetter.UnderlyingGetCodegen(
                        Cast(nestedGetter.TargetType, Ref("arrayItem")),
                        codegenMethodScope,
                        codegenClassScope));
        }
 private CodegenMethod GetFieldCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(field.DeclaringType, "und")
         .Block
         .DeclareVar<object>("value", Ref("und." + field.Name))
         .IfRefNullReturnNull("value")
         .MethodReturn(nestedGetter.UnderlyingGetCodegen(CastRef(nestedGetter.TargetType, "value"), codegenMethodScope, codegenClassScope));
 }
예제 #3
0
 private CodegenMethod GetObjectArrayCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(typeof(object[]), "array")
         .Block
         .DeclareVar<object>("value", ArrayAtIndex(Ref("array"), Constant(propertyIndex)))
         .IfRefNullReturnNull("value")
         .IfInstanceOf("value", typeof(EventBean))
         .BlockReturn(
             entryGetter.EventBeanGetCodegen(
                 CastRef(typeof(EventBean), "value"),
                 codegenMethodScope,
                 codegenClassScope))
         .MethodReturn(
             entryGetter.UnderlyingGetCodegen(
                 FlexCast(entryGetter.TargetType, Ref("value")),
                 codegenMethodScope,
                 codegenClassScope));
 }
예제 #4
0
 private CodegenMethod GetMapCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope
         .MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(typeof(IDictionary<string, object>), "map")
         .Block
         .DeclareVar<object>("value", ExprDotMethod(Ref("map"), "Get", Constant(propertyMap)))
         .IfRefNullReturnNull("value")
         .IfInstanceOf("value", typeof(EventBean))
         .BlockReturn(
             mapEntryGetter.EventBeanGetCodegen(
                 CastRef(typeof(EventBean), "value"),
                 codegenMethodScope,
                 codegenClassScope))
         .MethodReturn(
             mapEntryGetter.UnderlyingGetCodegen(
                 CastRef(mapEntryGetter.TargetType, "value"),
                 codegenMethodScope,
                 codegenClassScope));
 }