本文整理汇总了C#中MethodBuilder.DefineParameter方法的典型用法代码示例。如果您正苦于以下问题:C# MethodBuilder.DefineParameter方法的具体用法?C# MethodBuilder.DefineParameter怎么用?C# MethodBuilder.DefineParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MethodBuilder
的用法示例。
在下文中一共展示了MethodBuilder.DefineParameter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnParameter
// TODO: merge method and mb
public ReturnParameter (MemberCore method, MethodBuilder mb, Location location)
{
this.method = method;
try {
builder = mb.DefineParameter (0, ParameterAttributes.None, "");
}
catch (ArgumentOutOfRangeException) {
method.Compiler.Report.RuntimeMissingSupport (location, "custom attributes on the return type");
}
}
示例2: ApplyAttributes
public virtual void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa)
{
if (builder != null)
throw new InternalErrorException ("builder already exists");
var pattrs = ParametersCompiled.GetParameterAttribute (modFlags);
if (HasOptionalExpression)
pattrs |= ParameterAttributes.Optional;
if (mb == null)
builder = cb.DefineParameter (index, pattrs, Name);
else
builder = mb.DefineParameter (index, pattrs, 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
//
var def_value = DefaultValue;
Constant c = def_value != null ? def_value.Child as Constant : default_expr as Constant;
if (c != null) {
if (c.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) {
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.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
pa.Dynamic.EmitAttribute (builder);
} else if (parameter_type.HasDynamicElement) {
pa.Dynamic.EmitAttribute (builder, parameter_type, Location);
}
}
}
示例3: ApplyReturnValue
internal override void ApplyReturnValue(ClassLoaderWrapper loader, MethodBuilder mb, ref ParameterBuilder pb, object annotation)
{
// TODO make sure the descriptor is correct
Annotation ann = type.Annotation;
object[] arr = (object[])annotation;
for (int i = 2; i < arr.Length; i += 2)
{
if ("value".Equals(arr[i]))
{
if (pb == null)
{
pb = mb.DefineParameter(0, ParameterAttributes.None, null);
}
object[] value = (object[])arr[i + 1];
if (value[0].Equals(AnnotationDefaultAttribute.TAG_ANNOTATION))
{
ann.Apply(loader, pb, value);
}
else
{
for (int j = 1; j < value.Length; j++)
{
ann.Apply(loader, pb, value[j]);
}
}
break;
}
}
}