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


C# CSharp.FixedField类代码示例

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


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

示例1: Define

		public override bool Define ()
		{
			if (!base.Define ())
				return false;

			if (!BuiltinTypeSpec.IsPrimitiveType (MemberType)) {
				Report.Error (1663, Location,
					"`{0}': Fixed size buffers type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double",
					GetSignatureForError ());
			} else if (declarators != null) {
				var t = new TypeExpression (MemberType, TypeExpression.Location);
				int index = Parent.PartialContainer.Fields.IndexOf (this);
				foreach (var d in declarators) {
					var f = new FixedField (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
					f.initializer = d.Initializer;
					((ConstInitializer) f.initializer).Name = d.Name.Value;
					Parent.PartialContainer.Fields.Insert (++index, f);
				}
			}
			
			// Create nested fixed buffer container
			string name = String.Format ("<{0}>__FixedBuffer{1}", Name, GlobalCounter++);
			fixed_buffer_type = Parent.TypeBuilder.DefineNestedType (name,
				TypeAttributes.NestedPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit,
				Compiler.BuiltinTypes.ValueType.GetMetaInfo ());

			var ffield = fixed_buffer_type.DefineField (FixedElementName, MemberType.GetMetaInfo (), FieldAttributes.Public);
			
			FieldBuilder = Parent.TypeBuilder.DefineField (Name, fixed_buffer_type, ModifiersExtensions.FieldAttr (ModFlags));

			var element_spec = new FieldSpec (null, this, MemberType, ffield, ModFlags);
			spec = new FixedFieldSpec (Parent.Definition, this, FieldBuilder, element_spec, ModFlags);

			Parent.MemberCache.AddMember (spec);
			return true;
		}
开发者ID:agallero,项目名称:mono,代码行数:36,代码来源:field.cs

示例2: Visit

			public override void Visit(FixedField f)
			{
				var location = LocationsBag.GetMemberLocation(f);
				int locationIdx = 0;
				
				var newField = new FixedFieldDeclaration();
				AddAttributeSection(newField, f);
				AddModifiers(newField, location);
				if (location != null && location.Count > 0)
					newField.AddChild(new CSharpTokenNode(Convert(location [locationIdx++]), FixedFieldDeclaration.FixedKeywordRole), FixedFieldDeclaration.FixedKeywordRole);

				if (f.TypeExpression != null)
					newField.AddChild(ConvertToType(f.TypeExpression), Roles.Type);
				
				var variable = new FixedVariableInitializer();
				variable.AddChild(Identifier.Create(f.MemberName.Name, Convert(f.MemberName.Location)), Roles.Identifier);
				if (f.Initializer != null && !f.Initializer.IsNull) {
					variable.AddChild(new CSharpTokenNode(Convert(f.Initializer.Location), Roles.LBracket), Roles.LBracket);
					
					variable.AddChild((Expression)f.Initializer.Accept(this), Roles.Expression);
					var bracketLocations = LocationsBag.GetLocations(f.Initializer);
					if (bracketLocations != null)
						variable.AddChild(new CSharpTokenNode(Convert(bracketLocations [0]), Roles.RBracket), Roles.RBracket);
				}
				newField.AddChild(variable, FixedFieldDeclaration.VariableRole);
				
				if (f.Declarators != null) {
					foreach (var decl in f.Declarators) {
						var declLoc = LocationsBag.GetLocations(decl);
						if (declLoc != null)
							newField.AddChild(new CSharpTokenNode(Convert(declLoc [0]), Roles.Comma), Roles.Comma);
						
						variable = new FixedVariableInitializer();
						variable.AddChild(Identifier.Create(decl.Name.Value, Convert(decl.Name.Location)), Roles.Identifier);
						variable.AddChild(new CSharpTokenNode(Convert(decl.Initializer.Location), Roles.LBracket), Roles.LBracket);
						variable.AddChild((Expression)decl.Initializer.Accept(this), Roles.Expression);
						var bracketLocations = LocationsBag.GetLocations(decl.Initializer);
						if (bracketLocations != null)
							variable.AddChild(new CSharpTokenNode(Convert(bracketLocations [0]), Roles.RBracket), Roles.RBracket);

						newField.AddChild(variable, FixedFieldDeclaration.VariableRole);
					}
				}
				if (location != null && location.Count > locationIdx)
					newField.AddChild(new CSharpTokenNode(Convert(location [locationIdx]), Roles.Semicolon), Roles.Semicolon);
				typeStack.Peek().AddChild(newField, Roles.TypeMemberRole);
				
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:48,代码来源:CSharpParser.cs

示例3: Visit

			public override void Visit (FixedField f)
			{
				var location = LocationsBag.GetMemberLocation (f);
				
				FieldDeclaration newField = new FieldDeclaration ();
				
				AddModifiers (newField, location);
				if (location != null)
					newField.AddChild (new CSharpTokenNode (Convert (location[1]), "fixed".Length), FieldDeclaration.Roles.Keyword);
				newField.AddChild ((INode)f.TypeName.Accept (this), FieldDeclaration.Roles.ReturnType);
				
				VariableInitializer variable = new VariableInitializer ();
				variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), FieldDeclaration.Roles.Identifier);
				
				if (f.Initializer != null) {
					if (location != null)
						variable.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FieldDeclaration.Roles.Assign);
					variable.AddChild ((INode)f.Initializer.Accept (this), FieldDeclaration.Roles.Initializer);
				}
				newField.AddChild (variable, FieldDeclaration.Roles.Initializer);
				if (f.Declarators != null) {
					foreach (var decl in f.Declarators) {
						var declLoc = LocationsBag.GetLocations (decl);
						if (declLoc != null)
							newField.AddChild (new CSharpTokenNode (Convert (declLoc[declLoc.Count - 1]), 1), FieldDeclaration.Roles.Comma);
						
						variable = new VariableInitializer ();
						variable.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier);
						if (decl.Initializer != null) {
							if (declLoc != null)
								variable.AddChild (new CSharpTokenNode (Convert (declLoc[0]), 1), FieldDeclaration.Roles.Assign);
							variable.AddChild ((INode)decl.Initializer.Accept (this), FieldDeclaration.Roles.Initializer);
						}
						newField.AddChild (variable, FieldDeclaration.Roles.Initializer);
					}
				}
				if (location != null)
					newField.AddChild (new CSharpTokenNode (Convert (location[location.Count - 1]), 1), FieldDeclaration.Roles.Semicolon);

				typeStack.Peek ().AddChild (newField, TypeDeclaration.Roles.Member);

				
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:43,代码来源:CSharpParser.cs

