Ejemplo n.º 1
0
        private CodegenExpression EvaluateCodegenPrevAndTail(
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var method = parent.MakeChild(ResultType, GetType(), codegenClassScope);

            var eps = exprSymbol.GetAddEPS(method);
            var innerEval = CodegenLegoMethodExpression.CodegenExpression(
                ChildNodes[1].Forge,
                method,
                codegenClassScope,
                true);

            method.Block
                .IfCondition(Not(exprSymbol.GetAddIsNewData(method)))
                .BlockReturn(ConstantNull())
                .DeclareVar<EventBean>(
                    "substituteEvent",
                    LocalMethod(
                        GetSubstituteCodegen(method, exprSymbol, codegenClassScope),
                        eps,
                        exprSymbol.GetAddExprEvalCtx(method)))
                .IfRefNullReturnNull("substituteEvent")
                .DeclareVar<EventBean>("originalEvent", ArrayAtIndex(eps, Constant(StreamNumber)))
                .AssignArrayElement(eps, Constant(StreamNumber), Ref("substituteEvent"))
                .DeclareVar(
                    ResultType,
                    "evalResult",
                    LocalMethod(
                        innerEval,
                        eps,
                        exprSymbol.GetAddIsNewData(method),
                        exprSymbol.GetAddExprEvalCtx(method)))
                .AssignArrayElement(eps, Constant(StreamNumber), Ref("originalEvent"))
                .MethodReturn(Ref("evalResult"));

            return LocalMethod(method);
        }
Ejemplo n.º 2
0
        private CodegenMethod MakeFieldDescCodegen(
            CodegenMethodScope parent,
            CodegenClassScope classScope)
        {
            var method = parent
                .MakeChild(
                    typeof(IDictionary<string, JsonUnderlyingField>),
                    typeof(JsonEventTypeDetail),
                    classScope);

            method.Block.DeclareVar(
                typeof(IDictionary<string, JsonUnderlyingField>),
                "fields",
                NewInstance(typeof(Dictionary<string, JsonUnderlyingField>)));

            foreach (var entry in FieldDescriptors) {
                method.Block.ExprDotMethod(Ref("fields"), "Put", Constant(entry.Key), entry.Value.ToCodegenExpression());
            }

            method.Block.MethodReturn(Ref("fields"));
            return method;
        }
Ejemplo n.º 3
0
 public CodegenExpression Make(
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     var builder = new SAIFFInitializeBuilder(
         OP_PACKAGE_NAME + ".eventbussource.EventBusSourceFactory",
         GetType(),
         "eventbussource",
         parent,
         symbols,
         classScope);
     builder.Expression(
             "filterSpecActivatable",
             LocalMethod(
                 FilterSpecCompiled.MakeCodegen(
                     builder.Method(),
                     symbols,
                     classScope)))
         .Constant("IsSubmitEventBean", submitEventBean);
     return builder.Build();
 }
Ejemplo n.º 4
0
        private static CodegenExpression CodegenMultiKeyExprEvaluator(
            ExprForge[] expressionNodes,
            MultiKeyClassRef multiKeyClassRef,
            CodegenMethod method,
            CodegenClassScope classScope)
        {
            var evaluate = new CodegenExpressionLambda(method.Block)
                           .WithParams(PARAMS);
            var evaluator = NewInstance <ProxyExprEvaluator>(evaluate);

            // CodegenExpressionNewAnonymousClass evaluator = NewAnonymousClass(method.Block, typeof(ExprEvaluator));
            // CodegenMethod evaluate = CodegenMethod
            //  .MakeParentNode(typeof(object), typeof(StmtClassForgeableMultiKey), classScope)
            //  .AddParam(ExprForgeCodegenNames.PARAMS);
            //
            // evaluator.AddMethod("evaluate", evaluate);

            var exprSymbol = new ExprForgeCodegenSymbol(true, null);
            var exprMethod = method
                             .MakeChildWithScope(typeof(object), typeof(CodegenLegoMethodExpression), exprSymbol, classScope)
                             .AddParam(ExprForgeCodegenNames.PARAMS);

            var expressions = new CodegenExpression[expressionNodes.Length];

            for (var i = 0; i < expressionNodes.Length; i++)
            {
                expressions[i] = CodegenExpressionMayCoerce(expressionNodes[i], multiKeyClassRef.MKTypes[i], exprMethod, exprSymbol, classScope);
            }

            var instance = multiKeyClassRef.ClassNameMK.Type != null
                                ? NewInstance(multiKeyClassRef.ClassNameMK.Type, expressions)
                                : NewInstanceInner(multiKeyClassRef.ClassNameMK.Name, expressions);

            exprSymbol.DerivedSymbolsCodegen(method, exprMethod.Block, classScope);
            exprMethod.Block.MethodReturn(instance);

            evaluate.Block.BlockReturn(LocalMethod(exprMethod, REF_EPS, REF_ISNEWDATA, REF_EXPREVALCONTEXT));
            return(evaluator);
        }
