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


C# Ast.Field类代码示例

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


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

示例1: CreateViewStateSlice

		Expression CreateViewStateSlice(Field f)
		{
			// ViewState["<f.Name>"]
			return new SlicingExpression(
				new ReferenceExpression("ViewState"),
				new StringLiteralExpression(f.Name));
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:7,代码来源:ViewStateAttribute.cs

示例2: LeaveField

 public override void LeaveField(Field node)
 {
     if (!node.IsVisibilitySet)
     {
         node.Modifiers |= TypeMemberModifiers.Protected;
     }
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:7,代码来源:NormalizeTypeAndMemberDefinitions.cs

示例3: CreateGetter

		Method CreateGetter(Field f)
		{
			Method m = new Method();
			m.Name = "get";

			// value = ViewState["<f.Name>"]
			m.Body.Statements.Add(
				new ExpressionStatement(
					new BinaryExpression(
						BinaryOperatorType.Assign,
						new ReferenceExpression("value"),
						CreateViewStateSlice(f)
						)
					)
				);

			if (null != _default)
			{
				// return <_default> unless value
				ReturnStatement rs = new ReturnStatement(_default);
				rs.Modifier = new StatementModifier(StatementModifierType.Unless, new ReferenceExpression("value"));
				m.Body.Statements.Add(rs);
			}

			// return value
			m.Body.Statements.Add(
				new ReturnStatement(
					new ReferenceExpression("value")
					)
				);

			return m;
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:33,代码来源:ViewStateAttribute.cs

示例4: OnField

 public override void OnField(Field node)
 {
     if (this.LookingFor(node))
     {
         this.Found(node.Type);
     }
 }
开发者ID:paveltimofeev,项目名称:documentation,代码行数:7,代码来源:FieldTypeFinder.cs

示例5: OnField

		public override void OnField(Field node)
		{
			if (node.Type != null) {
				TypeReference initializerType = GetInferredType(node.Initializer);
				if (node.Type.Matches(initializerType)) {
					node.Type = null;
				}
			}
			base.OnField(node);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:10,代码来源:RemoveRedundantTypeReferencesVisitor.cs

示例6: OnField

		override public void OnField(Field node)
		{
			if (null == node.Entity)
			{
				node.Entity = new InternalField(node);
				if (!node.IsVisible && !node.IsSynthetic)
				{
					node.Annotate(PrivateMemberNeverUsed, null);
				}
			}
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:11,代码来源:BindTypeMembers.cs

示例7: CreateSetter

		Method CreateSetter(Field f)
		{
			Method m = new Method();
			m.Name = "set";
			m.Body.Statements.Add(
				new ExpressionStatement(
					new BinaryExpression(
						BinaryOperatorType.Assign,
						CreateViewStateSlice(f),
						new ReferenceExpression("value")
						)
					)
				);
			return m;
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:15,代码来源:ViewStateAttribute.cs

示例8: LeaveField

        public override void LeaveField(Field node)
        {
            if (!node.IsVisibilitySet)
            {
                node.Visibility = Context.Parameters.DefaultFieldVisibility;

                //protected field in a sealed type == private,
                //so let the compiler mark them private automatically in order to get
                //unused members warnings for free (and to make IL analysis tools happy as a bonus)
                if (node.IsProtected && node.DeclaringType.IsFinal)
                    node.Visibility = TypeMemberModifiers.Private;
            }

            LeaveMember(node);
        }
开发者ID:elfrostie,项目名称:boo,代码行数:15,代码来源:NormalizeTypeAndMemberDefinitions.cs

示例9: ExtendBaseClass

		/// <summary>
		/// Extends the base class by placing the blocks of macros into methods on the base class
		/// of the same name.
		/// </summary>
		/// <example>
		/// MyMethod:
		///		PerformActions
		/// 
		/// If an overridable method called MyMethod exists on <see cref="BaseClassCompilerStep.BaseClass"/>, then 
		/// it is overridden as follows:
		/// <code>
		/// public override void MyMethod() { PerformActions(); }
		/// </code>
		/// </example>
		protected override void ExtendBaseClass(Module module, ClassDefinition definition)
		{
			List<MethodInfo> methodsThatAreOverridable = new List<MethodInfo>();

			MethodInfo[] baseClassMethods =
				BaseClass.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public |
									 BindingFlags.InvokeMethod);

			foreach (MethodInfo method in baseClassMethods)
			{
				if(method.DeclaringType==typeof(object))
					continue;
				if (method.IsVirtual || method.IsAbstract)
					methodsThatAreOverridable.Add(method);
			}

			MethodSubstitutionTransformer mst = new MethodSubstitutionTransformer(methodsThatAreOverridable.ToArray(), definition);
			mst.Visit(module);

			foreach (Statement statement in module.Globals.Statements)
			{
				ExpressionStatement es = statement as ExpressionStatement;
				if (es != null)
				{
					BinaryExpression be = es.Expression as BinaryExpression;
					if (be != null)
					{
						if (be.Left.NodeType == NodeType.ReferenceExpression && be.Operator == BinaryOperatorType.Assign)
						{
							ReferenceExpression refExp = be.Left as ReferenceExpression;

							Field field = new Field(refExp.LexicalInfo);
							field.Name = refExp.Name;
							field.Initializer = be.Right;
							definition.Members.Add(field);
						}
					}
				}
			}

			if (transformers != null)
			{
				foreach (DepthFirstTransformer transformer in transformers)
					transformer.Visit(module);
			}
		}
开发者ID:JackWangCUMT,项目名称:rhino-dsl,代码行数:60,代码来源:MethodSubstitutionBaseClassCompilerStep.cs

示例10: ConvertField

		void ConvertField(TypeReference typeRef, VariableDeclaration variable, FieldDeclaration fieldDeclaration)
		{
			B.TypeMember m;
			if (currentType is B.EnumDefinition) {
				if (variable.Initializer.IsNull) {
					m = new B.EnumMember(GetLexicalInfo(fieldDeclaration));
				} else {
					PrimitiveExpression p = variable.Initializer as PrimitiveExpression;
					if (p == null || !(p.Value is int)) {
						AddError(fieldDeclaration, "enum member initializer must be integer value");
						return;
					}
					m = new B.EnumMember(GetLexicalInfo(fieldDeclaration), new B.IntegerLiteralExpression((int)p.Value));
				}
			} else {
				m = new B.Field(GetLexicalInfo(fieldDeclaration), ConvertTypeReference(typeRef), ConvertExpression(variable.Initializer));
				m.Modifiers = ConvertModifier(fieldDeclaration, B.TypeMemberModifiers.Private);
			}
			m.Name = variable.Name;
			ConvertAttributes(fieldDeclaration.Attributes, m.Attributes);
			if (currentType != null) currentType.Members.Add(m);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:22,代码来源:ConvertVisitorTypeMembers.cs

示例11: ProcessLiteralField

 void ProcessLiteralField(Field node)
 {
     Visit(node.Initializer);
     ProcessFieldInitializerType(node, node.Initializer.ExpressionType);
     ((InternalField)node.Entity).StaticValue = node.Initializer;
     node.Initializer = null;
 }
开发者ID:stuman08,项目名称:boo,代码行数:7,代码来源:ProcessMethodBodies.cs

示例12: ProcessFieldInitializerType

 void ProcessFieldInitializerType(Field node, IType initializerType)
 {
     if (null == node.Type)
         node.Type = CreateTypeReference(node.LexicalInfo, MapNullToObject(initializerType));
     else
         AssertTypeCompatibility(node.Initializer, GetType(node.Type), initializerType);
 }
开发者ID:stuman08,项目名称:boo,代码行数:7,代码来源:ProcessMethodBodies.cs

示例13: ProcessFieldInitializer

        void ProcessFieldInitializer(Field node)
        {
            Expression initializer = node.Initializer;
            if (null == initializer) return;

            //do not unnecessarily assign fields to default values
            switch (initializer.NodeType)
            {
                case NodeType.NullLiteralExpression:
                    node.Initializer = null;
                    return;
                case NodeType.IntegerLiteralExpression:
                    if (0 == ((IntegerLiteralExpression) initializer).Value) {
                        node.Initializer = null;
                        return;
                    }
                    break;
                case NodeType.BoolLiteralExpression:
                    if (false == ((BoolLiteralExpression) initializer).Value) {
                        node.Initializer = null;
                        return;
                    }
                    break;
                case NodeType.DoubleLiteralExpression:
                    if (0.0f == ((DoubleLiteralExpression) initializer).Value) {
                        node.Initializer = null;
                        return;
                    }
                    break;
            }

            Method method = GetInitializerMethod(node);
            method.Body.Add(
                CodeBuilder.CreateAssignment(
                    initializer.LexicalInfo,
                    CodeBuilder.CreateReference(node),
                    initializer));
            node.Initializer = null;
        }
开发者ID:stuman08,项目名称:boo,代码行数:39,代码来源:ProcessMethodBodies.cs

示例14: PreProcessFieldInitializer

        private void PreProcessFieldInitializer(Field node)
        {
            Expression initializer = node.Initializer;
            if (node.IsFinal && node.IsStatic)
            {
                if (IsValidLiteralInitializer(initializer))
                {
                    ProcessLiteralField(node);
                    return;
                }
            }

            BlockExpression closure = node.Initializer as BlockExpression;
            if (closure != null)
            {
                InferClosureSignature(closure);
            }

            Method method = GetInitializerMethod(node);
            InternalMethod entity = (InternalMethod)method.Entity;

            ReferenceExpression temp = new ReferenceExpression(TempInitializerName);

            BinaryExpression assignment = new BinaryExpression(
                node.LexicalInfo,
                BinaryOperatorType.Assign,
                temp,
                initializer);

            ProcessNodeInMethodContext(entity, entity, assignment);
            method.Locals.RemoveByEntity(temp.Entity);

            IType initializerType = GetExpressionType(assignment.Right);
            ProcessFieldInitializerType(node, initializerType);
            node.Initializer = assignment.Right;
        }
开发者ID:stuman08,项目名称:boo,代码行数:36,代码来源:ProcessMethodBodies.cs

示例15: GetInitializerMethod

 Method GetInitializerMethod(Field node)
 {
     return GetInitializerFor(node.DeclaringType, node.IsStatic);
 }
开发者ID:stuman08,项目名称:boo,代码行数:4,代码来源:ProcessMethodBodies.cs


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