Ejemplo n.º 1
0
        protected override CodegenExpression EvaluateCodegen(
            string readerMethodName,
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(requiredType, typeof(ExprTableAccessNode), classScope);

            CodegenExpression eps = symbols.GetAddEPS(method);
            var newData = symbols.GetAddIsNewData(method);
            CodegenExpression evalCtx = symbols.GetAddExprEvalCtx(method);

            var future = classScope.NamespaceScope.AddOrGetDefaultFieldWellKnown(
                new CodegenFieldNameTableAccess(subprop.TableAccessNumber),
                typeof(ExprTableEvalStrategy));
            method.Block
                .DeclareVar<AggregationRow>("row", ExprDotMethod(future, "GetAggregationRow", eps, newData, evalCtx))
                .IfRefNullReturnNull("row")
                .MethodReturn(
                    CodegenLegoCast.CastSafeFromObjectType(
                        requiredType,
                        ExprDotMethod(
                            GetReader(classScope),
                            readerMethodName,
                            Constant(column.Column),
                            Ref("row"),
                            symbols.GetAddEPS(method),
                            symbols.GetAddIsNewData(method),
                            symbols.GetAddExprEvalCtx(method))));
            return LocalMethod(method);
        }
Ejemplo n.º 2
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            if (!audit) {
                return Constant(value);
            }

            var methodNode = codegenMethodScope.MakeChild(
                EvaluationType,
                typeof(ExprDeclaredForgeConstant),
                codegenClassScope);

            methodNode.Block
                .Expression(
                    ExprDotMethodChain(exprSymbol.GetAddExprEvalCtx(methodNode))
                        .Get("AuditProvider")
                        .Add(
                            "Exprdef",
                            Constant(parent.Prototype.Name),
                            Constant(value),
                            exprSymbol.GetAddExprEvalCtx(methodNode)))
                .MethodReturn(Constant(value));
            return LocalMethod(methodNode);
        }
Ejemplo n.º 3
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            if (!audit) {
                return EvaluateCodegenNoAudit(requiredType, codegenMethodScope, exprSymbol, codegenClassScope);
            }

            var evaluationType = requiredType == typeof(object) ? typeof(object) : InnerForge.EvaluationType;
            var methodNode = codegenMethodScope.MakeChild(
                evaluationType,
                typeof(ExprDeclaredForgeBase),
                codegenClassScope);
            methodNode.Block
                .DeclareVar(
                    evaluationType,
                    "result",
                    EvaluateCodegenNoAudit(requiredType, methodNode, exprSymbol, codegenClassScope))
                .Expression(
                    ExprDotMethodChain(exprSymbol.GetAddExprEvalCtx(methodNode))
                        .Get("AuditProvider")
                        .Add(
                            "Exprdef",
                            Constant(parent.Prototype.Name),
                            Ref("result"),
                            exprSymbol.GetAddExprEvalCtx(methodNode)))
                .MethodReturn(Ref("result"));
            return LocalMethod(methodNode);
        }
Ejemplo n.º 4
0
 protected override CodegenExpression EvaluateCodegen(
     string readerMethodName,
     Type requiredType,
     CodegenMethodScope parent,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope classScope)
 {
     var future = agg.GetAggFuture(classScope);
     var method = parent.MakeChild(requiredType, GetType(), classScope);
     method.Block
         .DeclareVar(
             typeof(AggregationRow),
             "row",
             ExprDotMethod(
                 future,
                 "GetAggregationRow",
                 ExprDotName(symbols.GetAddExprEvalCtx(parent), "AgentInstanceId"),
                 symbols.GetAddEPS(parent),
                 symbols.GetAddIsNewData(parent),
                 symbols.GetAddExprEvalCtx(parent)))
         .IfRefNullReturnNull("row")
         .MethodReturn(
             CodegenLegoCast.CastSafeFromObjectType(
                 requiredType,
                 ExprDotMethod(
                     GetReader(classScope),
                     readerMethodName,
                     Constant(agg.Column),
                     Ref("row"),
                     symbols.GetAddEPS(method),
                     symbols.GetAddIsNewData(method),
                     symbols.GetAddExprEvalCtx(method))));
     return LocalMethod(method);
 }
