示例#1
0
        public override void InitBlock(
            CodegenBlock block,
            CodegenMethod methodNode,
            ExprForgeCodegenSymbol scope,
            CodegenClassScope codegenClassScope)
        {
            innerValue = InnerExpression.EvaluateCodegen(typeof(bool?), methodNode, scope, codegenClassScope);
            EnumTakeWhileHelper.InitBlockSizeOneScalar(numParameters, block, innerValue, InnerExpression.EvaluationType);
            block.DeclareVar(
                typeof(object[]),
                "all",
                StaticMethod(typeof(EnumTakeWhileHelper), "TakeWhileLastScalarToArray", EnumForgeCodegenNames.REF_ENUMCOLL));

            var forEach = block.ForLoop(
                typeof(int),
                "i",
                Op(ArrayLength(Ref("all")), "-", Constant(1)),
                Relational(Ref("i"), GE, Constant(0)),
                DecrementRef("i"))
                          .AssignArrayElement("props", Constant(0), ArrayAtIndex(Ref("all"), Ref("i")));

            if (numParameters >= 2)
            {
                forEach.IncrementRef("count")
                .AssignArrayElement("props", Constant(1), Ref("count"));
            }

            CodegenLegoBooleanExpression.CodegenBreakIfNotNullAndNotPass(forEach, InnerExpression.EvaluationType, innerValue);
            forEach.Expression(ExprDotMethod(Ref("result"), "AddFirst", ArrayAtIndex(Ref("all"), Ref("i"))));
        }
示例#2
0
 public override void InitBlock(
     CodegenBlock block,
     CodegenMethod methodNode,
     ExprForgeCodegenSymbol scope,
     CodegenClassScope codegenClassScope)
 {
     innerValue = InnerExpression.EvaluateCodegen(typeof(bool?), methodNode, scope, codegenClassScope);
     EnumTakeWhileHelper.InitBlockSizeOneEventPlus(numParameters, block, innerValue, StreamNumLambda, InnerExpression.EvaluationType);
 }
示例#3
0
        public override void ForEachBlock(
            CodegenBlock block,
            CodegenMethod methodNode,
            ExprForgeCodegenSymbol scope,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression eval = InnerExpression.EvaluateCodegen(_innerType, methodNode, scope, codegenClassScope);

            EnumDistinctOfHelper.ForEachBlock(block, eval, _innerType);
        }
示例#4
0
 public override void ForEachBlock(
     CodegenBlock block,
     CodegenMethod methodNode,
     ExprForgeCodegenSymbol scope,
     CodegenClassScope codegenClassScope)
 {
     block.DeclareVar <object>("item", InnerExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope))
     .IfCondition(NotEqualsNull(Ref("item")))
     .Expression(ExprDotMethod(Ref("result"), "Add", Ref("item")));
 }
示例#5
0
 public override void ForEachBlock(CodegenBlock block, CodegenMethod methodNode, ExprForgeCodegenSymbol scope, CodegenClassScope codegenClassScope)
 {
     block.DeclareVar <object>("key", InnerExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope))
     .DeclareVar <ICollection <object> >("value", Cast(typeof(ICollection <object>), ExprDotMethod(Ref("result"), "Get", Ref("key"))))
     .IfRefNull("value")
     .AssignRef("value", NewInstance(typeof(List <object>)))
     .Expression(ExprDotMethod(Ref("result"), "Put", Ref("key"), Ref("value")))
     .BlockEnd()
     .Expression(ExprDotMethod(Ref("value"), "Add", ExprDotUnderlying(Ref("next"))));
 }
示例#6
0
 public override void ForEachBlock(
     CodegenBlock block,
     CodegenMethod methodNode,
     ExprForgeCodegenSymbol scope,
     CodegenClassScope codegenClassScope)
 {
     block
     .DeclareVar <object>("item", InnerExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope))
     .AssignArrayElement(Ref("result"), Ref("count"), FlexCast(_arrayComponentType, Ref("item")));
 }
示例#7
0
 public override void ForEachBlock(
     CodegenBlock block,
     CodegenMethod methodNode,
     ExprForgeCodegenSymbol scope,
     CodegenClassScope codegenClassScope)
 {
     block.DeclareVar <object>("key", InnerExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope))
     .DeclareVar <object>("value", SecondExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope))
     .Expression(ExprDotMethod(Ref("map"), "Put", Ref("key"), Ref("value")));
 }
