當前位置: 首頁>>代碼示例>>C#>>正文


C# Analyzer.LeaveMethodDeclaration方法代碼示例

本文整理匯總了C#中Analyzer.LeaveMethodDeclaration方法的典型用法代碼示例。如果您正苦於以下問題:C# Analyzer.LeaveMethodDeclaration方法的具體用法?C# Analyzer.LeaveMethodDeclaration怎麽用?C# Analyzer.LeaveMethodDeclaration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Analyzer的用法示例。


在下文中一共展示了Analyzer.LeaveMethodDeclaration方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Analyze

        internal override void Analyze(Analyzer/*!*/ analyzer)
        {
            // method redeclared:
            if (method == null) return;

            base.Analyze(analyzer);

            PhpType declaring_type = analyzer.CurrentType;

            analyzer.EnterMethodDeclaration(method);

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

            method.Validate(analyzer.ErrorSink);

            // note, if the declaring type's base is unknown then it cannot be a CLR type;
            ClrType base_clr_type = method.DeclaringType.Base as ClrType;

            if (baseCtorParams != null)
            {
                if (base_clr_type != null)
                {
                    AnalyzeBaseCtorCallParams(analyzer, base_clr_type);
                }
                else if (!method.IsConstructor || method.DeclaringType.Base == null || body == null)
                {
                    analyzer.ErrorSink.Add(Errors.UnexpectedParentCtorInvocation, analyzer.SourceUnit, position);
                    baseCtorParams = null;
                }
                else if (method.DeclaringType.Base.Constructor == null)
                {
                    // base class has no constructor, the default parameterless is silently called (and that does nothing);
                    // report error, if there are any parameters passed to the parameterless ctor:
                    if (baseCtorParams.Count > 0)
                        analyzer.ErrorSink.Add(Errors.UnexpectedParentCtorInvocation, analyzer.SourceUnit, position);
                    baseCtorParams = null;
                }
                else
                {
                    GenericQualifiedName parent_name = new GenericQualifiedName(new QualifiedName(Name.ParentClassName));
                    DirectStMtdCall call_expr = new DirectStMtdCall(
                        position, parent_name, Position.Invalid,
                        method.DeclaringType.Base.Constructor.Name, Position.Invalid,
                        baseCtorParams, TypeRef.EmptyList);

                    body.Insert(0, new ExpressionStmt(position, call_expr));
                    baseCtorParams = null;
                }
            }
            else
            {
                // the type immediately extends CLR type with no default ctor, yet there is no call to the base ctor;
                // note, all constructor overloads reflected from the CLR type are visible as we are in a subclass:
                if (method.IsConstructor && base_clr_type != null && !base_clr_type.ClrConstructor.HasParameterlessOverload)
                {
                    analyzer.ErrorSink.Add(Errors.ExpectingParentCtorInvocation, analyzer.SourceUnit, position);
                }
            }
            if(method.IsDllImport && !method.IsStatic)
                analyzer.ErrorSink.Add(Errors.DllImportMethodMustBeStatic, analyzer.SourceUnit, position);
            if(method.IsDllImport && method.IsAbstract)
                analyzer.ErrorSink.Add(Errors.DllImportMethodCannotBeAbstract, analyzer.SourceUnit, position);

            if (body != null)
                body.Analyze(analyzer);

            method.ValidateBody(analyzer.ErrorSink);

            analyzer.LeaveMethodDeclaration();

            // add entry point if applicable:
            analyzer.SetEntryPoint(method, position);
        }
開發者ID:Ashod,項目名稱:Phalanger,代碼行數:74,代碼來源:TypeDecl.cs


注:本文中的Analyzer.LeaveMethodDeclaration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。