Beispiel #1
0
        private static CodegenExpression MakeEvaluate(
            SubselectEvaluationType evaluationType,
            ExprSubselectNode subselectNode,
            Type resultType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(resultType, typeof(ExprSubselectNode), classScope);

            CodegenExpression eps = symbols.GetAddEPS(method);
            var newData = symbols.GetAddIsNewData(method);
            CodegenExpression evalCtx = symbols.GetAddExprEvalCtx(method);

            // get matching events
            CodegenExpression future = classScope.NamespaceScope.AddOrGetDefaultFieldWellKnown(
                new CodegenFieldNameSubqueryResult(subselectNode.SubselectNumber),
                typeof(SubordTableLookupStrategy));
            var evalMatching = FlexWrap(ExprDotMethod(future, "Lookup", eps, evalCtx));
            method.Block.DeclareVar<FlexCollection>(NAME_MATCHINGEVENTS, evalMatching);

            // process matching events
            var evalMatchSymbol = new ExprSubselectEvalMatchSymbol();
            var processMethod = method
                .MakeChildWithScope(resultType, typeof(ExprSubselectNode), evalMatchSymbol, classScope)
                .AddParam(typeof(FlexCollection), NAME_MATCHINGEVENTS)
                .AddParam(ExprForgeCodegenNames.PARAMS);
            CodegenExpression process;
            if (evaluationType == PLAIN) {
                process = subselectNode.EvalMatchesPlainCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else if (evaluationType == GETEVENTCOLL) {
                process = subselectNode.EvalMatchesGetCollEventsCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else if (evaluationType == GETSCALARCOLL) {
                process = subselectNode.EvalMatchesGetCollScalarCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else if (evaluationType == GETEVENT) {
                process = subselectNode.EvalMatchesGetEventBeanCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else if (evaluationType == TYPABLESINGLE) {
                process = subselectNode.EvalMatchesTypableSingleCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else if (evaluationType == TYPABLEMULTI) {
                process = subselectNode.EvalMatchesTypableMultiCodegen(processMethod, evalMatchSymbol, classScope);
            }
            else {
                throw new IllegalStateException("Unrecognized evaluation type " + evaluationType);
            }

            evalMatchSymbol.DerivedSymbolsCodegen(processMethod, processMethod.Block, classScope);
            processMethod.Block.MethodReturn(process);

            method.Block.MethodReturn(LocalMethod(processMethod, REF_MATCHINGEVENTS, eps, newData, evalCtx));

            return LocalMethod(method);
        }