internal static CodegenMethod GetAvroFieldFragmentPolyCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, AvroEventPropertyGetter[] getters) { return codegenMethodScope.MakeChild( typeof(object), typeof(AvroEventBeanGetterDynamicPoly), codegenClassScope) .AddParam(typeof(GenericRecord), "record") .Block .IfRefNullReturnNull("record") .AssignRef( "record", CodegenExpressionBuilder.LocalMethod( NavigatePolyCodegen(codegenMethodScope, codegenClassScope, getters), CodegenExpressionBuilder.Ref("record"))) .IfRefNullReturnNull("record") .MethodReturn( getters[getters.Length - 1] .UnderlyingFragmentCodegen( CodegenExpressionBuilder.Ref("record"), codegenMethodScope, codegenClassScope)); }
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")); }
public CodegenExpression Codegen( CodegenMethod method, CodegenClassScope classScope, CodegenExpression typeInitSvcRef) { return(CodegenExpressionBuilder.NewInstance <ClassEPType>(CodegenExpressionBuilder.Constant(Clazz))); }
public CodegenExpression Codegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Type ltype, Type rtype) { var method = codegenMethodScope.MakeChild(typeof(int?), typeof(DivideInt), codegenClassScope) .AddParam(typeof(int?), "i1") .AddParam(typeof(int?), "i2") .Block .IfCondition( CodegenExpressionBuilder.EqualsIdentity( CodegenExpressionBuilder.Ref("i2"), CodegenExpressionBuilder.Constant(0))) .BlockReturn(CodegenExpressionBuilder.ConstantNull()) .MethodReturn( CodegenExpressionBuilder.Op( CodegenExpressionBuilder.Ref("i1"), "/", CodegenExpressionBuilder.Ref("i2"))); return(CodegenExpressionBuilder.LocalMethod( method, CodegenAsInt(left, ltype), CodegenAsInt(right, rtype))); }
public CodegenExpression Codegen( CodegenMethod method, CodegenClassScope classScope, CodegenExpression optionalEventTypeResolver) { return(CodegenExpressionBuilder.NewInstanceInner(ClassName, optionalEventTypeResolver)); }
public CodegenExpression ToExpression() { return CodegenExpressionBuilder.NewInstance( typeof(ConfigurationCompilerPlugInAggregationMultiFunction), CodegenExpressionBuilder.Constant(FunctionNames), CodegenExpressionBuilder.Constant(MultiFunctionForgeClassName), CodegenExpressionBuilder.MapOfConstant(AdditionalConfiguredProperties)); }
public static CodegenExpression Codegen( IntervalComputerDuringMinMaxStartEndForge forge, CodegenExpression leftStart, CodegenExpression leftEnd, CodegenExpression rightStart, CodegenExpression rightEnd, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope.MakeChild( typeof(bool), typeof(IntervalComputerDuringMinMaxStartEndEval), codegenClassScope) .AddParam(IntervalForgeCodegenNames.PARAMS); var block = methodNode.Block .DeclareVar <long>( "minStart", forge.minStartEval.Codegen( IntervalForgeCodegenNames.REF_RIGHTSTART, methodNode, exprSymbol, codegenClassScope)) .DeclareVar <long>( "maxStart", forge.maxStartEval.Codegen( IntervalForgeCodegenNames.REF_RIGHTSTART, methodNode, exprSymbol, codegenClassScope)) .DeclareVar <long>( "minEnd", forge.minEndEval.Codegen( IntervalForgeCodegenNames.REF_RIGHTEND, methodNode, exprSymbol, codegenClassScope)) .DeclareVar <long>( "maxEnd", forge.maxEndEval.Codegen( IntervalForgeCodegenNames.REF_RIGHTEND, methodNode, exprSymbol, codegenClassScope)); block.MethodReturn( CodegenExpressionBuilder.StaticMethod( typeof(IntervalComputerDuringAndIncludesMinMaxEval), forge.during ? "ComputeIntervalDuring" : "ComputeIntervalIncludes", IntervalForgeCodegenNames.REF_LEFTSTART, IntervalForgeCodegenNames.REF_LEFTEND, IntervalForgeCodegenNames.REF_RIGHTSTART, IntervalForgeCodegenNames.REF_RIGHTEND, CodegenExpressionBuilder.Ref("minStart"), CodegenExpressionBuilder.Ref("maxStart"), CodegenExpressionBuilder.Ref("minEnd"), CodegenExpressionBuilder.Ref("maxEnd"))); return(CodegenExpressionBuilder.LocalMethod(methodNode, leftStart, leftEnd, rightStart, rightEnd)); }
public CodegenMethod ProcessCodegen( CodegenExpression resultEventTypeOuter, CodegenExpression eventBeanFactory, CodegenMethodScope codegenMethodScope, SelectExprProcessorCodegenSymbol selectSymbol, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { // NOTE: Maintaining result-event-type as out own field as we may be an "inner" select-expr-processor var mType = codegenClassScope.AddDefaultFieldUnshared( true, typeof(EventType), EventTypeUtility.ResolveTypeCodegen(_resultEventTypeAvro, EPStatementInitServicesConstants.REF)); var schema = codegenClassScope.NamespaceScope.AddDefaultFieldUnshared( true, typeof(RecordSchema), CodegenExpressionBuilder.StaticMethod( typeof(AvroSchemaUtil), "ResolveRecordSchema", EventTypeUtility.ResolveTypeCodegen(_resultEventTypeAvro, EPStatementInitServicesConstants.REF))); var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope); var refEPS = exprSymbol.GetAddEPS(methodNode); methodNode.Block.MethodReturn( CodegenExpressionBuilder.StaticMethod( typeof(SelectExprJoinWildcardProcessorAvro), "ProcessSelectExprJoinWildcardAvro", refEPS, schema, eventBeanFactory, mType)); return methodNode; }
public override CodegenExpression DoDivideCodegen( CodegenExpressionRef s1, CodegenExpressionRef s2, CodegenClassScope codegenClassScope) { return(CodegenExpressionBuilder.Op(s1, "/", s2)); }
private CodegenExpression BuildMap<T>(IDictionary<string, T> map) { if (map == null) { return ConstantNull(); } if (map.IsEmpty()) { return StaticMethod(typeof(Collections), "GetEmptyMap", new Type[] { typeof(string), typeof(T) }); } if (map.Count == 1) { var single = map.First(); return StaticMethod( typeof(Collections), "SingletonMap", new Type[] { typeof(string), typeof(T) }, CodegenExpressionBuilder.Constant(single.Key), BuildMapValue(single.Value)); } var child = method.MakeChild(typeof(IDictionary<string, T>), originator, classScope); child.Block.DeclareVar<IDictionary<string, T>>( "map", NewInstance(typeof(LinkedHashMap<string, T>))); foreach (var entry in map) { child.Block.ExprDotMethod( Ref("map"), "Put", CodegenExpressionBuilder.Constant(entry.Key), BuildMapValue(entry.Value)); } return LocalMethod(child); }
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); }
public CodegenExpression EventBeanFragmentCodegen( CodegenExpression beanExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return CodegenExpressionBuilder.ConstantNull(); }
public CodegenExpression Make( CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { return CodegenExpressionBuilder.NewInstance(typeof(MyObjectArrayGraphSourceFactory)); }
public CodegenExpression CoerceCodegenMayNullBoxed( CodegenExpression param, Type valueType, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { if ((param is CodegenExpressionConstantNull) || (param is CodegenExpressionConstant exprConstant && exprConstant.IsNull)) { return(param); } return(((valueType != typeof(decimal)) && (valueType != typeof(decimal?))) ? CodegenExpressionBuilder.ExprDotMethod(param, "AsBoxedDecimal") : param); // return CodegenCoerceMayNull( // typeof(decimal), // typeof(decimal?), // "AsDecimal", // param, // valueTypeMustNumeric, // codegenMethodScope, // typeof(CoercerDecimal), // codegenClassScope); }
public CodegenExpression EventBeanGetIndexedCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpression beanExpression, CodegenExpression key) { var method = codegenMethodScope.MakeChild( typeof(object), typeof(AvroEventBeanGetterIndexedRuntimeKeyed), codegenClassScope) .AddParam(typeof(EventBean), "@event") .AddParam(typeof(int), "index") .Block .DeclareVar<GenericRecord>( "record", CodegenExpressionBuilder.CastUnderlying( typeof(GenericRecord), CodegenExpressionBuilder.Ref("@event"))) .DeclareVar<object>( "values", CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("record"), CodegenExpressionBuilder.Constant(_pos.Name))) .MethodReturn( CodegenExpressionBuilder.StaticMethod( typeof(AvroEventBeanGetterIndexed), "GetAvroIndexedValue", CodegenExpressionBuilder.Ref("values"), CodegenExpressionBuilder.Ref("index"))); return CodegenExpressionBuilder.LocalMethodBuild(method).Pass(beanExpression).Pass(key).Call(); }
public CodegenExpression EventBeanExistsCodegen( CodegenExpression beanExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return CodegenExpressionBuilder.ConstantTrue(); }
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); }
public CodegenExpression UnderlyingExistsCodegen( CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return CodegenExpressionBuilder.ConstantTrue(); }
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 UnderlyingFragmentCodegen( CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return CodegenExpressionBuilder.ConstantNull(); }
private CodegenMethod GetAvroFieldExistsCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope .MakeChild(typeof(bool), GetType(), codegenClassScope) .AddParam(typeof(GenericRecord), "record") .Block .DeclareVar<IDictionary<string, object>>( "values", CodegenExpressionBuilder.StaticMethod( typeof(CompatExtensions), "AsStringDictionary", CodegenExpressionBuilder.StaticMethod( typeof(GenericRecordExtensions), "Get", CodegenExpressionBuilder.Ref("record"), CodegenExpressionBuilder.Constant(_pos.Name)))) .IfRefNullReturnFalse("values") .MethodReturn( CodegenExpressionBuilder.ExprDotMethod( CodegenExpressionBuilder.Ref("values"), "ContainsKey", CodegenExpressionBuilder.Constant(_key))); }
public CodegenExpression EvaluateCodegen( Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope.MakeChild( typeof(object), typeof(ExprForgeStreamWithGetter), codegenClassScope); var refEPS = exprSymbol.GetAddEPS(methodNode); methodNode.Block .DeclareVar <EventBean>( "theEvent", CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(0))) .IfRefNotNull("theEvent") .BlockReturn( getter.EventBeanGetCodegen( CodegenExpressionBuilder.Ref("theEvent"), methodNode, codegenClassScope)) .MethodReturn(CodegenExpressionBuilder.ConstantNull()); return(CodegenExpressionBuilder.LocalMethod(methodNode)); }
public CodegenExpression CoerceCodegenMayNullBoxed( CodegenExpression value, Type valueType, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { if (valueType == null) { return(value); } if (valueType.IsValueType && valueType.CanNotBeNull()) { return(CodegenBigInt(value, valueType)); } if (valueType.IsBigInteger()) { return(value); } var method = codegenMethodScope .MakeChild(typeof(BigInteger), typeof(CoercerBigInt), codegenClassScope) .AddParam(valueType, "value") .Block .IfRefNullReturnNull("value") .MethodReturn(CodegenBigInt(CodegenExpressionBuilder.Ref("value"), valueType)); return(CodegenExpressionBuilder.LocalMethod(method, value)); }
public static CodegenExpression Codegen( IntervalComputerFinishedByThresholdForge forge, CodegenExpression leftStart, CodegenExpression leftEnd, CodegenExpression rightStart, CodegenExpression rightEnd, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope.MakeChild( typeof(bool?), typeof(IntervalComputerFinishedByThresholdEval), codegenClassScope) .AddParam(IntervalForgeCodegenNames.PARAMS); methodNode.Block .DeclareVar <long>( "threshold", forge.thresholdExpr.Codegen( CodegenExpressionBuilder.StaticMethod( typeof(Math), "Min", IntervalForgeCodegenNames.REF_RIGHTEND, IntervalForgeCodegenNames.REF_LEFTEND), methodNode, exprSymbol, codegenClassScope)) .IfCondition( CodegenExpressionBuilder.Relational( CodegenExpressionBuilder.Ref("threshold"), CodegenExpressionRelational.CodegenRelational.LT, CodegenExpressionBuilder.Constant(0))) .StaticMethod( typeof(IntervalComputerFinishedByThresholdEval), METHOD_LOGWARNINGINTERVALFINISHEDBYTHRESHOLD) .BlockReturn(CodegenExpressionBuilder.ConstantNull()) .IfConditionReturnConst( CodegenExpressionBuilder.Relational( IntervalForgeCodegenNames.REF_LEFTSTART, CodegenExpressionRelational.CodegenRelational.GE, IntervalForgeCodegenNames.REF_RIGHTSTART), false) .DeclareVar <long>( "delta", CodegenExpressionBuilder.StaticMethod( typeof(Math), "Abs", CodegenExpressionBuilder.Op( IntervalForgeCodegenNames.REF_LEFTEND, "-", IntervalForgeCodegenNames.REF_RIGHTEND))) .MethodReturn( CodegenExpressionBuilder.Relational( CodegenExpressionBuilder.Ref("delta"), CodegenExpressionRelational.CodegenRelational.LE, CodegenExpressionBuilder.Ref("threshold"))); return(CodegenExpressionBuilder.LocalMethod(methodNode, leftStart, leftEnd, rightStart, rightEnd)); }
public CodegenExpression Codegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Type ltype, Type rtype) { var resultType = typeof(decimal); if (ltype.IsNullable() || rtype.IsNullable() || _divisionByZeroReturnsNull) { resultType = typeof(decimal?); } var block = codegenMethodScope .MakeChild(resultType, typeof(DivideDecimalConvComputerBase), codegenClassScope) .AddParam(ltype, "d1") .AddParam(rtype, "d2") .Block .DeclareVar <decimal>( "s1", _convOne.CoerceCodegen(CodegenExpressionBuilder.Ref("d1"), ltype)) .DeclareVar <decimal>( "s2", _convTwo.CoerceCodegen(CodegenExpressionBuilder.Ref("d2"), rtype)); var ifZeroDivisor = block.IfCondition( CodegenExpressionBuilder.EqualsIdentity( CodegenExpressionBuilder.Ref("s2"), CodegenExpressionBuilder.Constant(0.0m))); if (_divisionByZeroReturnsNull) { ifZeroDivisor.BlockReturn(CodegenExpressionBuilder.ConstantNull()); } else { ifZeroDivisor.DeclareVar <decimal>( "result", CodegenExpressionBuilder.Op( CodegenExpressionBuilder.Ref("s1"), "/", CodegenExpressionBuilder.Constant(0.0m))) .BlockReturn(CodegenExpressionBuilder.Ref("result")); } var method = block.MethodReturn( DoDivideCodegen( CodegenExpressionBuilder.Ref("s1"), CodegenExpressionBuilder.Ref("s2"), codegenClassScope)); return(CodegenExpressionBuilder .LocalMethodBuild(method) .Pass(left) .Pass(right) .Call()); }
public CodegenExpression Codegen( CodegenMethod method, CodegenClassScope classScope, CodegenExpression typeInitSvcRef) { return(CodegenExpressionBuilder.NewInstance <EventEPType>( EventTypeUtility.ResolveTypeCodegen(EventType, typeInitSvcRef))); }
private CodegenExpression BuildMapValue(object value) { if (value is IDictionary<string, object>) { return BuildMap((IDictionary<string, object>) value); } return CodegenExpressionBuilder.Constant(value); }
public CodegenExpression Codegen( CodegenMethod method, CodegenClassScope classScope, CodegenExpression typeInitSvcRef) { // TBD: Shouldn't this be a static field reference? return(CodegenExpressionBuilder.EnumValue(typeof(NullEPType), "INSTANCE")); }
public CodegenExpression Codegen( CodegenMethod method, CodegenClassScope classScope, CodegenExpression typeInitSvcRef) { return(CodegenExpressionBuilder.NewInstance <ClassMultiValuedEPType>( CodegenExpressionBuilder.Constant(Container), CodegenExpressionBuilder.Constant(Component))); }
public CodegenExpression UnderlyingExistsCodegen( CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return CodegenExpressionBuilder.LocalMethod( IsExistsPropertyCodegen(codegenMethodScope, codegenClassScope), underlyingExpression); }