Esempio n. 1
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            if (PreviousType == ExprPreviousNodePreviousType.PREV ||
                PreviousType == ExprPreviousNodePreviousType.PREVTAIL) {
                return EvaluateCodegenPrevAndTail(codegenMethodScope, exprSymbol, codegenClassScope);
            }

            if (PreviousType == ExprPreviousNodePreviousType.PREVWINDOW) {
                return EvaluateCodegenPrevWindow(requiredType, codegenMethodScope, exprSymbol, codegenClassScope);
            }

            if (PreviousType == ExprPreviousNodePreviousType.PREVCOUNT) {
                return EvaluateCodegenPrevCount(requiredType, codegenMethodScope, exprSymbol, codegenClassScope);
            }

            throw new IllegalStateException("Unrecognized previous type " + PreviousType);
        }
Esempio n. 2
0
        public CodegenExpression EvaluateGetEventBeanCodegen(
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            if (PreviousType == ExprPreviousNodePreviousType.PREVWINDOW ||
                PreviousType == ExprPreviousNodePreviousType.PREVCOUNT) {
                return ConstantNull();
            }

            var method = parent.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
            method.Block
                .IfCondition(Not(exprSymbol.GetAddIsNewData(method)))
                .BlockReturn(ConstantNull())
                .MethodReturn(
                    LocalMethod(
                        GetSubstituteCodegen(method, exprSymbol, codegenClassScope),
                        exprSymbol.GetAddEPS(method),
                        exprSymbol.GetAddExprEvalCtx(method)));
            return LocalMethod(method);
        }
Esempio n. 3
0
        public override void ForEachBlock(
            CodegenBlock block,
            CodegenMethod methodNode,
            ExprForgeCodegenSymbol scope,
            CodegenClassScope codegenClassScope)
        {
            var innerType = InnerExpression.EvaluationType;

            block.DeclareVar(innerType, "num", InnerExpression.EvaluateCodegen(innerType, methodNode, scope, codegenClassScope));
            if (!innerType.IsPrimitive)
            {
                block.IfRefNull("num").BlockContinue();
            }

            var lhs = Ref("sum");
            var rhs = SimpleNumberCoercerFactory.CoercerDecimal.CodegenDecimal(Ref("num"), innerType);

            block.IncrementRef("rowcount")
            .AssignRef("sum", Op(lhs, "+", rhs))
            .BlockEnd();
        }
Esempio n. 4
0
        public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                typeof(EventBean[]),
                typeof(ExprEvalEnumerationSingleToCollForge),
                codegenClassScope);

            methodNode.Block
                .DeclareVar<EventBean>(
                    "@event",
                    enumerationForge.EvaluateGetEventBeanCodegen(methodNode, exprSymbol, codegenClassScope))
                .IfRefNullReturnNull("@event")
                .DeclareVar<EventBean[]>("events", NewArrayByLength(typeof(EventBean), Constant(1)))
                .AssignArrayElement(Ref("events"), Constant(0), Ref("@event"))
                .MethodReturn(Ref("events"));
            return LocalMethod(methodNode);
        }
Esempio n. 5
0
        protected internal static CodegenExpression CodegenToType(
            ExprCaseNodeForge forge,
            ExprNode node,
            CodegenMethod methodNode,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            Type nodeEvaluationType = node.Forge.EvaluationType;
            if (nodeEvaluationType == forge.EvaluationType || !forge.IsNumericResult) {
                return node.Forge.EvaluateCodegen(nodeEvaluationType, methodNode, exprSymbol, codegenClassScope);
            }

            if (nodeEvaluationType == null) {
                return ConstantNull();
            }

            return TypeHelper.CoerceNumberToBoxedCodegen(
                node.Forge.EvaluateCodegen(nodeEvaluationType, methodNode, exprSymbol, codegenClassScope),
                nodeEvaluationType,
                forge.EvaluationType);
        }
Esempio n. 6
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                _returnType,
                typeof(ExprEvalStreamInsertUnd),
                codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .IfCondition(EqualsNull(refEPS))
                .BlockReturn(ConstantNull())
                .DeclareVar<EventBean>("bean", ArrayAtIndex(refEPS, Constant(_streamNum)))
                .IfRefNullReturnNull("bean")
                .MethodReturn(FlexCast(_returnType, ExprDotUnderlying(Ref("bean"))));
            
            return LocalMethod(methodNode);
        }
