Exemplo n.º 1
0
        public override object VisitPackageFunctionStatement([NotNull] PackageFunctionStatementContext context)
        {
            var id        = (Result)Visit(context.id());
            var isVirtual = id.isVirtual ? " virtual " : "";
            var obj       = "";

            if (context.annotationSupport() != null)
            {
                obj += Visit(context.annotationSupport());
            }
            // 异步
            if (context.t.Type == FlowRight)
            {
                var pout = (string)Visit(context.parameterClauseOut());
                if (pout != "void")
                {
                    pout = $"{Task}<{pout}>";
                }
                else
                {
                    pout = Task;
                }
                obj += $"{id.permission} {isVirtual} async {pout} {id.text}";
            }
            else
            {
                obj += id.permission + isVirtual + " " + Visit(context.parameterClauseOut()) + " " + id.text;
            }

            // 泛型
            if (context.templateDefine() != null)
            {
                obj += Visit(context.templateDefine());
            }
            obj += Visit(context.parameterClauseIn()) + Wrap + BlockLeft + Wrap;
            obj += ProcessFunctionSupport(context.functionSupportStatement());
            obj += BlockRight + Wrap;
            return(obj);
        }
Exemplo n.º 2
0
        public override object VisitPackageFunctionStatement(PackageFunctionStatementContext context)
        {
            var id         = ((Result)Visit(context.id()));
            var is_virtual = "";

            if (id.is_virtual)
            {
                is_virtual = " virtual ";
            }
            var obj  = "";
            var pout = "";

            if (context.parameterClauseOut() == null)
            {
                pout = "void";
            }
            else
            {
                pout = ((string)Visit(context.parameterClauseOut()));
            }
            obj += (new System.Text.StringBuilder().Append(is_virtual).Append(" ").Append(pout).Append(" ").Append(id.text)).To_Str();
            var template_contract = "";

            if (context.templateDefine() != null)
            {
                var template = ((TemplateItem)Visit(context.templateDefine()));
                obj += template.template;
                template_contract = template.contract;
            }
            Add_current_set();
            obj += Visit(context.parameterClauseIn()) + template_contract + BlockLeft + Wrap;
            obj += ProcessFunctionSupport(context.functionSupportStatement());
            Delete_current_set();
            obj += BlockRight + Wrap;
            obj  = (new System.Text.StringBuilder().Append(id.permission).Append(" ")).To_Str() + obj;
            return(obj);
        }
Exemplo n.º 3
0
        public override object VisitPackageFunctionStatement(PackageFunctionStatementContext context)
        {
            var id        = (Result)(Visit(context.id()));
            var isVirtual = "";

            if (id.isVirtual)
            {
                isVirtual = " virtual ";
            }
            var obj  = "";
            var pout = "";

            if (context.parameterClauseOut() != null)
            {
                pout = (string)(Visit(context.parameterClauseOut()));
            }
            if (context.t.Type == Right_Flow)
            {
                if (pout != "void")
                {
                    if (context.y != null)
                    {
                        pout = (new System.Text.StringBuilder().Append(IEnum).Append("<").Append(pout).Append(">")).to_str();
                    }
                    pout = (new System.Text.StringBuilder().Append(Task).Append("<").Append(pout).Append(">")).to_str();
                }
                else
                {
                    pout = Task;
                }
                obj += (new System.Text.StringBuilder().Append(isVirtual).Append(" ").Append(pout).Append(" ").Append(id.text)).to_str();
            }
            else
            {
                if (context.y != null)
                {
                    if (pout != "void")
                    {
                        pout = (new System.Text.StringBuilder().Append(IEnum).Append("<").Append(pout).Append(">")).to_str();
                    }
                }
                obj += (new System.Text.StringBuilder().Append(isVirtual).Append(" ").Append(pout).Append(" ").Append(id.text)).to_str();
            }
            var templateContract = "";

            if (context.templateDefine() != null)
            {
                var template = (TemplateItem)(Visit(context.templateDefine()));
                obj += template.Template;
                templateContract = template.Contract;
            }
            this.add_current_set();
            this.add_func_stack();
            obj += Visit(context.parameterClauseIn()) + templateContract + BlockLeft + Wrap;
            obj += ProcessFunctionSupport(context.functionSupportStatement());
            this.delete_current_set();
            obj += BlockRight + Wrap;
            if (get_func_async())
            {
                obj = " async " + obj;
            }
            this.delete_func_stack();
            obj = (new System.Text.StringBuilder().Append(id.permission).Append(" ")).to_str() + obj;
            return(obj);
        }