private string GetMapCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(object), typeof(Map), "map", GetType())
         .DeclareVar(typeof(object), "result",
             _getterChain[0].CodegenUnderlyingGet(Ref("map"), context))
         .MethodReturn(LocalMethod(HandleGetterTrailingChainCodegen(context),
             Ref("result")));
 }
 private string GetFragmentCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(Object), typeof(Object[]), "array", this.GetType())
         .DeclareVar(typeof(Object), "value", ArrayAtIndex(Ref("array"), Constant(_propertyIndex)))
         .IfRefNullReturnNull("value")
         .DeclareVarWCast(typeof(EventBean), "theEvent", "value")
         .MethodReturn(_eventBeanEntryGetter.CodegenEventBeanFragment(Ref("theEvent"), context));
 }
 private string GetMapCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(object), typeof(Map), "map", GetType())
         .DeclareVar(typeof(EventBean[]), "wrapper",
             Cast(typeof(EventBean[]), ExprDotMethod(Ref("map"), "get", Constant(_propertyName))))
         .MethodReturn(LocalMethod(
             BaseNestableEventUtil.GetArrayPropertyValueCodegen(context, _index, _nestedGetter), Ref("wrapper")));
 }
Exemple #4
0
        public static string From(
            ICodegenContext context,
            Type expectedUnderlyingType,
            EventPropertyGetterSPI innerGetter,
            AccessType accessType,
            Type generator)
        {
            var block = context.AddMethod(accessType == AccessType.EXISTS ? typeof(bool) : typeof(object),
                                          typeof(object), "value", generator)
                        .IfNotInstanceOf("value", expectedUnderlyingType)
                        .IfInstanceOf("value", typeof(EventBean))
                        .DeclareVarWCast(typeof(EventBean), "bean", "value");

            switch (accessType)
            {
            case AccessType.GET:
                block = block.BlockReturn(innerGetter.CodegenEventBeanGet(Ref("bean"), context));
                break;

            case AccessType.EXISTS:
                block = block.BlockReturn(innerGetter.CodegenEventBeanExists(Ref("bean"), context));
                break;

            case AccessType.FRAGMENT:
                block = block.BlockReturn(innerGetter.CodegenEventBeanFragment(Ref("bean"), context));
                break;

            default:
                throw new UnsupportedOperationException("Invalid access type " + accessType);
            }

            block = block.BlockReturn(Constant(accessType == AccessType.EXISTS ? (object)false : null));

            ICodegenExpression expression;

            switch (accessType)
            {
            case AccessType.GET:
                expression = innerGetter.CodegenUnderlyingGet(Cast(
                                                                  expectedUnderlyingType, Ref("value")), context);
                break;

            case AccessType.EXISTS:
                expression = innerGetter.CodegenUnderlyingExists(Cast(
                                                                     expectedUnderlyingType, Ref("value")), context);
                break;

            case AccessType.FRAGMENT:
                expression = innerGetter.CodegenUnderlyingFragment(
                    Cast(expectedUnderlyingType, Ref("value")), context);
                break;

            default:
                throw new UnsupportedOperationException("Invalid access type " + accessType);
            }

            return(block.MethodReturn(expression));
        }
 private string GetCodegen(ICodegenContext context)
 {
     return(context
            .AddMethod(typeof(object), typeof(XmlNode), "node", GetType())
            .DeclareVar(typeof(object), "value", _getter.CodegenUnderlyingGet(Ref("node"), context))
            .MethodReturn(StaticMethod(GetType(), "GetXPathNodeListWCheck",
                                       Ref("value"),
                                       Constant(_index))));
 }
Exemple #6
0
 private String GetObjectArrayCodegen(ICodegenContext context)
 {
     return(context.AddMethod(typeof(Object), typeof(Object[]), "Array", GetType())
            .DeclareVar(typeof(EventBean[]), "wrapper", Cast(typeof(EventBean[]), ArrayAtIndex(
                                                                 Ref("array"), Constant(_propertyIndex))))
            .MethodReturn(LocalMethod(
                              BaseNestableEventUtil.GetArrayPropertyValueCodegen(context, _index, _nestedGetter),
                              Ref("wrapper"))));
 }
 private string GetFragmentCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(object), typeof(Map), "map", GetType())
         .DeclareVar(typeof(object), "value",
             ExprDotMethod(Ref("map"), "get",
                 Constant(PropertyMap)))
         .IfRefNullReturnNull("value")
         .MethodReturn(HandleNestedValueFragmentCodegen(Ref("value"), context));
 }