示例4: Visit

			public override void Visit (FixedField f)
			{
				DomField field = new DomField ();
				field.Name = ConvertQuoted (f.MemberName.Name);
				field.Documentation = RetrieveDocumentation (f.Location.Row);
				field.Location = Convert (f.MemberName.Location);
				field.Modifiers = ConvertModifiers (f.ModFlags) | MonoDevelop.Projects.Dom.Modifiers.Fixed;
				field.ReturnType = ConvertReturnType (f.TypeName);
				AddAttributes (field, f.OptAttributes, f);
				field.DeclaringType = typeStack.Peek ();
				typeStack.Peek ().Add (field);
				if (f.Declarators != null) {
					foreach (var decl in f.Declarators) {
						field = new DomField ();
						field.Name = ConvertQuoted (decl.Name.Value);
						field.Location = Convert (decl.Name.Location);
						field.Modifiers = ConvertModifiers (f.ModFlags) | MonoDevelop.Projects.Dom.Modifiers.Fixed;
						field.ReturnType = ConvertReturnType (f.TypeName);
						AddAttributes (field, f.OptAttributes, f);
						field.DeclaringType = typeStack.Peek ();
						typeStack.Peek ().Add (field);
					}
				}
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:24,代码来源:McsParser.cs

示例5: Visit

		public virtual void Visit (FixedField f)
		{
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:3,代码来源:visit.cs

示例6: yyparse


//.........这里部分代码省略.........
	  }
  break;
case 135:
#line 1076 "cs-parser.jay"
  { 
		FullNamedExpression type = (FullNamedExpression) yyVals[-2+yyTop];
		if (type == TypeManager.system_void_expr)
			Report.Error (670, GetLocation (yyVals[-2+yyTop]), "Fields cannot have void type");
		
		var mod = (Modifiers) yyVals[-3+yyTop];

		foreach (VariableMemberDeclaration var in (List<object>) yyVals[-1+yyTop]){
			Field field = new Field (current_class, type, mod, var.MemberName, (Attributes) yyVals[-4+yyTop]);

			field.Initializer = var.GetInitializer (type);

			if (RootContext.Documentation != null) {
				field.DocComment = Lexer.consume_doc_comment ();
				Lexer.doc_state = XmlCommentState.Allowed;
			}
			current_container.AddField (field);
			yyVal = field; /* FIXME: might be better if it points to the top item*/
		}
	  }
  break;
case 136:
#line 1102 "cs-parser.jay"
  { 
			FullNamedExpression type = (FullNamedExpression) yyVals[-2+yyTop];
			
			var mod = (Modifiers) yyVals[-4+yyTop];

			foreach (VariableDeclaration var in (List<VariableDeclaration>) yyVals[-1+yyTop]) {
				FixedField field = new FixedField (current_class, type, mod, var.identifier,
					var.GetInitializer (type), (Attributes) yyVals[-5+yyTop], var.Location);
					
				if (RootContext.Version < LanguageVersion.ISO_2)
					Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "fixed size buffers");

				if (RootContext.Documentation != null) {
					field.DocComment = Lexer.consume_doc_comment ();
					Lexer.doc_state = XmlCommentState.Allowed;
				}
				current_container.AddField (field);
				yyVal = field; /* FIXME: might be better if it points to the top item*/
			}
	  }
  break;
