コード例 #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);
            }
        }