Ejemplo n.º 5
0
        public static CodegenExpression Codegen(
            DTLocalDtoIntervalForge forge,
            CodegenExpression inner,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope
                .MakeChild(typeof(bool?), typeof(DTLocalDtoIntervalEval), codegenClassScope)
                .AddParam(typeof(DateTimeOffset), "target");

            methodNode.Block
                .DeclareVar<long>(
                    "time",
                    StaticMethod(
                        typeof(DatetimeLongCoercerDateTimeOffset),
                        "CoerceToMillis",
                        Ref("target")))
                .MethodReturn(
                    forge.intervalForge.Codegen(Ref("time"), Ref("time"), methodNode, exprSymbol, codegenClassScope));
            return LocalMethod(methodNode, inner);
        }
Ejemplo n.º 6
0
        public static CodegenExpression CodegenEvaluators(
            IList<ExprForge> expressions,
            CodegenMethodScope parent,
            Type originator,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(typeof(ExprEvaluator[]), originator, classScope);
            method.Block.DeclareVar<ExprEvaluator[]>(
                "evals",
                NewArrayByLength(typeof(ExprEvaluator), Constant(expressions.Count)));
            for (var i = 0; i < expressions.Count; i++) {
                method.Block.AssignArrayElement(
                    "evals",
                    Constant(i),
                    expressions[i] == null
                        ? ConstantNull()
                        : CodegenEvaluator(expressions[i], method, originator, classScope));
            }

            method.Block.MethodReturn(Ref("evals"));
            return LocalMethod(method);
        }
            public static CodegenExpression CoerceCodegenMayNull(
                CodegenExpression value,
                Type valueType,
                CodegenMethodScope codegenMethodScope,
                CodegenClassScope codegenClassScope)
            {
                return(((valueType != typeof(short)) &&
                        (valueType != typeof(int)) &&
                        (valueType != typeof(int?)))
                    ? CodegenExpressionBuilder.ExprDotMethod(value, "AsBoxedInt32")
                    : value);

//                return CodegenCoerceMayNull(
//                    typeof(int),
//                    typeof(int?),
//                    "AsInt32",
//                    param,
//                    type,
//                    codegenMethodScope,
//                    typeof(CoercerInt),
//                    codegenClassScope);
            }
