Class for applying custom attributes on the return type
Inheritance: ParameterBase
Exemple #1
0
		public override void Emit ()
		{
			base.Emit ();

			if (ReturnType.Type != null) {
				if (ReturnType.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
					Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
				} else if (ReturnType.Type.HasDynamicElement) {
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
					Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType.Type, Location);
				}

				ConstraintChecker.Check (this, ReturnType.Type, ReturnType.Location);
			}

			Constructor.ParameterInfo.ApplyAttributes (this, Constructor.ConstructorBuilder);
			Constructor.ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);

			parameters.CheckConstraints (this);
			parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder);
			InvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);

			if (BeginInvokeBuilder != null) {
				BeginInvokeBuilder.ParameterInfo.ApplyAttributes (this, BeginInvokeBuilder.MethodBuilder);
				EndInvokeBuilder.ParameterInfo.ApplyAttributes (this, EndInvokeBuilder.MethodBuilder);

				BeginInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
				EndInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
			}
		}
Exemple #2
0
		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Target == AttributeTargets.ReturnValue) {
				if (return_attributes == null)
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);

				return_attributes.ApplyAttributeBuilder (a, ctor, cdata, pa);
				return;
			}

			base.ApplyAttributeBuilder (a, ctor, cdata, pa);
		}
Exemple #3
0
		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Target == AttributeTargets.ReturnValue) {
				if (return_attributes == null)
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);

				return_attributes.ApplyAttributeBuilder (a, ctor, cdata, pa);
				return;
			}

			base.ApplyAttributeBuilder (a, ctor, cdata, pa);
		}
		public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
		{
			if (a.Target == AttributeTargets.ReturnValue) {
				if (return_attributes == null)
					return_attributes = new ReturnParameter (InvokeBuilder, Location);

				return_attributes.ApplyAttributeBuilder (a, cb, pa);
				return;
			}

			base.ApplyAttributeBuilder (a, cb, pa);
		}
Exemple #5
0
        public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
        {
            if (a.Target == AttributeTargets.ReturnValue)
            {
                if (return_attributes == null)
                {
                    return_attributes = new ReturnParameter(InvokeBuilder, Location);
                }

                return_attributes.ApplyAttributeBuilder(a, cb, pa);
                return;
            }

            base.ApplyAttributeBuilder(a, cb, pa);
        }
Exemple #6
0
        public override void Emit()
        {
            base.Emit();

            if (declarative_security != null)
            {
                foreach (var de in declarative_security)
                {
#if STATIC
                    TypeBuilder.__AddDeclarativeSecurity(de);
#else
                    TypeBuilder.AddDeclarativeSecurity(de.Key, de.Value);
#endif
                }
            }

            if (ReturnType.Type != null)
            {
                if (ReturnType.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
                {
                    return_attributes = new ReturnParameter(this, InvokeBuilder.MethodBuilder, Location);
                    Module.PredefinedAttributes.Dynamic.EmitAttribute(return_attributes.Builder);
                }
                else if (ReturnType.Type.HasDynamicElement)
                {
                    return_attributes = new ReturnParameter(this, InvokeBuilder.MethodBuilder, Location);
                    Module.PredefinedAttributes.Dynamic.EmitAttribute(return_attributes.Builder, ReturnType.Type, Location);
                }

                ConstraintChecker.Check(this, ReturnType.Type, ReturnType.Location);
            }

            Constructor.ParameterInfo.ApplyAttributes(this, Constructor.ConstructorBuilder);
            Constructor.ConstructorBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);

            parameters.CheckConstraints(this);
            parameters.ApplyAttributes(this, InvokeBuilder.MethodBuilder);
            InvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);

            if (BeginInvokeBuilder != null)
            {
                BeginInvokeBuilder.ParameterInfo.ApplyAttributes(this, BeginInvokeBuilder.MethodBuilder);
                EndInvokeBuilder.ParameterInfo.ApplyAttributes(this, EndInvokeBuilder.MethodBuilder);

                BeginInvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);
                EndInvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);
            }
        }