Ejemplo n.º 5
0
        public CodegenExpression Codegen(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            if (!audit) {
                return CodegenGet(requiredType, parent, symbols, classScope);
            }

            var targetType = GetCodegenReturnType(requiredType);
            var method = parent.MakeChild(targetType, this.GetType(), classScope);
            var valueInitializer = CodegenGet(requiredType, method, symbols, classScope);
            method.Block
                .DeclareVar(targetType, "value", valueInitializer)
                .Expression(
                    ExprDotMethodChain(symbols.GetAddExprEvalCtx(method))
                        .Get("AuditProvider")
                        .Add(
                            "Property",
                            Constant(identNode.ResolvedPropertyName),
                            Ref("value"),
                            symbols.GetAddExprEvalCtx(method)))
                .MethodReturn(Ref("value"));
            return LocalMethod(method);
        }
Ejemplo n.º 6
0
        public CodegenExpression EvaluateGetROCollectionScalarCodegen(
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            if (PreviousType == ExprPreviousNodePreviousType.PREVCOUNT) {
                return ConstantNull();
            }

            if (PreviousType == ExprPreviousNodePreviousType.PREVWINDOW) {
                var methodX = parent.MakeChild(typeof(ICollection<object>), GetType(), codegenClassScope);

                methodX.Block
                    .DeclareVar<PreviousGetterStrategy>(
                        "strategy",
                        ExprDotMethod(
                            GetterField(codegenClassScope),
                            "GetStrategy",
                            exprSymbol.GetAddExprEvalCtx(methodX)))
                    .Apply(
                        new PreviousBlockGetSizeAndIterator(methodX, exprSymbol, StreamNumber, Ref("strategy")).Accept);

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

                methodX.Block
                    .DeclareVar<EventBean>("originalEvent", ArrayAtIndex(eps, Constant(StreamNumber)))
                    .DeclareVar<ICollection<object>>("result", NewInstance<ArrayDeque<object>>(Ref("size")))
                    .ForLoopIntSimple("i", Ref("size"))
                    .AssignArrayElement(
                        eps,
                        Constant(StreamNumber),
                        Cast(typeof(EventBean), ExprDotMethod(Ref("events"), "Advance")))
                    .ExprDotMethod(
                        Ref("result"),
                        "Add",
                        LocalMethod(innerEval, eps, ConstantTrue(), exprSymbol.GetAddExprEvalCtx(methodX)))
                    .BlockEnd()
                    .AssignArrayElement(eps, Constant(StreamNumber), Ref("originalEvent"))
                    .MethodReturn(Ref("result"));
                return LocalMethod(methodX);
            }

            var method = parent.MakeChild(typeof(ICollection<object>), GetType(), codegenClassScope);
            method.Block.DeclareVar<object>(
                    "result",
                    EvaluateCodegenPrevAndTail(method, exprSymbol, codegenClassScope))
                .IfRefNullReturnNull("result")
                .MethodReturn(StaticMethod(typeof(Collections), "SingletonList", Ref("result")));
            return LocalMethod(method);
        }
Ejemplo n.º 7
0
        private CodegenMethod EvaluateGetROCollectionScalarCodegenRewritten(
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var nodeObject = GetNodeObject(codegenClassScope);
            var scope = new ExprForgeCodegenSymbol(true, null);
            var methodNode = codegenMethodScope
                .MakeChildWithScope(
                    typeof(ICollection<object>),
                    typeof(ExprDeclaredForgeBase),
                    scope,
                    codegenClassScope)
                .AddParam(ExprForgeCodegenNames.PARAMS);
            CodegenExpression refEPS = scope.GetAddEPS(methodNode);
            CodegenExpression refExprEvalCtx = scope.GetAddExprEvalCtx(methodNode);

            // generate code for the inner value so we know its symbols and derived symbols
            var innerValue =
                ((ExprEnumerationForge) InnerForge).EvaluateGetROCollectionScalarCodegen(
                    methodNode,
                    scope,
                    codegenClassScope);

            // produce derived symbols
            var block = methodNode.Block;
            scope.DerivedSymbolsCodegen(methodNode, block, codegenClassScope);

            if (isCache) {
                block
                    .DeclareVar<ExpressionResultCacheForDeclaredExprLastColl>(
                        "cache",
                        ExprDotMethodChain(refExprEvalCtx)
                            .Get("ExpressionResultCacheService")
                            .Get("AllocateDeclaredExprLastColl"))
                    .DeclareVar<ExpressionResultCacheEntryEventBeanArrayAndCollBean>(
                        "entry",
                        ExprDotMethod(
                            Ref("cache"),
                            "GetDeclaredExpressionLastColl",
                            nodeObject,
                            refEPS))
                    .IfCondition(NotEqualsNull(Ref("entry")))
                    .BlockReturn(
                        Unwrap<object>(ExprDotName(Ref("entry"), "Result")))
                    .DeclareVar<ICollection<object>>("result", innerValue)
                    .Expression(
                        ExprDotMethod(
                            Ref("cache"),
                            "SaveDeclaredExpressionLastColl",
                            nodeObject,
                            refEPS,
                            FlexWrap(Unwrap<EventBean>(Ref("result")))));
            }
            else {
                block.DeclareVar<ICollection<object>>("result", innerValue);
            }

            block.MethodReturn(FlexWrap(Ref("result")));
            return methodNode;
        }