Ejemplo n.º 8
0
 protected internal static CodegenMethod SortWGroupKeysInternalCodegen(
     OrderByProcessorForgeImpl forge,
     CodegenClassScope classScope,
     CodegenNamedMethods namedMethods)
 {
     var createSortProperties = CreateSortPropertiesCodegen(forge, classScope, namedMethods);
     CodegenExpression comparator = classScope.AddOrGetDefaultFieldSharable(forge.IComparer);
     Consumer<CodegenMethod> code = method => {
         method.Block.DeclareVar<IList<object>>(
                 "sortValuesMultiKeys",
                 LocalMethod(
                     createSortProperties,
                     REF_GENERATINGEVENTS,
                     Ref("groupByKeys"),
                     REF_ISNEWDATA,
                     REF_EXPREVALCONTEXT,
                     MEMBER_AGGREGATIONSVC))
             .MethodReturn(
                 StaticMethod(
                     typeof(OrderByProcessorUtil),
                     "SortGivenOutgoingAndSortKeys",
                     REF_OUTGOINGEVENTS,
                     Ref("sortValuesMultiKeys"),
                     comparator));
     };
     return namedMethods.AddMethod(
         typeof(EventBean[]),
         "SortWGroupKeysInternal",
         CodegenNamedParam.From(
             typeof(EventBean[]), REF_OUTGOINGEVENTS.Ref,
             typeof(EventBean[][]), REF_GENERATINGEVENTS.Ref,
             typeof(object[]), "groupByKeys",
             typeof(bool), REF_ISNEWDATA.Ref,
             typeof(ExprEvaluatorContext), REF_EXPREVALCONTEXT.Ref,
             typeof(AggregationService), MEMBER_AGGREGATIONSVC.Ref),
         typeof(OrderByProcessorImpl),
         classScope,
         code);
 }
Ejemplo n.º 9
0
 private CodegenMethod GetAvroFragmentCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     var factory = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
     var eventType = codegenClassScope.AddDefaultFieldUnshared(
         true,
         typeof(EventType),
         EventTypeUtility.ResolveTypeCodegen(_fragmentEventType, EPStatementInitServicesConstants.REF));
     return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(typeof(GenericRecord), "record")
         .Block
         .DeclareVar<object>(
             "value",
             UnderlyingGetCodegen(Ref("record"), codegenMethodScope, codegenClassScope))
         .MethodReturn(
             ExprDotMethod(
                 factory,
                 "AdapterForTypedAvro",
                 Ref("value"),
                 eventType));
 }
Ejemplo n.º 10
0
 internal static CodegenMethod GetAvroFieldValuePolyExistsCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope,
     AvroEventPropertyGetter[] getters)
 {
     return codegenMethodScope.MakeChild(typeof(bool), typeof(AvroEventBeanGetterDynamicPoly), codegenClassScope)
         .AddParam(typeof(GenericRecord), "record")
         .Block
         .IfRefNullReturnFalse("record")
         .AssignRef(
             "record",
             CodegenExpressionBuilder.LocalMethod(
                 NavigatePolyCodegen(codegenMethodScope, codegenClassScope, getters),
                 CodegenExpressionBuilder.Ref("record")))
         .IfRefNullReturnFalse("record")
         .MethodReturn(
             getters[getters.Length - 1]
                 .UnderlyingExistsCodegen(
                     CodegenExpressionBuilder.Ref("record"),
                     codegenMethodScope,
                     codegenClassScope));
 }
Ejemplo n.º 11
0
        public CodegenExpression EventBeanGetCodegen(
            CodegenExpression beanExpression,
            CodegenMethodScope parent,
            CodegenClassScope classScope)
        {
            CodegenMethod method = parent.MakeChild(typeof(object), this.GetType(), classScope)
                .AddParam(typeof(EventBean), "eventBean");
            CodegenMethod methodExpr = CodegenLegoMethodExpression.CodegenExpression(eval.Forge, method, classScope, true);
            method.Block
                .DeclareVar<EventBean[]>("events", NewArrayWithInit(typeof(EventBean), Ref("eventBean")))
                .DeclareVar<string>(
                    "code",
                    Cast(typeof(string), LocalMethod(methodExpr, Ref("events"), ConstantTrue(), ConstantNull())))
                .MethodReturn(
                    StaticMethod(
                        typeof(ContextControllerHashedGetterCRC32SingleForge),
                        "StringToCRC32Hash",
                        Ref("code"),
                        Constant(granularity)));

            return LocalMethod(method, beanExpression);
        }
        private CodegenExpression MakeProperties(
            IDictionary<StatementProperty, object> properties,
            CodegenMethodScope parent,
            CodegenClassScope classScope)
        {
            if (properties.IsEmpty()) {
                return StaticMethod(typeof(Collections), "GetEmptyDataMap");
            }

            Func<StatementProperty, CodegenExpression> field = x => EnumValue(typeof(StatementProperty), x.GetName());
            Func<object, CodegenExpression> value = Constant;
            if (properties.Count == 1) {
                var first = properties.First();
                return StaticMethod(
                    typeof(Collections),
                    "SingletonMap",
                    field.Invoke(first.Key),
                    Cast(typeof(object), value.Invoke(first.Value)));
            }

            var method = parent.MakeChild(
                typeof(IDictionary<StatementProperty, object>),
                typeof(StatementInformationalsCompileTime),
                classScope);
            method.Block
                .DeclareVar<IDictionary<StatementProperty, object>>(
                    "properties",
                    NewInstance(typeof(Dictionary<StatementProperty, object>)));
            foreach (var entry in properties) {
                method.Block.ExprDotMethod(
                    Ref("properties"),
                    "Put",
                    field.Invoke(entry.Key),
                    value.Invoke(entry.Value));
            }

            method.Block.MethodReturn(Ref("properties"));
            return LocalMethod(method);
        }