Esempio n. 7
0
        public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                EvaluationType,
                typeof(PropertyDotNonLambdaForge),
                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);
        }
Esempio n. 8
0
 public CodegenExpression Codegen(
     CodegenExpression inner,
     Type innerType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(table, codegenClassScope, this.GetType());
     var refEPS = exprSymbol.GetAddEPS(codegenMethodScope);
     var refIsNewData = exprSymbol.GetAddIsNewData(codegenMethodScope);
     var refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     return StaticMethod(
         typeof(ExprDotForgeUnpackCollEventBeanTable),
         "ConvertToTableUnderling",
         inner,
         eventToPublic,
         refEPS,
         refIsNewData,
         refExprEvalCtx);
 }
        public CodegenExpression Codegen(
            CodegenExpression reference,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                    typeof(long),
                    typeof(IntervalDeltaExprTimePeriodNonConstForge),
                    codegenClassScope)
                .AddParam(typeof(long), "reference");

            methodNode.Block
                .DeclareVar<double>(
                    "sec",
                    timePeriod.EvaluateAsSecondsCodegen(methodNode, exprSymbol, codegenClassScope))
                .MethodReturn(
                    timeAbacus.DeltaForSecondsDoubleCodegen(
                        Ref("sec"), codegenClassScope));
            return LocalMethod(methodNode, reference);
        }
Esempio n. 10
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            ExprForge child = ChildNodes[0].Forge;
            if (child.EvaluationType == typeof(bool)) {
                Not(child.EvaluateCodegen(requiredType, codegenMethodScope, exprSymbol, codegenClassScope));
            }

            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                typeof(bool?),
                typeof(ExprNotNode),
                codegenClassScope);
            methodNode.Block
                .DeclareVar<bool?>("b", child.EvaluateCodegen(typeof(bool?), methodNode, exprSymbol, codegenClassScope))
                .IfRefNullReturnNull("b")
                .MethodReturn(Not(Ref("b")));
            return LocalMethod(methodNode);
        }
Esempio n. 11
0
            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));
            }
Esempio n. 12
0
        internal override void ApplyLeaveFiltered(
            CodegenMethod method,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope,
            CodegenNamedMethods namedMethods)
        {
            var eps = symbols.GetAddEPS(method);
            var ctx = symbols.GetAddExprEvalCtx(method);
            var dereferenceRemove = DereferenceRemoveFromCollCodegen(method, namedMethods, classScope);
            method.Block.DeclareVar<EventBean>("theEvent", ArrayAtIndex(eps, Constant(forge.Spec.StreamNum)))
                .IfRefNull("theEvent")
                .BlockReturnNoValue();

            if (joinRefs == null) {
                method.Block.InstanceMethod(dereferenceRemove, Ref("theEvent"), eps, ctx);
            }
            else {
                method.Block.IfCondition(ExprDotMethod(joinRefs, "Remove", Ref("theEvent")))
                    .InstanceMethod(dereferenceRemove, Ref("theEvent"), eps, ctx);
            }
        }
Esempio n. 13
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var method = parent.MakeChild(EvaluationType, GetType(), codegenClassScope);
            var innerEval = CodegenLegoMethodExpression.CodegenExpression(InnerForge, method, codegenClassScope, true);
            var eps = exprSymbol.GetAddEPS(method);

            // see ExprPriorEvalStrategyBase
            CodegenExpression future = codegenClassScope.NamespaceScope.AddOrGetDefaultFieldWellKnown(
                priorStrategyFieldName,
                typeof(PriorEvalStrategy));

            var innerMethod = LocalMethod(
                innerEval,
                eps,
                exprSymbol.GetAddIsNewData(method),
                exprSymbol.GetAddExprEvalCtx(method));
            method.Block
                .DeclareVar<EventBean>("originalEvent", ArrayAtIndex(eps, Constant(StreamNumber)))
                .DeclareVar<EventBean>(
                    "substituteEvent",
                    ExprDotMethod(
                        future,
                        "GetSubstituteEvent",
                        Ref("originalEvent"),
                        exprSymbol.GetAddIsNewData(method),
                        Constant(ConstantIndexNumber),
                        Constant(RelativeIndex),
                        exprSymbol.GetAddExprEvalCtx(method),
                        Constant(StreamNumber)))
                .AssignArrayElement(eps, Constant(StreamNumber), Ref("substituteEvent"))
                .DeclareVar(EvaluationType, "evalResult", innerMethod)
                .AssignArrayElement(eps, Constant(StreamNumber), Ref("originalEvent"))
                .MethodReturn(Ref("evalResult"));

            return LocalMethod(method);
        }
