Пример #1
0
 public ExprDotNodeForgeStreamEvalMethod(
     ExprDotNodeForgeStream forge,
     ExprDotEval[] evaluators)
 {
     this.forge = forge;
     this.evaluators = evaluators;
 }
Пример #2
0
 public ExprDotNodeForgeStreamEvalEventBean(
     ExprDotNodeForgeStream forge,
     ExprDotEval[] evaluators)
 {
     this.forge = forge;
     this.evaluators = evaluators;
 }
Пример #3
0
        public static CodegenExpression Codegen(
            ExprDotNodeForgeStream forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                forge.EvaluationType,
                typeof(ExprDotNodeForgeStreamEvalEventBean),
                codegenClassScope);
            CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);

            CodegenExpression typeInformation = ConstantNull();
            if (codegenClassScope.IsInstrumented) {
                typeInformation =
                    codegenClassScope.AddOrGetDefaultFieldSharable(
                        new EPTypeCodegenSharable(EPTypeHelper.SingleEvent(forge.EventType), codegenClassScope));
            }

            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(forge.StreamNumber)))
                .Apply(
                    InstrumentationCode.Instblock(
                        codegenClassScope,
                        "qExprDotChain",
                        typeInformation,
                        Ref("@event"),
                        Constant(forge.Evaluators.Length)))
                .IfRefNull("@event")
                .Apply(InstrumentationCode.Instblock(codegenClassScope, "aExprDotChain"))
                .BlockReturn(ConstantNull())
                .DeclareVar(
                    forge.EvaluationType,
                    "result",
                    ExprDotNodeUtility.EvaluateChainCodegen(
                        methodNode,
                        exprSymbol,
                        codegenClassScope,
                        Ref("@event"),
                        typeof(EventBean),
                        forge.Evaluators,
                        null))
                .Apply(InstrumentationCode.Instblock(codegenClassScope, "aExprDotChain"))
                .MethodReturn(Ref("result"));
            return LocalMethod(methodNode);
        }
Пример #4
0
        public static CodegenExpression Codegen(
            ExprDotNodeForgeStream forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var evaluationType = forge.EvaluationType;
            var eventUndType = forge.EventType.UnderlyingType;
            var methodNode = codegenMethodScope.MakeChild(
                evaluationType,
                typeof(ExprDotNodeForgeStreamEvalMethod),
                codegenClassScope);
            var refEPS = exprSymbol.GetAddEPS(methodNode);

            var block = methodNode.Block
                .Apply(
                    Instblock(
                        codegenClassScope,
                        "qExprStreamUndMethod",
                        Constant(ExprNodeUtilityPrint.ToExpressionStringMinPrecedence(forge))))
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(forge.StreamNumber)));
            if (evaluationType == typeof(void)) {
                block.IfCondition(EqualsNull(Ref("@event")))
                    .Apply(Instblock(codegenClassScope, "aExprStreamUndMethod", ConstantNull()))
                    .BlockReturnNoValue();
            }
            else {
                block.IfRefNull("@event")
                    .Apply(Instblock(codegenClassScope, "aExprStreamUndMethod", ConstantNull()))
                    .BlockReturn(ConstantNull());
            }

            var typeInformation = ConstantNull();
            if (codegenClassScope.IsInstrumented) {
                typeInformation = codegenClassScope.AddOrGetDefaultFieldSharable(
                    new EPTypeCodegenSharable(
                        EPTypeHelper.SingleValue(forge.EventType.UnderlyingType),
                        codegenClassScope));
            }

            block.DeclareVar(eventUndType, "inner", Cast(eventUndType, ExprDotName(Ref("@event"), "Underlying")))
                .Apply(
                    Instblock(
                        codegenClassScope,
                        "qExprDotChain",
                        typeInformation,
                        Ref("inner"),
                        Constant(forge.Evaluators.Length)));
            var invoke = ExprDotNodeUtility.EvaluateChainCodegen(
                methodNode,
                exprSymbol,
                codegenClassScope,
                Ref("inner"),
                eventUndType,
                forge.Evaluators,
                null);
            if (evaluationType == typeof(void)) {
                block.Expression(invoke)
                    .Apply(Instblock(codegenClassScope, "aExprDotChain"))
                    .Apply(Instblock(codegenClassScope, "aExprStreamUndMethod", ConstantNull()))
                    .MethodEnd();
            }
            else {
                block.DeclareVar(evaluationType, "result", invoke)
                    .Apply(Instblock(codegenClassScope, "aExprDotChain"))
                    .Apply(Instblock(codegenClassScope, "aExprStreamUndMethod", Ref("result")))
                    .MethodReturn(Ref("result"));
            }

            return LocalMethod(methodNode);
        }