Esempio n. 1
0
        /// <summary>
        /// Perform the actual expansion of the macro
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <returns></returns>
        protected override Statement DoExpand(MacroStatement macro)
        {
            List <string> columns = new List <string>();

            if (!macro.Body.IsEmpty)
            {
                Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "GroupBy cannot contain statements"));
                return(null);
            }
            foreach (Expression argument in macro.Arguments)
            {
                ReferenceExpression expr = argument as ReferenceExpression;
                if (expr == null)
                {
                    Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "GroupBy arguments must be refernce expressions. Example: groupBy name, surname"));
                    return(null);
                }
                columns.Add(expr.Name);
            }

            Method method = CreateGetColumnsToGroupByMethod(macro, columns);

            ParentMethods.Add(method);

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Perform the actual expansion of the macro
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <returns></returns>
        protected override Statement DoExpand(MacroStatement macro)
        {
            if (macro.Arguments.Count != 0)
            {
                Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "No arguments allowed for action statement"));
                return(null);
            }

            Method mergeRowsMethod = new Method("MergeRows");

            mergeRowsMethod.Modifiers = TypeMemberModifiers.Override;
            mergeRowsMethod.Parameters.Add(new ParameterDeclaration("left", new SimpleTypeReference(typeof(Row).FullName)));
            mergeRowsMethod.Parameters.Add(new ParameterDeclaration("right", new SimpleTypeReference(typeof(Row).FullName)));
            CodeBuilder.DeclareLocal(mergeRowsMethod, "row", TypeSystemServices.Map(typeof(Row)));
            mergeRowsMethod.Body.Add(
                new BinaryExpression(BinaryOperatorType.Assign,
                                     new ReferenceExpression("row"),
                                     new MethodInvocationExpression(
                                         AstUtil.CreateReferenceExpression(typeof(Row).FullName))
                                     )
                );
            mergeRowsMethod.Body.Add(macro.Body);
            mergeRowsMethod.Body.Add(new ReturnStatement(new ReferenceExpression("row")));

            ParentMethods.Add(mergeRowsMethod);
            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// Perform the actual expansion of the macro
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <returns></returns>
        protected override Statement DoExpand(MacroStatement macro)
        {
            Method accumulate = new Method("FinishAggregation");

            accumulate.Modifiers = TypeMemberModifiers.Override;
            accumulate.Parameters.Add(new ParameterDeclaration("aggregate", CodeBuilder.CreateTypeReference(typeof(Row))));

            accumulate.Body = macro.Body;

            ParentMethods.Add(accumulate);

            return(null);
        }
        /// <summary>
        /// Perform the actual expansion of the macro
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <returns></returns>
        protected override Statement DoExpand(MacroStatement macro)
        {
            Method rowProcessed = new Method("OnFinishedProcessing");

            rowProcessed.Modifiers = TypeMemberModifiers.Override;
            rowProcessed.Parameters.Add(new ParameterDeclaration("op", CodeBuilder.CreateTypeReference(typeof(IOperation))));

            rowProcessed.Body = macro.Body;

            ParentMethods.Add(rowProcessed);

            return(null);
        }