case 137:
#line 1127 "cs-parser.jay"
  {
		Report.Error (1641, GetLocation (yyVals[-1+yyTop]), "A fixed size buffer field must have the array size specifier after the field name");
	  }
  break;
case 138:
#line 1134 "cs-parser.jay"
  {
		var decl = new List<VariableDeclaration> (2);
		decl.Add ((VariableDeclaration)yyVals[0+yyTop]);
		yyVal = decl;
  	  }
  break;
case 139:
#line 1140 "cs-parser.jay"
  {
		var decls = (List<VariableDeclaration>) yyVals[-2+yyTop];
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs

示例7: Visit

			public override void Visit (FixedField f)
			{
				var location = LocationsBag.GetMemberLocation (f);
				
				var newField = new FixedFieldDeclaration ();
				AddAttributeSection (newField, f);
				AddModifiers (newField, location);
				if (location != null)
					newField.AddChild (new CSharpTokenNode (Convert (location [0]), "fixed".Length), FixedFieldDeclaration.Roles.Keyword);
				newField.AddChild (ConvertToType (f.TypeName), FixedFieldDeclaration.Roles.Type);
				
				var variable = new FixedVariableInitializer ();
				variable.AddChild (new Identifier (f.MemberName.Name, Convert (f.MemberName.Location)), FixedFieldDeclaration.Roles.Identifier);
				if (!f.Initializer.IsNull) {
					var bracketLocations = LocationsBag.GetLocations (f.Initializer);
					if (bracketLocations != null && bracketLocations.Count > 1)
						variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.LBracket);
						
					variable.AddChild ((Expression)f.Initializer.Accept (this), FieldDeclaration.Roles.Expression);
					if (bracketLocations != null && bracketLocations.Count > 1)
						variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.RBracket);
				}
				newField.AddChild (variable, FixedFieldDeclaration.VariableRole);
				
				if (f.Declarators != null) {
					foreach (var decl in f.Declarators) {
						var declLoc = LocationsBag.GetLocations (decl);
						if (declLoc != null)
							newField.AddChild (new CSharpTokenNode (Convert (declLoc [0]), 1), FieldDeclaration.Roles.Comma);
						
						variable = new FixedVariableInitializer ();
						variable.AddChild (new Identifier (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier);
						if (!decl.Initializer.IsNull) {
							var bracketLocations = LocationsBag.GetLocations (f.Initializer);
							if (bracketLocations != null && bracketLocations.Count > 1)
								variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.LBracket);
							variable.AddChild ((Expression)decl.Initializer.Accept (this), FieldDeclaration.Roles.Expression);
							if (bracketLocations != null && bracketLocations.Count > 1)
								variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.RBracket);
						}
						newField.AddChild (variable, FixedFieldDeclaration.VariableRole);
					}
				}
				if (location != null)
					newField.AddChild (new CSharpTokenNode (Convert (location [1]), 1), FieldDeclaration.Roles.Semicolon);
				typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole);
				
			}
开发者ID:rmattuschka,项目名称:ILSpy,代码行数:48,代码来源:CSharpParser.cs

示例8: Visit

			public override void Visit (FixedField f)
			{
				DomField field = new DomField ();
				field.Name = f.MemberName.Name;
				field.Documentation = RetrieveDocumentation (f.Location.Row);
				field.Location = Convert (f.MemberName.Location);
				field.Modifiers = ConvertModifiers (f.ModFlags) | MonoDevelop.Projects.Dom.Modifiers.Fixed;
				field.ReturnType = ConvertReturnType (f.TypeName);
				AddAttributes (field, f.OptAttributes);
				field.DeclaringType = typeStack.Peek ();
				typeStack.Peek ().Add (field);
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:12,代码来源:McsParser.cs


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