示例#8
0
        public override CodegenExpression Codegen(
            EnumForgeCodegenParams premade,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var resultTypeMember = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(typeof(ObjectArrayEventType), EventTypeUtility.ResolveTypeCodegen(_resultEventType, EPStatementInitServicesConstants.REF)));

            var scope      = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope
                             .MakeChildWithScope(typeof(IDictionary <object, object>), typeof(EnumToMapScalar), scope, codegenClassScope)
                             .AddParam(EnumForgeCodegenNames.PARAMS);
            var hasIndex = _numParameters >= 2;
            var hasSize  = _numParameters >= 3;

            var block = methodNode.Block
                        .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty"))
                        .BlockReturn(EnumValue(typeof(EmptyDictionary <object, object>), "Instance"));

            block.DeclareVar <IDictionary <object, object> >("map", NewInstance(typeof(NullableDictionary <object, object>)))
            .DeclareVar(
                typeof(ObjectArrayEventBean),
                "resultEvent",
                NewInstance(typeof(ObjectArrayEventBean), NewArrayByLength(typeof(object), Constant(_numParameters)), resultTypeMember))
            .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(StreamNumLambda), Ref("resultEvent"))
            .DeclareVar <object[]>("props", ExprDotName(Ref("resultEvent"), "Properties"));
            if (hasIndex)
            {
                block.DeclareVar <int>("count", Constant(-1));
            }

            if (hasSize)
            {
                block.AssignArrayElement(Ref("props"), Constant(2), ExprDotName(REF_ENUMCOLL, "Count"));
            }

            var forEach = block
                          .ForEach(typeof(object), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                          .AssignArrayElement("props", Constant(0), Ref("next"));

            if (hasIndex)
            {
                forEach.IncrementRef("count").AssignArrayElement("props", Constant(1), Ref("count"));
            }

            forEach
            .DeclareVar <object>("key", InnerExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope))
            .DeclareVar <object>("value", _secondExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope))
            .Expression(ExprDotMethod(Ref("map"), "Put", Ref("key"), Ref("value")));

            block.MethodReturn(Ref("map"));
            return(LocalMethod(methodNode, premade.Eps, premade.Enumcoll, premade.IsNewData, premade.ExprCtx));
        }
示例#9
0
        public override void ForEachBlock(CodegenBlock block, CodegenMethod methodNode, ExprForgeCodegenSymbol scope, CodegenClassScope codegenClassScope)
        {
            var innerType = InnerExpression.EvaluationType;

            block.DeclareVar(innerType, "value", InnerExpression.EvaluateCodegen(innerType, methodNode, scope, codegenClassScope));
            if (!innerType.IsPrimitive)
            {
                block.IfRefNull("value").BlockContinue();
            }
            sumMethodFactory.CodegenEnterNumberTypedNonNull(block, Ref("value"));
        }
示例#10
0
 public override void ForEachBlock(
     CodegenBlock block,
     CodegenMethod methodNode,
     ExprForgeCodegenSymbol scope,
     CodegenClassScope codegenClassScope)
 {
     CodegenLegoBooleanExpression.CodegenContinueIfNotNullAndNotPass(
         block,
         InnerExpression.EvaluationType,
         InnerExpression.EvaluateCodegen(typeof(bool?), methodNode, scope, codegenClassScope));
     block.BlockReturn(Ref("next"));
 }
示例#11
0
 public override void ForEachBlock(
     CodegenBlock block,
     CodegenMethod methodNode,
     ExprForgeCodegenSymbol scope,
     CodegenClassScope codegenClassScope)
 {
     CodegenLegoBooleanExpression.CodegenReturnBoolIfNullOrBool(
         block,
         InnerExpression.EvaluationType,
         InnerExpression.EvaluateCodegen(typeof(bool?), methodNode, scope, codegenClassScope),
         all,
         all ? false : (bool?)null,
         !all,
         !all);
 }
示例#12
0
 public override void ForEachBlock(
     CodegenBlock block,
     CodegenMethod methodNode,
     ExprForgeCodegenSymbol scope,
     CodegenClassScope codegenClassScope)
 {
     block.DeclareVar(_innerTypeBoxed, "value", InnerExpression.EvaluateCodegen(_innerTypeBoxed, methodNode, scope, codegenClassScope))
     .IfRefNull("value")
     .BlockContinue()
     .IfCondition(EqualsNull(Ref("minKey")))
     .AssignRef("minKey", Ref("value"))
     .AssignRef("result", Ref("next"))
     .IfElse()
     .IfCondition(Relational(ExprDotMethod(Ref("minKey"), "CompareTo", Ref("value")), _max ? LT : GT, Constant(0)))
     .AssignRef("minKey", Ref("value"))
     .AssignRef("result", Ref("next"));
 }
        public override void ForEachBlock(
            CodegenBlock block,
            CodegenMethod methodNode,
            ExprForgeCodegenSymbol scope,
            CodegenClassScope codegenClassScope)
        {
            var innerType = InnerExpression.EvaluationType;

            block.DeclareVar(innerType, "num", InnerExpression.EvaluateCodegen(innerType, methodNode, scope, codegenClassScope));
            if (!innerType.IsPrimitive)
            {
                block.IfRefNull("num").BlockContinue();
            }

            var lhs = Ref("sum");
            var rhs = SimpleNumberCoercerFactory.CoercerBigInt.CodegenBigInt(Ref("num"), innerType);

            block.IncrementRef("rowcount")
            .AssignRef("sum", Op(lhs, "+", rhs))
            .BlockEnd();
        }