Esempio n. 14
0
        public static CodegenExpression CodegenCalendar(
            CalendarSetForge forge,
            CodegenExpression dateTimeEx,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var field = Constant(forge.field);
            var evaluationType = forge.valueExpr.EvaluationType;
            if (evaluationType.CanNotBeNull()) {
                var valueExpr = forge.valueExpr
                    .EvaluateCodegen(evaluationType, codegenMethodScope, exprSymbol, codegenClassScope);
                return ExprDotMethod(dateTimeEx, "SetFieldValue", field, valueExpr);
            }
            else {
                var methodNode = codegenMethodScope
                    .MakeChild(typeof(void), typeof(CalendarSetForgeOp), codegenClassScope)
                    .AddParam(typeof(DateTimeEx), "dtx");
                var valueExpr = forge.valueExpr
                    .EvaluateCodegen(evaluationType, methodNode, exprSymbol, codegenClassScope);

                methodNode.Block
                    .DeclareVar<int?>(
                        "value",
                        SimpleNumberCoercerFactory.CoercerInt.CoerceCodegenMayNull(
                            valueExpr,
                            forge.valueExpr.EvaluationType,
                            methodNode,
                            codegenClassScope))
                    .IfRefNullReturnNull("value")
                    .Expression(
                        ExprDotMethod(
                            dateTimeEx,
                            "SetFieldValue",
                            field,
                            Unbox<int?>(Ref("value"))))
                    .MethodEnd();
                return LocalMethod(methodNode, dateTimeEx);
            }
        }
Esempio n. 15
0
        public static CodegenExpression Codegen(
            EnumLastOfPredicateScalarForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var typeMember = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(
                    typeof(ObjectArrayEventType),
                    EventTypeUtility.ResolveTypeCodegen(forge.type, EPStatementInitServicesConstants.REF)));

            var resultType = Boxing.GetBoxedType(EPTypeHelper.GetCodegenReturnType(forge.resultType));
            var paramsType = EnumForgeCodegenNames.PARAMS;
            var scope = new ExprForgeCodegenSymbol(false, null);
            
            var methodNode = codegenMethodScope
                .MakeChildWithScope(resultType, typeof(EnumLastOfPredicateScalarForgeEval), scope, codegenClassScope)
                .AddParam(paramsType);

            CodegenBlock block;
            block = methodNode.Block
                .DeclareVar<object>("result", ConstantNull())
                .DeclareVar<ObjectArrayEventBean>(
                    "evalEvent",
                    NewInstance<ObjectArrayEventBean>(NewArrayByLength(typeof(object), Constant(1)), typeMember))
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("evalEvent"))
                .DeclareVar<object[]>("props", ExprDotName(Ref("evalEvent"), "Properties"));
            var forEach = block
                .ForEach(typeof(object), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                .AssignArrayElement("props", Constant(0), Ref("next"));
            CodegenLegoBooleanExpression.CodegenContinueIfNotNullAndNotPass(
                forEach,
                forge.InnerExpression.EvaluationType,
                forge.InnerExpression.EvaluateCodegen(typeof(bool?), methodNode, scope, codegenClassScope));
            forEach.AssignRef("result", Ref("next"));
            block.MethodReturn(Cast(resultType, Ref("result")));
            return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx);
        }
