예제 #1
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            var methodNode = parent.MakeChild(EvaluationType, typeof(ExprVariableNodeImpl), classScope);
            var readerExpression = GetReaderExpression(VariableMetadata, methodNode, symbols, classScope);

            var block = methodNode.Block
                .DeclareVar<VariableReader>("reader", readerExpression);
            if (VariableMetadata.EventType == null) {
                block.DeclareVar(
                        EvaluationType,
                        "value",
                        Cast(EvaluationType, ExprDotName(Ref("reader"), "Value")))
                    .MethodReturn(Ref("value"));
            }
            else {
                block.DeclareVar<object>("value", ExprDotName(Ref("reader"), "Value"))
                    .IfRefNullReturnNull("value")
                    .DeclareVar<EventBean>("theEvent", Cast(typeof(EventBean), Ref("value")));
                if (optSubPropName == null) {
                    block.MethodReturn(Cast(EvaluationType, ExprDotUnderlying(Ref("theEvent"))));
                }
                else {
                    block.MethodReturn(
                        CodegenLegoCast.CastSafeFromObjectType(
                            EvaluationType,
                            optSubPropGetter.EventBeanGetCodegen(Ref("theEvent"), methodNode, classScope)));
                }
            }

            return LocalMethod(methodNode);
        }
예제 #2
0
        public static CodegenExpression Codegen(
            DTLocalBeanIntervalNoEndTSForge forge,
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope
                .MakeChild(forge.returnType, typeof(DTLocalBeanIntervalNoEndTSEval), codegenClassScope)
                .AddParam(typeof(EventBean), "target");

            methodNode.Block
                .DeclareVar(
                    forge.getterResultType,
                    "timestamp",
                    CodegenLegoCast.CastSafeFromObjectType(
                        forge.getterResultType,
                        forge.getter.EventBeanGetCodegen(Ref("target"), methodNode, codegenClassScope)))
                .IfRefNullReturnNull("timestamp")
                .MethodReturn(
                    forge.inner.Codegen(
                        Ref("timestamp"),
                        forge.getterResultType,
                        methodNode,
                        exprSymbol,
                        codegenClassScope));
            return LocalMethod(methodNode, inner);
        }
예제 #3
0
        private void MakeTrySetNativeValue(
            CodegenMethod method,
            CodegenClassScope classScope)
        {
            var cases      = GetCasesNumberNtoM(desc);
            var switchStmt = method.Block.SwitchBlockExpressions(Ref("name"), cases, true, false);

            if (method.IsOverride)
            {
                switchStmt
                .DefaultBlock
                .BlockReturn(ExprDotMethod(Ref("base"), "TrySetNativeValue", Ref("name"), Ref("value")));
            }
            else
            {
                switchStmt
                .DefaultBlock
                .BlockReturn(ConstantFalse());
            }

            var index = 0;

            foreach (var property in desc.PropertiesThisType)
            {
                var field           = desc.FieldDescriptorsInclSupertype.Get(property.Key);
                var valueExpression = CodegenLegoCast.CastSafeFromObjectType(field.PropertyType, Ref("value"));

                switchStmt
                .Blocks[index++]
                .AssignMember(field.FieldName, valueExpression)
                .BlockReturn(ConstantTrue());
            }
        }
예제 #4
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 static CodegenExpression Codegen(
            ExprDotForgeGetCollection forge,
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                forge.TypeInfo.GetNormalizedClass(),
                typeof(ExprDotForgeGetCollectionEval),
                codegenClassScope)
                             .AddParam(innerType, "target");

            var block = methodNode.Block;

            if (!innerType.IsPrimitive)
            {
                block.IfRefNullReturnNull("target");
            }

            var targetType = EPTypeHelper.GetCodegenReturnType(forge.TypeInfo);

            block.DeclareVar <int>("index", forge.IndexExpression.EvaluateCodegen(typeof(int), methodNode, exprSymbol, codegenClassScope))
            .MethodReturn(
                CodegenLegoCast.CastSafeFromObjectType(
                    targetType,
                    StaticMethod(
                        typeof(ExprDotForgeGetCollectionEval),
                        "CollectionElementAt",
                        Ref("target"),
                        Ref("index"))));
            return(LocalMethod(methodNode, inner));
        }