示例#14
0
        public override CodegenExpression Codegen(
            EnumForgeCodegenParams premade,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var scope      = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope.MakeChildWithScope(typeof(EventBean), typeof(EnumFirstOfEvent), scope, codegenClassScope)
                             .AddParam(EnumForgeCodegenNames.PARAMS);

            var block   = methodNode.Block;
            var forEach = block
                          .ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                          .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(StreamNumLambda), Ref("next"));

            CodegenLegoBooleanExpression.CodegenContinueIfNotNullAndNotPass(
                forEach,
                InnerExpression.EvaluationType,
                InnerExpression.EvaluateCodegen(typeof(bool?), methodNode, scope, codegenClassScope));
            forEach.BlockReturn(Ref("next"));
            block.MethodReturn(ConstantNull());
            return(LocalMethod(methodNode, premade.Eps, premade.Enumcoll, premade.IsNewData, premade.ExprCtx));
        }
示例#15
0
        public override CodegenExpression Codegen(
            EnumForgeCodegenParams premade,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var scope      = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope
                             .MakeChildWithScope(typeof(IDictionary <object, object>), typeof(EnumToMapEvent), scope, codegenClassScope)
                             .AddParam(EnumForgeCodegenNames.PARAMS);

            var block = methodNode.Block
                        .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty"))
                        .BlockReturn(EnumValue(typeof(EmptyDictionary <object, object>), "Instance"));

            block.DeclareVar(typeof(IDictionary <object, object>), "map", NewInstance(typeof(NullableDictionary <object, object>)));
            block.ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
            .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(StreamNumLambda), Ref("next"))
            .DeclareVar <object>("key", InnerExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope))
            .DeclareVar <object>("value", secondExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope))
            .Expression(ExprDotMethod(Ref("map"), "Put", Ref("key"), Ref("value")));
            block.MethodReturn(Ref("map"));
            return(LocalMethod(methodNode, premade.Eps, premade.Enumcoll, premade.IsNewData, premade.ExprCtx));
        }
示例#16
0
        public override void InitBlock(
            CodegenBlock block,
            CodegenMethod methodNode,
            ExprForgeCodegenSymbol scope,
            CodegenClassScope codegenClassScope)
        {
            innerValue = InnerExpression.EvaluateCodegen(typeof(bool?), methodNode, scope, codegenClassScope);
            var blockSingle = block.IfCondition(EqualsIdentity(ExprDotName(EnumForgeCodegenNames.REF_ENUMCOLL, "Count"), Constant(1)))
                              .DeclareVar <EventBean>("item", Cast(typeof(EventBean), ExprDotMethodChain(EnumForgeCodegenNames.REF_ENUMCOLL).Add("First")))
                              .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(StreamNumLambda), Ref("item"));

            block.DebugStack();

            CodegenLegoBooleanExpression.CodegenReturnValueIfNotNullAndNotPass(
                blockSingle,
                InnerExpression.EvaluationType,
                innerValue,
                EnumValue(typeof(FlexCollection), "Empty"));
            blockSingle.BlockReturn(
                FlexWrap(StaticMethod(typeof(Collections), "SingletonList", Ref("item"))));

            block
            .DeclareVar <ArrayDeque <EventBean> >("result", NewInstance <ArrayDeque <EventBean> >())
            .DeclareVar <EventBean[]>("all", StaticMethod(typeof(EnumTakeWhileHelper), "TakeWhileLastEventBeanToArray", EnumForgeCodegenNames.REF_ENUMCOLL));

            var forEach = block.ForLoop(
                typeof(int),
                "i",
                Op(ArrayLength(Ref("all")), "-", Constant(1)),
                Relational(Ref("i"), GE, Constant(0)),
                DecrementRef("i"))
                          .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(StreamNumLambda), ArrayAtIndex(Ref("all"), Ref("i")));

            CodegenLegoBooleanExpression.CodegenBreakIfNotNullAndNotPass(forEach, InnerExpression.EvaluationType, innerValue);
            forEach.Expression(ExprDotMethod(Ref("result"), "AddFirst", ArrayAtIndex(Ref("all"), Ref("i"))));
        }