Ejemplo n.º 8
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
                .LocalMethod(dereferenceRemove, Ref("theEvent"), eps, ctx);
            }
            else
            {
                method.Block
                .IfCondition(ExprDotMethod(joinRefs, "Remove", Ref("theEvent")))
                .LocalMethod(dereferenceRemove, Ref("theEvent"), eps, ctx);
            }
        }
Ejemplo n.º 9
0
        public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbol,
            CodegenClassScope classScope)
        {
            CodegenExpression future = classScope.NamespaceScope.AddOrGetDefaultFieldWellKnown(
                aggregationResultFutureMemberName,
                typeof(AggregationResultFuture));
            CodegenMethod method = parent.MakeChild(returnType, this.GetType(), classScope);
            CodegenExpression getGroupKey = ExprDotMethod(
                future,
                "GetGroupKey",
                ExprDotName(symbol.GetAddExprEvalCtx(method), "AgentInstanceId"));
            if (numGroupKeys == 1) {
                method.Block.MethodReturn(CodegenLegoCast.CastSafeFromObjectType(returnType, getGroupKey));
            }
            else {
                method.Block
                    .DeclareVar<HashableMultiKey>("mk", Cast(typeof(HashableMultiKey), getGroupKey))
                    .MethodReturn(
                        CodegenLegoCast.CastSafeFromObjectType(
                            returnType,
                            ArrayAtIndex(ExprDotName(Ref("mk"), "Keys"), Constant(groupKeyIndex))));
            }

            return LocalMethod(method);
        }
Ejemplo n.º 10
0
        public CodegenExpression Codegen(
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression eventToPublic = TableDeployTimeResolver.MakeTableEventToPublicField(
                tableMetadata,
                codegenClassScope,
                this.GetType());
            CodegenMethod methodNode = codegenMethodScope
                .MakeChild(typeof(object[]), typeof(ExprDotForgeUnpackBeanTable), codegenClassScope)
                .AddParam(typeof(EventBean), "target");

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

            methodNode.Block
                .IfRefNullReturnNull("target")
                .MethodReturn(
                    ExprDotMethod(eventToPublic, "ConvertToUnd", Ref("target"), refEPS, refIsNewData, refExprEvalCtx));
            return LocalMethod(methodNode, inner);
        }
Ejemplo n.º 11
0
 private CodegenExpression EvaluateCodegenNoAudit(
     Type requiredType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var evaluationType = requiredType == typeof(object) ? typeof(object) : InnerForge.EvaluationType;
     var methodNode = codegenMethodScope.MakeChild(
         evaluationType,
         typeof(ExprDeclaredForgeBase),
         codegenClassScope);
     var refEPS = exprSymbol.GetAddEPS(methodNode);
     var refIsNewData = exprSymbol.GetAddIsNewData(methodNode);
     var refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(methodNode);
     methodNode.Block
         .DeclareVar<EventBean[]>(
             "rewritten",
             CodegenEventsPerStreamRewritten(refEPS, methodNode, codegenClassScope))
         .MethodReturn(
             LocalMethod(
                 EvaluateCodegenRewritten(requiredType, methodNode, codegenClassScope),
                 Ref("rewritten"),
                 refIsNewData,
                 refExprEvalCtx));
     return LocalMethod(methodNode);
 }
