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


C# AttributeEncoder.EncodeEmptyNamedArguments方法代码示例

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


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

示例1: EmitIndexerName

		void EmitIndexerName ()
		{
			if (!has_normal_indexers)
				return;

			var ctor = Module.PredefinedMembers.DefaultMemberAttributeCtor.Get ();
			if (ctor == null)
				return;

			var encoder = new AttributeEncoder ();
			encoder.Encode (GetAttributeDefaultMember ());
			encoder.EncodeEmptyNamedArguments ();

			TypeBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ());
		}
开发者ID:fvalette,项目名称:mono,代码行数:15,代码来源:class.cs

示例2: EmitFieldSize

		void EmitFieldSize (int buffer_size)
		{
			int type_size = BuiltinTypeSpec.GetSize (MemberType);

			if (buffer_size > int.MaxValue / type_size) {
				Report.Error (1664, Location, "Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit",
					GetSignatureForError (), buffer_size.ToString (), TypeManager.CSharpName (MemberType));
				return;
			}

			AttributeEncoder encoder;

			var ctor = Module.PredefinedMembers.StructLayoutAttributeCtor.Resolve (Location);
			if (ctor == null)
				return;

			var field_size = Module.PredefinedMembers.StructLayoutSize.Resolve (Location);
			var field_charset = Module.PredefinedMembers.StructLayoutCharSet.Resolve (Location);
			if (field_size == null || field_charset == null)
				return;

			var char_set = CharSet ?? Module.DefaultCharSet ?? 0;

			encoder = new AttributeEncoder ();
			encoder.Encode ((short)LayoutKind.Sequential);
			encoder.EncodeNamedArguments (
				new [] { field_size, field_charset },
				new Constant [] { 
					new IntConstant (Compiler.BuiltinTypes, buffer_size * type_size, Location),
					new IntConstant (Compiler.BuiltinTypes, (int) char_set, Location)
				}
			);

			fixed_buffer_type.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ());

			//
			// Don't emit FixedBufferAttribute attribute for private types
			//
			if ((ModFlags & Modifiers.PRIVATE) != 0)
				return;

			ctor = Module.PredefinedMembers.FixedBufferAttributeCtor.Resolve (Location);
			if (ctor == null)
				return;

			encoder = new AttributeEncoder ();
			encoder.EncodeTypeName (MemberType);
			encoder.Encode (buffer_size);
			encoder.EncodeEmptyNamedArguments ();

			FieldBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ());
		}
开发者ID:agallero,项目名称:mono,代码行数:52,代码来源:field.cs