Exemple #7
0
        public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
        {
            if (a.Target == AttributeTargets.ReturnValue)
            {
                if (return_attributes == null)
                {
                    return_attributes = new ReturnParameter(this, InvokeBuilder.MethodBuilder, Location);
                }

                return_attributes.ApplyAttributeBuilder(a, ctor, cdata, pa);
                return;
            }

            if (a.IsValidSecurityAttribute())
            {
                a.ExtractSecurityPermissionSet(ctor, ref declarative_security);
                return;
            }

            base.ApplyAttributeBuilder(a, ctor, cdata, pa);
        }
Exemple #8
0
        public override void Emit()
        {
            if (TypeManager.IsDynamicType(ret_type))
            {
                return_attributes = new ReturnParameter(InvokeBuilder, Location);
                return_attributes.EmitPredefined(PredefinedAttributes.Get.Dynamic, Location);
            }

            Parameters.ApplyAttributes(InvokeBuilder);

            if (BeginInvokeBuilder != null)
            {
                ParametersCompiled p = (ParametersCompiled)TypeManager.GetParameterData(BeginInvokeBuilder);
                p.ApplyAttributes(BeginInvokeBuilder);
            }

            if (OptAttributes != null)
            {
                OptAttributes.Emit();
            }

            base.Emit();
        }
Exemple #9
0
        public virtual void Emit(DeclSpace parent)
        {
            method_data.Emit (parent);

            if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
                PredefinedAttributes.Get.CompilerGenerated.EmitAttribute (method_data.MethodBuilder);
            if (((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0))
                PredefinedAttributes.Get.DebuggerHidden.EmitAttribute (method_data.MethodBuilder);

            if (ReturnType == InternalType.Dynamic) {
                return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);
                PredefinedAttributes.Get.Dynamic.EmitAttribute (return_attributes.Builder);
            } else {
                var trans_flags = TypeManager.HasDynamicTypeUsed (ReturnType);
                if (trans_flags != null) {
                    var pa = PredefinedAttributes.Get.DynamicTransform;
                    if (pa.Constructor != null || pa.ResolveConstructor (Location, ArrayContainer.MakeType (TypeManager.bool_type))) {
                        return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);
                        return_attributes.Builder.SetCustomAttribute (
                            new CustomAttributeBuilder (pa.Constructor, new object [] { trans_flags }));
                    }
                }
            }

            if (OptAttributes != null)
                OptAttributes.Emit ();

            if (declarative_security != null) {
                foreach (var de in declarative_security) {
                    method_data.MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
                }
            }

            block = null;
        }
		public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
		{
			if (a.Type == pa.CLSCompliant || a.Type == pa.Obsolete || a.Type == pa.Conditional) {
				Report.Error (1667, a.Location,
					"Attribute `{0}' is not valid on property or event accessors. It is valid on `{1}' declarations only",
					TypeManager.CSharpName (a.Type), a.GetValidTargets ());
				return;
			}

			if (a.IsValidSecurityAttribute ()) {
				if (declarative_security == null)
					declarative_security = new ListDictionary ();
				a.ExtractSecurityPermissionSet (declarative_security);
				return;
			}

			if (a.Target == AttributeTargets.Method) {
				method_data.MethodBuilder.SetCustomAttribute (cb);
				return;
			}

			if (a.Target == AttributeTargets.ReturnValue) {
				if (return_attributes == null)
					return_attributes = new ReturnParameter (method_data.MethodBuilder, Location);

				return_attributes.ApplyAttributeBuilder (a, cb, pa);
				return;
			}

			ApplyToExtraTarget (a, cb, pa);
		}
Exemple #11
0
		public override void Emit ()
		{
			base.Emit ();

			if (declarative_security != null) {
				foreach (var de in declarative_security) {
#if STATIC
					TypeBuilder.__AddDeclarativeSecurity (de);
#else
					TypeBuilder.AddDeclarativeSecurity (de.Key, de.Value);
#endif
				}
			}

			if (ReturnType.Type != null) {
				if (ReturnType.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
					Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
				} else if (ReturnType.Type.HasDynamicElement) {
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
					Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType.Type, Location);
				}

				ConstraintChecker.Check (this, ReturnType.Type, ReturnType.Location);
			}

			Constructor.ParameterInfo.ApplyAttributes (this, Constructor.ConstructorBuilder);
			Constructor.ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);

			parameters.CheckConstraints (this);
			parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder);
			InvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);

			if (BeginInvokeBuilder != null) {
				BeginInvokeBuilder.ParameterInfo.ApplyAttributes (this, BeginInvokeBuilder.MethodBuilder);
				EndInvokeBuilder.ParameterInfo.ApplyAttributes (this, EndInvokeBuilder.MethodBuilder);

				BeginInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
				EndInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
			}
		}