Ejemplo n.º 13
0
        public CodegenMethod Codegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbolWEventType symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(typeof(FilterSpecPlanPath), typeof(FilterSpecParamForge), classScope);
            method.Block.DeclareVar(
                typeof(FilterSpecPlanPathTriplet[]),
                "triplets",
                NewArrayByLength(typeof(FilterSpecPlanPathTriplet), Constant(Triplets.Length)));
            for (var i = 0; i < Triplets.Length; i++) {
                var triplet = Triplets[i].Codegen(method, symbols, classScope);
                method.Block.AssignArrayElement("triplets", Constant(i), LocalMethod(triplet));
            }

            method.Block
                .DeclareVar<FilterSpecPlanPath>("path", NewInstance(typeof(FilterSpecPlanPath)))
                .SetProperty(Ref("path"), "Triplets", Ref("triplets"))
                .SetProperty(Ref("path"), "PathNegate", OptionalEvaluator(PathNegate, method, classScope))
                .MethodReturn(Ref("path"));
            return method;
        }
Ejemplo n.º 14
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));
 }
Ejemplo n.º 15
0
 public AggregatorMinMaxEver(
     AggregationForgeFactoryMinMax factory,
     int col,
     CodegenCtor rowCtor,
     CodegenMemberCol membersColumnized,
     CodegenClassScope classScope,
     Type optionalDistinctValueType,
     DataInputOutputSerdeForge optionalDistinctSerde,
     bool hasFilter,
     ExprNode optionalFilter,
     DataInputOutputSerdeForge serde)
     : base(factory, col, rowCtor, membersColumnized, classScope, optionalDistinctValueType, optionalDistinctSerde, hasFilter, optionalFilter)
 {
     _factory = factory;
     _currentMinMax = membersColumnized.AddMember(col, typeof(IComparable), "currentMinMax");
     _serde = classScope.AddOrGetDefaultFieldSharable(
         new CodegenSharableSerdeClassTyped(
             CodegenSharableSerdeClassTyped.CodegenSharableSerdeName.VALUE_NULLABLE,
             factory.ResultType,
             serde,
             classScope));
 }
Ejemplo n.º 16
0
        public static CodegenExpression Codegen(
            DTLocalDtxIntervalForge forge,
            CodegenExpression start,
            CodegenExpression end,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope
                .MakeChild(typeof(bool?), typeof(DTLocalDtxIntervalEval), codegenClassScope)
                .AddParam(typeof(DateTimeEx), "start")
                .AddParam(typeof(DateTimeEx), "end");

            methodNode.Block.MethodReturn(
                forge.intervalForge.Codegen(
                    ExprDotName(Ref("start"), "UtcMillis"),
                    ExprDotName(Ref("end"), "UtcMillis"),
                    methodNode,
                    exprSymbol,
                    codegenClassScope));
            return LocalMethod(methodNode, start, end);
        }
