public override CodegenMethod ProcessCodegen( CodegenExpression resultEventType, CodegenExpression eventBeanFactory, CodegenMethodScope codegenMethodScope, SelectExprProcessorCodegenSymbol selectSymbol, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope); var expr = exprForge.EvaluateCodegen( typeof(IDictionary <string, object>), methodNode, exprSymbol, codegenClassScope); if (!TypeHelper.IsSubclassOrImplementsInterface( exprForge.EvaluationType, typeof(IDictionary <string, object>))) { expr = CodegenExpressionBuilder.Cast(typeof(IDictionary <string, object>), expr); } methodNode.Block.DeclareVar <IDictionary <string, object> >("result", expr) .IfRefNullReturnNull("result") .MethodReturn( CodegenExpressionBuilder.ExprDotMethod( eventBeanFactory, "AdapterForTypedMap", CodegenExpressionBuilder.Ref("result"), resultEventType)); return(methodNode); }
private CodegenMethod IsExistsPropertyCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(bool), GetType(), codegenClassScope) .AddParam(typeof(GenericRecord), "record") .Block .DeclareVar<Field>( "field", CodegenExpressionBuilder.ExprDotMethodChain(CodegenExpressionBuilder.Ref("record")) .Get("Schema") .Add("GetField", CodegenExpressionBuilder.Constant(_fieldTop))) .IfRefNullReturnFalse("field") .DeclareVar<object>( "inner", CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("record"), CodegenExpressionBuilder.Constant(_fieldTop))) .IfRefNotTypeReturnConst("inner", typeof(GenericRecord), false) .MethodReturn( _getter.UnderlyingExistsCodegen( CodegenExpressionBuilder.Cast(typeof(GenericRecord), CodegenExpressionBuilder.Ref("inner")), codegenMethodScope, codegenClassScope)); }
private CodegenMethod GetCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope) .AddParam(typeof(GenericRecord), "record") .Block .DeclareVar<GenericRecord>( "inner", CodegenExpressionBuilder.Cast( typeof(GenericRecord), CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("record"), CodegenExpressionBuilder.Constant(_top.Name)))) .IfRefNullReturnNull("inner") .DeclareVar<IDictionary<string, object>>( "map", CodegenLegoCast.CastSafeFromObjectType( typeof(IDictionary<string, object>), CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("inner"), CodegenExpressionBuilder.Constant(_pos.Name)))) .MethodReturn( CodegenExpressionBuilder.StaticMethod( typeof(AvroEventBeanGetterMapped), "GetAvroMappedValueWNullCheck", CodegenExpressionBuilder.Ref("map"), CodegenExpressionBuilder.Constant(_key))); }
internal static CodegenMethod NavigatePolyCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, AvroEventPropertyGetter[] getters) { var block = codegenMethodScope.MakeChild( typeof(GenericRecord), typeof(AvroEventBeanGetterDynamicPoly), codegenClassScope) .AddParam(typeof(GenericRecord), "record") .Block; block.DeclareVar<object>("value", CodegenExpressionBuilder.ConstantNull()); for (var i = 0; i < getters.Length - 1; i++) { block.AssignRef( "value", getters[i] .UnderlyingGetCodegen( CodegenExpressionBuilder.Ref("record"), codegenMethodScope, codegenClassScope)) .IfRefNotTypeReturnConst("value", typeof(GenericRecord), null) .AssignRef( "record", CodegenExpressionBuilder.Cast(typeof(GenericRecord), CodegenExpressionBuilder.Ref("value"))); } return block.MethodReturn(CodegenExpressionBuilder.Ref("record")); }
private CodegenMethod GetCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope) .AddParam(typeof(GenericRecord), "record") .Block .DeclareVar<GenericRecord>( "inner", CodegenExpressionBuilder.Cast( typeof(GenericRecord), CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("record"), CodegenExpressionBuilder.Constant(_top.Name)))) .IfRefNullReturnNull("inner") .DeclareVar<object>( "collection", CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("inner"), CodegenExpressionBuilder.Constant(_pos))) .MethodReturn( CodegenExpressionBuilder.StaticMethod( typeof(AvroEventBeanGetterIndexed), "GetAvroIndexedValue", CodegenExpressionBuilder.Ref("collection"), CodegenExpressionBuilder.Constant(_index))); }
public CodegenExpression EvaluateCodegen( Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.MakeChild( typeof(ICollection<object>), GetType(), codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode); methodNode.Block .DeclareVar<EventBean>( "@event", CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(_streamNum))) .IfRefNullReturnNull("@event") .DeclareVar<object[]>( "result", CodegenExpressionBuilder.Cast( typeof(object[]), _getter.EventBeanGetCodegen( CodegenExpressionBuilder.Ref("@event"), methodNode, codegenClassScope))) .IfRefNullReturnNull("result") .MethodReturn( CodegenExpressionBuilder.StaticMethod( typeof(CompatExtensions), "AsList", CodegenExpressionBuilder.Ref("result"))); return CodegenExpressionBuilder.LocalMethod(methodNode); }
private CodegenMethod GetCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope) .AddParam(typeof(GenericRecord), "record") .Block .DeclareVar<GenericRecord>( "inner", CodegenExpressionBuilder.Cast( typeof(GenericRecord), CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("record"), CodegenExpressionBuilder.Constant(_fieldTop)))) .MethodReturn( CodegenExpressionBuilder.Conditional( CodegenExpressionBuilder.EqualsNull(CodegenExpressionBuilder.Ref("inner")), CodegenExpressionBuilder.ConstantNull(), _getter.UnderlyingGetCodegen( CodegenExpressionBuilder.Ref("inner"), codegenMethodScope, codegenClassScope))); }
public CodegenExpression MakeCopyMethodClassScoped(CodegenClassScope classScope) { var factory = classScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE); return CodegenExpressionBuilder.NewInstance( typeof(AvroEventBeanCopyMethod), CodegenExpressionBuilder.Cast( typeof(AvroEventType), EventTypeUtility.ResolveTypeCodegen(_avroEventType, EPStatementInitServicesConstants.REF)), factory); }
public static CodegenExpression CodegenAsString( CodegenExpression @ref, Type type) { if (type == typeof(string)) { return(@ref); } return(CodegenExpressionBuilder.Cast(typeof(string), @ref)); }
public CodegenExpression UnderlyingGetCodegen( CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { var values = CodegenExpressionBuilder.Cast( typeof(ICollection<object>), CodegenExpressionBuilder.ExprDotMethod( underlyingExpression, "Get", CodegenExpressionBuilder.Constant(_key.Name))); return CodegenExpressionBuilder.StaticMethod( GetType(), "GetAvroIndexedValue", values, CodegenExpressionBuilder.Constant(_index)); }
public CodegenExpression UnderlyingGetCodegen( CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return CodegenExpressionBuilder.LocalMethod( AvroEventBeanGetterDynamicPoly.GetAvroFieldValuePolyCodegen( codegenMethodScope, codegenClassScope, _getters), CodegenExpressionBuilder.Cast( typeof(GenericRecord), CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", underlyingExpression, CodegenExpressionBuilder.Constant(_top.Name)))); }
public static CodegenExpression MakeAnonymous( FilterSpecParamFilterForEvalDoubleForge eval, Type originator, CodegenClassScope classScope, CodegenMethod method) { var getFilterValueDouble = new CodegenExpressionLambda(method.Block) .WithParams(FilterSpecParam.GET_FILTER_VALUE_FP) .WithBody( block => block.BlockReturn( CodegenExpressionBuilder.Cast( typeof(double), eval.MakeCodegen(classScope, method)))); //anonymousClass.AddMethod("GetFilterValueDouble", getFilterValueDouble); //getFilterValueDouble.Block.MethodReturn( // CodegenExpressionBuilder.Cast( // typeof(double), // eval.MakeCodegen( // classScope, // getFilterValueDouble))); //var getFilterValue = new CodegenExpressionLambda(method.Block) // .WithParams(FilterSpecParam.GET_FILTER_VALUE_FP) // .WithBody( // block => block.BlockReturn( // CodegenExpressionBuilder.ExprDotMethod( // CodegenExpressionBuilder.Ref("this"), // "GetFilterValueDouble", // FilterSpecParam.REF_MATCHEDEVENTMAP, // ExprForgeCodegenNames.REF_EXPREVALCONTEXT, // FilterSpecParam.REF_STMTCTXFILTEREVALENV))); //anonymousClass.AddMethod("GetFilterValue", getFilterValue); //getFilterValue.Block.MethodReturn( // CodegenExpressionBuilder.ExprDotMethod( // CodegenExpressionBuilder.Ref("this"), // "GetFilterValueDouble", // FilterSpecParam.REF_MATCHEDEVENTMAP, // ExprForgeCodegenNames.REF_EXPREVALCONTEXT, // FilterSpecParam.REF_STMTCTXFILTEREVALENV)); return(CodegenExpressionBuilder.NewInstance <ProxyFilterSpecParamFilterForEvalDouble>(getFilterValueDouble)); }
public CodegenExpression EvaluateCodegen( Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope.MakeChild(returnType, GetType(), codegenClassScope); var refEPS = exprSymbol.GetAddEPS(methodNode); methodNode.Block .DeclareVar <EventBean>( "theEvent", CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(streamNumEval))) .IfRefNullReturnNull("theEvent") .MethodReturn( CodegenExpressionBuilder.Cast( returnType, CodegenExpressionBuilder.ExprDotUnderlying(CodegenExpressionBuilder.Ref("theEvent")))); return(CodegenExpressionBuilder.LocalMethod(methodNode)); }
public CodegenExpression UnderlyingGetCodegen( CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { #if false return CodegenExpressionBuilder.Cast( _propertyType, CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", underlyingExpression, CodegenExpressionBuilder.Constant(_propertyIndex.Name))); #else return CodegenLegoCast.CastSafeFromObjectType( _propertyType, CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", underlyingExpression, CodegenExpressionBuilder.Constant(_propertyIndex.Name))); #endif }
private CodegenMethod IsExistsPropertyCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(bool), GetType(), codegenClassScope) .AddParam(typeof(GenericRecord), "record") .Block .DeclareVar<GenericRecord>( "inner", CodegenExpressionBuilder.Cast( typeof(GenericRecord), CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("record"), CodegenExpressionBuilder.Constant(_posTop.Name)))) .IfRefNullReturnFalse("inner") .MethodReturn( CodegenExpressionBuilder.NotEqualsNull( CodegenExpressionBuilder.ExprDotMethodChain(CodegenExpressionBuilder.Ref("inner")) .Get("Schema") .Add("GetField", CodegenExpressionBuilder.Constant(_propertyName)))); }
public CodegenExpression Codegen( CodegenExpression input, Type inputType, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { if (TypeHelper.IsSubclassOrImplementsInterface(inputType, typeToCastTo)) { return input; } var cache = codegenClassScope.AddDefaultFieldUnshared( true, typeof(CopyOnWriteArraySet<Pair<Type, bool>>), NewInstance(typeof(CopyOnWriteArraySet<Pair<Type, bool>>))); return CodegenExpressionBuilder.Cast( typeToCastTo, StaticMethod( typeof(SimpleTypeCasterAnyType), "SimpleTypeCasterCast", input, Constant(typeToCastTo), cache)); }
public CodegenMethod ProcessCodegen( CodegenExpression resultEventType, CodegenExpression eventBeanFactory, CodegenMethodScope codegenMethodScope, SelectExprProcessorCodegenSymbol selectSymbol, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope); var refEPS = exprSymbol.GetAddEPS(methodNode); var theEvent = CodegenExpressionBuilder.Cast( typeof(AvroGenericDataBackedEventBean), CodegenExpressionBuilder.ArrayAtIndex( refEPS, CodegenExpressionBuilder.Constant(_underlyingStreamNumber))); methodNode.Block.MethodReturn( CodegenExpressionBuilder.ExprDotMethod( eventBeanFactory, "AdapterForTypedAvro", CodegenExpressionBuilder.ExprDotName(theEvent, "Properties"), resultEventType)); return methodNode; }
private CodegenMethod GetAvroFieldValueCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope) .AddParam(typeof(GenericRecord), "record") .Block .DeclareVar<IDictionary<string, object>>( "values", CodegenExpressionBuilder.Cast( typeof(IDictionary<string, object>), CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("record"), CodegenExpressionBuilder.Constant(_pos.Name)))) .IfRefNullReturnNull("values") .MethodReturn( CodegenExpressionBuilder.ExprDotMethod( CodegenExpressionBuilder.Ref("values"), "Get", CodegenExpressionBuilder.Constant(_key))); }
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)); }
private CodegenMethod GetCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope) .AddParam(typeof(GenericRecord), "record") .Block .DeclareVar<GenericRecord>( "inner", CodegenExpressionBuilder.Cast( typeof(GenericRecord), CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("record"), CodegenExpressionBuilder.Constant(_posTop.Name)))) .IfRefNullReturnNull("inner") .MethodReturn( CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("inner"), CodegenExpressionBuilder.Constant(_propertyName))); }
public CodegenMethod ProcessCodegen( CodegenExpression resultEventType, CodegenExpression eventBeanFactory, CodegenMethodScope codegenMethodScope, SelectExprProcessorCodegenSymbol selectSymbol, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var schema = codegenClassScope.NamespaceScope.AddDefaultFieldUnshared( true, typeof(RecordSchema), CodegenExpressionBuilder.StaticMethod( typeof(AvroSchemaUtil), "ResolveRecordSchema", EventTypeUtility.ResolveTypeCodegen(ResultEventType, EPStatementInitServicesConstants.REF))); var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope); var refEPS = exprSymbol.GetAddEPS(methodNode); var block = methodNode.Block .DeclareVar<AvroGenericDataBackedEventBean>( "theEvent", CodegenExpressionBuilder.Cast( typeof(AvroGenericDataBackedEventBean), CodegenExpressionBuilder.ArrayAtIndex( refEPS, CodegenExpressionBuilder.Constant(_underlyingStreamNumber)))) .DeclareVar<GenericRecord>( "source", CodegenExpressionBuilder.ExprDotName( CodegenExpressionBuilder.Ref("theEvent"), "Properties")) .DeclareVar<GenericRecord>( "target", CodegenExpressionBuilder.NewInstance(typeof(GenericRecord), schema)); foreach (var item in _items) { CodegenExpression value; if (item.OptionalFromIndex != null) { value = CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("source"), CodegenExpressionBuilder.Constant(item.OptionalFromIndex.Name)); } else { if (item.OptionalWidener != null) { value = item.Forge.EvaluateCodegen( item.Forge.EvaluationType, methodNode, exprSymbol, codegenClassScope); value = item.OptionalWidener.WidenCodegen(value, methodNode, codegenClassScope); } else { value = item.Forge.EvaluateCodegen( typeof(object), methodNode, exprSymbol, codegenClassScope); } } block.StaticMethod( typeof(GenericRecordExtensions), "Put", CodegenExpressionBuilder.Ref("target"), CodegenExpressionBuilder.Constant(item.ToIndex.Name), value); } block.MethodReturn( CodegenExpressionBuilder.ExprDotMethod( eventBeanFactory, "AdapterForTypedAvro", CodegenExpressionBuilder.Ref("target"), resultEventType)); return methodNode; }