Exemple #12
0
		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Target == AttributeTargets.ReturnValue) {
				if (return_attributes == null)
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);

				return_attributes.ApplyAttributeBuilder (a, ctor, cdata, pa);
				return;
			}

			if (a.IsValidSecurityAttribute ()) {
				a.ExtractSecurityPermissionSet (ctor, ref declarative_security);
				return;
			}

			base.ApplyAttributeBuilder (a, ctor, cdata, pa);
		}
Exemple #13
0
 ReturnParameter CreateReturnBuilder()
 {
     return(return_attributes ?? (return_attributes = new ReturnParameter(this, InvokeBuilder.MethodBuilder, Location)));
 }
Exemple #14
0
		public override void Emit ()
		{
			if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
				Compiler.PredefinedAttributes.CompilerGenerated.EmitAttribute (MethodBuilder);
			if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
				Compiler.PredefinedAttributes.DebuggerHidden.EmitAttribute (MethodBuilder);

			if (ReturnType == InternalType.Dynamic) {
				return_attributes = new ReturnParameter (this, MethodBuilder, Location);
				Compiler.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
			} else if (ReturnType.HasDynamicElement) {
				return_attributes = new ReturnParameter (this, MethodBuilder, Location);
				Compiler.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType);
			}

			if (OptAttributes != null)
				OptAttributes.Emit ();

			if (declarative_security != null) {
				foreach (var de in declarative_security) {
					MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
				}
			}

			if (MethodData != null)
				MethodData.Emit (Parent);

			base.Emit ();

			Block = null;
			MethodData = null;
		}
Exemple #15
0
		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Target == AttributeTargets.ReturnValue) {
				if (return_attributes == null)
					return_attributes = new ReturnParameter (this, MethodBuilder, Location);

				return_attributes.ApplyAttributeBuilder (a, ctor, cdata, pa);
				return;
			}

			if (a.IsInternalMethodImplAttribute) {
				is_external_implementation = true;
			}

			if (a.Type == pa.DllImport) {
				const Modifiers extern_static = Modifiers.EXTERN | Modifiers.STATIC;
				if ((ModFlags & extern_static) != extern_static) {
					Report.Error (601, a.Location, "The DllImport attribute must be specified on a method marked `static' and `extern'");
				}
				is_external_implementation = true;
			}

			if (a.IsValidSecurityAttribute ()) {
				if (declarative_security == null)
					declarative_security = new Dictionary<SecurityAction, PermissionSet> ();
				a.ExtractSecurityPermissionSet (declarative_security);
				return;
			}

			if (MethodBuilder != null)
				MethodBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), cdata);
		}
		public virtual void Emit (DeclSpace parent)
		{
			method_data.Emit (parent);

			if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
				PredefinedAttributes.Get.CompilerGenerated.EmitAttribute (method_data.MethodBuilder);
			if (((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0))
				PredefinedAttributes.Get.DebuggerHidden.EmitAttribute (method_data.MethodBuilder);

			if (TypeManager.IsDynamicType (ReturnType)) {
				return_attributes = new ReturnParameter (method_data.MethodBuilder, Location);
				return_attributes.EmitPredefined (PredefinedAttributes.Get.Dynamic, Location);
			}

			if (OptAttributes != null)
				OptAttributes.Emit ();

			if (declarative_security != null) {
				foreach (DictionaryEntry de in declarative_security) {
					method_data.MethodBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
				}
			}

			block = null;
		}
Exemple #17
0
		public override void EmitType ()
		{
			if (ReturnType.Type != null) {
				if (ReturnType.Type == InternalType.Dynamic) {
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
					Compiler.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
				} else if (ReturnType.Type.HasDynamicElement) {
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
					Compiler.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType.Type);
				}
			}

			parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder);
			
			Constructor.ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
			InvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);

			if (BeginInvokeBuilder != null) {
				BeginInvokeBuilder.ParameterInfo.ApplyAttributes (this, BeginInvokeBuilder.MethodBuilder);

				BeginInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
				EndInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
			}

			if (OptAttributes != null) {
				OptAttributes.Emit ();
			}

			base.Emit ();
		}
