public virtual void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa)
{
if (builder != null)
throw new InternalErrorException ("builder already exists");
if (mb == null)
builder = cb.DefineParameter (index, Attributes, Name);
else
builder = mb.DefineParameter (index, Attributes, Name);
if (OptAttributes != null)
OptAttributes.Emit ();
if (HasDefaultValue) {
//
// Emit constant values for true constants only, the other
// constant-like expressions will rely on default value expression
//
Constant c = default_expr as Constant;
if (c != null) {
if (default_expr.Type == TypeManager.decimal_type) {
pa.DecimalConstant.EmitAttribute (builder, (decimal) c.GetValue (), c.Location);
} else {
builder.SetConstant (c.GetValue ());
}
} else if (default_expr.Type.IsStruct) {
//
// Handles special case where default expression is used with value-type
//
// void Foo (S s = default (S)) {}
//
builder.SetConstant (null);
}
}
if (parameter_type != null) {
if (parameter_type == InternalType.Dynamic) {
pa.Dynamic.EmitAttribute (builder);
} else if (parameter_type.HasDynamicElement) {
pa.Dynamic.EmitAttribute (builder, parameter_type, Location);
}
}
}