• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Ast.TypeDefinition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Boo.Lang.Compiler.Ast.TypeDefinition的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinition类的具体用法?C# TypeDefinition怎么用?C# TypeDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TypeDefinition类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了TypeDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LiftGenericTypeDefinition

		private static TypeReference LiftGenericTypeDefinition(TypeDefinition node)
		{
			var typeRef = new GenericTypeReference(node.LexicalInfo, node.QualifiedName);
			foreach (GenericParameterDeclaration parameter in node.GenericParameters)
				typeRef.GenericArguments.Add(Lift(parameter.Name));
			return typeRef;
		}
开发者ID:HaKDMoDz,项目名称:GNet,代码行数:7,代码来源:TypeReference.cs


示例2: LeaveTypeDefinition

		void LeaveTypeDefinition(TypeDefinition node)
		{
			if (!node.IsVisibilitySet)
				node.Modifiers |= Context.Parameters.DefaultTypeVisibility;

			node.Name = NormalizeName(node.Name);
		}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:7,代码来源:NormalizeTypeAndMemberDefinitions.cs


示例3: OnCandidatePartialDefinition

		private void OnCandidatePartialDefinition(TypeDefinition node)
		{
			if (!node.IsPartial)
				return;

			var typeName = node.FullName;

			TypeDefinition originalDefinition;
			if (_partials.TryGetValue(typeName, out originalDefinition))
			{
				if (node == originalDefinition) // MergePartialTypes can be executed more than once
					return;

				if (originalDefinition.NodeType != node.NodeType)
				{
					Errors.Add(CompilerErrorFactory.IncompatiblePartialDefinition(node, typeName, AstUtil.TypeKeywordFor(originalDefinition), AstUtil.TypeKeywordFor(node)));
					return;
				}

				MergeImports(node, originalDefinition);
				originalDefinition.Merge(node);
				RemoveCurrentNode();
			}
			else
				_partials[typeName] = node;
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:26,代码来源:MergePartialTypes.cs


示例4: BuildUniqueTypeMemberName

        //use this to build a type member name unique in the inheritance hierarchy.
        public static string BuildUniqueTypeMemberName(TypeDefinition type, string name)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");

            StringBuilder nameBuilder = new StringBuilder("$");
            nameBuilder.Append(name);
            nameBuilder.Append("__");
            nameBuilder.Append(type.QualifiedName);
            if (type.HasGenericParameters)
            {
                nameBuilder.Append("_");
                string[] parameterNames = Array.ConvertAll<GenericParameterDeclaration, string>(
                    type.GenericParameters.ToArray(),
                    delegate(GenericParameterDeclaration gpd) { return gpd.Name; });
                foreach (string parameterName in parameterNames)
                {
                    nameBuilder.Append("_");
                    nameBuilder.Append(parameterName);
                }
            }
            nameBuilder.Replace('.', '_');
            nameBuilder.Append("$");
            return nameBuilder.ToString();
        }
开发者ID:boo,项目名称:boo-lang,代码行数:26,代码来源:AstUtil.cs