예제 #6
0
 private CodegenMethod GetCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(typeof(GenericRecord), "record")
         .Block
         .DeclareVar<GenericRecord>(
             "inner",
             CodegenExpressionBuilder.Cast(
                 typeof(GenericRecord),
                 CodegenExpressionBuilder.StaticMethod(
                     typeof(GenericRecordExtensions),
                     "Get",
                     CodegenExpressionBuilder.Ref("record"),
                     CodegenExpressionBuilder.Constant(_top.Name))))
         .IfRefNullReturnNull("inner")
         .DeclareVar<IDictionary<string, object>>(
             "map",
             CodegenLegoCast.CastSafeFromObjectType(
                 typeof(IDictionary<string, object>),
                 CodegenExpressionBuilder.StaticMethod(
                     typeof(GenericRecordExtensions),
                     "Get",
                     CodegenExpressionBuilder.Ref("inner"),
                     CodegenExpressionBuilder.Constant(_pos.Name))))
         .MethodReturn(
             CodegenExpressionBuilder.StaticMethod(
                 typeof(AvroEventBeanGetterMapped),
                 "GetAvroMappedValueWNullCheck",
                 CodegenExpressionBuilder.Ref("map"),
                 CodegenExpressionBuilder.Constant(_key)));
 }
예제 #7
0
        private CodegenExpression CodegenEvaluateGetInternal(
            CodegenExpression @event,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var block = codegenMethodScope
                .MakeChild(typeof(FlexCollection), typeof(PropertyDotScalarArrayForge), codegenClassScope)
                .AddParam(typeof(EventBean), "@event")
                .Block
                .DeclareVar(
                    getterReturnType,
                    "value",
                    CodegenLegoCast.CastSafeFromObjectType(
                        getterReturnType,
                        getter.EventBeanGetCodegen(Ref("@event"), codegenMethodScope, codegenClassScope)))
                .IfRefNullReturnNull("value");
            CodegenMethod method;
            if (ComponentTypeCollection.CanNotBeNull() ||
                ComponentTypeCollection.GetUnboxedType().CanNotBeNull()) {
                method = block.MethodReturn(
                    FlexWrap(
                        NewInstance<ArrayWrappingCollection>(
                            Ref("value"))));
            }
            else {
                method = block.MethodReturn(Ref("value"));
            }

            return LocalMethodBuild(method).Pass(@event).Call();
        }
예제 #8
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);
        }
        public static CodegenExpression Codegen(
            ExprDotNodeForgePropertyExpr forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                forge.EvaluationType,
                typeof(ExprDotNodeForgePropertyExprEvalMapped),
                codegenClassScope);
            var refEPS = exprSymbol.GetAddEPS(methodNode);

            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(forge.StreamNum)))
                .IfRefNullReturnNull("@event")
                .DeclareVar<string>(
                    "result",
                    forge.ExprForge.EvaluateCodegen(typeof(string), methodNode, exprSymbol, codegenClassScope))
                .IfRefNullReturnNull("result")
                .DebugStack();
                
            methodNode.Block
                .MethodReturn(
                    CodegenLegoCast.CastSafeFromObjectType(
                        forge.EvaluationType,
                        forge.MappedGetter.EventBeanGetMappedCodegen(
                            methodNode,
                            codegenClassScope,
                            Ref("@event"),
                            Ref("result"))));

            return LocalMethod(methodNode);
        }
예제 #10
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);
 }
