private string GetFragmentCodegen(ICodegenContext context) { return(context.AddMethod(typeof(object), typeof(GenericRecord), "record", this.GetType()) .DeclareVar( typeof(Collection), "values", Cast(typeof(Collection), ExprDotMethod(Ref("record"), "Get", Constant(_posTop)))) .DeclareVar( typeof(object), "value", StaticMethod( typeof(AvroEventBeanGetterIndexed), "GetAvroIndexedValue", Ref("values"), Constant(_index))) .IfRefNullReturnNull("value") .IfRefNotTypeReturnConst("value", typeof(GenericRecord), null) .MethodReturn(_nested.CodegenUnderlyingFragment(Cast(typeof(GenericRecord), Ref("value")), context))); }
private string GetCodegen(ICodegenContext context) { var mgetter = context.MakeAddMember(typeof(EventPropertyGetter), _nestedGetter); var msvc = context.MakeAddMember(typeof(EventAdapterService), _eventAdapterService); return context.AddMethod(typeof(object), typeof(EventBean), "obj", GetType()) .DeclareVar(typeof(object), "result", _revisionGetter.CodegenEventBeanGet(Ref("obj"), context)) .IfRefNullReturnNull("result") .DeclareVar(typeof(EventBean), "theEvent", ExprDotMethod(Ref(msvc.MemberName), "adapterForBean", Ref("result"))) .MethodReturn(ExprDotMethod(Ref(mgetter.MemberName), "get", Ref("theEvent"))); }
public static ICodegenExpression HandleNestedValueArrayWithObjectArrayCodegen( int index, ObjectArrayEventPropertyGetter getter, ICodegenExpression @ref, ICodegenContext context, Type generator) { var method = CodegenBlockPropertyBeanOrUnd.From(context, typeof(object[]), getter, CodegenBlockPropertyBeanOrUnd.AccessType.GET, generator); return(LocalMethod(method, StaticMethodTakingExprAndConst(typeof(BaseNestableEventUtil), "GetBNArrayValueAtIndex", @ref, index))); }
private string GetBeanPropInternalCodegen(ICodegenContext context) { return(context .AddMethod(BeanPropType, TargetType, "object", GetType()) .DeclareVar(typeof(object), "value", ExprDotName(Ref("object"), _field.Name)) .IfRefNotTypeReturnConst("value", typeof(string), null) .DeclareVar(typeof(string), "v", Cast(typeof(string), Ref("value"))) .MethodReturn(Cast(BeanPropType, StaticMethod(GetType(), "GetValueAtIndex", Ref("v"), Constant(_index))))); }
private String GetValueAsFragmentCodegen(ICodegenContext context) { var member = context.MakeAddMember(typeof(FragmentFactory), _fragmentFactory); return(context .AddMethod(typeof(object), typeof(object), "node", GetType()) .DeclareVar(typeof(object), "result", StaticMethod( typeof(DOMIndexedGetter), "GetNodeValue", Ref("node"), Constant(_propertyName), Constant(_index))) .IfRefNullReturnNull("result") .MethodReturn(ExprDotMethod(Ref(member.MemberName), "GetEvent", Ref("result")))); }
private string GetMapCodegen(ICodegenContext context) { return context.AddMethod(typeof(object), typeof(Map), "map", GetType()) .DeclareVar(typeof(object), "value", ExprDotMethod(Ref("map"), "get", Constant(_propertyMap))) .IfRefNullReturnNull("value") .IfInstanceOf("value", typeof(EventBean)) .BlockReturn(_mapEntryGetter.CodegenEventBeanGet(CastRef(typeof(EventBean), "value"), context)) .MethodReturn( _mapEntryGetter.CodegenUnderlyingGet(CastRef(_mapEntryGetter.TargetType, "value"), context)); }
private string GetBeanPropInternalCodegen(ICodegenContext context) { return context.AddMethod(BeanPropType, TargetType, "object", GetType()) .DeclareVar(typeof(object), "value", ExprDotName(Ref("object"), _field.Name)) .IfRefNotTypeReturnConst("value", typeof(IList<object>), null) .DeclareVar(typeof(IList<object>), "l", Cast(typeof(IList<object>), Ref("value"))) .IfConditionReturnConst( Relational(ExprDotMethod(Ref("l"), "size"), CodegenRelational.LE, Constant(_index)), null) .MethodReturn(Cast(BeanPropType, ExprDotMethod(Ref("l"), "get", Constant(_index)))); }
private String GetCodegen(ICodegenContext context) { var mComponentType = context.MakeAddMember(typeof(Type), _componentType); var mParser = context.MakeAddMember(typeof(SimpleTypeParser), _parser); return(context.AddMethod(typeof(object), typeof(object), "node", GetType()) .DeclareVar(typeof(object[]), "result", _getter.GetValueAsNodeArrayCodegen(Ref("node"), context)) .IfRefNullReturnNull("result") .MethodReturn( StaticMethod( GetType(), "GetDOMArrayFromNodes", Ref("result"), Ref(mComponentType.MemberName), Ref(mParser.MemberName)))); }
private string NavigateRecordMethodCodegen(ICodegenContext context) { var block = context.AddMethod(typeof(GenericRecord), typeof(GenericRecord), "record", GetType()) .DeclareVar(typeof(GenericRecord), "current", Ref("record")) .DeclareVarNull(typeof(Object), "value"); for (var i = 0; i < _nested.Length - 1; i++) { block.AssignRef("value", _nested[i].CodegenUnderlyingGet(Ref("current"), context)) .IfRefNotTypeReturnConst("value", typeof(GenericRecord), null) .AssignRef("current", CastRef(typeof(GenericRecord), "value")); } return(block.MethodReturn(Ref("current"))); }
private string GetCodegen(ICodegenContext context) { return(context.AddMethod(typeof(Object), typeof(GenericRecord), "record", GetType()) .DeclareVar( typeof(GenericRecord), "inner", Cast( typeof(GenericRecord), ExprDotMethod(Ref("record"), "Get", Constant(_top)))) .IfRefNullReturnNull("inner") .DeclareVar( typeof(Map), "map", Cast(typeof(Map), ExprDotMethod(Ref("inner"), "Get", Constant(_pos)))) .MethodReturn( StaticMethod( typeof(AvroEventBeanGetterMapped), "GetAvroMappedValueWNullCheck", Ref("map"), Constant(_key)))); }
public static ICodegenExpression HandleNestedValueArrayWithMapExistsCode(int index, MapEventPropertyGetter getter, ICodegenExpression @ref, ICodegenContext context, EventAdapterService eventAdapterService, EventType fragmentType, Type generator) { var method = CodegenBlockPropertyBeanOrUnd.From(context, typeof(Map), getter, CodegenBlockPropertyBeanOrUnd.AccessType.EXISTS, generator); return(LocalMethod(method, StaticMethodTakingExprAndConst(typeof(BaseNestableEventUtil), "GetBNArrayValueAtIndex", @ref, index))); }
private String GetValueAsNodeArrayCodegen <T>(ICodegenContext codegenContext) { var arrayType = typeof(T[]); var scalarType = typeof(T); var block = codegenContext.AddMethod(arrayType, scalarType, "node", GetType()); for (int i = 0; i < _domGetterChain.Length - 1; i++) { block.AssignRef("node", _domGetterChain[i].GetValueAsNodeCodegen(Ref("node"), codegenContext)); block.IfRefNullReturnNull("node"); } return(block.MethodReturn( _domGetterChain[_domGetterChain.Length - 1] .GetValueAsNodeArrayCodegen(Ref("node"), codegenContext))); }
public static EventPropertyGetter Compile( this ICodegenContext codegenContext, string engineURI, ClassLoaderProvider classLoaderProvider, EventPropertyGetterSPI getterSPI, string propertyExpression) { var get = getterSPI.CodegenEventBeanGet(Ref("bean"), codegenContext); var exists = getterSPI.CodegenEventBeanExists(Ref("bean"), codegenContext); var fragment = getterSPI.CodegenEventBeanFragment(Ref("bean"), codegenContext); var singleBeanParam = CodegenNamedParam.From(typeof(EventBean), "bean"); // For: public object Get(EventBean eventBean) ; // For: public bool IsExistsProperty(EventBean eventBean); // For: public object GetFragment(EventBean eventBean) ; var getMethod = new CodegenMethod(typeof(object), "Get", singleBeanParam, null); getMethod.Statements.MethodReturn(get); var isExistsPropertyMethod = new CodegenMethod(typeof(bool), "IsExistsProperty", singleBeanParam, null); isExistsPropertyMethod.Statements.MethodReturn(exists); var fragmentMethod = new CodegenMethod(typeof(object), "GetFragment", singleBeanParam, null); fragmentMethod.Statements.MethodReturn(fragment); var clazz = new CodegenClass( "com.espertech.esper.codegen.uri_" + engineURI, typeof(EventPropertyGetter).Name + "_" + CodeGenerationIDGenerator.GenerateClass(), typeof(EventPropertyGetter), codegenContext.Members, new [] { getMethod, isExistsPropertyMethod, fragmentMethod }, codegenContext.Methods ); string debugInfo = null; if (codegenContext.IsDebugEnabled) { debugInfo = getterSPI.GetType().FullName + " for property '" + propertyExpression + "'"; } return(codegenContext.Compiler.Compile( clazz, classLoaderProvider, typeof(EventPropertyGetter), debugInfo)); }
public static string GetBeanArrayValueCodegen( ICodegenContext context, BeanEventPropertyGetter nestedGetter, int index) { return(context.AddMethod(typeof(object), typeof(object), "value", typeof(BaseNestableEventUtil)) .IfRefNullReturnNull("value") .IfConditionReturnConst( Not(ExprDotMethodChain(Ref("value")).AddNoParam("getClass") .AddNoParam("isArray")), null) .IfConditionReturnConst( Relational(StaticMethod(typeof(Array), "getLength", Ref("value")), CodegenRelational.LE, Constant(index)), null) .DeclareVar(typeof(object), "arrayItem", StaticMethod(typeof(Array), "get", Ref("value"), Constant(index))) .IfRefNullReturnNull("arrayItem") .MethodReturn( nestedGetter.CodegenUnderlyingGet(Cast(nestedGetter.TargetType, Ref("arrayItem")), context))); }
public ICodegenExpression CodegenUnderlyingFragment(ICodegenExpression underlyingExpression, ICodegenContext context) { if (_fragmentFactory == null) { return(ConstantNull()); } var mExpression = context.MakeAddMember(typeof(XPathExpression), _expression); var mExpressionText = context.MakeAddMember(typeof(String), _expressionText); var mProperty = context.MakeAddMember(typeof(String), _property); var mFragmentFactory = context.MakeAddMember(typeof(FragmentFactory), _fragmentFactory); var mResultType = context.MakeAddMember(typeof(XmlQualifiedName), _resultType); return(StaticMethod(typeof(XPathPropertyGetter), "evaluateXPathFragment", underlyingExpression, Ref(mExpression.MemberName), Ref(mExpressionText.MemberName), Ref(mProperty.MemberName), Ref(mFragmentFactory.MemberName), Ref(mResultType.MemberName))); }
private string HandleGetterTrailingChainCodegen(ICodegenContext context) { var block = context.AddMethod(typeof(object), typeof(object), "result", GetType()); for (var i = 1; i < _mapGetterChain.Length; i++) { block.IfRefNullReturnNull("result"); var getter = _mapGetterChain[i]; block.IfNotInstanceOf("result", typeof(Map)) .IfInstanceOf("result", typeof(EventBean)) .AssignRef("result", getter.CodegenEventBeanGet(CastRef(typeof(EventBean), "result"), context)) .BlockElse() .BlockReturn(ConstantNull()) .BlockElse() .AssignRef("result", getter.CodegenUnderlyingGet(CastRef(typeof(Map), "result"), context)) .BlockEnd(); } return block.MethodReturn(Ref("result")); }
public EngineImportServiceImpl( bool allowExtendedAggregationFunc, bool isUdfCache, bool isDuckType, bool sortUsingCollator, MathContext optionalDefaultMathContext, TimeZoneInfo timeZone, TimeAbacus timeAbacus, ConfigurationEngineDefaults.ThreadingProfile threadingProfile, IDictionary<string, object> transientConfiguration, AggregationFactoryFactory aggregationFactoryFactory, bool isCodegenEventPropertyGetters, string engineURI, ICodegenContext context, ClassLoaderProvider classLoaderProvider) { _imports = new List<AutoImportDesc>(); _annotationImports = new List<AutoImportDesc>(2); _aggregationFunctions = new Dictionary<string, ConfigurationPlugInAggregationFunction>(); _aggregationAccess = new List<Pair<ISet<string>, ConfigurationPlugInAggregationMultiFunction>>(); _singleRowFunctions = new Dictionary<string, EngineImportSingleRowDesc>(); _methodInvocationRef = new Dictionary<string, ConfigurationMethodRef>(); _allowExtendedAggregationFunc = allowExtendedAggregationFunc; IsUdfCache = isUdfCache; IsDuckType = isDuckType; IsSortUsingCollator = sortUsingCollator; DefaultMathContext = optionalDefaultMathContext; TimeZone = timeZone; TimeAbacus = timeAbacus; ThreadingProfile = threadingProfile; _transientConfiguration = transientConfiguration; AggregationFactoryFactory = aggregationFactoryFactory; _advancedIndexProviders = new LinkedHashMap<string, AdvancedIndexFactoryProvider>(); _advancedIndexProviders.Put("pointregionquadtree", new AdvancedIndexFactoryProviderPointRegionQuadTree()); _advancedIndexProviders.Put("mxcifquadtree", new AdvancedIndexFactoryProviderMXCIFQuadTree()); IsCodegenEventPropertyGetters = isCodegenEventPropertyGetters; _engineURI = engineURI; _context = context; _classLoaderProvider = classLoaderProvider; }
private string GetBeanPropCodegen(ICodegenContext context, bool exists) { var block = context.AddMethod(exists ? typeof(bool) : TypeHelper.GetBoxedType(_getterChain[_getterChain.Length - 1].BeanPropType), _getterChain[0].TargetType, "value", this.GetType()); if (!exists) { block.IfRefNullReturnNull("value"); } else { block.IfRefNullReturnFalse("value"); } string lastName = "value"; for (int i = 0; i < _getterChain.Length - 1; i++) { string varName = "l" + i; block.DeclareVar(_getterChain[i].BeanPropType, varName, _getterChain[i].CodegenUnderlyingGet( Ref(lastName), context)); lastName = varName; if (!exists) { block.IfRefNullReturnNull(lastName); } else { block.IfRefNullReturnFalse(lastName); } } if (!exists) { return block.MethodReturn(_getterChain[_getterChain.Length - 1].CodegenUnderlyingGet( Ref(lastName), context)); } else { return block.MethodReturn(_getterChain[_getterChain.Length - 1].CodegenUnderlyingExists( Ref(lastName), context)); } }
internal static string GetBeanPropInternalCodegen( ICodegenContext context, Type beanPropType, Type targetType, MethodInfo method, int index) { return(context.AddMethod(beanPropType, targetType, "object", typeof(ListMethodPropertyGetter)) .DeclareVar(typeof(object), "value", ExprDotMethod(Ref("object"), method.Name)) .IfRefNotTypeReturnConst("value", typeof(IList <object>), null) .DeclareVar(typeof(IList <object>), "l", Cast(typeof(IList <object>), Ref("value"))) .IfConditionReturnConst(Relational( ExprDotMethod(Ref("l"), "get_Count"), CodegenRelational.LE, Constant(index)), null) .MethodReturn(Cast( beanPropType, ExprDotMethod( Ref("l"), "get", Constant(index))))); }
public ICodegenExpression CodegenUnderlyingFragment(ICodegenExpression underlyingExpression, ICodegenContext context) { throw VAERevisionEventPropertyGetterDeclaredGetVersioned.RevisionImplementationNotProvided(); }
public ICodegenExpression CodegenEventBeanFragment(ICodegenExpression beanExpression, ICodegenContext context) { return ConstantNull(); }
public ICodegenExpression CodegenEventBeanExists(ICodegenExpression beanExpression, ICodegenContext context) { return ConstantTrue(); }
public ICodegenExpression CodegenEventBeanGet(ICodegenExpression beanExpression, ICodegenContext context) { return ExprDotMethod(Cast(typeof(RevisionEventBeanMerge), beanExpression), "GetKey"); }
public ICodegenExpression CodegenUnderlyingFragment(ICodegenExpression underlyingExpression, ICodegenContext context) { return ConstantNull(); }
public ICodegenExpression CodegenUnderlyingExists(ICodegenExpression underlyingExpression, ICodegenContext context) { return ExprDotMethod(underlyingExpression, "containsKey", Constant(_propertyName)); }
public ICodegenExpression CodegenUnderlyingGet(ICodegenExpression underlyingExpression, ICodegenContext context) { return ExprDotMethod(underlyingExpression, "Get", Constant(_propertyName)); }
public ICodegenExpression CodegenEventBeanExists(ICodegenExpression beanExpression, ICodegenContext context) { return ExprDotMethod(CastUnderlying(typeof(Map), beanExpression), "containsKey", Constant(_propertyName)); }
public ICodegenExpression CodegenEventBeanExists(ICodegenExpression beanExpression, ICodegenContext context) { return CodegenUnderlyingExists(CastUnderlying(typeof(XmlNode), beanExpression), context); }
public ICodegenExpression GetValueAsFragmentCodegen(ICodegenExpression value, ICodegenContext context) { return ConstantNull(); }
public ICodegenExpression GetValueAsNodeArrayCodegen(ICodegenExpression value, ICodegenContext context) { return ConstantNull(); }