Exemple #18
0
		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Target == AttributeTargets.ReturnValue) {
				if (return_attributes == null)
					return_attributes = new ReturnParameter (this, MethodBuilder, Location);

				return_attributes.ApplyAttributeBuilder (a, ctor, cdata, pa);
				return;
			}

			if (a.Type == pa.MethodImpl) {
				if ((ModFlags & Modifiers.ASYNC) != 0 && (a.GetMethodImplOptions () & MethodImplOptions.Synchronized) != 0) {
					Report.Error (4015, a.Location, "`{0}': Async methods cannot use `MethodImplOptions.Synchronized'",
						GetSignatureForError ());
				}

				is_external_implementation = a.IsInternalCall ();
			} else if (a.Type == pa.DllImport) {
				const Modifiers extern_static = Modifiers.EXTERN | Modifiers.STATIC;
				if ((ModFlags & extern_static) != extern_static) {
					Report.Error (601, a.Location, "The DllImport attribute must be specified on a method marked `static' and `extern'");
				}
				is_external_implementation = true;
			}

			if (a.IsValidSecurityAttribute ()) {
				a.ExtractSecurityPermissionSet (ctor, ref declarative_security);
				return;
			}

			if (MethodBuilder != null)
				MethodBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), cdata);
		}
Exemple #19
0
		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Type == pa.CLSCompliant || a.Type == pa.Obsolete || a.Type == pa.Conditional) {
				Report.Error (1667, a.Location,
					"Attribute `{0}' is not valid on property or event accessors. It is valid on `{1}' declarations only",
					a.Type.GetSignatureForError (), a.GetValidTargets ());
				return;
			}

			if (a.IsValidSecurityAttribute ()) {
				a.ExtractSecurityPermissionSet (ctor, ref declarative_security);
				return;
			}

			if (a.Target == AttributeTargets.Method) {
				method_data.MethodBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), cdata);
				return;
			}

			if (a.Target == AttributeTargets.ReturnValue) {
				if (return_attributes == null)
					return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);

				return_attributes.ApplyAttributeBuilder (a, ctor, cdata, pa);
				return;
			}

			ApplyToExtraTarget (a, ctor, cdata, pa);
		}
		public override void Emit ()
		{
			if (TypeManager.IsDynamicType (ret_type)) {
				return_attributes = new ReturnParameter (InvokeBuilder, Location);
				return_attributes.EmitPredefined (PredefinedAttributes.Get.Dynamic, Location);
			}

			Parameters.ApplyAttributes (InvokeBuilder);

			if (BeginInvokeBuilder != null) {
				ParametersCompiled p = (ParametersCompiled) TypeManager.GetParameterData (BeginInvokeBuilder);
				p.ApplyAttributes (BeginInvokeBuilder);
			}

			if (OptAttributes != null) {
				OptAttributes.Emit ();
			}

			base.Emit ();
		}
Exemple #21
0
		public override void Emit ()
		{
			if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
				Module.PredefinedAttributes.CompilerGenerated.EmitAttribute (MethodBuilder);
			if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
				Module.PredefinedAttributes.DebuggerHidden.EmitAttribute (MethodBuilder);
			if ((ModFlags & Modifiers.DEBUGGER_STEP_THROUGH) != 0)
				Module.PredefinedAttributes.DebuggerStepThrough.EmitAttribute (MethodBuilder);

			if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
				return_attributes = new ReturnParameter (this, MethodBuilder, Location);
				Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
			} else if (ReturnType.HasDynamicElement) {
				return_attributes = new ReturnParameter (this, MethodBuilder, Location);
				Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType, Location);
			}

			if (OptAttributes != null)
				OptAttributes.Emit ();

			if (declarative_security != null) {
				foreach (var de in declarative_security) {
#if STATIC
					MethodBuilder.__AddDeclarativeSecurity (de);
#else
					MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
#endif
				}
			}

			//
			// Optimization but it also covers cases where we cannot check
			// constraints because method is captured into generated class
			// and type parameters context is now different
			//
			if (type_expr != null && !IsCompilerGenerated)
				ConstraintChecker.Check (this, member_type, type_expr.Location);

			base.Emit ();

			if (MethodData != null)
				MethodData.Emit (Parent);

			if (block != null && block.StateMachine is AsyncTaskStorey) {
				var psm = Module.PredefinedAttributes.AsyncStateMachine;
				psm.EmitAttribute (MethodBuilder, block.StateMachine);
			}

			if ((ModFlags & Modifiers.PARTIAL) == 0)
				Block = null;
		}