Ejemplo n.º 17
0
 public static void GetEnumeratorJoinCodegen(
     ResultSetProcessorSimpleForge forge,
     CodegenClassScope classScope,
     CodegenMethod method,
     CodegenInstanceAux instance)
 {
     method.Block.DeclareVar<UniformPair<EventBean[]>>(
             "result",
             ExprDotMethod(
                 Ref("this"),
                 "ProcessJoinResult",
                 REF_JOINSET,
                 StaticMethod(typeof(Collections), "GetEmptySet", new[] {typeof(MultiKeyArrayOfKeys<EventBean>)}),
                 ConstantTrue()))
         .IfRefNull("result")
         .BlockReturn(
             StaticMethod(typeof(Collections), "GetEmptyEnumerator", new[] {typeof(EventBean)}))
         .MethodReturn(
             ExprDotMethod(
                 StaticMethod(typeof(Arrays), "Enumerate", GetProperty(Ref("result"), "First")),
                 "GetEnumerator"));
 }
Ejemplo n.º 18
0
        public CodegenExpression Codegen(
            EnumForgeCodegenParams premade,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            Type arrayType = TypeHelper.GetArrayType(_arrayComponentType);
            ExprForgeCodegenSymbol scope      = new ExprForgeCodegenSymbol(false, null);
            CodegenMethod          methodNode = codegenMethodScope.MakeChildWithScope(arrayType, typeof(EnumArrayOfScalarNoParams), scope, codegenClassScope)
                                                .AddParam(EnumForgeCodegenNames.PARAMS);

            CodegenBlock block = methodNode.Block
                                 .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty"))
                                 .BlockReturn(NewArrayByLength(_arrayComponentType, Constant(0)))
                                 .DeclareVar(arrayType, "result", NewArrayByLength(_arrayComponentType, ExprDotName(EnumForgeCodegenNames.REF_ENUMCOLL, "Count")))
                                 .DeclareVar <int>("count", Constant(0));

            block.ForEach(typeof(object), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
            .AssignArrayElement(Ref("result"), Ref("count"), Cast(_arrayComponentType, Ref("next")))
            .IncrementRef("count");
            block.MethodReturn(Ref("result"));
            return(LocalMethod(methodNode, premade.Eps, premade.Enumcoll, premade.IsNewData, premade.ExprCtx));
        }
Ejemplo n.º 19
0
        public override CodegenExpression UnderlyingFragmentCodegen(
            CodegenExpression underlyingExpression,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            if (FragmentType == null) {
                return ConstantNull();
            }

            CodegenExpression factory = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            CodegenExpression eventType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(FragmentType, EPStatementInitServicesConstants.REF));
            return StaticMethod(
                typeof(JsonFieldGetterHelperSchema),
                "HandleJsonCreateFragmentArray",
                underlyingExpression,
                Constant(Field.PropertyName),
                eventType,
                factory);
        }
Ejemplo n.º 20
0
        public override CodegenExpression UnderlyingFragmentCodegen(
            CodegenExpression underlyingExpression,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            if (OptionalInnerType == null) {
                return ConstantNull();
            }

            CodegenExpression factory = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            CodegenExpression eventType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(OptionalInnerType, EPStatementInitServicesConstants.REF));
            return StaticMethod(
                typeof(JsonFieldGetterHelperProvided),
                "HandleJsonProvidedCreateFragmentIndexed",
                ExprDotName(underlyingExpression, field.Name),
                Constant(Index),
                eventType,
                factory);
        }
