Exemple #1
0
 public static CodegenExpression CodegenExpressionMayCoerce(
     ExprForge forge, 
     Type targetType,
     CodegenMethod exprMethod,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope classScope)
 {
     CodegenExpression expr = forge.EvaluateCodegen(forge.EvaluationType, exprMethod, exprSymbol, classScope);
     return ExprNodeUtilityCodegen.CodegenCoerce(expr, forge.EvaluationType, targetType, false);
 }
Exemple #2
0
        public virtual CodegenMethod MakeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbolWEventType symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(
                typeof(ExprFilterSpecLookupable),
                typeof(ExprFilterSpecLookupableForge),
                classScope);
            CodegenExpression singleEventEvalExpr = ConstantNull();
            if (_optionalEventEvalForge != null) {
                var eval = new CodegenExpressionLambda(method.Block)
                    .WithParam<EventBean>("bean")
                    .WithParam<ExprEvaluatorContext>("ctx");
                var anonymous = NewInstance<ProxyExprEventEvaluator>(eval);
                eval.Block.BlockReturn(
                    _optionalEventEvalForge.EventBeanWithCtxGet(Ref("bean"), Ref("ctx"), method, classScope));
                singleEventEvalExpr = anonymous;
            }

            CodegenExpression epsEvalExpr = ConstantNull();
            if (_optionalExprForge != null) {
                epsEvalExpr = ExprNodeUtilityCodegen.CodegenEvaluator(
                    _optionalExprForge, method, typeof(ExprFilterSpecLookupableForge), classScope);
            }

            CodegenExpression serdeExpr = _valueSerde == null ? ConstantNull() : _valueSerde.Codegen(method, classScope, null);
            CodegenExpression returnTypeExpr = _returnType == null ? ConstantNull() : Typeof(_returnType);

            method.Block
                .DeclareVar<ExprEventEvaluator>("eval", singleEventEvalExpr)
                .DeclareVar<ExprEvaluator>("expr", epsEvalExpr)
                .DeclareVar<ExprFilterSpecLookupable>(
                    "lookupable",
                    NewInstance<ExprFilterSpecLookupable>(
                        Constant(_expression),
                        Ref("eval"),
                        Ref("expr"),
                        returnTypeExpr,
                        Constant(_isNonPropertyGetter),
                        serdeExpr))
                .Expression(
                    ExprDotMethodChain(symbols.GetAddInitSvc(method))
                        .Get(EPStatementInitServicesConstants.FILTERSHAREDLOOKUPABLEREGISTERY)
                        .Add(
                            "RegisterLookupable",
                            symbols.GetAddEventType(method),
                            Ref("lookupable")))
                .MethodReturn(Ref("lookupable"));
            return method;
        }