Ejemplo n.º 12
0
 protected override CodegenExpression EvaluateCodegen(
     string readerMethodName,
     Type requiredType,
     CodegenMethodScope parent,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(requiredType, GetType(), classScope);
     method.Block
         .DeclareVar(
             typeof(AggregationRow),
             "row",
             StaticMethod(typeof(ExprTableIdentNode), "TableColumnRow", Constant(identNode.StreamNum), symbols.GetAddEPS(method)))
         .IfRefNullReturnNull("row")
         .MethodReturn(
             CodegenLegoCast.CastSafeFromObjectType(
                 requiredType,
                 ExprDotMethod(
                     GetReader(classScope),
                     readerMethodName,
                     Constant(column.Column),
                     Ref("row"),
                     symbols.GetAddEPS(method),
                     symbols.GetAddIsNewData(method),
                     symbols.GetAddExprEvalCtx(method))));
     return LocalMethod(method);
 }
Ejemplo n.º 13
0
        protected internal static CodegenExpression MakeEvaluate(
            AccessEvaluationType evaluationType,
            ExprTableAccessNode accessNode,
            Type resultType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            if (accessNode.TableAccessNumber == -1) {
                throw new IllegalStateException("Table expression node has not been assigned");
            }

            var method = parent.MakeChild(resultType, typeof(ExprTableAccessNode), classScope);

            CodegenExpression eps = symbols.GetAddEPS(method);
            var newData = symbols.GetAddIsNewData(method);
            CodegenExpression evalCtx = symbols.GetAddExprEvalCtx(method);

            var future = classScope.NamespaceScope.AddOrGetDefaultFieldWellKnown(
                new CodegenFieldNameTableAccess(accessNode.TableAccessNumber),
                typeof(ExprTableEvalStrategy));
            var evaluation = ExprDotMethod(future, evaluationType.MethodName, eps, newData, evalCtx);
            if (resultType != typeof(object)) {
                evaluation = CodegenLegoCast.CastSafeFromObjectType(resultType, evaluation);
                //evaluation = Cast(resultType, evaluation);
            }

            method.Block.MethodReturn(evaluation);
            return LocalMethod(method);
        }
Ejemplo n.º 14
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope codegenClassScope)
        {
            var method = parent.MakeChild(requiredType, GetType(), codegenClassScope);
            method.Block.DeclareVar<object>(
                "result",
                StaticMethod(
                    typeof(ExprTableIdentNode),
                    "TableColumnAggValue",
                    Constant(_streamNum),
                    Constant(_columnNum),
                    symbols.GetAddEPS(method),
                    symbols.GetAddIsNewData(method),
                    symbols.GetAddExprEvalCtx(method)));
            if (requiredType == typeof(object)) {
                method.Block.MethodReturn(Ref("result"));
            }
            else {
                method.Block.MethodReturn(Cast(requiredType.GetBoxedType(), Ref("result")));
            }

            return LocalMethod(method);
        }
Ejemplo n.º 15
0
        private CodegenMethod EvaluateCodegenRewritten(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var nodeObject = GetNodeObject(codegenClassScope);
            var evaluationType = DetermineEvaluationType(requiredType);

            var scope = new ExprForgeCodegenSymbol(true, null);
            var methodNode = codegenMethodScope
                .MakeChildWithScope(evaluationType, typeof(ExprDeclaredForgeBase), scope, codegenClassScope)
                .AddParam(ExprForgeCodegenNames.PARAMS);
            CodegenExpression refEPS = scope.GetAddEPS(methodNode);
            CodegenExpression refExprEvalCtx = scope.GetAddExprEvalCtx(methodNode);

            // generate code for the inner value so we know its symbols and derived symbols
            var innerValue = InnerForge.EvaluateCodegen(
                requiredType,
                methodNode,
                scope,
                codegenClassScope);

            // produce derived symbols
            var block = methodNode.Block;
            scope.DerivedSymbolsCodegen(methodNode, block, codegenClassScope);

            if (isCache) {
                CodegenExpression eval = ExprDotName(Ref("entry"), "Result");
                if (evaluationType != typeof(object)) {
                    eval = Cast(InnerForge.EvaluationType, eval);
                }

                block
                    .DeclareVar<ExpressionResultCacheForDeclaredExprLastValue>(
                        "cache",
                        ExprDotMethodChain(refExprEvalCtx)
                            .Get("ExpressionResultCacheService")
                            .Get("AllocateDeclaredExprLastValue"))
                    .DeclareVar<ExpressionResultCacheEntryEventBeanArrayAndObj>(
                        "entry",
                        ExprDotMethod(Ref("cache"), "GetDeclaredExpressionLastValue", nodeObject, refEPS))
                    .IfCondition(NotEqualsNull(Ref("entry")))
                    .BlockReturn(eval)
                    .DeclareVar(evaluationType, "result", innerValue)
                    .Expression(
                        ExprDotMethod(
                            Ref("cache"),
                            "SaveDeclaredExpressionLastValue",
                            nodeObject,
                            refEPS,
                            Ref("result")));
            }
            else {
                block.DeclareVar(evaluationType, "result", innerValue);
            }

            block.MethodReturn(Ref("result"));
            return methodNode;
        }