示例5: EnterTypeDefinition

		void EnterTypeDefinition(TypeDefinition node)
		{
			List<Field> list = new List<Field>();
			fieldStack.Push(list);
			foreach (TypeMember member in node.Members) {
				if (member is Field)
					list.Add((Field)member);
			}
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:9,代码来源:RemoveRedundantTypeReferencesVisitor.cs


示例6: BindMembers

        public static void BindMembers(string cacheName,TypeDefinition type){
            if (!cache.ContainsKey(cacheName)) return;
            foreach (var member in cache[cacheName]){ 
                type.Members.Add(member);
            }
            cache.Remove(cacheName);

            new Method().Parameters.Add(new ParameterDeclaration("name",new SimpleTypeReference("string")));
        }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:9,代码来源:MacroCache.cs


示例7: OnTypeDefinition

		private void OnTypeDefinition(TypeDefinition node)
		{
			var old = _currentType;
			_currentType = (IType)node.Entity;
			Visit(node.Attributes);
			Visit(node.BaseTypes);
			Visit(node.Members);
			Visit(node.GenericParameters);
			_currentType = old;
		}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:10,代码来源:DetectInnerGenerics.cs


示例8: InternalGenericParameter

        public InternalGenericParameter(TypeSystemServices tss, GenericParameterDeclaration declaration)
        {
            _tss = tss;
            _declaration = declaration;

            // Determine and remember declaring type and declaring method (if applicable)
            _declaringMethod = declaration.ParentNode as Method;
            _declaringType = (
                _declaringMethod == null ?
                declaration.ParentNode as TypeDefinition : _declaringMethod.DeclaringType);
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:11,代码来源:InternalGenericParameter.cs


示例9: ExtendBaseClass

 protected override void ExtendBaseClass(TypeDefinition definition)
 {
     Property property = new Property("Environment");
     property.Getter = new Method("getter_Environment");
     property.Getter.Body.Add(
         new ReturnStatement(
             new StringLiteralExpression(environment ?? "")
             )
         );
     definition.Members.Add(property);
 }
开发者ID:janlimpens,项目名称:rhino-commons,代码行数:11,代码来源:BinsorCompilerStep.cs


示例10: CheckMembers

		void CheckMembers(TypeDefinition node)
		{
			_members.Clear();
			
			foreach (TypeMember member in node.Members)
			{
				if (member.NodeType == NodeType.StatementTypeMember)
					continue;

				var list = GetMemberList(member.Name);
				CheckMember(list, member);
				list.Add(member);
			}
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:14,代码来源:CheckMemberNames.cs


示例11: MergeImports

        static void MergeImports(TypeDefinition from, TypeDefinition to)
        {
            Module fromModule = from.EnclosingModule;
            Module toModule = to.EnclosingModule;
            if (fromModule == toModule) return;
            if (toModule.ContainsAnnotation(fromModule)) return;

            toModule.Imports.ExtendWithClones(fromModule.Imports.Where(i => !toModule.Imports.Any(i2 => i.Matches(i2))));
            // annotate so we remember not to merge the imports
            // again in the future
            toModule.Annotate(fromModule);

            //annotate so that we know these modules have been merged
            //this is used by checkneverusedmembers step
            if (!fromModule.ContainsAnnotation("merged-module"))
                fromModule.Annotate("merged-module");
            if (!toModule.ContainsAnnotation("merged-module"))
                toModule.Annotate("merged-module");
        }
开发者ID:boo-lang,项目名称:boo,代码行数:19,代码来源:MergePartialTypes.cs


示例12: LeaveTypeDefinition

		override public void LeaveTypeDefinition(TypeDefinition node)
		{
			_safeVars.Clear(); //clear type var cache (CheckAmbiguousVariableNames)

			if (node.NodeType == NodeType.Module)
				return;

			string qualifiedName = node.QualifiedName;
			if (node.HasGenericParameters)
			{
				qualifiedName += "`" + node.GenericParameters.Count;
			}

			if (_types.ContainsKey(qualifiedName))
			{
				Errors.Add(CompilerErrorFactory.NamespaceAlreadyContainsMember(node, GetNamespace(node), node.Name));
				return;
			}
			_types.Add(qualifiedName, node); 
		}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:20,代码来源:StricterErrorChecking.cs


示例13: BaseTypeResolution

		public BaseTypeResolution(CompilerContext context, TypeDefinition typeDefinition, List<TypeDefinition> visited) : base(context)
		{
			_typeDefinition = typeDefinition;
			_visited = visited;
			_visited.Add(_typeDefinition);

			_removed = 0;
			_index = -1;

			NameResolutionService nameResolution = NameResolutionService;
			INamespace previous = nameResolution.CurrentNamespace;
			nameResolution.EnterNamespace(ParentNamespaceOf(_typeDefinition));
			try
			{
				Run();
			}
			finally
			{
				nameResolution.EnterNamespace(previous);
			}
		}
开发者ID:HaKDMoDz,项目名称:GNet,代码行数:21,代码来源:BaseTypeResolution.cs


示例14: GenerateConstructors

		private void GenerateConstructors(TypeDefinition definition)
		{
			ConstructorInfo[] ctors =
				baseClass.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
			foreach (ConstructorInfo ctor in ctors)
			{
				if (ctor.IsPrivate)
					continue;
				Constructor constructor = new Constructor(definition.LexicalInfo);
				definition.Members.Add(constructor);
				MethodInvocationExpression super = new MethodInvocationExpression(new SuperLiteralExpression());
				constructor.Body.Add(super);
				foreach (ParameterInfo info in ctor.GetParameters())
				{
					SimpleTypeReference typeReference =
						new SimpleTypeReference(TypeUtilities.GetFullName(info.ParameterType));
					constructor.Parameters.Add(new ParameterDeclaration(info.Name,
																		typeReference)
						);
					super.Arguments.Add(new ReferenceExpression(info.Name));
				}
			}
		}
开发者ID:yonglehou,项目名称:NGinnBPM,代码行数:23,代码来源:BaseClassCompilerStep.cs


示例15: GetStaticConstructor

 Constructor GetStaticConstructor(TypeDefinition type)
 {
     return CodeBuilder.GetOrCreateStaticConstructorFor(type);
 }
开发者ID:stuman08,项目名称:boo,代码行数:4,代码来源:ProcessMethodBodies.cs


示例16: GetInitializerFor

 private Method GetInitializerFor(TypeDefinition type, bool isStatic)
 {
     string methodName = isStatic ? "$static_initializer$" : "$initializer$";
     Method method = (Method)type[methodName];
     if (null == method)
     {
         if (isStatic)
         {
             if (!type.HasStaticConstructor)
             {
                 // when the class doesnt have a static constructor
                 // yet, create one and use it as the static
                 // field initializer method
                 method = CodeBuilder.CreateStaticConstructor(type);
             }
             else
             {
                 method = CreateInitializerMethod(type, methodName, TypeMemberModifiers.Static);
                 AddInitializerToStaticConstructor(type, (InternalMethod)method.Entity);
             }
         }
         else
         {
             method = CreateInitializerMethod(type, methodName, TypeMemberModifiers.None);
         }
         type[methodName] = method;
     }
     return method;
 }
开发者ID:stuman08,项目名称:boo,代码行数:29,代码来源:ProcessMethodBodies.cs


示例17: GetFieldsInitializerInitializedField

        private Field GetFieldsInitializerInitializedField(TypeDefinition type)
        {
            string name = AstUtil.BuildUniqueTypeMemberName(type, "initialized");
            Field field= (Field) type.Members[name];

            if (null == field)
            {
                field = CodeBuilder.CreateField(name, TypeSystemServices.BoolType);
                field.Visibility = TypeMemberModifiers.Private;
                type.Members.Add(field);
                MarkVisited(field);
            }
            return field;
        }
开发者ID:stuman08,项目名称:boo,代码行数:14,代码来源:ProcessMethodBodies.cs


示例18: CreateInitializerMethod

 Method CreateInitializerMethod(TypeDefinition type, string name, TypeMemberModifiers modifiers)
 {
     Method method = CodeBuilder.CreateMethod(name, TypeSystemServices.VoidType, modifiers);
     type.Members.Add(method);
     MarkVisited(method);
     return method;
 }
开发者ID:stuman08,项目名称:boo,代码行数:7,代码来源:ProcessMethodBodies.cs


示例19: AddInitializerToStaticConstructor

 void AddInitializerToStaticConstructor(TypeDefinition type, InternalMethod initializer)
 {
     GetStaticConstructor(type).Body.Insert(0,
                                            CodeBuilder.CreateMethodInvocation(initializer));
 }
开发者ID:stuman08,项目名称:boo,代码行数:5,代码来源:ProcessMethodBodies.cs


示例20: AddInitializerToInstanceConstructors

        void AddInitializerToInstanceConstructors(TypeDefinition type, Method initializer)
        {
            int n = 0;

            //count number of non-static constructors
            foreach (TypeMember node in type.Members)
            {
                if (NodeType.Constructor == node.NodeType && !node.IsStatic)
                    n++;
            }

            //if there is more than one we need $initialized$ guard check
            if (n > 1)
                AddInitializedGuardToInitializer(type, initializer);

            foreach (TypeMember node in type.Members)
            {
                if (NodeType.Constructor == node.NodeType && !node.IsStatic)
                {
                    Constructor constructor = (Constructor) node;
                    n = GetIndexAfterSuperInvocation(constructor.Body);
                    foreach (Statement st in initializer.Body.Statements)
                    {
                        constructor.Body.Insert(n, (Statement) st.Clone());
                        n++;
                    }
                    foreach (Local loc in initializer.Locals)
                    {
                        constructor.Locals.Add(loc);
                    }
                }
            }
        }
开发者ID:stuman08,项目名称:boo,代码行数:33,代码来源:ProcessMethodBodies.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ast.TypeMember类代码示例发布时间:2022-05-24
下一篇:
C# Ast.SlicingExpression类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap