示例#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);
			}
		}
示例#2
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
                }
            }

            var rtype = ReturnType.Type;
            if (rtype != null)
            {
                if (rtype.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
                {
                    Module.PredefinedAttributes.Dynamic.EmitAttribute(CreateReturnBuilder().Builder);
                }
                else if (rtype.HasDynamicElement)
                {
                    Module.PredefinedAttributes.Dynamic.EmitAttribute(CreateReturnBuilder().Builder, rtype, Location);
                }
                else if (rtype is ReadOnlyReferenceContainer)
                {
                    Module.PredefinedAttributes.IsReadOnly.EmitAttribute(CreateReturnBuilder().Builder);
                }

                if (rtype.HasNamedTupleElement)
                {
                    Module.PredefinedAttributes.TupleElementNames.EmitAttribute(CreateReturnBuilder().Builder, rtype, 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);
            }
        }
示例#3
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);
            }
        }