예제 #11
0
        private CodegenExpression CodegenEvaluateGetInternal(
            CodegenExpression @event,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var block = codegenMethodScope
                .MakeChild(typeof(FlexCollection), typeof(PropertyDotScalarArrayForge), codegenClassScope)
                .AddParam(typeof(EventBean), "@event")
                .Block
                .DeclareVar(
                    _getterReturnType,
                    "value",
                    CodegenLegoCast.CastSafeFromObjectType(
                        _getterReturnType,
                        _getter.EventBeanGetCodegen(Ref("@event"), codegenMethodScope, codegenClassScope)));
            
            var method = block.MethodReturn(
                    StaticMethod(
                        typeof(PropertyDotScalarStringForge),
                        "ConvertToCollection",
                        Constant(_propertyName),
                        Ref("value")));

            return LocalMethodBuild(method).Pass(@event).Call();
        }
예제 #12
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);
        }
        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));
        }
예제 #14
0
        public static CodegenExpression Codegen(
            ExprDotNodeForgePropertyExpr forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                forge.EvaluationType,
                typeof(ExprDotNodeForgePropertyExprEvalIndexed),
                codegenClassScope);

            CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(forge.StreamNum)))
                .IfRefNullReturnNull("@event")
                .DeclareVar<int?>(
                    "index",
                    forge.ExprForge.EvaluateCodegen(typeof(int?), methodNode, exprSymbol, codegenClassScope))
                .IfRefNullReturnNull("index")
                .MethodReturn(
                    CodegenLegoCast.CastSafeFromObjectType(
                        forge.EvaluationType,
                        forge.IndexedGetter.EventBeanGetIndexedCodegen(
                            methodNode,
                            codegenClassScope,
                            Ref("@event"),
                            Unbox(Ref("index")))));
            return LocalMethod(methodNode);
        }
예제 #15
0
        public CodegenExpression EvaluateEventGetROCollectionScalarCodegen(
            CodegenMethodScope methodScope,
            ExprEnumerationGivenEventSymbol symbols,
            CodegenClassScope codegenClassScope)
        {
            if (getterReturnType.IsGenericCollection()) {
                return getter.EventBeanGetCodegen(
                    symbols.GetAddEvent(methodScope),
                    methodScope,
                    codegenClassScope);
            }

            CodegenMethod method = methodScope.MakeChild(
                typeof(ICollection<object>),
                typeof(PropertyDotScalarIterable),
                codegenClassScope);
            method.Block.DeclareVar(
                    getterReturnType,
                    "result",
                    CodegenLegoCast.CastSafeFromObjectType(
                        typeof(IEnumerable),
                        getter.EventBeanGetCodegen(symbols.GetAddEvent(method), methodScope, codegenClassScope)))
                .IfRefNullReturnNull("result")
                .MethodReturn(StaticMethod(typeof(CollectionUtil), "IterableToCollection", Ref("result")));
            return LocalMethod(method);
        }
예제 #16
0
 private static CodegenMethod GetBeanPropInternalCodegen(
     CodegenMethodScope codegenMethodScope,
     Type beanPropType,
     Type targetType,
     MethodInfo method,
     CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope
         .MakeChild(beanPropType, typeof(ListMethodPropertyGetter), codegenClassScope)
         .AddParam(targetType, "@object")
         .AddParam(typeof(int), "index")
         .Block
         .DeclareVar<object>("value", ExprDotMethod(Ref("@object"), method.Name))
         .DeclareVar<IList<object>>(
             "l",
             CodegenLegoCast.CastSafeFromObjectType(
                 typeof(IList<object>),
                 Ref("value")))
         .IfRefNullReturnNull("l")
         .IfConditionReturnConst(Relational(ExprDotName(Ref("l"), "Count"), LE, Ref("index")), null)
         .MethodReturn(
             Cast(
                 beanPropType,
                 ArrayAtIndex(Ref("l"), Ref("index"))));
 }
예제 #17
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);
        }
