Exemple #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);
            }
        }
Exemple #2
0
        internal void Analyze(Analyzer /*!*/ analyzer)
        {
            attributes.Analyze(analyzer, this);

            if (initValue != null)
            {
                initValue = initValue.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
            }

            // adds arguments to local variables table:
            if (!routine.Builder.LocalVariables.AddParameter(name, passedByRef))
            {
                // parameter with the same name specified twice
                analyzer.ErrorSink.Add(Errors.DuplicateParameterName, analyzer.SourceUnit, position, name);
            }

            if (isOut && !passedByRef)
            {
                // out can be used only on by-ref params:
                analyzer.ErrorSink.Add(Errors.OutAttributeOnByValueParam, analyzer.SourceUnit, position, name);
            }
        }
Exemple #3
0
        internal override Statement /*!*/ Analyze(Analyzer /*!*/ analyzer)
        {
            attributes.AnalyzeMembers(analyzer, analyzer.CurrentScope);
            attributes.Analyze(analyzer, this);

            bool is_unreachable = analyzer.IsThisCodeUnreachable();

            foreach (GlobalConstantDecl cd in constants)
            {
                cd.GlobalConstant.Declaration.IsUnreachable = is_unreachable;
                // cd.Constant.CustomAttributes = attributes;
                cd.Analyze(analyzer);
            }

            if (is_unreachable)
            {
                analyzer.ReportUnreachableCode(position);
                return(EmptyStmt.Unreachable);
            }
            else
            {
                return(this);
            }
        }