Ejemplo n.º 16
0
        private static CodegenExpression MakeEvaluate(
            SubselectEvaluationType evaluationType,
            ExprSubselectNode subselectNode,
            Type resultType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(resultType, typeof(ExprSubselectNode), classScope);

            CodegenExpression eps = symbols.GetAddEPS(method);
            var newData = symbols.GetAddIsNewData(method);
            CodegenExpression evalCtx = symbols.GetAddExprEvalCtx(method);

            // get matching events
            CodegenExpression future = classScope.NamespaceScope.AddOrGetDefaultFieldWellKnown(
                new CodegenFieldNameSubqueryResult(subselectNode.SubselectNumber),
                typeof(SubordTableLookupStrategy));
            var evalMatching = FlexWrap(ExprDotMethod(future, "Lookup", eps, evalCtx));
            method.Block.DeclareVar<FlexCollection>(NAME_MATCHINGEVENTS, evalMatching);

            // process matching events
            var evalMatchSymbol = new ExprSubselectEvalMatchSymbol();
            var processMethod = method
                .MakeChildWithScope(resultType, typeof(ExprSubselectNode), evalMatchSymbol, classScope)
                .AddParam(typeof(FlexCollection), NAME_MATCHINGEVENTS)
                .AddParam(ExprForgeCodegenNames.PARAMS);
            CodegenExpression process;
            if (evaluationType == PLAIN) {
                process = subselectNode.EvalMatchesPlainCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else if (evaluationType == GETEVENTCOLL) {
                process = subselectNode.EvalMatchesGetCollEventsCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else if (evaluationType == GETSCALARCOLL) {
                process = subselectNode.EvalMatchesGetCollScalarCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else if (evaluationType == GETEVENT) {
                process = subselectNode.EvalMatchesGetEventBeanCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else if (evaluationType == TYPABLESINGLE) {
                process = subselectNode.EvalMatchesTypableSingleCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else if (evaluationType == TYPABLEMULTI) {
                process = subselectNode.EvalMatchesTypableMultiCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else {
                throw new IllegalStateException("Unrecognized evaluation type " + evaluationType);
            }

            evalMatchSymbol.DerivedSymbolsCodegen(processMethod, processMethod.Block, classScope);
            processMethod.Block.MethodReturn(process);

            method.Block.MethodReturn(LocalMethod(processMethod, REF_MATCHINGEVENTS, eps, newData, evalCtx));

            return LocalMethod(method);
        }
Ejemplo n.º 17
0
 public CodegenExpression EvaluateCodegen(
     Type requiredType,
     CodegenMethodScope parent,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope classScope)
 {
     return(Cast(
                requiredType,
                CodegenLegoCast.CastSafeFromObjectType(requiredType,
                                                       ExprDotName(symbols.GetAddExprEvalCtx(parent), "FilterReboolConstant"))));
 }
Ejemplo n.º 18
0
 public CodegenExpression EvaluateCodegen(
     Type requiredType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     return StaticMethod(
         typeof(ExprCurrentEvaluationContextNode),
         "ExprCurrentEvaluationContextMake",
         refExprEvalCtx);
 }
Ejemplo n.º 19
0
 internal override void ApplyLeaveFiltered(
     CodegenMethod method,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope classScope,
     CodegenNamedMethods namedMethods)
 {
     method.Block.ExprDotMethod(
         state,
         "ApplyLeave",
         symbols.GetAddEPS(method),
         symbols.GetAddExprEvalCtx(method));
 }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
0
        public CodegenExpression EvaluateGetROCollectionEventsCodegen(
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            if (PreviousType == ExprPreviousNodePreviousType.PREV ||
                PreviousType == ExprPreviousNodePreviousType.PREVTAIL ||
                PreviousType == ExprPreviousNodePreviousType.PREVCOUNT) {
                return ConstantNull();
            }

            if (PreviousType != ExprPreviousNodePreviousType.PREVWINDOW) {
                throw new IllegalStateException("Unrecognized previous type " + PreviousType);
            }

            var method = parent.MakeChild(typeof(FlexCollection), GetType(), codegenClassScope);
            method.Block.DeclareVar<PreviousGetterStrategy>(
                "strategy",
                ExprDotMethod(
                    GetterField(codegenClassScope),
                    "GetStrategy",
                    exprSymbol.GetAddExprEvalCtx(method)));

            method.Block.IfCondition(Not(exprSymbol.GetAddIsNewData(method))).BlockReturn(ConstantNull());
            var randomAccess = method.Block.IfCondition(InstanceOf(Ref("strategy"), typeof(RandomAccessByIndexGetter)));
            {
                randomAccess
                    .DeclareVar<RandomAccessByIndexGetter>(
                        "getter",
                        Cast(typeof(RandomAccessByIndexGetter), Ref("strategy")))
                    .DeclareVar<RandomAccessByIndex>(
                        "randomAccess",
                        ExprDotName(Ref("getter"), "Accessor"))
                    .BlockReturn(FlexWrap(ExprDotName(Ref("randomAccess"), "WindowCollectionReadOnly")));
            }
            var relativeAccess = randomAccess.IfElse();
            {
                relativeAccess
                    .DeclareVar<RelativeAccessByEventNIndexGetter>(
                        "getter",
                        Cast(typeof(RelativeAccessByEventNIndexGetter), Ref("strategy")))
                    .DeclareVar<EventBean>(
                        "evalEvent",
                        ArrayAtIndex(exprSymbol.GetAddEPS(method), Constant(StreamNumber)))
                    .DeclareVar<RelativeAccessByEventNIndex>(
                        "relativeAccess",
                        ExprDotMethod(Ref("getter"), "GetAccessor", Ref("evalEvent")))
                    .IfRefNullReturnNull("relativeAccess")
                    .BlockReturn(FlexWrap(ExprDotName(Ref("relativeAccess"), "WindowToEventCollReadOnly")));
            }
            return LocalMethod(method);
        }
Ejemplo n.º 22
0
        public CodegenExpression EvaluateGetEventBeanCodegen(
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod method = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);

            method.Block
            .DeclareVar <EventBean>("@event", ExprDotName(exprSymbol.GetAddExprEvalCtx(method), "ContextProperties"))
            .IfRefNullReturnNull("@event")
            .MethodReturn(Cast(typeof(EventBean), _getterSpi.EventBeanFragmentCodegen(Ref("@event"), method, codegenClassScope)));
            return(LocalMethod(method));
        }
Ejemplo n.º 23
0
 public CodegenExpression EvaluateGetROCollectionScalarCodegen(
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var refEPS = exprSymbol.GetAddEPS(codegenMethodScope);
     var refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     return CodegenEvaluateEventGetROCollectionScalar(
         ArrayAtIndex(refEPS, Constant(streamId)),
         refExprEvalCtx,
         codegenMethodScope,
         codegenClassScope);
 }
Ejemplo n.º 24
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.º 25
0
 internal override void ApplyEnterFiltered(
     CodegenMethod method,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope classScope,
     CodegenNamedMethods namedMethods)
 {
     CodegenExpression eps = symbols.GetAddEPS(method);
     CodegenExpression ctx = symbols.GetAddExprEvalCtx(method);
     method.Block.DeclareVar<EventBean>("theEvent", ArrayAtIndex(eps, Constant(_forge.Spec.StreamNum)))
         .IfCondition(EqualsNull(Ref("theEvent")))
         .BlockReturnNoValue()
         .InstanceMethod(AddEventCodegen(method, namedMethods, classScope), Ref("theEvent"), eps, ctx);
 }
Ejemplo n.º 26
0
        private CodegenExpression EvaluateCodegenPrevWindow(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var method = parent.MakeChild(ResultType, GetType(), codegenClassScope);

            method.Block
                .DeclareVar<PreviousGetterStrategy>(
                    "strategy",
                    ExprDotMethod(GetterField(codegenClassScope), "GetStrategy", exprSymbol.GetAddExprEvalCtx(method)))
                .Apply(new PreviousBlockGetSizeAndIterator(method, exprSymbol, StreamNumber, Ref("strategy")).Accept);

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

            method.Block.DeclareVar<EventBean>("originalEvent", ArrayAtIndex(eps, Constant(StreamNumber)))
                .DeclareVar(ResultType, "result", NewArrayByLength(ResultType.GetElementType(), Ref("size")))
                .ForLoopIntSimple("i", Ref("size"))
                .ExprDotMethod(Ref("events"), "MoveNext")
                .AssignArrayElement(
                    eps,
                    Constant(StreamNumber),
                    Cast(typeof(EventBean), ExprDotName(Ref("events"), "Current")))
                .AssignArrayElement(
                    "result",
                    Ref("i"),
                    LocalMethod(innerEval, eps, ConstantTrue(), exprSymbol.GetAddExprEvalCtx(method)))
                .BlockEnd()
                .AssignArrayElement(eps, Constant(StreamNumber), Ref("originalEvent"))
                .MethodReturn(Ref("result"));
            return LocalMethod(method);
        }
Ejemplo n.º 27
0
 private CodegenExpression MakeEval(
     string method,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope codegenClassScope)
 {
     var eval = GetField(codegenClassScope);
     return ExprDotMethod(
         eval,
         method,
         symbols.GetAddEPS(codegenMethodScope),
         symbols.GetAddIsNewData(codegenMethodScope),
         symbols.GetAddExprEvalCtx(codegenMethodScope));
 }
Ejemplo n.º 28
0
 public CodegenExpression EvaluateGetEventBeanCodegen(
     CodegenMethodScope parent,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var future = GetAggFuture(codegenClassScope);
     return ExprDotMethod(
         future,
         "GetEventBean",
         Constant(column),
         exprSymbol.GetAddEPS(parent),
         exprSymbol.GetAddIsNewData(parent),
         exprSymbol.GetAddExprEvalCtx(parent));
 }
Ejemplo n.º 29
0
        public static CodegenExpression Codegen(
            ExprDotMethodForgeDuck forge,
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression mCache = codegenClassScope.AddDefaultFieldUnshared<IDictionary<Type, MethodInfo>>(
                true,
                NewInstance(typeof(Dictionary<Type, MethodInfo>)));
            var methodNode = codegenMethodScope
                .MakeChild(typeof(object), typeof(ExprDotMethodForgeDuckEval), codegenClassScope)
                .AddParam(innerType, "target");

            var block = methodNode.Block
                .IfRefNullReturnNull("target")
                .DeclareVar<MethodInfo>(
                    "method",
                    StaticMethod(
                        typeof(ExprDotMethodForgeDuckEval),
                        "DotMethodDuckGetMethod",
                        ExprDotMethod(Ref("target"), "GetType"),
                        mCache,
                        Constant(forge.MethodName),
                        Constant(forge.ParameterTypes),
                        Constant(new bool[forge.ParameterTypes.Length])))
                .IfRefNullReturnNull("method")
                .DeclareVar<object[]>(
                    "args",
                    NewArrayByLength(typeof(object), Constant(forge.Parameters.Length)));
            for (var i = 0; i < forge.Parameters.Length; i++) {
                block.AssignArrayElement(
                    "args",
                    Constant(i),
                    forge.Parameters[i].EvaluateCodegen(typeof(object), methodNode, exprSymbol, codegenClassScope));
            }

            var statementName = ExprDotName(exprSymbol.GetAddExprEvalCtx(methodNode), "StatementName");
            block.MethodReturn(
                StaticMethod(
                    typeof(ExprDotMethodForgeDuckEval),
                    "DotMethodDuckInvokeMethod",
                    Ref("method"),
                    Ref("target"),
                    Ref("args"),
                    statementName));
            return LocalMethod(methodNode, inner);
        }
Ejemplo n.º 30
0
        public CodegenExpression EvaluateGetROCollectionScalarCodegen(
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression future = GetAggFuture(codegenClassScope);

            return(ExprDotMethod(
                       future,
                       "GetCollectionScalar",
                       Constant(column),
                       exprSymbol.GetAddEPS(parent),
                       exprSymbol.GetAddIsNewData(parent),
                       exprSymbol.GetAddExprEvalCtx(parent)));
        }