Exemple #8
0
 private string GetCodegen(ICodegenContext context)
 {
     return(context.AddMethod(typeof(object), typeof(GenericRecord), "record", this.GetType())
            .DeclareVar(
                typeof(GenericRecord), "inner",
                StaticMethodTakingExprAndConst(this.GetType(), "GetAtIndex", Ref("record"), _posTop, _index))
            .IfRefNullReturnNull("inner")
            .MethodReturn(_nested.CodegenUnderlyingGet(Ref("inner"), context)));
 }
 private String GetBeanPropInternalCodegen(ICodegenContext context)
 {
     return(context.AddMethod(BeanPropType, TargetType, "object", this.GetType())
            .DeclareVar(typeof(object), "value", ExprDotName(Ref("object"), _field.Name))
            .MethodReturn(Cast(BeanPropType, StaticMethod(
                                   typeof(EnumerableMethodPropertyGetter), "GetBeanEventIterableValue",
                                   Ref("value"),
                                   Constant(_index)))));
 }
Exemple #10
0
        private string NavigateMethodCodegen(ICodegenContext context)
        {
            var navigateRecordMethod = NavigateRecordMethodCodegen(context);

            return(context.AddMethod(typeof(GenericRecord), typeof(GenericRecord), "record", GetType())
                   .DeclareVar(typeof(Object), "value", StaticMethodTakingExprAndConst(typeof(AvroEventBeanGetterNestedIndexRooted), "GetAtIndex", Ref("record"), _posTop, _index))
                   .IfRefNullReturnNull("value")
                   .MethodReturn(LocalMethod(navigateRecordMethod, CastRef(typeof(GenericRecord), "value"))));
        }
 private String GetObjectArrayCodegen(ICodegenContext context)
 {
     return(context.AddMethod(typeof(Object), typeof(Object[]), "oa", GetType())
            .DeclareVar(typeof(Object), "inner", ArrayAtIndex(Ref("oa"), Constant(_propertyIndex)))
            .MethodReturn(LocalMethod(
                              BaseNestableEventUtil.GetArrayPropertyAsUnderlyingsArrayCodegen(_underlyingType, context),
                              Cast(typeof(EventBean[]),
                                   Ref("inner")))));
 }
Exemple #12
0
        private string GetAvroFragmentCodegen(ICodegenContext context)
        {
            var mSvc  = context.MakeAddMember(typeof(EventAdapterService), _eventAdapterService);
            var mType = context.MakeAddMember(typeof(EventType), _fragmentType);

            return(context.AddMethod(typeof(Object), typeof(GenericRecord), "record", GetType())
                   .DeclareVar(typeof(Object), "value", CodegenUnderlyingGet(Ref("record"), context))
                   .MethodReturn(StaticMethod(GetType(), "GetFragmentAvro", Ref("value"), Ref(mSvc.MemberName), Ref(mType.MemberName))));
        }
Exemple #13
0
 private string GetFragmentCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(object), typeof(EventBean), "theEvent", GetType())
         .DeclareVarWCast(typeof(DecoratingEventBean), "wrapperEvent", "theEvent")
         .DeclareVar(typeof(EventBean), "wrappedEvent",
             ExprDotMethod(Ref("wrapperEvent"), "getUnderlyingEvent"))
         .IfRefNullReturnNull("wrappedEvent")
         .MethodReturn(_underlyingGetter.CodegenEventBeanFragment(Ref("wrappedEvent"), context));
 }