示例3: EmitIndexerName

		void EmitIndexerName ()
		{
			if (!seen_normal_indexers)
				return;

			PredefinedAttribute pa = Module.PredefinedAttributes.DefaultMember;
			if (pa.Constructor == null &&
				!pa.ResolveConstructor (Location, TypeManager.string_type))
				return;

			var encoder = new AttributeEncoder ();
			encoder.Encode (GetAttributeDefaultMember ());
			encoder.EncodeEmptyNamedArguments ();

			pa.EmitAttribute (TypeBuilder, encoder);
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:16,代码来源:class.cs

示例4: EmitFieldSize

        void EmitFieldSize(int buffer_size)
        {
            PredefinedAttribute pa;
            AttributeEncoder encoder;

            pa = Module.PredefinedAttributes.StructLayout;
            if (pa.Constructor == null && !pa.ResolveConstructor (Location, TypeManager.short_type))
                return;

            var char_set_type = Module.PredefinedTypes.CharSet.Resolve (Location);
            if (char_set_type == null)
                return;

            var field_size = pa.GetField ("Size", TypeManager.int32_type, Location);
            var field_charset = pa.GetField ("CharSet", char_set_type, Location);
            if (field_size == null || field_charset == null)
                return;

            var char_set = CharSet ?? Module.DefaultCharSet ?? 0;

            encoder = new AttributeEncoder ();
            encoder.Encode ((short)LayoutKind.Sequential);
            encoder.EncodeNamedArguments (
                new [] { field_size, field_charset },
                new Constant [] { new IntConstant (buffer_size, Location), new IntConstant ((int) char_set, Location) }
            );

            pa.EmitAttribute (fixed_buffer_type, encoder);

            //
            // Don't emit FixedBufferAttribute attribute for private types
            //
            if ((ModFlags & Modifiers.PRIVATE) != 0)
                return;

            pa = Module.PredefinedAttributes.FixedBuffer;
            if (pa.Constructor == null && !pa.ResolveConstructor (Location, TypeManager.type_type, TypeManager.int32_type))
                return;

            encoder = new AttributeEncoder ();
            encoder.EncodeTypeName (MemberType);
            encoder.Encode (buffer_size);
            encoder.EncodeEmptyNamedArguments ();

            pa.EmitAttribute (FieldBuilder, encoder);
        }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:46,代码来源:field.cs

示例5: EmitFieldSize

		void EmitFieldSize (int buffer_size)
		{
			int type_size = BuiltinTypeSpec.GetSize (MemberType);

			if (buffer_size > int.MaxValue / type_size) {
				Report.Error (1664, Location, "Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit",
					GetSignatureForError (), buffer_size.ToString (), MemberType.GetSignatureForError ());
				return;
			}

			AttributeEncoder encoder;
			MethodSpec ctor;

			var char_set = CharSetValue ?? Module.DefaultCharSet ?? 0;
#if STATIC
			//
			// Set struct layout without resolving StructLayoutAttribute which is not always available
			//

			TypeAttributes attribs = TypeAttributes.SequentialLayout;
			switch (char_set) {
			case CharSet.None:
			case CharSet.Ansi:
				attribs |= TypeAttributes.AnsiClass;
				break;
			case CharSet.Auto:
				attribs |= TypeAttributes.AutoClass;
				break;
			case CharSet.Unicode:
				attribs |= TypeAttributes.UnicodeClass;
				break;
			}

			fixed_buffer_type.__SetAttributes (fixed_buffer_type.Attributes | attribs);
			fixed_buffer_type.__SetLayout (0, buffer_size * type_size);
#else
			ctor = Module.PredefinedMembers.StructLayoutAttributeCtor.Resolve (Location);
			if (ctor == null)
				return;

			var field_size = Module.PredefinedMembers.StructLayoutSize.Resolve (Location);
			var field_charset = Module.PredefinedMembers.StructLayoutCharSet.Resolve (Location);
			if (field_size == null || field_charset == null)
				return;

			encoder = new AttributeEncoder ();
			encoder.Encode ((short)LayoutKind.Sequential);
			encoder.EncodeNamedArguments (
				new [] { field_size, field_charset },
				new Constant [] { 
					new IntConstant (Compiler.BuiltinTypes, buffer_size * type_size, Location),
					new IntConstant (Compiler.BuiltinTypes, (int) char_set, Location)
				}
			);

			fixed_buffer_type.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ());
#endif
			//
			// Don't emit FixedBufferAttribute attribute for private types
			//
			if ((ModFlags & Modifiers.PRIVATE) != 0)
				return;

			ctor = Module.PredefinedMembers.FixedBufferAttributeCtor.Resolve (Location);
			if (ctor == null)
				return;

			encoder = new AttributeEncoder ();
			encoder.EncodeTypeName (MemberType);
			encoder.Encode (buffer_size);
			encoder.EncodeEmptyNamedArguments ();

			FieldBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ());
		}
开发者ID:Profit0004,项目名称:mono,代码行数:74,代码来源:field.cs

示例6: EmitFieldSize

		void EmitFieldSize (int buffer_size)
		{
			int type_size = Expression.GetTypeSize (MemberType);

			if (buffer_size > int.MaxValue / type_size) {
				Report.Error (1664, Location, "Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit",
					GetSignatureForError (), buffer_size.ToString (), TypeManager.CSharpName (MemberType));
				return;
			}
			
			PredefinedAttribute pa;
			AttributeEncoder encoder;

			pa = Module.PredefinedAttributes.StructLayout;
			if (pa.Constructor == null && !pa.ResolveConstructor (Location, TypeManager.short_type))
				return;

			var char_set_type = Module.PredefinedTypes.CharSet.Resolve (Location);
			if (char_set_type == null)
				return;

			var field_size = pa.GetField ("Size", TypeManager.int32_type, Location);
			var field_charset = pa.GetField ("CharSet", char_set_type, Location);
			if (field_size == null || field_charset == null)
				return;

			var char_set = CharSet ?? Module.DefaultCharSet;

			encoder = new AttributeEncoder ();
			encoder.Encode ((short)LayoutKind.Sequential);
			encoder.EncodeNamedArguments (
				new [] { field_size, field_charset },
				new Constant [] { new IntConstant (buffer_size * type_size, Location), new IntConstant ((int) char_set, Location) }
			);

			pa.EmitAttribute (fixed_buffer_type, encoder);

			//
			// Don't emit FixedBufferAttribute attribute for private types
			//
			if ((ModFlags & Modifiers.PRIVATE) != 0)
				return;

			pa = Module.PredefinedAttributes.FixedBuffer;
			if (pa.Constructor == null && !pa.ResolveConstructor (Location, TypeManager.type_type, TypeManager.int32_type))
				return;

			encoder = new AttributeEncoder ();
			encoder.EncodeTypeName (MemberType);
			encoder.Encode (buffer_size);
			encoder.EncodeEmptyNamedArguments ();

			pa.EmitAttribute (FieldBuilder, encoder);
		}
开发者ID:wamiq,项目名称:debian-mono,代码行数:54,代码来源:field.cs


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