예제 #18
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);
            
            method.Block.DeclareVar<object>("key", ExprDotMethod(future, "GetGroupKey", ExprDotName(symbol.GetAddExprEvalCtx(method), "AgentInstanceId")));
            method.Block
                .IfCondition(InstanceOf(Ref("key"), typeof(MultiKey)))
                .DeclareVar<MultiKey>("mk", Cast(typeof(MultiKey), Ref("key")))
                .BlockReturn(CodegenLegoCast.CastSafeFromObjectType(returnType, ExprDotMethod(Ref("mk"), "GetKey", Constant(groupKeyIndex))));

            method.Block.IfCondition(InstanceOf(Ref("key"), typeof(MultiKeyArrayWrap)))
                .DeclareVar<MultiKeyArrayWrap>("mk", Cast(typeof(MultiKeyArrayWrap), Ref("key")))
                .BlockReturn(CodegenLegoCast.CastSafeFromObjectType(returnType, ExprDotName(Ref("mk"), "Array")));

            method.Block.MethodReturn(CodegenLegoCast.CastSafeFromObjectType(returnType, Ref("key")));
            
            return LocalMethod(method);
        }
예제 #19
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);
 }
예제 #20
0
        private CodegenExpression CodegenEvaluateInternal(
            CodegenExpression @event,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            if (getterReturnType.IsGenericCollection()) {
                return getter.EventBeanGetCodegen(@event, codegenMethodScope, codegenClassScope);
            }

            CodegenMethod method = codegenMethodScope.MakeChild(
                    typeof(ICollection<object>),
                    typeof(PropertyDotScalarIterable),
                    codegenClassScope)
                .AddParam(typeof(EventBean), "@event")
                .Block
                .DeclareVar(
                    getterReturnType,
                    "result",
                    CodegenLegoCast.CastSafeFromObjectType(
                        getterReturnType,
                        getter.EventBeanGetCodegen(Ref("@event"), codegenMethodScope, codegenClassScope)))
                .IfRefNullReturnNull("result")
                .MethodReturn(StaticMethod(typeof(CompatExtensions), "UnwrapIntoList", new [] { typeof(object) }, Ref("result")));
            return LocalMethodBuild(method).Pass(@event).Call();
        }
예제 #21
0
 public CodegenExpression EvaluateCodegen(
     Type requiredType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope codegenClassScope)
 {
     return CodegenLegoCast.CastSafeFromObjectType(
         requiredType,
         MakeEval("Evaluate", codegenMethodScope, symbols, codegenClassScope));
 }
예제 #22
0
 public CodegenExpression EvaluateCodegen(
     Type requiredType,
     CodegenMethodScope parent,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope classScope)
 {
     return(Cast(
                requiredType,
                CodegenLegoCast.CastSafeFromObjectType(requiredType,
                                                       ExprDotName(symbols.GetAddExprEvalCtx(parent), "FilterReboolConstant"))));
 }
예제 #23
0
 private CodegenExpression EvaluateArrayCodegen(
     CodegenMethodScope parent,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(ArrayType, GetType(), classScope);
     method.Block
         .DeclareVar<EventBean>("@event", ArrayAtIndex(symbols.GetAddEPS(method), Constant(0)))
         .IfRefNullReturnNull("@event")
         .MethodReturn(CodegenLegoCast.CastSafeFromObjectType(ArrayType, Getter.EventBeanGetCodegen(Ref("@event"), method, classScope)));
     return LocalMethod(method);
 }
