Beispiel #1
0
        public override CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                typeof(string),
                typeof(ExprTypeofNodeForgeFragmentType),
                codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(streamId)))
                .IfRefNullReturnNull("@event")
                .DeclareVar<object>(
                    "fragment",
                    getter.EventBeanFragmentCodegen(Ref("@event"), methodNode, codegenClassScope))
                .IfRefNullReturnNull("fragment")
                .IfInstanceOf("fragment", typeof(EventBean))
                .BlockReturn(
                    ExprDotMethodChain(Cast(typeof(EventBean), Ref("fragment"))).Get("EventType").Get("Name"))
                .IfCondition(ExprDotMethodChain(Ref("fragment")).Add("GetType").Get("IsArray"))
                .BlockReturn(Constant(fragmentType + "[]"))
                .MethodReturn(ConstantNull());
            return LocalMethod(methodNode);
        }
Beispiel #2
0
        public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                typeof(long?),
                typeof(ExprEvaluatorStreamDTPropFragment),
                codegenClassScope);
            var refEPS = exprSymbol.GetAddEPS(methodNode);

            methodNode.Block
                .DeclareVar<EventBean>("theEvent", ArrayAtIndex(refEPS, Constant(streamId)))
                .IfRefNullReturnNull("theEvent")
                .DeclareVar<object>(
                    "@event",
                    getterFragment.EventBeanFragmentCodegen(Ref("theEvent"), methodNode, codegenClassScope))
                .IfCondition(Not(InstanceOf(Ref("@event"), typeof(EventBean))))
                .BlockReturn(ConstantNull())
                .MethodReturn(
                    CodegenLegoCast.CastSafeFromObjectType(
                        typeof(long),
                        getterTimestamp.EventBeanGetCodegen(
                            Cast(typeof(EventBean), Ref("@event")),
                            methodNode,
                            codegenClassScope)));
            return LocalMethod(methodNode);
        }
        public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            CodegenMethod        method = parent.MakeChild(typeof(EventBean), typeof(PropertyDotNonLambdaFragmentIndexedForge), classScope);
            CodegenExpressionRef refEps = symbols.GetAddEPS(method);

            method.Block
            .DeclareVar <EventBean>("@event", ArrayAtIndex(refEps, Constant(_streamId)))
            .IfRefNullReturnNull("@event")
            .DeclareVar <EventBean[]>("array", Cast(typeof(EventBean[]), _getter.EventBeanFragmentCodegen(Ref("@event"), method, classScope)))
            .DeclareVar(typeof(int?), "index", _indexExpr.Forge.EvaluateCodegen(typeof(int?), method, symbols, classScope))
            .IfRefNullReturnNull("index")
            .IfCondition(Relational(Ref("index"), CodegenExpressionRelational.CodegenRelational.GE, ArrayLength(Ref("array"))))
            .BlockThrow(
                NewInstance(
                    typeof(EPException),
                    Concat(
                        Constant("Array length "),
                        ArrayLength(Ref("array")),
                        Constant(" less than index "),
                        Ref("index"),
                        Constant(" for property '" + _propertyName + "'"))))
            .MethodReturn(CodegenLegoCast.CastSafeFromObjectType(
                              typeof(EventBean), ArrayAtIndex(
                                  Ref("array"), Unbox(Ref("index")))));
            return(LocalMethod(method));
        }
        public CodegenExpression EvaluateGetEventBeanCodegen(CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope)
        {
            var method = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);

            method.Block
            .DeclareVar <EventBean>("@event", ArrayAtIndex(exprSymbol.GetAddEPS(method), Constant(_streamId)))
            .IfRefNullReturnNull("@event")
            .MethodReturn(Cast(typeof(EventBean), _getterSpi.EventBeanFragmentCodegen(Ref("@event"), method, codegenClassScope)));
            return(LocalMethod(method));
        }
Beispiel #5
0
        public CodegenExpression EvaluateGetEventBeanCodegen(
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                typeof(EventBean),
                typeof(PropertyDotEventSingleForge),
                codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(streamId)))
                .IfRefNullReturnNull("@event")
                .MethodReturn(
                    Cast(
                        typeof(EventBean),
                        getter.EventBeanFragmentCodegen(Ref("@event"), methodNode, codegenClassScope)));
            return LocalMethod(methodNode);
        }
