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


C# Ast.ClassDefinition类代码示例

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


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

示例1: CheckBaseTypes

        void CheckBaseTypes(ClassDefinition node)
        {
            IType baseClass = null;
            foreach (TypeReference baseTypeRef in node.BaseTypes)
            {
                IType baseType = GetType(baseTypeRef);
                if (baseType.IsInterface)
                    continue;

                if (null != baseClass)
                {
                    Error(
                        CompilerErrorFactory.ClassAlreadyHasBaseType(baseTypeRef,
                            node.Name,
                            baseClass.FullName)
                        );
                    continue;
                }

                baseClass = baseType;
                if (baseClass.IsFinal && !TypeSystemServices.IsError(baseClass))
                {
                    Error(
                        CompilerErrorFactory.CannotExtendFinalType(
                            baseTypeRef,
                            baseClass.FullName));
                }
            }

            if (null == baseClass)
                node.BaseTypes.Insert(0, CodeBuilder.CreateTypeReference(TypeSystemServices.ObjectType)	);
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:32,代码来源:BindBaseTypes.cs

示例2: LeaveClassDefinition

        public override void LeaveClassDefinition(ClassDefinition node)
        {
            MarkVisited(node);
            if(!_classDefinitionList.Contains(node.Name))
            {
                _classDefinitionList.Add(node.Name, node);
            }
            foreach (TypeReference baseTypeRef in node.BaseTypes)
            {
                IType baseType = GetType(baseTypeRef);
                EnsureRelatedNodeWasVisited(node, baseType);

                if (baseType.IsInterface)
                {
                    ResolveInterfaceMembers(node, baseTypeRef, baseType);
                }
                else
                {
                    if (IsAbstract(baseType))
                    {
                        ResolveAbstractMembers(node, baseTypeRef, baseType);
                    }
                }
            }
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:25,代码来源:ProcessInheritedAbstractMembers.cs

示例3: Run

		/// <summary>
		/// Run this compiler step
		/// </summary>
		public override void Run()
		{
			if (Context.References.Contains(baseClass.Assembly) == false)
                Context.Parameters.References.Add(baseClass.Assembly);

			foreach (Module module in CompileUnit.Modules)
			{
				foreach (string ns in namespaces)
				{
					module.Imports.Add(new Import(module.LexicalInfo, ns));
				}

				ClassDefinition definition = new ClassDefinition();
				definition.Name = module.FullName;
				definition.BaseTypes.Add(new SimpleTypeReference(baseClass.FullName));

				GenerateConstructors(definition);

				// This is called before the module.Globals is set to a new block so that derived classes may retrieve the
				// block from the module.
				ExtendBaseClass(module, definition);

				module.Globals = new Block();
				module.Members.Add(definition);
			}
		}
开发者ID:yonglehou,项目名称:NGinnBPM,代码行数:29,代码来源:BaseClassCompilerStep.cs

示例4: OnStructDefinition

		override public void OnStructDefinition(StructDefinition node)
		{
			ClassDefinition cd = new ClassDefinition(node.LexicalInfo);
			cd.Name = node.Name;
			cd.Attributes = node.Attributes;
			cd.Modifiers = node.Modifiers;
			cd.Members = node.Members;
			cd.GenericParameters = node.GenericParameters;
			cd.BaseTypes = node.BaseTypes;
			cd.BaseTypes.Insert(0, CodeBuilder.CreateTypeReference(TypeSystemServices.ValueTypeType));
			foreach (TypeMember member in cd.Members)
			{
				if (member.IsVisibilitySet)
					continue;

				switch (member.NodeType)
				{
					case NodeType.Field:
						member.Visibility = Context.Parameters.DefaultFieldVisibility;
						break;
					case NodeType.Property:
						member.Visibility = Context.Parameters.DefaultPropertyVisibility;
						break;
					case NodeType.Method:
						member.Visibility = Context.Parameters.DefaultMethodVisibility;
						break;
				}

				if (member.IsProtected)
					member.Visibility = TypeMemberModifiers.Public;
			}
			OnClassDefinition(cd);
			ReplaceCurrentNode(cd);
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:34,代码来源:BindTypeDefinitions.cs

示例5: Run

        public override void Run()
        {
            foreach(var module in CompileUnit.Modules)
            {
                foreach(string name in options.NamespacesToImport)
                {
                    module.Imports.Add(new Import(module.LexicalInfo, name));
                }

                var macro = new ClassDefinition {Name = GetViewTypeName(module.FullName)};
                macro.BaseTypes.Add(new SimpleTypeReference(options.BaseType));

                AddConstructor(macro);
                ScriptDirectoryProperty(macro, module);
                AddRunMethod(macro, module);

                foreach(var member in module.Members)
                {
                    macro.Members.Add(member);
                }

                module.Members.Clear();
                module.Members.Add(macro);
            }
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:25,代码来源:TransformToBrailStep.cs

示例6: AddConstructor

        // create a constructor that delegate to the base class
        private void AddConstructor(ClassDefinition macro)
        {
            var ctor = new Constructor(macro.LexicalInfo);

            ctor.Parameters.Add(
                new ParameterDeclaration("viewEngine",
                                         new SimpleTypeReference("MvcContrib.BrailViewEngine.BooViewEngine"))); // TODO: Update Reference

            //			ctor.Parameters.Add(
            //				new ParameterDeclaration("output",
            //				                         new SimpleTypeReference("System.IO.TextWriter")));
            //			ctor.Parameters.Add(
            //				new ParameterDeclaration("context",
            //				                         new SimpleTypeReference("Castle.MonoRail.Framework.IEngineContext")));
            //
            //			ctor.Parameters.Add(
            //				new ParameterDeclaration("__controller",
            //				                         new SimpleTypeReference("Castle.MonoRail.Framework.IController")));
            //
            //			ctor.Parameters.Add(
            //				new ParameterDeclaration("__controllerContext",
            //										 new SimpleTypeReference("Castle.MonoRail.Framework.IControllerContext")));

            var mie = new MethodInvocationExpression(new SuperLiteralExpression());
            mie.Arguments.Add(AstUtil.CreateReferenceExpression("viewEngine"));
            //			mie.Arguments.Add(AstUtil.CreateReferenceExpression("output"));
            //			mie.Arguments.Add(AstUtil.CreateReferenceExpression("context"));
            //			mie.Arguments.Add(AstUtil.CreateReferenceExpression("__controller"));
            //			mie.Arguments.Add(AstUtil.CreateReferenceExpression("__controllerContext"));

            ctor.Body.Add(mie);

            macro.Members.Add(ctor);
        }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:35,代码来源:TransformToBrailStep.cs

示例7: Run

		public override void Run()
		{
			foreach(Module module in CompileUnit.Modules)
			{
				module.Imports.Add(new Import(module.LexicalInfo, "Castle.MonoRail.Views.Brail"));
				module.Imports.Add(new Import(module.LexicalInfo, "Castle.MonoRail.Framework"));

				foreach(string name in options.NamespacesToImport)
				{
					module.Imports.Add(new Import(module.LexicalInfo, name));
				}

				ClassDefinition macro = new ClassDefinition();
				macro.Name = GetViewTypeName(module.FullName);
				macro.BaseTypes.Add(new SimpleTypeReference("Castle.MonoRail.Views.Brail.BrailBase"));

				AddConstructor(macro);
				ScriptDirectoryProperty(macro, module);
				ViewFileNameProperty(macro, module);
				AddRunMethod(macro, module);

				foreach(TypeMember member in module.Members)
				{
					macro.Members.Add(member);
				}

				module.Members.Clear();
				module.Members.Add(macro);
			}
		}
开发者ID:candland,项目名称:Castle.MonoRail,代码行数:30,代码来源:TransformToBrailStep.cs

示例8: OnClassDefinition

 public override void OnClassDefinition(ClassDefinition node)
 {
     IAccessibilityChecker saved = _checker;
     _checker = new AccessibilityChecker(node);
     base.OnClassDefinition(node);
     _checker = saved;
 }
开发者ID:boo,项目名称:boo-lang,代码行数:7,代码来源:CheckMembersProtectionLevel.cs

示例9: CheckPrivateMembersNeverUsed

 protected void CheckPrivateMembersNeverUsed(ClassDefinition node)
 {
     foreach (TypeMember member in node.Members)
     {
         WarnIfPrivateMemberNeverUsed(member);
     }
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:7,代码来源:CheckNeverUsedMembers.cs

示例10: Run

			public override void Run()
			{
				var klass = new ClassDefinition { Name = "Foo" };
				var baseType = new SimpleTypeReference("object");
				klass.BaseTypes.Add(baseType);

				var method = new Method { Name = "Bar" };
				method.Body.Add(
					new ReturnStatement(
						new IntegerLiteralExpression(42)));
				klass.Members.Add(method);

				var module = CompileUnit.Modules[0];
				Assert.AreEqual(0, module.Members.Count);

				My<CodeReifier>.Instance.ReifyInto(module, klass);

				Assert.AreEqual(1, module.Members.Count);
				Assert.AreSame(klass, module.Members[0]);

				var klassEntity = (IType) klass.Entity;
				Assert.IsTrue(klassEntity.IsClass);
				Assert.AreSame(TypeSystemServices.ObjectType, klassEntity.BaseType);

				var methodEntity = (IMethod)method.Entity;
				Assert.AreEqual(method.Name, methodEntity.Name);
				Assert.AreSame(TypeSystemServices.IntType, methodEntity.ReturnType);
			}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:28,代码来源:CodeReifierTest.cs

示例11: EnterClassDefinition

 public override bool EnterClassDefinition(ClassDefinition node)
 {
     if (WasVisited(node))
         return false;
     _visited.Add(node);
     return true;
 }
开发者ID:scottstephens,项目名称:boo,代码行数:7,代码来源:MacroExpander.cs

示例12: CheckMembers

 protected void CheckMembers(ClassDefinition node)
 {
     foreach (TypeMember member in node.Members)
     {
         WarnIfPrivateMemberNeverUsed(member);
         WarnIfProtectedMemberInSealedClass(member);
     }
 }
开发者ID:boo,项目名称:boo-lang,代码行数:8,代码来源:CheckNeverUsedMembers.cs

示例13: OnClassDefinition

 public override void OnClassDefinition(ClassDefinition node)
 {
     if (null == node.Entity)
     {
         node.Entity = new InternalClass(TypeSystemServices, node);
     }
     Visit(node.Members);
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:8,代码来源:BindTypeDefinitions.cs

示例14: LeaveClassDefinition

        public override void LeaveClassDefinition(ClassDefinition node)
        {
            CheckModifierCombination(node);
            CantBeMarkedPartialIfNested(node);

            if (node.IsStatic)
                node.Modifiers |= TypeMemberModifiers.Abstract | TypeMemberModifiers.Final;
        }
开发者ID:scottstephens,项目名称:boo,代码行数:8,代码来源:PreErrorChecking.cs

示例15: Merge

 public void Merge(ClassDefinition node)
 {
     if (null == node) throw new ArgumentNullException("node");
     if (ReferenceEquals(this, node)) return;
     this.Attributes.Extend(node.Attributes);
     this.BaseTypes.Extend(node.BaseTypes);
     this.Members.Extend(node.Members);
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:8,代码来源:ClassDefinition.cs


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