예제 #24
0
        public static CodegenExpression Codegen(
            DTLocalBeanIntervalWithEndForge forge,
            CodegenExpression inner,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope
                .MakeChild(typeof(bool?), typeof(DTLocalBeanIntervalWithEndEval), codegenClassScope)
                .AddParam(typeof(EventBean), "target");

            var block = methodNode.Block;
            block.DeclareVar(
                forge.getterStartReturnType,
                "start",
                CodegenLegoCast.CastSafeFromObjectType(
                    forge.getterStartReturnType,
                    forge.getterStartTimestamp.EventBeanGetCodegen(
                        Ref("target"), 
                        methodNode, 
                        codegenClassScope)));
            if (forge.getterStartReturnType.CanBeNull()) {
                block.IfRefNullReturnNull("start");
            }

            block.DeclareVar(
                forge.getterEndReturnType,
                "end",
                CodegenLegoCast.CastSafeFromObjectType(
                    forge.getterEndReturnType,
                    forge.getterEndTimestamp.EventBeanGetCodegen(
                        Ref("target"), 
                        methodNode, 
                        codegenClassScope)));
            if (forge.getterEndReturnType.CanBeNull()) {
                block.IfRefNullReturnNull("end");
            }

            CodegenExpression startValue = Unbox(Ref("start"), forge.getterStartReturnType);
            CodegenExpression endValue = Unbox(Ref("end"), forge.getterEndReturnType);

            block.MethodReturn(
                forge.inner.Codegen(
                    startValue,
                    endValue,
                    methodNode, 
                    exprSymbol, 
                    codegenClassScope));

            return LocalMethod(methodNode, inner);
        }
예제 #25
0
 public CodegenExpression EvaluateCodegen(
     Type requiredType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenMethod methodNode = codegenMethodScope.MakeChild(returnType, this.GetType(), codegenClassScope);
     CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
     methodNode.Block
         .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(streamNum)))
         .IfRefNullReturnNull("@event")
         .MethodReturn(
             CodegenLegoCast.CastSafeFromObjectType(returnType, ExprDotName(Ref("@event"), "Underlying")));
     return LocalMethod(methodNode);
 }
        public static CodegenExpression EvaluateCodegen(
            Type requiredType,
            ExprNewInstanceNodeArrayForge forge,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            if (forge.Parent.IsArrayInitializedByExpr) {
                return forge.Parent.ChildNodes[0].Forge.EvaluateCodegen(requiredType, parent, symbols, classScope);
            }

            var method = parent.MakeChild(requiredType, typeof(ExprNewInstanceNodeArrayForgeEval), classScope);
            var dimensions = forge.Parent.ChildNodes;

            var dimValue = new CodegenExpression[dimensions.Length];
            for (var i = 0; i < dimensions.Length; i++) {
                var dimForge = forge.Parent.ChildNodes[i].Forge;
                var dimForgeType = dimForge.EvaluationType;
                var dimExpr = dimForge.EvaluateCodegen(typeof(int?), method, symbols, classScope);
                if (dimForge.ForgeConstantType == ExprForgeConstantType.COMPILETIMECONST) {
                    dimValue[i] = Unbox(dimExpr, dimForgeType);
                }
                else {
                    var name = "dim" + i;
                    method.Block
                        .DeclareVar(typeof(int?), name, dimExpr)
                        .IfRefNull(name)
                        .BlockThrow(NewInstance(typeof(EPException), Constant(NULL_MSG)));
                    dimValue[i] = Unbox(Ref(name));
                }
            }

            CodegenExpression make;
            if (dimValue.Length == 1) {
                make = NewArrayByLength(forge.TargetClass, dimValue[0]);
            }
            else {
                var @params = new CodegenExpression[dimValue.Length + 1];
                @params[0] = Clazz(forge.TargetClass);
                Array.Copy(dimValue, 0, @params, 1, dimValue.Length);
                make = StaticMethod(typeof(Arrays), "CreateJagged", @params);
            }
            
            method.Block.MethodReturn(CodegenLegoCast.CastSafeFromObjectType(requiredType, make));
            return LocalMethod(method);
        }