Exemple #22
0
		public virtual void Emit (TypeDefinition parent)
		{
			method_data.Emit (parent);

			if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
				Module.PredefinedAttributes.CompilerGenerated.EmitAttribute (method_data.MethodBuilder);
			if (((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0))
				Module.PredefinedAttributes.DebuggerHidden.EmitAttribute (method_data.MethodBuilder);

			if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
				return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);
				Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
			} else if (ReturnType.HasDynamicElement) {
				return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);
				Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType, Location);
			}

			if (OptAttributes != null)
				OptAttributes.Emit ();

			if (declarative_security != null) {
				foreach (var de in declarative_security) {
#if STATIC
					method_data.MethodBuilder.__AddDeclarativeSecurity (de);
#else
					method_data.MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
#endif
				}
			}

			block = null;
		}
Exemple #23
0
		public override void EmitType ()
		{
			if (ReturnType.Type != null) {
				if (ReturnType.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
					Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
				} else if (ReturnType.Type.HasDynamicElement) {
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
					Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType.Type, Location);
				}

				ConstraintChecker.Check (this, ReturnType.Type, ReturnType.Location);
			}

			Constructor.ParameterInfo.ApplyAttributes (this, Constructor.ConstructorBuilder);
			Constructor.ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);

			parameters.CheckConstraints (this);
			parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder);
			InvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);

			if (BeginInvokeBuilder != null) {
				BeginInvokeBuilder.ParameterInfo.ApplyAttributes (this, BeginInvokeBuilder.MethodBuilder);
				EndInvokeBuilder.ParameterInfo.ApplyAttributes (this, EndInvokeBuilder.MethodBuilder);

				BeginInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
				EndInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
			}

			if (OptAttributes != null) {
				OptAttributes.Emit ();
			}

			base.Emit ();
		}
Exemple #24
0
		public override void Emit ()
		{
			if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
				Module.PredefinedAttributes.CompilerGenerated.EmitAttribute (MethodBuilder);
			if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
				Module.PredefinedAttributes.DebuggerHidden.EmitAttribute (MethodBuilder);

			if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
				return_attributes = new ReturnParameter (this, MethodBuilder, Location);
				Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
			} else if (ReturnType.HasDynamicElement) {
				return_attributes = new ReturnParameter (this, MethodBuilder, Location);
				Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType, Location);
			}

			if (OptAttributes != null)
				OptAttributes.Emit ();

			if (declarative_security != null) {
				foreach (var de in declarative_security) {
#if STATIC
					MethodBuilder.__AddDeclarativeSecurity (de);
#else
					MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
#endif
				}
			}

			if (type_expr != null)
				ConstraintChecker.Check (this, member_type, type_expr.Location);

			base.Emit ();

			if (MethodData != null)
				MethodData.Emit (Parent);

			Block = null;
		}
Exemple #25
0
		public override void EmitType ()
		{
			if (ReturnType.Type == InternalType.Dynamic) {
				return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
				Compiler.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
			} else {
				var trans_flags = TypeManager.HasDynamicTypeUsed (ReturnType.Type);
				if (trans_flags != null) {
					var pa = Compiler.PredefinedAttributes.DynamicTransform;
					if (pa.Constructor != null || pa.ResolveConstructor (Location, ArrayContainer.MakeType (TypeManager.bool_type))) {
						return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
						return_attributes.Builder.SetCustomAttribute (
							new CustomAttributeBuilder (pa.Constructor, new object [] { trans_flags }));
					}
				}
			}

			Parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder);
			
			Constructor.ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
			InvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);

			if (BeginInvokeBuilder != null) {
				BeginInvokeBuilder.ParameterInfo.ApplyAttributes (this, BeginInvokeBuilder.MethodBuilder);

				BeginInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
				EndInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
			}

			if (OptAttributes != null) {
				OptAttributes.Emit ();
			}

			base.Emit ();
		}