Beispiel #6
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));
        }
        public CodegenExpression Codegen(
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            var type = EPTypeHelper.GetCodegenReturnType(_returnType);

            if (innerType == typeof(EventBean))
            {
                return(CodegenLegoCast.CastSafeFromObjectType(type, _getter.EventBeanFragmentCodegen(inner, parent, classScope)));
            }

            var methodNode = parent.MakeChild(type, typeof(ExprDotForgePropertyFragment), classScope).AddParam(innerType, "target");

            methodNode.Block
            .IfInstanceOf("target", typeof(EventBean))
            .BlockReturn(
                CodegenLegoCast.CastSafeFromObjectType(type, _getter.EventBeanFragmentCodegen(Cast(typeof(EventBean), inner), methodNode, classScope)))
            .MethodReturn(ConstantNull());
            return(LocalMethod(methodNode, inner));
        }
Beispiel #8
0
 public static CodegenMethod GetArrayPropertyFragmentCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope,
     int index,
     EventPropertyGetterSPI nestedGetter)
 {
     return codegenMethodScope.MakeChild(typeof(object), typeof(BaseNestableEventUtil), codegenClassScope)
         .AddParam(typeof(EventBean[]), "wrapper")
         .Block
         .IfRefNullReturnNull("wrapper")
         .IfConditionReturnConst(Relational(ArrayLength(Ref("wrapper")), LE, Constant(index)), null)
         .DeclareVar<EventBean>("inner", ArrayAtIndex(Ref("wrapper"), Constant(index)))
         .MethodReturn(
             nestedGetter.EventBeanFragmentCodegen(Ref("inner"), codegenMethodScope, codegenClassScope));
 }
 private CodegenMethod GetFragmentCodegen(
     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")
         .DeclareVar<EventBean>("theEvent", Cast(typeof(EventBean), Ref("value")))
         .MethodReturn(
             eventBeanEntryGetter.EventBeanFragmentCodegen(
                 Ref("theEvent"),
                 codegenMethodScope,
                 codegenClassScope));
 }
Beispiel #10
0
 private CodegenMethod GetFragmentCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(typeof(EventBean), "theEvent")
         .Block
         .DeclareVarWCast(typeof(DecoratingEventBean), "wrapperEvent", "theEvent")
         .DeclareVar<EventBean>("wrappedEvent", ExprDotName(Ref("wrapperEvent"), "UnderlyingEvent"))
         .IfRefNullReturnNull("wrappedEvent")
         .MethodReturn(
             underlyingGetter.EventBeanFragmentCodegen(
                 Ref("wrappedEvent"),
                 codegenMethodScope,
                 codegenClassScope));
 }
 private CodegenMethod GetFragmentCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(typeof(object[]), "array")
         .Block
         .DeclareVar<object>("value", ArrayAtIndex(Ref("array"), Constant(propertyIndex)))
         .IfRefNullReturnNull("value")
         .DeclareVarWCast(typeof(EventBean), "theEvent", "value")
         .MethodReturn(
             eventBeanEntryGetter.EventBeanFragmentCodegen(
                 Ref("theEvent"),
                 codegenMethodScope,
                 codegenClassScope));
 }
Beispiel #12
0
        public CodegenExpression Make(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            CodegenMethod method = parent.MakeChild(typeof(ContainedEventEvalGetter), this.GetType(), classScope);

            var getFragment = new CodegenExpressionLambda(method.Block)
                .WithParams(new CodegenNamedParam(typeof(EventBean), "@event"));
            var anonymousClass = NewInstance<ProxyEventPropertyFragmentGetter>(getFragment);

            //var anonymousClass = NewAnonymousClass(
            //    method.Block,
            //    typeof(EventPropertyFragmentGetter));
            //var getFragment = CodegenMethod.MakeParentNode(typeof(object), this.GetType(), classScope)
            //    .AddParam(typeof(EventBean), "@event");
            //anonymousClass.AddMethod("GetFragment", getFragment);
            getFragment.Block.BlockReturn(getter.EventBeanFragmentCodegen(Ref("@event"), method /* getFragment */, classScope));

            method.Block.MethodReturn(NewInstance<ContainedEventEvalGetter>(anonymousClass));
            return LocalMethod(method);
        }