예제 #27
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            var methodNode = parent.MakeChild(EvaluationType, typeof(ExprVariableNodeImpl), classScope);

            CodegenExpression readerExpression;
            if (VariableMetadata.OptionalContextName == null) {
                readerExpression =
                    classScope.AddOrGetDefaultFieldSharable(new VariableReaderCodegenFieldSharable(VariableMetadata));
            }
            else {
                var field = classScope.AddOrGetDefaultFieldSharable(
                    new VariableReaderPerCPCodegenFieldSharable(VariableMetadata));
                var cpid = ExprDotName(symbols.GetAddExprEvalCtx(methodNode), "AgentInstanceId");
                readerExpression = Cast(typeof(VariableReader), ExprDotMethod(field, "Get", cpid));
            }

            var block = methodNode.Block
                .DeclareVar<VariableReader>("reader", readerExpression);
            if (VariableMetadata.EventType == null) {
                block.DeclareVar(
                        EvaluationType,
                        "value",
                        Cast(EvaluationType, ExprDotName(Ref("reader"), "Value")))
                    .MethodReturn(Ref("value"));
            }
            else {
                block.DeclareVar<object>("value", ExprDotName(Ref("reader"), "Value"))
                    .IfRefNullReturnNull("value")
                    .DeclareVar<EventBean>("theEvent", Cast(typeof(EventBean), Ref("value")));
                if (optSubPropName == null) {
                    block.MethodReturn(Cast(EvaluationType, ExprDotUnderlying(Ref("theEvent"))));
                }
                else {
                    block.MethodReturn(
                        CodegenLegoCast.CastSafeFromObjectType(
                            EvaluationType,
                            optSubPropGetter.EventBeanGetCodegen(Ref("theEvent"), methodNode, classScope)));
                }
            }

            return LocalMethod(methodNode);
        }
예제 #28
0
 public CodegenExpression EvaluateEventGetROCollectionScalarCodegen(
     CodegenMethodScope methodScope,
     ExprEnumerationGivenEventSymbol symbols,
     CodegenClassScope codegenClassScope)
 {
     var methodNode = methodScope.MakeChild(
         typeof(ICollection<object>),
         typeof(PropertyDotScalarCollection),
         codegenClassScope);
     methodNode.Block.MethodReturn(
         CodegenLegoCast.CastSafeFromObjectType(
             typeof(ICollection<object>),
             getter.EventBeanGetCodegen(
                 symbols.GetAddEvent(methodNode),
                 methodScope,
                 codegenClassScope)));
     return LocalMethod(methodNode);
 }
예제 #29
0
        public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(EvaluationType, typeof(ExprEvalByGetter), codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(_streamNum)))
                .IfRefNullReturnNull("@event")
                .MethodReturn(
                    CodegenLegoCast.CastSafeFromObjectType(
                        EvaluationType,
                        _getter.EventBeanGetCodegen(Ref("@event"), methodNode, codegenClassScope)));
            return LocalMethod(methodNode);
        }
예제 #30
0
        public static CodegenMethod Codegen(
            ExprMathNodeForge forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope,
            ExprNode lhs,
            ExprNode rhs)
        {
            var methodNode = codegenMethodScope.MakeChild(
                forge.EvaluationType,
                typeof(ExprMathNodeForgeEval),
                codegenClassScope);
            var lhsType = lhs.Forge.EvaluationType;
            var rhsType = rhs.Forge.EvaluationType;
            var block = methodNode.Block
                .DeclareVar(
                    lhsType,
                    "left",
                    lhs.Forge.EvaluateCodegen(lhsType, methodNode, exprSymbol, codegenClassScope));
            if (lhsType.CanBeNull()) {
                block.IfRefNullReturnNull("left");
            }

            block.DeclareVar(
                rhsType,
                "right",
                rhs.Forge.EvaluateCodegen(rhsType, methodNode, exprSymbol, codegenClassScope));
            if (rhsType.CanBeNull()) {
                block.IfRefNullReturnNull("right");
            }

            block.MethodReturn(
                CodegenLegoCast.CastSafeFromObjectType(
                    forge.EvaluationType,
                    forge.ArithTypeEnumComputer.Codegen(
                        methodNode,
                        codegenClassScope,
                        Ref("left"),
                        Ref("right"),
                        lhsType,
                        rhsType)));
            return methodNode;
        }