Ejemplo n.º 21
0
        public override CodegenExpression UnderlyingExistsCodegen(
            CodegenExpression underlyingExpression,
            CodegenMethodScope parent,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression memberCache = codegenClassScope.AddOrGetDefaultFieldSharable(SharableCode);
            var method = parent.MakeChild(typeof(bool), typeof(DynamicPropertyGetterByMethodOrPropertyBase), codegenClassScope)
                         .AddParam(typeof(object), "@object");

            method.Block
            .DeclareVar <DynamicPropertyDescriptorByMethod>("desc", GetPopulateCacheCodegen(memberCache, Ref("@object"), method, codegenClassScope))
            .IfCondition(EqualsNull(ExprDotName(Ref("desc"), "Method")))
            .BlockReturn(ConstantFalse())
            .MethodReturn(
                StaticMethod(
                    typeof(DynamicMappedPropertyGetterByMethodOrProperty),
                    "DynamicMappedPropertyExists",
                    Ref("desc"),
                    Ref("@object"),
                    Constant(_parameters[0])));
            return(LocalMethod(method, underlyingExpression));
        }
Ejemplo n.º 22
0
        public override CodegenExpression Codegen(
            EnumForgeCodegenParams premade,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var scope      = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope.MakeChildWithScope(typeof(EventBean), typeof(EnumFirstOfEvent), scope, codegenClassScope)
                             .AddParam(EnumForgeCodegenNames.PARAMS);

            var block   = methodNode.Block;
            var forEach = block
                          .ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                          .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(StreamNumLambda), Ref("next"));

            CodegenLegoBooleanExpression.CodegenContinueIfNotNullAndNotPass(
                forEach,
                InnerExpression.EvaluationType,
                InnerExpression.EvaluateCodegen(typeof(bool?), methodNode, scope, codegenClassScope));
            forEach.BlockReturn(Ref("next"));
            block.MethodReturn(ConstantNull());
            return(LocalMethod(methodNode, premade.Eps, premade.Enumcoll, premade.IsNewData, premade.ExprCtx));
        }
Ejemplo n.º 23
0
        public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                EvaluationType,
                typeof(ExprEvaluatorStreamDTProp),
                codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);

            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(streamId)))
                .IfRefNullReturnNull("@event")
                .MethodReturn(
                    CodegenLegoCast.CastSafeFromObjectType(
                        EvaluationType,
                        getter.EventBeanGetCodegen(Ref("@event"), methodNode, codegenClassScope)));
            return LocalMethod(methodNode);
        }
Ejemplo n.º 24
0
 private CodegenMethod NavigateMethodCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     var navigateRecordMethod = NavigateRecordMethodCodegen(codegenMethodScope, codegenClassScope);
     return codegenMethodScope.MakeChild(typeof(GenericRecord), GetType(), codegenClassScope)
         .AddParam(typeof(GenericRecord), "record")
         .Block
         .DeclareVar<object>(
             "value",
             CodegenExpressionBuilder.StaticMethod(
                 typeof(AvroEventBeanGetterNestedIndexRooted),
                 "GetAtIndex",
                 CodegenExpressionBuilder.Ref("record"),
                 CodegenExpressionBuilder.Constant(_posTop.Name),
                 CodegenExpressionBuilder.Constant(_index)))
         .IfRefNullReturnNull("value")
         .MethodReturn(
             CodegenExpressionBuilder.LocalMethod(
                 navigateRecordMethod,
                 CodegenExpressionBuilder.CastRef(typeof(GenericRecord), "value")));
 }
Ejemplo n.º 25
0
 public override CodegenExpression Codegen(
     EnumForgeCodegenParams args,
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpression math =
         codegenClassScope.AddOrGetDefaultFieldSharable(new MathContextCodegenField(_optionalMathContext));
     var method = codegenMethodScope
         .MakeChild(typeof(decimal?), typeof(EnumAverageScalarForge), codegenClassScope)
         .AddParam(EnumForgeCodegenNames.PARAMS)
         .Block
         .DeclareVar<EnumAverageDecimalEventsForgeEval.AggregatorAvgDecimal>(
             "agg",
             NewInstance(typeof(EnumAverageDecimalEventsForgeEval.AggregatorAvgDecimal), math))
         .ForEach(typeof(object), "num", EnumForgeCodegenNames.REF_ENUMCOLL)
         .IfRefNull("num")
         .BlockContinue()
         .Expression(ExprDotMethod(Ref("agg"), "Enter", Ref("num")))
         .BlockEnd()
         .MethodReturn(ExprDotName(Ref("agg"), "Value"));
     return LocalMethod(method, args.Expressions);
 }
