当前位置: 首页>>代码示例>>C#>>正文


C# Analyzer.LeaveTypeDecl方法代码示例

本文整理汇总了C#中Analyzer.LeaveTypeDecl方法的典型用法代码示例。如果您正苦于以下问题:C# Analyzer.LeaveTypeDecl方法的具体用法?C# Analyzer.LeaveTypeDecl怎么用?C# Analyzer.LeaveTypeDecl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Analyzer的用法示例。


在下文中一共展示了Analyzer.LeaveTypeDecl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Analyze

		/// <include file='Doc/Nodes.xml' path='doc/method[@name="Statement.Analyze"]/*'/>
		internal override Statement Analyze(Analyzer/*!*/ analyzer)
		{
			// remove classes that has been merged to the aggregate from the further processing:
			if (IsPartialMergeResiduum)
				return EmptyStmt.PartialMergeResiduum;

			// functions in incomplete (not emitted) class can't be emitted
			type.Declaration.IsInsideIncompleteClass = analyzer.IsInsideIncompleteClass();

			// the ClassDecl is fully analyzed even if it will be replaced in the AST by EvalEx
			// and even if it is unreachable in order to discover all possible errors in compile-time

			type.Declaration.IsUnreachable = analyzer.IsThisCodeUnreachable();

			if (type.Declaration.IsUnreachable)
				analyzer.ReportUnreachableCode(position);

			attributes.Analyze(analyzer, this);
			typeSignature.Analyze(analyzer);

			analyzer.EnterTypeDecl(type);

            foreach (var member in members)
            {
                member.EnterAnalyzer(analyzer);
                member.Analyze(analyzer);
                member.LeaveAnalyzer(analyzer);
            }

			analyzer.LeaveTypeDecl();

			AnalyzeDocComments(analyzer);

			// validate the type after all members has been analyzed and validated:
			type.Validate(analyzer.ErrorSink);

			if (type.Declaration.IsUnreachable)
			{
				// only a conditional declaration can be unreachable
				// => not emiting the declaration is ok

				return EmptyStmt.Unreachable;
			}
			else if (!type.IsComplete)
			{
				// mark all functions declared in incomplete class as 'non-compilable'

				// convert incomplete class to an eval if applicable:
				if (analyzer.SourceUnit.CompilationUnit.IsPure && analyzer.CurrentType == null &&
					analyzer.CurrentRoutine == null)
				{
					// error, since there is no place for global code in pure mode:
					analyzer.ErrorSink.Add(Errors.IncompleteClass, analyzer.SourceUnit, position, this.name);
					return this;
				}

				if (analyzer.SourceUnit.CompilationUnit.IsTransient)
				{
					TransientCompilationUnit transient_unit = (TransientCompilationUnit)analyzer.SourceUnit.CompilationUnit;

					// report an error only for synthetic evals as we are 100% sure that the class cannot be completed;
					// note that a synthetic eval can be created even in transient code as some base types could be 
					// declared there conditionally:
					if (transient_unit.EvalKind == EvalKinds.SyntheticEval)
					{
						analyzer.ErrorSink.Add(Errors.IncompleteClass, analyzer.SourceUnit, position, this.name);
						return this;
					}
				}

                // report the warning, incomplete_class
                analyzer.ErrorSink.Add(Warnings.IncompleteClass, analyzer.SourceUnit, position, this.name);

                this.typeDefinitionCode = analyzer.SourceUnit.GetSourceCode(entireDeclarationPosition);
                //// we return an eval
                //EvalEx evalEx = new EvalEx(
                //    entireDeclarationPosition, this.typeDefinitionCode,
                //    (this.Namespace != null && this.Namespace.QualifiedName.Namespaces.Length > 0) ? this.Namespace.QualifiedName : (QualifiedName?)null,
                //    this.validAliases);
                //Statement stmt = new ExpressionStmt(entireDeclarationPosition, evalEx);

                //// this annotation is for the duck-type generation - we need to know the original typedecl
                //evalEx.Annotations.Set<TypeDecl>(this);

                //return stmt;

                // we emit eval
                return this;
			}
			else
			{
				return this;
			}
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:95,代码来源:TypeDecl.cs


注:本文中的Analyzer.LeaveTypeDecl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。