Exemple #14
0
 internal static String GetBeanPropCodegen(ICodegenContext context, Type beanPropType, Type targetType, MethodInfo method, int index)
 {
     return(context.AddMethod(beanPropType, targetType, "object", typeof(EnumerableMethodPropertyGetter))
            .DeclareVar(typeof(object), "value", ExprDotMethod(Ref("object"), method.Name))
            .MethodReturn(Cast(beanPropType, StaticMethod(
                                   typeof(EnumerableMethodPropertyGetter), "GetBeanEventEnumerableValue",
                                   Ref("value"),
                                   Constant(index)))));
 }
 private string IsExistsPropertyCodegen(ICodegenContext context)
 {
     return(context.AddMethod(typeof(bool), typeof(GenericRecord), "record", GetType())
            .DeclareVar(typeof(Field), "field", ExprDotMethodChain(Ref("record")).AddNoParam("GetSchema").AddWConst("GetField", _fieldTop))
            .IfRefNullReturnFalse("field")
            .DeclareVar(typeof(Object), "inner", ExprDotMethod(Ref("record"), "get", Constant(_fieldTop)))
            .IfRefNotTypeReturnConst("inner", typeof(GenericRecord), false)
            .MethodReturn(_getter.CodegenUnderlyingExists(Cast(typeof(GenericRecord), Ref("inner")), context)));
 }
 private string GetFragmentCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(object), typeof(Map), "map", GetType())
         .DeclareVar(typeof(EventBean[]), "wrapper",
             Cast(typeof(EventBean[]),
                 ExprDotMethod(Ref("map"), "get",
                     Constant(_propertyName))))
         .MethodReturn(StaticMethod(typeof(BaseNestableEventUtil), "GetBNArrayPropertyBean",
             Ref("wrapper"), Constant(_index)));
 }
 private string GetMapCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(object), typeof(Map), "map", GetType())
         .DeclareVar(typeof(object), "value",
             ExprDotMethod(Ref("map"), "get",
                 Constant(_propertyMap)))
         .MethodReturn(LocalMethod(
             BaseNestableEventUtil.GetBeanArrayValueCodegen(context, _nestedGetter, _index),
             Ref("value")));
 }
Exemple #18
0
 private String GetObjectArrayCodegen(ICodegenContext context)
 {
     return(context.AddMethod(typeof(Object), typeof(Object[]), "array", this.GetType())
            .DeclareVar(typeof(EventBean[]), "wrapper",
                        Cast(typeof(EventBean[]),
                             ArrayAtIndex(Ref("array"),
                                          Constant(_propertyIndex))))
            .MethodReturn(StaticMethod(typeof(BaseNestableEventUtil),
                                       "GetBNArrayPropertyUnderlying", Ref("wrapper"), Constant(_index))));
 }
Exemple #19
0
 private string HandleNestedValueCodegen(ICodegenContext context)
 {
     var block = context.AddMethod(typeof(object), typeof(object), "value", GetType())
         .IfRefNotTypeReturnConst("value", typeof(Map), "null");
     if (_nestedGetter is MapEventPropertyGetter)
         return block.MethodReturn(
             ((MapEventPropertyGetter) _nestedGetter).CodegenUnderlyingGet(
                 Cast(typeof(Map), Ref("value")), context));
     return block.MethodReturn(ConstantNull());
 }
 private string IsMapExistsPropertyCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(bool), typeof(Map), "map", GetType())
         .IfConditionReturnConst(_getterChain[0].CodegenUnderlyingExists(Ref("map"), context),
             false)
         .DeclareVar(typeof(object), "result",
             _getterChain[0].CodegenUnderlyingGet(Ref("map"), context))
         .MethodReturn(LocalMethod(HandleIsExistsTrailingChainCodegen(context),
             Ref("result")));
 }
 private string IsMapExistsPropertyCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(bool), typeof(Map), "map", GetType())
         .DeclareVar(typeof(object), "valueTopObj",
             ExprDotMethod(Ref("map"), "get",
                 Constant(_propertyMap)))
         .IfRefNotTypeReturnConst("valueTopObj", typeof(Map), false)
         .DeclareVar(typeof(Map), "value", CastRef(typeof(Map), "valueTopObj"))
         .MethodReturn(_getter.CodegenUnderlyingExists(Ref("value"), context));
 }