Esempio n. 16
0
        public static CodegenExpression Codegen(
            EnumIntersectForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var scope = new ExprForgeCodegenSymbol(false, null);
            var namedParams = EnumForgeCodegenNames.PARAMS;
            var returnType = typeof(FlexCollection);

            var methodNode = codegenMethodScope
                .MakeChildWithScope(
                    returnType,
                    typeof(EnumIntersectForgeEval),
                    scope,
                    codegenClassScope)
                .AddParam(namedParams);

            var block = methodNode.Block;
            if (forge.scalar) {
                block.DeclareVar<FlexCollection>(
                    "other",
                    forge.evaluatorForge.EvaluateGetROCollectionScalarCodegen(methodNode, scope, codegenClassScope));
            }
            else {
                block.DeclareVar<FlexCollection>(
                    "other",
                    forge.evaluatorForge.EvaluateGetROCollectionEventsCodegen(methodNode, scope, codegenClassScope));
            }

            block.MethodReturn(
                FlexWrap(
                    StaticMethod(
                        typeof(EnumIntersectForgeEval),
                        "EnumIntersectForgeEvalSet",
                        Ref("other"),
                        EnumForgeCodegenNames.REF_ENUMCOLL)));

            return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx);
        }
Esempio n. 17
0
        public static CodegenExpression CodegenStartEnd(
            DTLocalDtxOpsIntervalForge forge,
            CodegenExpression start,
            CodegenExpression end,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression timeZoneField =
                codegenClassScope.AddOrGetDefaultFieldSharable(RuntimeSettingsTimeZoneField.INSTANCE);
            var methodNode = codegenMethodScope
                .MakeChild(typeof(bool?), typeof(DTLocalDtxOpsIntervalEval), codegenClassScope)
                .AddParam(typeof(DateTimeEx), "startTimestamp")
                .AddParam(typeof(DateTimeEx), "endTimestamp");

            var block = methodNode.Block
                .DeclareVar<long>("startLong", ExprDotName(Ref("startTimestamp"), "UtcMillis"))
                .DeclareVar<long>("endLong", ExprDotName(Ref("endTimestamp"), "UtcMillis"))
                .DeclareVar<DateTimeEx>("dtx", StaticMethod(typeof(DateTimeEx), "GetInstance", timeZoneField))
                .Expression(ExprDotMethod(Ref("dtx"), "SetUtcMillis", Ref("startLong")));
            EvaluateCalOpsDtxCodegen(
                block,
                forge.calendarForges,
                Ref("dtx"),
                methodNode,
                exprSymbol,
                codegenClassScope);
            block.DeclareVar<long>("startTime", ExprDotName(Ref("dtx"), "UtcMillis"))
                .DeclareVar<long>(
                    "endTime",
                    Op(Ref("startTime"), "+", Op(Ref("endLong"), "-", Ref("startLong"))))
                .MethodReturn(
                    forge.intervalForge.Codegen(
                        Ref("startTime"),
                        Ref("endTime"),
                        methodNode,
                        exprSymbol,
                        codegenClassScope));
            return LocalMethod(methodNode, start, end);
        }
Esempio n. 18
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);
        }
Esempio n. 19
0
        public static CodegenExpression CodegenEvaluate(
            InnerDotArrObjectToCollForge forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                typeof(ICollection<object>),
                typeof(InnerDotArrObjectToCollEval),
                codegenClassScope);

            Type evalType = forge.rootForge.EvaluationType;
            methodNode.Block
                .DeclareVar(
                    forge.rootForge.EvaluationType,
                    "array",
                    forge.rootForge.EvaluateCodegen(evalType, methodNode, exprSymbol, codegenClassScope))
                .IfRefNullReturnNull("array")
                .MethodReturn(
                    Unwrap<object>(Ref("array")));
            return LocalMethod(methodNode);
        }
Esempio n. 20
0
        public CodegenExpression Codegen(
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope) 
        {
            CodegenExpression eventToPublic = TableDeployTimeResolver.MakeTableEventToPublicField(tableMetadata, classScope, GetType());
            CodegenMethod methodNode = parent
                .MakeChild(typeof(Object[]), typeof(ExprDotForgeUnpackBeanTable), classScope)
                .AddParam(typeof(EventBean), "target");

            CodegenExpressionRef refEPS = symbols.GetAddEPS(methodNode);
            CodegenExpression refIsNewData = symbols.GetAddIsNewData(methodNode);
            CodegenExpressionRef refExprEvalCtx = symbols.GetAddExprEvalCtx(methodNode);

            methodNode.Block
                .IfRefNullReturnNull("target")
                .MethodReturn(
                    ExprDotMethod(eventToPublic, "ConvertToUnd", Ref("target"), refEPS, refIsNewData, refExprEvalCtx));
            return LocalMethod(methodNode, inner);
        }
