public EnumOrderByAscDescEventsForgeEval( EnumOrderByAscDescEventsForge forge, ExprEvaluator innerExpression) { _forge = forge; _innerExpression = innerExpression; }
public static CodegenExpression Codegen( EnumOrderByAscDescEventsForge forge, EnumForgeCodegenParams args, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { var innerBoxedType = forge.InnerExpression.EvaluationType.GetBoxedType(); var scope = new ExprForgeCodegenSymbol(false, null); var methodNode = codegenMethodScope.MakeChildWithScope( typeof(ICollection<EventBean>), typeof(EnumOrderByAscDescEventsForgeEval), scope, codegenClassScope) .AddParam(EnumForgeCodegenNames.PARAMS); var block = methodNode.Block .DeclareVar<OrderedDictionary<object, object>>( "sort", NewInstance(typeof(OrderedDictionary<object, object>))) .DeclareVar<bool>("hasColl", ConstantFalse()); block.ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL) .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("next")) .DeclareVar( innerBoxedType, "value", forge.InnerExpression.EvaluateCodegen(innerBoxedType, methodNode, scope, codegenClassScope)) .DeclareVar<object>("entry", ExprDotMethod(Ref("sort"), "Get", Ref("value"))) .IfCondition(EqualsNull(Ref("entry"))) .Expression(ExprDotMethod(Ref("sort"), "Put", Ref("value"), Ref("next"))) .BlockContinue() .IfCondition(InstanceOf(Ref("entry"), typeof(ICollection<object>))) .ExprDotMethod(Cast(typeof(ICollection<object>), Ref("entry")), "Add", Ref("next")) .BlockContinue() .DeclareVar<Deque<object>>("coll", NewInstance<ArrayDeque<object>>(Constant(2))) .ExprDotMethod(Ref("coll"), "Add", Ref("entry")) .ExprDotMethod(Ref("coll"), "Add", Ref("next")) .ExprDotMethod(Ref("sort"), "Put", Ref("value"), Ref("coll")) .AssignRef("hasColl", ConstantTrue()) .BlockEnd(); block.MethodReturn( Unwrap<EventBean>( StaticMethod( typeof(EnumOrderByAscDescEventsForgeEval), "EnumOrderBySortEval", Ref("sort"), Ref("hasColl"), Constant(forge.descending)))); return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx); }