Пример #1
0
        /// <include file='Doc/Nodes.xml' path='doc/method[@name="Statement.Analyze"]/*'/>
        internal override Statement /*!*/ Analyze(Analyzer /*!*/ analyzer)
        {
            // functions in incomplete (not emitted) class can't be emitted
            function.Declaration.IsInsideIncompleteClass = analyzer.IsInsideIncompleteClass();

            attributes.Analyze(analyzer, this);

            // function is analyzed even if it is unreachable in order to discover more errors at compile-time:
            function.Declaration.IsUnreachable = analyzer.IsThisCodeUnreachable();

            if (function.Declaration.IsUnreachable)
            {
                analyzer.ReportUnreachableCode(position);
            }

            analyzer.EnterFunctionDeclaration(function);

            typeSignature.Analyze(analyzer);
            signature.Analyze(analyzer);

            function.Validate(analyzer.ErrorSink);

            this.Body.Analyze(analyzer);

            // validate function and its body:
            function.ValidateBody(analyzer.ErrorSink);

            /*
             * if (docComment != null)
             *      AnalyzeDocComment(analyzer);
             */

            analyzer.LeaveFunctionDeclaration();

            if (function.Declaration.IsUnreachable)
            {
                return(EmptyStmt.Unreachable);
            }
            else
            {
                // add entry point if applicable:
                analyzer.SetEntryPoint(function, position);
                return(this);
            }
        }