Esempio n. 21
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);
        }
Esempio n. 22
0
        public static CodegenExpression Codegen(
            DTLocalDtxOpsDtzForge forge,
            CodegenExpression inner,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope
                .MakeChild(typeof(DateTime), typeof(DTLocalDtxOpsDtzEval), codegenClassScope)
                .AddParam(typeof(DateTime), "dateTime");

            CodegenBlock block = methodNode.Block;
            EvaluateCalOpsDateTimeCodegen(
                block,
                "dateTime",
                forge.calendarForges,
                methodNode,
                exprSymbol,
                codegenClassScope);
            block.MethodReturn(Ref("dateTime"));
            return LocalMethod(methodNode, inner);
        }
Esempio n. 23
0
 public static CodegenExpression Codegen(
     DTLocalDtxOpsDtoForge forge,
     CodegenExpression inner,
     Type innerType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var methodNode = codegenMethodScope
         .MakeChild(typeof(DateTimeOffset), typeof(DTLocalDtxOpsDtoEval), codegenClassScope)
         .AddParam(typeof(DateTimeOffset), "target");
     var block = methodNode.Block;
     DTLocalUtil.EvaluateCalOpsDtoCodegen(
         block,
         "target",
         forge.calendarForges,
         methodNode,
         exprSymbol,
         codegenClassScope);
     block.MethodReturn(Ref("target"));
     return LocalMethod(methodNode, inner);
 }
Esempio n. 24
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);
        }
Esempio n. 25
0
        public static CodegenExpression CodegenUnderlying(
            ExprDotMethodForgeNoDuck forge,
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var underlyingType = forge.Method.DeclaringType;
            var returnType     = forge.Method.ReturnType;
            var methodNode     = codegenMethodScope
                                 .MakeChild(returnType.GetBoxedType(), typeof(ExprDotMethodForgeNoDuckEvalUnderlying), codegenClassScope)
                                 .AddParam(typeof(EventBean), "target");

            var eval = ExprDotMethodForgeNoDuckEvalPlain.CodegenPlain(
                forge,
                Ref("underlying"),
                underlyingType,
                methodNode,
                exprSymbol,
                codegenClassScope);

            if (returnType != typeof(void))
            {
                methodNode.Block
                .IfRefNullReturnNull("target")
                .DeclareVar(underlyingType, "underlying", Cast(underlyingType, ExprDotName(Ref("target"), "Underlying")))
                .MethodReturn(eval);
            }
            else
            {
                methodNode.Block
                .IfRefNotNull("target")
                .DeclareVar(underlyingType, "underlying", Cast(underlyingType, ExprDotName(Ref("target"), "Underlying")))
                .Expression(eval);
            }

            return(LocalMethod(methodNode, inner));
        }
Esempio n. 26
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));
        }
Esempio n. 27
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));
        }
Esempio n. 28
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);
        }
        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);
        }
Esempio n. 30
0
        public static CodegenExpression Codegen(
            EnumAverageDecimalEventsForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var innerType = forge.InnerExpression.EvaluationType;

            CodegenExpression math =
                codegenClassScope.AddOrGetDefaultFieldSharable(new MathContextCodegenField(forge.optionalMathContext));

            var scope = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope.MakeChildWithScope(
                    typeof(decimal?),
                    typeof(EnumAverageDecimalEventsForgeEval),
                    scope,
                    codegenClassScope)
                .AddParam(EnumForgeCodegenNames.PARAMS);

            var block = methodNode.Block;
            block.DeclareVar<AggregatorAvgDecimal>(
                "agg",
                NewInstance<AggregatorAvgDecimal>(math));
            var forEach = block.ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("next"))
                .DeclareVar(
                    innerType,
                    "num",
                    forge.InnerExpression.EvaluateCodegen(innerType, methodNode, scope, codegenClassScope));
            if (innerType.CanBeNull()) {
                forEach.IfRefNull("num").BlockContinue();
            }

            forEach.Expression(ExprDotMethod(Ref("agg"), "Enter", Ref("num")))
                .BlockEnd();
            block.MethodReturn(ExprDotName(Ref("agg"), "Value"));
            return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx);
        }