Exemple #22
0
        private String GetValueAsFragmentCodegen(ICodegenContext context)
        {
            var mType = context.MakeAddMember(typeof(FragmentFactory), _fragmentFactory);

            return(context
                   .AddMethod(typeof(object), typeof(object), "node", GetType())
                   .DeclareVar(typeof(object), "result", GetValueAsNodeCodegen(Ref("node"), context))
                   .IfRefNullReturnNull("result")
                   .MethodReturn(ExprDotMethod(Ref(mType.MemberName), "GetEvent", Ref("result"))));
        }
 private string GetMapCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(object), typeof(Map), "map", GetType())
         .DeclareVar(typeof(object), "eventBean",
             ExprDotMethod(Ref("map"), "get",
                 Constant(_propertyName)))
         .IfRefNullReturnNull("eventBean")
         .MethodReturn(ExprDotMethod(
             Cast(typeof(EventBean), Ref("eventBean")), "GetUnderlying"));
 }
 internal static string GetBeanPropInternalCode(ICodegenContext context, MethodInfo method, int index)
 {
     return context.AddMethod(method.ReturnType.GetElementType().GetBoxedType(), method.DeclaringType, "obj",
             typeof(ArrayFastPropertyGetter))
         .DeclareVar(method.ReturnType, "array", ExprDotMethod(Ref("obj"), method.Name))
         .IfConditionReturnConst(
             Relational(ArrayLength(Ref("array")),
                 CodegenRelational.LE, Constant(index)), null)
         .MethodReturn(ArrayAtIndex(Ref("array"), Constant(index)));
 }
Exemple #25
0
 private string GetCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(object), typeof(EventBean), "eventBean", GetType())
         .DeclareVar(typeof(RevisionEventBeanDeclared), "riv",
             Cast(typeof(RevisionEventBeanDeclared), Ref("eventBean")))
         .DeclareVar(typeof(EventBean), "bean",
             ExprDotMethod(Ref("riv"), "getLastBaseEvent"))
         .IfRefNullReturnNull("bean")
         .MethodReturn(_fullGetter.CodegenEventBeanGet(Ref("bean"), context));
 }
 private string GetBeanPropInternalCodegen(ICodegenContext context)
 {
     return context.AddMethod(BeanPropType, TargetType, "object", this.GetType())
         .DeclareVar(typeof(Object), "result", ExprDotName(Ref("object"), _field.Name))
         .IfRefNotTypeReturnConst("result", typeof(Map), null)
         .DeclareVarWCast(typeof(Map), "map", "result")
         .MethodReturn(Cast(
             BeanPropType, ExprDotMethod(
                 Ref("map"), "get", Constant(_key))));
 }
Exemple #27
0
 private string GetBeanPropInternalCodegen(ICodegenContext context)
 {
     return(context.AddMethod(BeanPropType, TargetType, "object", this.GetType())
            .DeclareVar(typeof(Object), "value", ExprDotName(Ref("object"), _field.Name))
            .IfConditionReturnConst(
                Relational(StaticMethod(typeof(Array), "getLength", Ref("value")),
                           CodegenRelational.LE, Constant(_index)), null)
            .MethodReturn(Cast(BeanPropType,
                               StaticMethod(typeof(Array), "get", Ref("value"), Constant(_index)))));
 }
Exemple #28
0
 private string GetMapCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(object), typeof(Map), "map", GetType())
         .DeclareVar(typeof(object), "mapValue",
             ExprDotMethod(Ref("map"), "get",
                 Constant(_propertyName)))
         .MethodReturn(LocalMethod(
             BaseNestableEventUtil.GetArrayPropertyAsUnderlyingsArrayCodegen(_underlyingType, context),
             Cast(typeof(EventBean[]), Ref("mapValue"))));
 }
Exemple #29
0
 private string GetFragmentCodegen(ICodegenContext context)
 {
     return context.AddMethod(typeof(object), typeof(Map), "map", GetType())
         .DeclareVar(typeof(object), "value",
             ExprDotMethod(Ref("map"), "get",
                 Constant(_propertyMap)))
         .IfRefNullReturnNull("value")
         .DeclareVar(typeof(EventBean), "theEvent",
             Cast(typeof(EventBean), Ref("value")))
         .MethodReturn(_eventBeanEntryGetter.CodegenEventBeanFragment(Ref("theEvent"), context));
 }
 internal static string GetBeanPropInternalCodegen(ICodegenContext context, Type beanPropType, Type targetType, MethodInfo method, Object key)
 {
     return context.AddMethod(beanPropType, targetType, "object", typeof(KeyedMapMethodPropertyGetter))
         .DeclareVar(method.ReturnType, "result", ExprDotMethod(Ref("object"), method.Name))
         .IfRefNotTypeReturnConst("result", typeof(Map), null)
         .MethodReturn(Cast(
             beanPropType, ExprDotMethod(
                 Cast(typeof(Map), Ref("result")),
                 "get",
                 Constant(key))));
 }