Beispiel #13
0
        private CodegenExpression CodegenEvaluateInternal(
            CodegenExpressionRef @event,
            Func<CodegenMethod, CodegenExpressionRef> refExprEvalCtxFunc,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            if (_disablePropertyExpressionEventCollCache) {
                var methodNodeX = codegenMethodScope.MakeChild(
                        typeof(FlexCollection),
                        typeof(PropertyDotEventCollectionForge),
                        codegenClassScope)
                    .AddParam(typeof(EventBean), "@event");

                methodNodeX.Block
                    .DeclareVar<EventBean[]>(
                        "events",
                        Cast(
                            typeof(EventBean[]),
                            _getter.EventBeanFragmentCodegen(Ref("@event"), methodNodeX, codegenClassScope)))
                    .IfRefNullReturnNull("events")
                    .MethodReturn(FlexWrap(Ref("events")));
                return LocalMethod(methodNodeX, @event);
            }

            var methodNode = codegenMethodScope
                .MakeChild(typeof(FlexCollection), typeof(PropertyDotEventCollectionForge), codegenClassScope)
                .AddParam(typeof(EventBean), "@event");
            CodegenExpressionRef refExprEvalCtx = refExprEvalCtxFunc.Invoke(methodNode);

            methodNode.Block
                .DeclareVar<ExpressionResultCacheForPropUnwrap>(
                    "cache",
                    ExprDotMethodChain(refExprEvalCtx)
                        .Get("ExpressionResultCacheService")
                        .Get("AllocateUnwrapProp"))
                .DeclareVar<ExpressionResultCacheEntryBeanAndCollBean>(
                    "cacheEntry",
                    ExprDotMethod(Ref("cache"), "GetPropertyColl", Constant(_propertyNameCache), Ref("@event")))
                .IfCondition(NotEqualsNull(Ref("cacheEntry")))
                .BlockReturn(ExprDotName(Ref("cacheEntry"), "Result"))
                .DeclareVar<EventBean[]>(
                    "events",
                    Cast(
                        typeof(EventBean[]),
                        _getter.EventBeanFragmentCodegen(Ref("@event"), methodNode, codegenClassScope)))
                .DeclareVarNoInit(typeof(FlexCollection), "coll")
                .IfRefNull("events")
                .AssignRef("coll", ConstantNull())
                .IfElse()
                .AssignRef("coll", FlexWrap(Ref("events")))
                .BlockEnd()
                .Expression(
                    ExprDotMethod(
                        Ref("cache"),
                        "SavePropertyColl",
                        Constant(_propertyNameCache),
                        Ref("@event"),
                        Ref("coll")))
                .MethodReturn(Ref("coll"));
            return LocalMethod(methodNode, @event);
        }
        public static CodegenMethod From(
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope,
            Type expectedUnderlyingType,
            EventPropertyGetterSPI innerGetter,
            AccessType accessType,
            Type generator)
        {
            var methodNode = codegenMethodScope.MakeChild(
                accessType == AccessType.EXISTS ? typeof(bool) : typeof(object),
                generator,
                codegenClassScope)
                             .AddParam(typeof(object), "value");
            var block = methodNode.Block
                        .IfInstanceOf("value", typeof(EventBean))
                        .DeclareVarWCast(typeof(EventBean), "bean", "value");

            if (accessType == AccessType.GET)
            {
                block = block.BlockReturn(
                    innerGetter.EventBeanGetCodegen(Ref("bean"), codegenMethodScope, codegenClassScope));
            }
            else if (accessType == AccessType.EXISTS)
            {
                block = block.BlockReturn(
                    innerGetter.EventBeanExistsCodegen(Ref("bean"), codegenMethodScope, codegenClassScope));
            }
            else if (accessType == AccessType.FRAGMENT)
            {
                block = block.BlockReturn(
                    innerGetter.EventBeanFragmentCodegen(Ref("bean"), codegenMethodScope, codegenClassScope));
            }
            else
            {
                throw new UnsupportedOperationException("Invalid access type " + accessType);
            }

            block = block
                    .IfNotInstanceOf("value", expectedUnderlyingType)
                    .BlockReturn(
                accessType == AccessType.EXISTS
                        ? Constant(false)
                        : ConstantNull());

            CodegenExpression expression;

            if (accessType == AccessType.GET)
            {
                expression = innerGetter.UnderlyingGetCodegen(
                    Cast(expectedUnderlyingType, Ref("value")),
                    codegenMethodScope,
                    codegenClassScope);
            }
            else if (accessType == AccessType.EXISTS)
            {
                expression = innerGetter.UnderlyingExistsCodegen(
                    Cast(expectedUnderlyingType, Ref("value")),
                    codegenMethodScope,
                    codegenClassScope);
            }
            else if (accessType == AccessType.FRAGMENT)
            {
                expression = innerGetter.UnderlyingFragmentCodegen(
                    Cast(expectedUnderlyingType, Ref("value")),
                    codegenMethodScope,
                    codegenClassScope);
            }
            else
            {
                throw new UnsupportedOperationException("Invalid access type " + accessType);
            }

            block.MethodReturn(expression);
            return(methodNode);
        }