Ejemplo n.º 26
0
        public override CodegenMethod MakeCodegen(
            CodegenClassScope classScope,
            CodegenMethodScope parent,
            SAIFFInitializeSymbolWEventType symbols)
        {
            var method = parent
                         .MakeChild(typeof(FilterSpecParam), GetType(), classScope);

            method.Block
            .DeclareVar <ExprFilterSpecLookupable>(
                "lookupable",
                LocalMethod(lookupable.MakeCodegen(method, symbols, classScope)))
            .DeclareVar <FilterOperator>("filterOperator", EnumValue(typeof(FilterOperator), filterOperator.GetName()));

            var getFilterValue = new CodegenExpressionLambda(method.Block)
                                 .WithParams(FilterSpecParam.GET_FILTER_VALUE_FP);
            var inner = NewInstance <ProxyFilterSpecParam>(
                Ref("lookupable"),
                Ref("filterOperator"),
                getFilterValue);

            var rhsExpression       = CodegenLegoMethodExpression.CodegenExpression(_value.Forge, method, classScope);
            var matchEventConvertor = _convertor.Make(method, classScope);

            CodegenExpression valueExpr = LocalMethod(rhsExpression, Ref("eps"), ConstantTrue(), REF_EXPREVALCONTEXT);

            if (_numberCoercer != null)
            {
                valueExpr = _numberCoercer.CoerceCodegenMayNullBoxed(valueExpr, _value.Forge.EvaluationType, method, classScope);
            }

            getFilterValue.Block
            .DeclareVar <EventBean[]>("eps", LocalMethod(matchEventConvertor, FilterSpecParam.REF_MATCHEDEVENTMAP))
            .BlockReturn(FilterValueSetParamImpl.CodegenNew(valueExpr));

            method.Block.MethodReturn(inner);
            return(method);
        }
Ejemplo n.º 27
0
        private void MakeUnderlyingCodegen(
            CodegenBlock block,
            CodegenMethodScope method,
            CodegenClassScope codegenClassScope)
        {
            block
            .DeclareVar(_jsonEventType.UnderlyingType, "und", Cast(_jsonEventType.UnderlyingType, _beanInstantiator.Make(method, codegenClassScope)))
            .DeclareVar <object>("value", ConstantNull());

            for (var i = 0; i < _writeFieldReflection.Length; i++)
            {
                block.AssignRef("value", ArrayAtIndex(Ref("properties"), Constant(i)));

                var targetType = _writeFieldReflection[i].FieldType;
                CodegenExpression value;
                if (targetType.IsPrimitive)
                {
                    var caster = SimpleTypeCasterFactory.GetCaster(typeof(object), targetType);
                    value = caster.Codegen(Ref("value"), typeof(object), method, codegenClassScope);
                }
                else
                {
                    value = Cast(targetType, Ref("value"));
                }

                var set = Assign(ExprDotName(Ref("und"), _writeFieldReflection[i].Name), value);
                if (_primitiveType[i])
                {
                    block.IfRefNotNull("value").Expression(set).BlockEnd();
                }
                else
                {
                    block.Expression(set);
                }
            }

            block.BlockReturn(Ref("und"));
        }
