本文整理汇总了C#中Mono.CSharp.TypeContainer.EmitFieldInitializers方法的典型用法代码示例。如果您正苦于以下问题:C# TypeContainer.EmitFieldInitializers方法的具体用法?C# TypeContainer.EmitFieldInitializers怎么用?C# TypeContainer.EmitFieldInitializers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.TypeContainer
的用法示例。
在下文中一共展示了TypeContainer.EmitFieldInitializers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
//
// Emits the code
//
public void Emit (TypeContainer parent)
{
ILGenerator ig = ConstructorBuilder.GetILGenerator ();
EmitContext ec = new EmitContext (parent, Location, ig, null, ModFlags, true);
//
// extern methods have no bodies
//
if ((ModFlags & Modifiers.EXTERN) != 0) {
if ((block != null) && ((ModFlags & Modifiers.EXTERN) != 0)) {
Report.Error (
179, Location, "External constructor `" +
TypeManager.CSharpSignature (ConstructorBuilder) +
"' can not have a body");
return;
}
} else if (block == null) {
Report.Error (
501, Location, "Constructor `" +
TypeManager.CSharpSignature (ConstructorBuilder) +
"' must declare a body since it is not marked extern");
return;
}
if ((ModFlags & Modifiers.STATIC) == 0){
if (parent is Class && Initializer == null)
Initializer = new ConstructorBaseInitializer (
null, Parameters.EmptyReadOnlyParameters, Location.Null);
//
// Spec mandates that Initializers will not have
// `this' access
//
ec.IsStatic = true;
if (Initializer != null && !Initializer.Resolve (ec))
return;
ec.IsStatic = false;
}
LabelParameters (ec, ConstructorBuilder, OptAttributes);
SymbolWriter sw = CodeGen.SymbolWriter;
bool generate_debugging = false;
if ((sw != null) && (block != null) &&
!Location.IsNull (Location) &&
!Location.IsNull (block.EndLocation)) {
sw.OpenMethod (parent, ConstructorBuilder, Location, block.EndLocation);
generate_debugging = true;
}
//
// Classes can have base initializers and instance field initializers.
//
if (parent is Class){
if ((ModFlags & Modifiers.STATIC) == 0)
parent.EmitFieldInitializers (ec);
}
if (Initializer != null)
Initializer.Emit (ec);
if ((ModFlags & Modifiers.STATIC) != 0)
parent.EmitFieldInitializers (ec);
Attribute.ApplyAttributes (ec, ConstructorBuilder, this, OptAttributes);
// If this is a non-static `struct' constructor and doesn't have any
// initializer, it must initialize all of the struct's fields.
if ((parent is Struct) && ((ModFlags & Modifiers.STATIC) == 0) &&
(Initializer == null))
Block.AddThisVariable (parent, Location);
ec.EmitTopBlock (block, ParameterInfo, Location);
if (generate_debugging)
sw.CloseMethod ();
block = null;
}