本文整理汇总了C#中Delegate.DefineContainer方法的典型用法代码示例。如果您正苦于以下问题:C# Delegate.DefineContainer方法的具体用法?C# Delegate.DefineContainer怎么用?C# Delegate.DefineContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Delegate
的用法示例。
在下文中一共展示了Delegate.DefineContainer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitCall
//.........这里部分代码省略.........
del_type = new GenericTypeExpr (te, new TypeArguments (targs), loc);
if (targs_for_instance != null)
del_type_instance_access = new GenericTypeExpr (te, new TypeArguments (targs_for_instance), loc);
else
del_type_instance_access = del_type;
}
}
//
// Create custom delegate when no appropriate predefined delegate has been found
//
Delegate d;
if (del_type == null) {
TypeSpec rt = isStatement ? ec.BuiltinTypes.Void : type;
Parameter[] p = new Parameter[dyn_args_count + 1];
p[0] = new Parameter (targs[0], "p0", Parameter.Modifier.NONE, null, loc);
var site = ec.CreateDynamicSite ();
int index = site.Containers == null ? 0 : site.Containers.Count;
if (mutator != null)
rt = mutator.Mutate (rt);
for (int i = 1; i < dyn_args_count + 1; ++i) {
p[i] = new Parameter (targs[i], "p" + i.ToString ("X"), arguments[i - 1].Modifier, null, loc);
}
d = new Delegate (site, new TypeExpression (rt, loc),
Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED,
new MemberName ("Container" + index.ToString ("X")),
new ParametersCompiled (p), null);
d.CreateContainer ();
d.DefineContainer ();
d.Define ();
d.PrepareEmit ();
site.AddTypeContainer (d);
//
// Add new container to inflated site container when the
// member cache already exists
//
if (site.CurrentType is InflatedTypeSpec && index > 0)
site.CurrentType.MemberCache.AddMember (d.CurrentType);
del_type = new TypeExpression (d.CurrentType, loc);
if (targs_for_instance != null) {
del_type_instance_access = null;
} else {
del_type_instance_access = del_type;
}
} else {
d = null;
}
var site_type_decl = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec, new TypeArguments (del_type), loc);
var field = site_container.CreateCallSiteField (site_type_decl, loc);
if (field == null)
return;
if (del_type_instance_access == null) {
var dt = d.CurrentType.DeclaringType.MakeGenericType (module, context_mvars.Types);
del_type_instance_access = new TypeExpression (MemberCache.GetMember (dt, d.CurrentType), loc);
}