Ejemplo n.º 28
0
        public override CodegenMethod MakeCodegen(
            CodegenClassScope classScope,
            CodegenMethodScope parent,
            SAIFFInitializeSymbolWEventType symbols)
        {
            var method = parent.MakeChild(typeof(FilterSpecParam), GetType(), classScope);

            method.Block
                .DeclareVar<ExprFilterSpecLookupable>(
                    "lookupable",
                    LocalMethod(lookupable.MakeCodegen(method, symbols, classScope)))
                .DeclareVar<FilterOperator>("filterOperator", EnumValue(filterOperator));

            var getFilterValue = new CodegenExpressionLambda(method.Block)
                .WithParams(FilterSpecParam.GET_FILTER_VALUE_FP);
            var param = NewInstance<ProxyFilterSpecParam>(
                Ref("lookupable"),
                Ref("filterOperator"),
                getFilterValue);

            //var param = NewAnonymousClass(
            //    method.Block,
            //    typeof(FilterSpecParam),
            //    Arrays.AsList<CodegenExpression>(Ref("lookupable"), Ref("filterOperator")));
            //var getFilterValue = CodegenMethod.MakeParentNode(typeof(object), GetType(), classScope)
            //    .AddParam(FilterSpecParam.GET_FILTER_VALUE_FP);
            //param.AddMethod("GetFilterValue", getFilterValue);

            var value = _deployTimeConstant.CodegenGetDeployTimeConstValue(classScope);
            if (_numberCoercer != null) {
                value = _numberCoercer.CoerceCodegenMayNullBoxed(value, _returnType, method, classScope);
            }

            getFilterValue.Block.BlockReturn(FilterValueSetParamImpl.CodegenNew(value));

            method.Block.MethodReturn(param);
            return method;
        }
Ejemplo n.º 29
0
        public static CodegenExpression CodegenTypeableSingle(
            ExprCaseNodeForge forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                typeof(object[]),
                typeof(ExprCaseNodeForgeEvalTypable),
                codegenClassScope);


            CodegenBlock block = methodNode.Block
                .DeclareVar<IDictionary<object, object>>(
                    "map",
                    StaticMethod(
                        typeof(CompatExtensions),
                        "UnwrapDictionary",
                        forge.EvaluateCodegen(
                            typeof(IDictionary<object, object>),
                            methodNode,
                            exprSymbol,
                            codegenClassScope)))
                .DeclareVar<object[]>(
                    "row",
                    NewArrayByLength(typeof(object), ExprDotName(Ref("map"), "Count")));
            int index = -1;
            foreach (KeyValuePair<string, object> entry in forge.mapResultType) {
                index++;
                block.AssignArrayElement(
                    Ref("row"),
                    Constant(index),
                    ExprDotMethod(Ref("map"), "Get", Constant(entry.Key)));
            }

            block.MethodReturn(Ref("row"));
            return LocalMethod(methodNode);
        }
Ejemplo n.º 30
0
        public CodegenExpression EvaluateMatchesCodegen(
            CodegenMethodScope parent,
            ExprSubselectEvalMatchSymbol symbols,
            CodegenClassScope classScope)
        {
            var leftResultType = valueEval.EvaluationType.GetBoxedType();
            var method = parent.MakeChild(subselect.EvaluationType, GetType(), classScope);
            method.Block
                .ApplyTri(
                    new ReturnIfNoMatch(Constant(resultWhenNoMatchingEvents), Constant(resultWhenNoMatchingEvents)),
                    method,
                    symbols)
                .DeclareVar(
                    leftResultType,
                    "leftResult",
                    valueEval.EvaluateCodegen(valueEval.EvaluationType, parent, symbols, classScope))
                .ApplyTri(DECLARE_EVENTS_SHIFTED, method, symbols);

            var nrSymbols = new SubselectForgeNRSymbol(leftResultType);
            var child = parent
                .MakeChildWithScope(subselect.EvaluationType, GetType(), nrSymbols, classScope)
                .AddParam(leftResultType, NAME_LEFTRESULT)
                .AddParam(typeof(EventBean[]), NAME_EPS)
                .AddParam(typeof(bool), NAME_ISNEWDATA)
                .AddParam(typeof(FlexCollection), NAME_MATCHINGEVENTS)
                .AddParam(typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT);
            child.Block.MethodReturn(CodegenEvaluateInternal(child, nrSymbols, classScope));
            method.Block.MethodReturn(
                LocalMethod(
                    child,
                    REF_LEFTRESULT,
                    REF_EVENTS_SHIFTED,
                    symbols.GetAddIsNewData(method),
                    symbols.GetAddMatchingEvents(method),
                    symbols.GetAddExprEvalCtx(method)));

            return LocalMethod(method);
        }